aboutsummaryrefslogtreecommitdiffstats
path: root/src/w32term.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/w32term.c')
-rw-r--r--src/w32term.c76
1 files changed, 50 insertions, 26 deletions
diff --git a/src/w32term.c b/src/w32term.c
index f7622568569..cba210ebab5 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -1140,8 +1140,6 @@ w32_per_char_metric (hdc, font, char2b, font_type)
1140{ 1140{
1141 /* The result metric information. */ 1141 /* The result metric information. */
1142 XCharStruct *pcm; 1142 XCharStruct *pcm;
1143 ABC char_widths;
1144 SIZE sz;
1145 BOOL retval; 1143 BOOL retval;
1146 1144
1147 xassert (font && char2b); 1145 xassert (font && char2b);
@@ -1161,37 +1159,63 @@ w32_per_char_metric (hdc, font, char2b, font_type)
1161 if (font->hfont) 1159 if (font->hfont)
1162 SelectObject (hdc, font->hfont); 1160 SelectObject (hdc, font->hfont);
1163 1161
1164 if (font_type == UNICODE_FONT) 1162 if ((font->tm.tmPitchAndFamily & TMPF_TRUETYPE) != 0)
1165 retval = GetCharABCWidthsW (hdc, *char2b, *char2b, &char_widths);
1166 else if (font_type == ANSI_FONT)
1167 retval = GetCharABCWidthsA (hdc, *char2b, *char2b, &char_widths);
1168
1169 if (retval)
1170 { 1163 {
1171 pcm->width = char_widths.abcA + char_widths.abcB + char_widths.abcC; 1164 ABC char_widths;
1172 pcm->lbearing = char_widths.abcA; 1165
1173 pcm->rbearing = pcm->width - char_widths.abcC; 1166 if (font_type == UNICODE_FONT)
1167 retval = GetCharABCWidthsW (hdc, *char2b, *char2b, &char_widths);
1168 else if (font_type == ANSI_FONT)
1169 retval = GetCharABCWidthsA (hdc, *char2b, *char2b, &char_widths);
1170
1171 if (retval)
1172 {
1173 pcm->width = char_widths.abcA + char_widths.abcB + char_widths.abcC;
1174 pcm->lbearing = char_widths.abcA;
1175 pcm->rbearing = pcm->width - char_widths.abcC;
1176 }
1177 else
1178 {
1179 /* Windows 9x does not implement GetCharABCWidthsW, so if that
1180 failed, try GetTextExtentPoint32W, which is implemented and
1181 at least gives us some of the info we are after (total
1182 character width). */
1183 SIZE sz;
1184
1185 if (font_type == UNICODE_FONT)
1186 retval = GetTextExtentPoint32W (hdc, char2b, 1, &sz);
1187
1188 if (retval)
1189 {
1190 pcm->width = sz.cx;
1191 pcm->rbearing = sz.cx;
1192 pcm->lbearing = 0;
1193 }
1194 else
1195 {
1196 xfree (pcm);
1197 return NULL;
1198 }
1199 }
1174 } 1200 }
1175 else 1201 else
1176 { 1202 {
1177 /* Windows 9x does not implement GetCharABCWidthsW, so if that 1203 /* Do our best to deduce the desired metrics data for non-Truetype
1178 failed, try GetTextExtentPoint32W, which is implemented and 1204 fonts (generally, raster fonts). */
1179 at least gives us some of the info we are after (total 1205 INT char_width;
1180 character width). */
1181 if (font_type == UNICODE_FONT)
1182 retval = GetTextExtentPoint32W (hdc, char2b, 1, &sz);
1183 1206
1207 retval = GetCharWidth (hdc, *char2b, *char2b, &char_width);
1184 if (retval) 1208 if (retval)
1185 { 1209 {
1186 pcm->width = sz.cx; 1210 pcm->width = char_width;
1187 pcm->rbearing = sz.cx; 1211 pcm->rbearing = char_width;
1188 pcm->lbearing = 0; 1212 pcm->lbearing = 0;
1189 } 1213 }
1190 else 1214 else
1191 { 1215 {
1192 xfree (pcm); 1216 xfree (pcm);
1193 return NULL; 1217 return NULL;
1194 } 1218 }
1195 } 1219 }
1196 1220
1197 pcm->ascent = FONT_BASE (font); 1221 pcm->ascent = FONT_BASE (font);