aboutsummaryrefslogtreecommitdiffstats
path: root/src/w32term.c
diff options
context:
space:
mode:
authorJason Rumney2008-06-26 22:11:25 +0000
committerJason Rumney2008-06-26 22:11:25 +0000
commitc35f9821de5ec0cf127185890191ad0154600d0d (patch)
tree18fc6dbe64578d453a0004a8d7b7c4dc3a94e13c /src/w32term.c
parentec06f5c9a0d4fc01c3af9e14add64bb09f977fb6 (diff)
downloademacs-c35f9821de5ec0cf127185890191ad0154600d0d.tar.gz
emacs-c35f9821de5ec0cf127185890191ad0154600d0d.zip
* w32font.h (FONT_HANDLE, FONT_TEXTMETRIC): New macros.
* w32term.c (x_draw_glyph_string_foreground): (x_draw_composite_glyph_string_foreground): Sync with xterm.c. Use FONT_HANDLE macro. (x_draw_glyph_string): Use FONT_TEXTMETRIC macro. * w32uniscribe.c (uniscribe_otf_capability, uniscribe_shape): (uniscribe_encode_char): Use FONT_HANDLE macro. * w32font.c (Fx_select_font): Use FONT_HANDLE macro. (w32font_text_extents): Use precast w32_font. (w32font_close): Free cached metrics. (w32font_open_internal): Allocate space for name on stack.
Diffstat (limited to 'src/w32term.c')
-rw-r--r--src/w32term.c53
1 files changed, 18 insertions, 35 deletions
diff --git a/src/w32term.c b/src/w32term.c
index 57662051302..28861eea902 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -1237,8 +1237,6 @@ x_draw_glyph_string_foreground (s)
1237 struct glyph_string *s; 1237 struct glyph_string *s;
1238{ 1238{
1239 int i, x; 1239 int i, x;
1240 struct w32font_info * w32_font;
1241 HFONT old_font;
1242 1240
1243 /* If first glyph of S has a left box line, start drawing the text 1241 /* If first glyph of S has a left box line, start drawing the text
1244 of S to the right of that box line. */ 1242 of S to the right of that box line. */
@@ -1248,21 +1246,10 @@ x_draw_glyph_string_foreground (s)
1248 else 1246 else
1249 x = s->x; 1247 x = s->x;
1250 1248
1251 if (s->for_overlaps || (s->background_filled_p && s->hl != DRAW_CURSOR)
1252 || cleartype_active)
1253 SetBkMode (s->hdc, TRANSPARENT);
1254 else
1255 SetBkMode (s->hdc, OPAQUE);
1256
1257 SetTextColor (s->hdc, s->gc->foreground); 1249 SetTextColor (s->hdc, s->gc->foreground);
1258 SetBkColor (s->hdc, s->gc->background); 1250 SetBkColor (s->hdc, s->gc->background);
1259 SetTextAlign (s->hdc, TA_BASELINE | TA_LEFT); 1251 SetTextAlign (s->hdc, TA_BASELINE | TA_LEFT);
1260 1252
1261 w32_font = (struct w32font_info *) s->font;
1262
1263 if (w32_font && w32_font->hfont)
1264 old_font = SelectObject (s->hdc, w32_font->hfont);
1265
1266 /* Draw characters of S as rectangles if S's font could not be 1253 /* Draw characters of S as rectangles if S's font could not be
1267 loaded. */ 1254 loaded. */
1268 if (s->font_not_found_p) 1255 if (s->font_not_found_p)
@@ -1278,24 +1265,27 @@ x_draw_glyph_string_foreground (s)
1278 } 1265 }
1279 else 1266 else
1280 { 1267 {
1281 int boff = s->font->baseline_offset; 1268 struct font *font = s->font;
1269 int boff = font->baseline_offset;
1282 int y; 1270 int y;
1271 HFONT old_font;
1272
1273 old_font = SelectObject (s->hdc, FONT_HANDLE (font));
1283 1274
1284 if (s->font->vertical_centering) 1275 if (font->vertical_centering)
1285 boff = VCENTER_BASELINE_OFFSET (s->font, s->f) - boff; 1276 boff = VCENTER_BASELINE_OFFSET (font, s->f) - boff;
1286 1277
1287 y = s->ybase - boff; 1278 y = s->ybase - boff;
1288 if (s->for_overlaps 1279 if (s->for_overlaps
1289 || (s->background_filled_p && s->hl != DRAW_CURSOR)) 1280 || (s->background_filled_p && s->hl != DRAW_CURSOR))
1290 s->font->driver->draw (s, 0, s->nchars, x, y, 0); 1281 font->driver->draw (s, 0, s->nchars, x, y, 0);
1291 else 1282 else
1292 s->font->driver->draw (s, 0, s->nchars, x, y, 1); 1283 font->driver->draw (s, 0, s->nchars, x, y, 1);
1293 if (s->face->overstrike) 1284 if (s->face->overstrike)
1294 s->font->driver->draw (s, 0, s->nchars, x + 1, y, 0); 1285 font->driver->draw (s, 0, s->nchars, x + 1, y, 0);
1295 }
1296 1286
1297 if (w32_font && w32_font->hfont) 1287 SelectObject (s->hdc, old_font);
1298 SelectObject (s->hdc, old_font); 1288 }
1299} 1289}
1300 1290
1301/* Draw the foreground of composite glyph string S. */ 1291/* Draw the foreground of composite glyph string S. */
@@ -1305,8 +1295,6 @@ x_draw_composite_glyph_string_foreground (s)
1305 struct glyph_string *s; 1295 struct glyph_string *s;
1306{ 1296{
1307 int i, j, x; 1297 int i, j, x;
1308 HFONT old_font;
1309 struct w32font_info * w32_font;
1310 1298
1311 /* If first glyph of S has a left box line, start drawing the text 1299 /* If first glyph of S has a left box line, start drawing the text
1312 of S to the right of that box line. */ 1300 of S to the right of that box line. */
@@ -1323,14 +1311,8 @@ x_draw_composite_glyph_string_foreground (s)
1323 1311
1324 SetTextColor (s->hdc, s->gc->foreground); 1312 SetTextColor (s->hdc, s->gc->foreground);
1325 SetBkColor (s->hdc, s->gc->background); 1313 SetBkColor (s->hdc, s->gc->background);
1326 SetBkMode (s->hdc, TRANSPARENT);
1327 SetTextAlign (s->hdc, TA_BASELINE | TA_LEFT); 1314 SetTextAlign (s->hdc, TA_BASELINE | TA_LEFT);
1328 1315
1329 w32_font = (struct w32font_info *) s->font;
1330
1331 if (w32_font && w32_font->hfont)
1332 old_font = SelectObject (s->hdc, w32_font->hfont);
1333
1334 /* Draw a rectangle for the composition if the font for the very 1316 /* Draw a rectangle for the composition if the font for the very
1335 first character of the composition could not be loaded. */ 1317 first character of the composition could not be loaded. */
1336 if (s->font_not_found_p) 1318 if (s->font_not_found_p)
@@ -1339,11 +1321,14 @@ x_draw_composite_glyph_string_foreground (s)
1339 w32_draw_rectangle (s->hdc, s->gc, x, s->y, s->width - 1, 1321 w32_draw_rectangle (s->hdc, s->gc, x, s->y, s->width - 1,
1340 s->height - 1); 1322 s->height - 1);
1341 } 1323 }
1342 1324 else
1343 { 1325 {
1344 struct font *font = s->font; 1326 struct font *font = s->font;
1345 int y = s->ybase; 1327 int y = s->ybase;
1346 int width = 0; 1328 int width = 0;
1329 HFONT old_font;
1330
1331 old_font = SelectObject (s->hdc, FONT_HANDLE (font));
1347 1332
1348 if (s->cmp->method == COMPOSITION_WITH_GLYPH_STRING) 1333 if (s->cmp->method == COMPOSITION_WITH_GLYPH_STRING)
1349 { 1334 {
@@ -1393,10 +1378,8 @@ x_draw_composite_glyph_string_foreground (s)
1393 font->driver->draw (s, j, j + 1, xx + 1, yy, 0); 1378 font->driver->draw (s, j, j + 1, xx + 1, yy, 0);
1394 } 1379 }
1395 } 1380 }
1381 SelectObject (s->hdc, old_font);
1396 } 1382 }
1397
1398 if (w32_font && w32_font->hfont)
1399 SelectObject (s->hdc, old_font);
1400} 1383}
1401 1384
1402 1385
@@ -2345,7 +2328,7 @@ x_draw_glyph_string (s)
2345 2328
2346 /* Draw strike-through. */ 2329 /* Draw strike-through. */
2347 if (s->face->strike_through_p 2330 if (s->face->strike_through_p
2348 && !((struct w32font_info *) s->font)->metrics.tmStruckOut) 2331 && !FONT_TEXTMETRIC(s->font).tmStruckOut)
2349 { 2332 {
2350 unsigned long h = 1; 2333 unsigned long h = 1;
2351 unsigned long dy = (s->height - h) / 2; 2334 unsigned long dy = (s->height - h) / 2;