unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Dave Abrahams <dave@boostpro.com>
To: Chong Yidong <cyd@stupidchicken.com>
Cc: 8863@debbugs.gnu.org
Subject: bug#8863: 23.3; Strikethrough won't display on MacOS
Date: Fri, 01 Jul 2011 22:03:12 -0400	[thread overview]
Message-ID: <m2fwmpe8wv.fsf@pluto.luannocracy.com> (raw)
In-Reply-To: <87aade24li.fsf@stupidchicken.com> (Chong Yidong's message of "Sat, 18 Jun 2011 17:48:41 -0400")

[-- Attachment #1: Type: text/plain, Size: 1193 bytes --]


on Sat Jun 18 2011, Chong Yidong <cyd-AT-stupidchicken.com> wrote:

> Dave Abrahams <dave@boostpro.com> writes:
>
>> Title says it all.  Faces with the "strikethrough" property set show up
>> as un-struck-through.
>
> Does this (100% untested) patch do the right thing?
>
> *** src/nsfont.m	2011-01-02 23:50:46 +0000
> --- src/nsfont.m	2011-06-18 21:48:28 +0000
> ***************
> *** 1188,1193 ****
> --- 1188,1207 ----
>   /*[context GSSetTextDrawingMode: GSTextFill]; /// not implemented yet */
>         }
>   
> +     /* do strike-through */
> +     if (face->strike_through_p)
> +       {
> + 	float line_y = r.origin.y - 0.5 * font->height;
> +         if (face->strike_through_color != 0)
> +           [ns_lookup_indexed_color (face->strike_through_color, s->f) set];
> +         else
> +           [col set];
> +         DPSmoveto (context, r.origin.x, line_y);
> +         DPSlineto (context, r.origin.x + r.size.width, line_y);
> +         if (face->strike_through_color != 0)
> +           [col set];
> +       }
> + 
>       /* do underline */
>       if (face->underline_p)
>         {

No, but the enclosed 2 patches, together, seem to.  Would somebody apply
these, please?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: MacOS strikethrough patch #1 of 2 --]
[-- Type: text/x-patch, Size: 445 bytes --]

--- src/nsterm.h	2011-01-08 17:45:14.000000000 +0000
+++ src/nsterm.h	2011-07-02 01:46:06.000000000 +0000
@@ -435,6 +435,7 @@
   char bold, ital;  /* convenience flags */
   char synthItal;
   float voffset;  /* mean of ascender/descender offsets */
+  float xheight;  /* used to position the strikethrough line */
   XCharStruct max_bounds;
   /* we compute glyph codes and metrics on-demand in blocks of 256 indexed
      by hibyte, lobyte */

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: MacOS strikethrough patch #2 of 2 --]
[-- Type: text/x-patch, Size: 1893 bytes --]

--- src/nsfont.m.old	2011-07-02 01:52:29.000000000 +0000
+++ src/nsfont.m	2011-07-02 01:53:51.000000000 +0000
@@ -840,6 +840,7 @@
     font_info->underwidth = [sfont underlineThickness];
     font_info->size = font->pixel_size;
     font_info->voffset = lrint (hshrink * [sfont ascender] + expand * hd / 2);
+    font_info->xheight = lrint (hshrink * [sfont xHeight] + expand * hd / 2);
 
     /* max bounds */
     font_info->max_bounds.ascent =
@@ -1188,6 +1189,22 @@
 /*[context GSSetTextDrawingMode: GSTextFill]; /// not implemented yet */
       }
 
+    /* do strike-through */
+    if (face->strike_through_p)
+      {
+	 float line_y = lrint (r.origin.y - 0.5 * font->xheight);
+        if (face->strike_through_color != 0)
+          [ns_lookup_indexed_color (face->strike_through_color, s->f) set];
+        else
+          [col set];
+        DPSmoveto (context, r.origin.x, line_y);
+        DPSlineto (context, r.origin.x + r.size.width, line_y);
+        if (face->strike_through_color != 0)
+          [col set];
+      }
+    else 
+     [col set];
+
     /* do underline */
     if (face->underline_p)
       {
@@ -1248,6 +1265,23 @@
         CGContextSetTextDrawingMode (gcontext, kCGTextFill);
       }
 
+    if (face->strike_through_p)
+      {
+	 float line_y = lrint (r.origin.y - 0.5 * font->xheight);
+        if (face->strike_through_color != 0)
+          [ns_lookup_indexed_color (face->strike_through_color, s->f) set];
+        else
+          [col set];
+        CGContextBeginPath (gcontext);
+        CGContextMoveToPoint (gcontext, r.origin.x, line_y);
+        CGContextAddLineToPoint (gcontext, r.origin.x + r.size.width, line_y);
+        CGContextStrokePath (gcontext);
+        if (face->strike_through_color != 0)
+          [col set];
+      }
+    else
+      [col set];
+
     if (face->underline_p)
       {
         if (face->underline_color != 0)

[-- Attachment #4: Type: text/plain, Size: 62 bytes --]


-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com

  reply	other threads:[~2011-07-02  2:03 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-14 16:05 bug#8863: 23.3; Strikethrough won't display on MacOS Dave Abrahams
2011-06-18 21:48 ` Chong Yidong
2011-07-02  2:03   ` Dave Abrahams [this message]
2011-07-02  5:53     ` Alp Aker
2011-07-03  2:27       ` Dave Abrahams
2011-06-22 18:07 ` Alp Aker
2011-07-26 19:41 ` bug#8863: [PATCH] " Alp Aker
2011-07-28 18:26   ` Chong Yidong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2fwmpe8wv.fsf@pluto.luannocracy.com \
    --to=dave@boostpro.com \
    --cc=8863@debbugs.gnu.org \
    --cc=cyd@stupidchicken.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).