comparison src/w32term.c @ 23806:b59294a6167e

(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).
author Geoff Voelker <voelker@cs.washington.edu>
date Thu, 03 Dec 1998 00:06:03 +0000
parents 70999481c915
children ef1cba882819
comparison
equal deleted inserted replaced
23805:44ad68548ff9 23806:b59294a6167e
603 wchar_t *x_2byte_buffer 603 wchar_t *x_2byte_buffer
604 = (wchar_t *) alloca (FRAME_WINDOW_WIDTH (f) * sizeof (*x_2byte_buffer)); 604 = (wchar_t *) alloca (FRAME_WINDOW_WIDTH (f) * sizeof (*x_2byte_buffer));
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);
615 HDC hdc = get_frame_dc (f); 616 HDC hdc = get_frame_dc (f);
616 int orig_left = left; 617 int orig_left = left;
955 require_clipping = (!NILP (Vclip_large_size_font) 956 require_clipping = (!NILP (Vclip_large_size_font)
956 && (font->tm.tmAscent > baseline 957 && (font->tm.tmAscent > baseline
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;
964 965
965 /* Stippling not supported under w32. */ 966 /* Stippling not supported under w32. */
966 967
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. */
973 w32_fill_area (f, hdc, bg, 975 w32_fill_area (f, hdc, bg,
974 left, 976 left,
998 SelectObject (hdc, font->hfont); 1000 SelectObject (hdc, font->hfont);
999 1001
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;
1007 UINT fuOptions = 0; 1010 UINT fuOptions = 0;
1008 1011
1061 { 1064 {
1062 /* Handle composite characters. */ 1065 /* Handle composite characters. */
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 {
1069 /* Set up a clipping rectangle for ExtTextOut */ 1074 /* Set up a clipping rectangle for ExtTextOut */
1070 fuOptions |= ETO_CLIPPED; 1075 fuOptions |= ETO_CLIPPED;
1100 if (cmpcharp->cmp_rule) 1105 if (cmpcharp->cmp_rule)
1101 x_offset = (cmpcharp->col_offset[0] 1106 x_offset = (cmpcharp->col_offset[0]
1102 * FONT_WIDTH (FRAME_FONT (f))); 1107 * FONT_WIDTH (FRAME_FONT (f)));
1103 1108
1104 i = 1; 1109 i = 1;
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;
1105 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,
1109 top /*+ baseline*/, 1139 top /*+ baseline*/,
1197 lowest = bottom; 1227 lowest = bottom;
1198 y_offset = bottom + font->tm.tmDescent; 1228 y_offset = bottom + font->tm.tmDescent;
1199 x_offset = (cmpcharp->col_offset[gidx] 1229 x_offset = (cmpcharp->col_offset[gidx]
1200 * FONT_WIDTH (FRAME_FONT(f))); 1230 * FONT_WIDTH (FRAME_FONT(f)));
1201 } 1231 }
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;
1202 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*/,
1206 fuOptions, clip_region, 1261 fuOptions, clip_region,