diff options
| author | Alan Third | 2022-04-17 21:15:05 +0100 |
|---|---|---|
| committer | Alan Third | 2022-04-18 20:24:51 +0100 |
| commit | fa91925e13a717c7f3cf8cd30fe4f9e867c091f4 (patch) | |
| tree | 05b6cc1106a2c53510bf30923613d5668ab63c3b /src | |
| parent | 5c7b5c65ada6c07509a46ec459bf3a3aea3a6386 (diff) | |
| download | emacs-fa91925e13a717c7f3cf8cd30fe4f9e867c091f4.tar.gz emacs-fa91925e13a717c7f3cf8cd30fe4f9e867c091f4.zip | |
Fix glyphless glyph display on NS (bug#54970)
* src/nsterm.m (ns_draw_glyphless_glyph_string_foreground): New
function.
(ns_draw_glyph_string): Use the new function.
* src/nsfont.m (nsfont_draw): Fix the location the glyphs are drawn,
and also which glyphs are drawn.
(ns_glyph_metrics): Reverse ascent and descent.
Diffstat (limited to 'src')
| -rw-r--r-- | src/nsfont.m | 14 | ||||
| -rw-r--r-- | src/nsterm.m | 79 |
2 files changed, 82 insertions, 11 deletions
diff --git a/src/nsfont.m b/src/nsfont.m index f3c8a82930b..e913a50cb69 100644 --- a/src/nsfont.m +++ b/src/nsfont.m | |||
| @@ -1176,15 +1176,15 @@ nsfont_draw (struct glyph_string *s, int from, int to, int x, int y, | |||
| 1176 | 1176 | ||
| 1177 | face = s->face; | 1177 | face = s->face; |
| 1178 | 1178 | ||
| 1179 | r.origin.x = s->x; | 1179 | r.origin.x = x; |
| 1180 | if (s->face->box != FACE_NO_BOX && s->first_glyph->left_box_line_p) | 1180 | if (s->face->box != FACE_NO_BOX && s->first_glyph->left_box_line_p) |
| 1181 | r.origin.x += max (s->face->box_vertical_line_width, 0); | 1181 | r.origin.x += max (s->face->box_vertical_line_width, 0); |
| 1182 | 1182 | ||
| 1183 | r.origin.y = s->y; | 1183 | r.origin.y = y; |
| 1184 | r.size.height = FONT_HEIGHT (font); | 1184 | r.size.height = FONT_HEIGHT (font); |
| 1185 | 1185 | ||
| 1186 | for (int i = from; i < to; ++i) | 1186 | for (int i = 0; i < len; ++i) |
| 1187 | c[i] = s->char2b[i]; | 1187 | c[i] = s->char2b[i + from]; |
| 1188 | 1188 | ||
| 1189 | /* Fill background if requested. */ | 1189 | /* Fill background if requested. */ |
| 1190 | if (with_background && !isComposite) | 1190 | if (with_background && !isComposite) |
| @@ -1210,8 +1210,6 @@ nsfont_draw (struct glyph_string *s, int from, int to, int x, int y, | |||
| 1210 | } | 1210 | } |
| 1211 | 1211 | ||
| 1212 | /* set up for character rendering */ | 1212 | /* set up for character rendering */ |
| 1213 | r.origin.y = y; | ||
| 1214 | |||
| 1215 | if (s->hl == DRAW_CURSOR) | 1213 | if (s->hl == DRAW_CURSOR) |
| 1216 | col = FRAME_BACKGROUND_COLOR (s->f); | 1214 | col = FRAME_BACKGROUND_COLOR (s->f); |
| 1217 | else | 1215 | else |
| @@ -1721,8 +1719,8 @@ ns_glyph_metrics (struct nsfont_info *font_info, unsigned int block) | |||
| 1721 | metrics->rbearing = lrint (rb); | 1719 | metrics->rbearing = lrint (rb); |
| 1722 | metrics->lbearing = lrint (lb); | 1720 | metrics->lbearing = lrint (lb); |
| 1723 | 1721 | ||
| 1724 | metrics->descent = NSMinY (r); | 1722 | metrics->descent = - NSMaxY (r); |
| 1725 | metrics->ascent = NSMaxY (r); | 1723 | metrics->ascent = - NSMinY (r); |
| 1726 | } | 1724 | } |
| 1727 | unblock_input (); | 1725 | unblock_input (); |
| 1728 | } | 1726 | } |
diff --git a/src/nsterm.m b/src/nsterm.m index 550f29212e9..5a6a4d663b9 100644 --- a/src/nsterm.m +++ b/src/nsterm.m | |||
| @@ -3945,6 +3945,81 @@ ns_draw_composite_glyph_string_foreground (struct glyph_string *s) | |||
| 3945 | } | 3945 | } |
| 3946 | } | 3946 | } |
| 3947 | 3947 | ||
| 3948 | /* Draw the foreground of glyph string S for glyphless characters. */ | ||
| 3949 | static void | ||
| 3950 | ns_draw_glyphless_glyph_string_foreground (struct glyph_string *s) | ||
| 3951 | { | ||
| 3952 | struct glyph *glyph = s->first_glyph; | ||
| 3953 | NSGlyph char2b[8]; | ||
| 3954 | int x, i, j; | ||
| 3955 | |||
| 3956 | /* If first glyph of S has a left box line, start drawing the text | ||
| 3957 | of S to the right of that box line. */ | ||
| 3958 | if (s->face && s->face->box != FACE_NO_BOX | ||
| 3959 | && s->first_glyph->left_box_line_p) | ||
| 3960 | x = s->x + max (s->face->box_vertical_line_width, 0); | ||
| 3961 | else | ||
| 3962 | x = s->x; | ||
| 3963 | |||
| 3964 | s->char2b = char2b; | ||
| 3965 | |||
| 3966 | for (i = 0; i < s->nchars; i++, glyph++) | ||
| 3967 | { | ||
| 3968 | char buf[7]; | ||
| 3969 | char *str = NULL; | ||
| 3970 | int len = glyph->u.glyphless.len; | ||
| 3971 | |||
| 3972 | if (glyph->u.glyphless.method == GLYPHLESS_DISPLAY_ACRONYM) | ||
| 3973 | { | ||
| 3974 | if (len > 0 | ||
| 3975 | && CHAR_TABLE_P (Vglyphless_char_display) | ||
| 3976 | && (CHAR_TABLE_EXTRA_SLOTS (XCHAR_TABLE (Vglyphless_char_display)) | ||
| 3977 | >= 1)) | ||
| 3978 | { | ||
| 3979 | Lisp_Object acronym | ||
| 3980 | = (! glyph->u.glyphless.for_no_font | ||
| 3981 | ? CHAR_TABLE_REF (Vglyphless_char_display, | ||
| 3982 | glyph->u.glyphless.ch) | ||
| 3983 | : XCHAR_TABLE (Vglyphless_char_display)->extras[0]); | ||
| 3984 | if (STRINGP (acronym)) | ||
| 3985 | str = SSDATA (acronym); | ||
| 3986 | } | ||
| 3987 | } | ||
| 3988 | else if (glyph->u.glyphless.method == GLYPHLESS_DISPLAY_HEX_CODE) | ||
| 3989 | { | ||
| 3990 | unsigned int ch = glyph->u.glyphless.ch; | ||
| 3991 | eassume (ch <= MAX_CHAR); | ||
| 3992 | sprintf (buf, "%0*X", ch < 0x10000 ? 4 : 6, ch); | ||
| 3993 | str = buf; | ||
| 3994 | } | ||
| 3995 | |||
| 3996 | if (str) | ||
| 3997 | { | ||
| 3998 | int upper_len = (len + 1) / 2; | ||
| 3999 | |||
| 4000 | /* It is assured that all LEN characters in STR is ASCII. */ | ||
| 4001 | for (j = 0; j < len; j++) | ||
| 4002 | char2b[j] = s->font->driver->encode_char (s->font, str[j]) & 0xFFFF; | ||
| 4003 | s->font->driver->draw (s, 0, upper_len, | ||
| 4004 | x + glyph->slice.glyphless.upper_xoff, | ||
| 4005 | s->ybase + glyph->slice.glyphless.upper_yoff, | ||
| 4006 | false); | ||
| 4007 | s->font->driver->draw (s, upper_len, len, | ||
| 4008 | x + glyph->slice.glyphless.lower_xoff, | ||
| 4009 | s->ybase + glyph->slice.glyphless.lower_yoff, | ||
| 4010 | false); | ||
| 4011 | } | ||
| 4012 | if (glyph->u.glyphless.method != GLYPHLESS_DISPLAY_THIN_SPACE) | ||
| 4013 | ns_draw_box (NSMakeRect (x, s->ybase - glyph->ascent, | ||
| 4014 | glyph->pixel_width - 1, | ||
| 4015 | glyph->ascent + glyph->descent - 1), | ||
| 4016 | 1, 1, | ||
| 4017 | [NSColor colorWithUnsignedLong:NS_FACE_FOREGROUND (s->face)], | ||
| 4018 | YES, YES); | ||
| 4019 | x += glyph->pixel_width; | ||
| 4020 | } | ||
| 4021 | } | ||
| 4022 | |||
| 3948 | static void | 4023 | static void |
| 3949 | ns_draw_glyph_string (struct glyph_string *s) | 4024 | ns_draw_glyph_string (struct glyph_string *s) |
| 3950 | /* -------------------------------------------------------------------------- | 4025 | /* -------------------------------------------------------------------------- |
| @@ -4058,9 +4133,7 @@ ns_draw_glyph_string (struct glyph_string *s) | |||
| 4058 | else | 4133 | else |
| 4059 | ns_maybe_dumpglyphs_background | 4134 | ns_maybe_dumpglyphs_background |
| 4060 | (s, s->first_glyph->type == COMPOSITE_GLYPH); | 4135 | (s, s->first_glyph->type == COMPOSITE_GLYPH); |
| 4061 | /* ... */ | 4136 | ns_draw_glyphless_glyph_string_foreground (s); |
| 4062 | /* Not yet implemented. */ | ||
| 4063 | /* ... */ | ||
| 4064 | break; | 4137 | break; |
| 4065 | 4138 | ||
| 4066 | default: | 4139 | default: |