diff options
| author | Geoff Voelker | 1998-12-03 00:06:03 +0000 |
|---|---|---|
| committer | Geoff Voelker | 1998-12-03 00:06:03 +0000 |
| commit | feba565d2aa88fcb9edcfb84c1a501873177c5ea (patch) | |
| tree | 799bb7def7f19ae724ef7133897e0d76afffd9bf | |
| parent | 93066bc2ab6611079211300de323876bc19f8c8f (diff) | |
| download | emacs-feba565d2aa88fcb9edcfb84c1a501873177c5ea.tar.gz emacs-feba565d2aa88fcb9edcfb84c1a501873177c5ea.zip | |
(dumpglyphs): Use unsigned char arrays.
Use FONT_MAX_WIDTH to detect and fudge proportional fonts
for various languages.
Compensate for fonts that have underhangs (e.g., Thai).
| -rw-r--r-- | src/w32term.c | 67 |
1 files changed, 61 insertions, 6 deletions
diff --git a/src/w32term.c b/src/w32term.c index c8538adbeeb..a88f3f7afc3 100644 --- a/src/w32term.c +++ b/src/w32term.c | |||
| @@ -605,10 +605,11 @@ dumpglyphs (f, left, top, gp, n, hl, just_foreground, cmpcharp) | |||
| 605 | register wchar_t *cp; /* Steps through x_2byte_buffer[]. */ | 605 | register wchar_t *cp; /* Steps through x_2byte_buffer[]. */ |
| 606 | 606 | ||
| 607 | /* Allocate double the window width, as this buffer may contain MBCS | 607 | /* Allocate double the window width, as this buffer may contain MBCS |
| 608 | characters under w32. */ | 608 | characters under w32. Unsigned to let GetCharABCWidths work. */ |
| 609 | char *x_1byte_buffer | 609 | unsigned char *x_1byte_buffer |
| 610 | = (char *) alloca (2 * FRAME_WINDOW_WIDTH (f) * sizeof (*x_1byte_buffer)); | 610 | = (unsigned char *) alloca (2 * FRAME_WINDOW_WIDTH (f) |
| 611 | register char *bp; /* Steps through x_1byte_buffer[]. */ | 611 | * sizeof (*x_1byte_buffer)); |
| 612 | register unsigned char *bp; /* Steps through x_1byte_buffer[]. */ | ||
| 612 | register int tlen = GLYPH_TABLE_LENGTH; | 613 | register int tlen = GLYPH_TABLE_LENGTH; |
| 613 | register Lisp_Object *tbase = GLYPH_TABLE_BASE; | 614 | register Lisp_Object *tbase = GLYPH_TABLE_BASE; |
| 614 | Window window = FRAME_W32_WINDOW (f); | 615 | Window window = FRAME_W32_WINDOW (f); |
| @@ -957,7 +958,7 @@ dumpglyphs (f, left, top, gp, n, hl, just_foreground, cmpcharp) | |||
| 957 | || font->tm.tmDescent > | 958 | || font->tm.tmDescent > |
| 958 | line_height - baseline | 959 | line_height - baseline |
| 959 | || (!cmpcharp | 960 | || (!cmpcharp |
| 960 | && FONT_WIDTH (font) > glyph_width))); | 961 | && FONT_MAX_WIDTH (font) > glyph_width))); |
| 961 | 962 | ||
| 962 | if (font && (just_foreground || (cmpcharp && gidx > 0))) | 963 | if (font && (just_foreground || (cmpcharp && gidx > 0))) |
| 963 | background_filled = 1; | 964 | background_filled = 1; |
| @@ -967,6 +968,7 @@ dumpglyphs (f, left, top, gp, n, hl, just_foreground, cmpcharp) | |||
| 967 | else if (!font | 968 | else if (!font |
| 968 | || FONT_HEIGHT (font) < line_height | 969 | || FONT_HEIGHT (font) < line_height |
| 969 | || FONT_WIDTH (font) < glyph_width | 970 | || FONT_WIDTH (font) < glyph_width |
| 971 | || FONT_MAX_WIDTH (font) != FONT_WIDTH (font) | ||
| 970 | || cmpcharp) | 972 | || cmpcharp) |
| 971 | { | 973 | { |
| 972 | /* Fill in the background for the current run. */ | 974 | /* Fill in the background for the current run. */ |
| @@ -1000,7 +1002,8 @@ dumpglyphs (f, left, top, gp, n, hl, just_foreground, cmpcharp) | |||
| 1000 | if (!cmpcharp) | 1002 | if (!cmpcharp) |
| 1001 | { | 1003 | { |
| 1002 | int multibyte_pos_offset = 0; | 1004 | int multibyte_pos_offset = 0; |
| 1003 | if (require_clipping || FONT_WIDTH (font) != glyph_width) | 1005 | if (require_clipping || FONT_WIDTH (font) != glyph_width |
| 1006 | || FONT_MAX_WIDTH (font) != FONT_WIDTH (font)) | ||
| 1004 | { | 1007 | { |
| 1005 | RECT clip_rectangle; | 1008 | RECT clip_rectangle; |
| 1006 | LPRECT clip_region = NULL; | 1009 | LPRECT clip_region = NULL; |
| @@ -1063,6 +1066,8 @@ dumpglyphs (f, left, top, gp, n, hl, just_foreground, cmpcharp) | |||
| 1063 | RECT clip_rectangle; | 1066 | RECT clip_rectangle; |
| 1064 | LPRECT clip_region = NULL; | 1067 | LPRECT clip_region = NULL; |
| 1065 | UINT fuOptions = 0; | 1068 | UINT fuOptions = 0; |
| 1069 | ABC char_placement; | ||
| 1070 | int char_width = 0; | ||
| 1066 | 1071 | ||
| 1067 | if (require_clipping) | 1072 | if (require_clipping) |
| 1068 | { | 1073 | { |
| @@ -1103,6 +1108,31 @@ dumpglyphs (f, left, top, gp, n, hl, just_foreground, cmpcharp) | |||
| 1103 | 1108 | ||
| 1104 | i = 1; | 1109 | i = 1; |
| 1105 | 1110 | ||
| 1111 | /* Truetype fonts often contain underhangs to | ||
| 1112 | handle composition characters. This works | ||
| 1113 | against our attempts to position the characters | ||
| 1114 | manually, so we need to compensate for this. | ||
| 1115 | */ | ||
| 1116 | if (print_via_unicode ? | ||
| 1117 | GetCharABCWidthsW (hdc, *x_2byte_buffer, | ||
| 1118 | *x_2byte_buffer, | ||
| 1119 | &char_placement) | ||
| 1120 | : GetCharABCWidths (hdc, *x_1byte_buffer, | ||
| 1121 | *x_1byte_buffer, | ||
| 1122 | &char_placement)) | ||
| 1123 | { | ||
| 1124 | char_width = char_placement.abcA | ||
| 1125 | + char_placement.abcB + char_placement.abcC; | ||
| 1126 | x_offset += FONT_WIDTH (font) - char_width; | ||
| 1127 | } | ||
| 1128 | /* Don't let characters go beyond the glyph | ||
| 1129 | boundary whatever their over/underhangs. */ | ||
| 1130 | if (x_offset > glyph_width - char_width) | ||
| 1131 | x_offset = glyph_width - char_width; | ||
| 1132 | |||
| 1133 | if (x_offset < 0) | ||
| 1134 | x_offset = 0; | ||
| 1135 | |||
| 1106 | /* Draw the first character at the normal position. */ | 1136 | /* Draw the first character at the normal position. */ |
| 1107 | if (print_via_unicode) | 1137 | if (print_via_unicode) |
| 1108 | ExtTextOutW (hdc, left + x_offset, | 1138 | ExtTextOutW (hdc, left + x_offset, |
| @@ -1200,6 +1230,31 @@ dumpglyphs (f, left, top, gp, n, hl, just_foreground, cmpcharp) | |||
| 1200 | * FONT_WIDTH (FRAME_FONT(f))); | 1230 | * FONT_WIDTH (FRAME_FONT(f))); |
| 1201 | } | 1231 | } |
| 1202 | 1232 | ||
| 1233 | /* Truetype fonts often contain underhangs to | ||
| 1234 | handle composition characters. This works | ||
| 1235 | against our attempts to position the characters | ||
| 1236 | manually, so we need to compensate for this. | ||
| 1237 | */ | ||
| 1238 | if (print_via_unicode ? | ||
| 1239 | GetCharABCWidthsW (hdc, *(x_2byte_buffer + i), | ||
| 1240 | *(x_2byte_buffer + i), | ||
| 1241 | &char_placement) | ||
| 1242 | : GetCharABCWidths (hdc, *(x_1byte_buffer + i), | ||
| 1243 | *(x_1byte_buffer + i), | ||
| 1244 | &char_placement)) | ||
| 1245 | { | ||
| 1246 | char_width = char_placement.abcA | ||
| 1247 | + char_placement.abcB + char_placement.abcC; | ||
| 1248 | x_offset += FONT_WIDTH (font) - char_width; | ||
| 1249 | } | ||
| 1250 | /* Don't let characters go beyond the glyph | ||
| 1251 | boundary whatever their over/underhangs. */ | ||
| 1252 | if (x_offset > glyph_width - char_width) | ||
| 1253 | x_offset = glyph_width - char_width; | ||
| 1254 | |||
| 1255 | if (x_offset < 0) | ||
| 1256 | x_offset = 0; | ||
| 1257 | |||
| 1203 | if (print_via_unicode) | 1258 | if (print_via_unicode) |
| 1204 | ExtTextOutW (hdc, left + x_offset, | 1259 | ExtTextOutW (hdc, left + x_offset, |
| 1205 | top /*+ baseline - y_offset*/, | 1260 | top /*+ baseline - y_offset*/, |