Mercurial > emacs
comparison src/macterm.c @ 80779:3e9e1107a4aa
[USE_ATSUI] (mac_draw_image_string_atsui) [MAC_OS_X]: Fix coordinate flipping.
[USE_CG_TEXT_DRAWING] (mac_draw_image_string_cg): Likewise.
author | YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> |
---|---|
date | Sat, 30 Aug 2008 08:07:48 +0000 |
parents | 166332494a32 |
children | 5e49fbefd047 |
comparison
equal
deleted
inserted
replaced
80778:da845bd3dced | 80779:3e9e1107a4aa |
---|---|
1010 #ifdef MAC_OSX | 1010 #ifdef MAC_OSX |
1011 } | 1011 } |
1012 else | 1012 else |
1013 { | 1013 { |
1014 static CGContextRef context; | 1014 static CGContextRef context; |
1015 CGFloat port_height = FRAME_PIXEL_HEIGHT (f); | |
1016 static const ATSUAttributeTag tags[] = {kATSUCGContextTag}; | 1015 static const ATSUAttributeTag tags[] = {kATSUCGContextTag}; |
1017 static const ByteCount sizes[] = {sizeof (CGContextRef)}; | 1016 static const ByteCount sizes[] = {sizeof (CGContextRef)}; |
1018 static const ATSUAttributeValuePtr values[] = {&context}; | 1017 static const ATSUAttributeValuePtr values[] = {&context}; |
1019 | 1018 |
1020 #if USE_CG_DRAWING | 1019 #if USE_CG_DRAWING |
1024 | 1023 |
1025 GetPort (&port); | 1024 GetPort (&port); |
1026 QDBeginCGContext (port, &context); | 1025 QDBeginCGContext (port, &context); |
1027 if (gc->n_clip_rects || bg_width) | 1026 if (gc->n_clip_rects || bg_width) |
1028 { | 1027 { |
1029 CGContextTranslateCTM (context, 0, port_height); | 1028 CGContextTranslateCTM (context, 0, FRAME_PIXEL_HEIGHT (f)); |
1030 CGContextScaleCTM (context, 1, -1); | 1029 CGContextScaleCTM (context, 1, -1); |
1031 if (gc->n_clip_rects) | 1030 if (gc->n_clip_rects) |
1032 CGContextClipToRects (context, gc->clip_rects, | 1031 CGContextClipToRects (context, gc->clip_rects, |
1033 gc->n_clip_rects); | 1032 gc->n_clip_rects); |
1034 #endif | 1033 #endif |
1040 x, y - FONT_BASE (GC_FONT (gc)), | 1039 x, y - FONT_BASE (GC_FONT (gc)), |
1041 bg_width, | 1040 bg_width, |
1042 FONT_HEIGHT (GC_FONT (gc)))); | 1041 FONT_HEIGHT (GC_FONT (gc)))); |
1043 } | 1042 } |
1044 CGContextScaleCTM (context, 1, -1); | 1043 CGContextScaleCTM (context, 1, -1); |
1045 CGContextTranslateCTM (context, 0, -port_height); | |
1046 #if !USE_CG_DRAWING | 1044 #if !USE_CG_DRAWING |
1047 } | 1045 } |
1048 #endif | 1046 #endif |
1049 CG_SET_FILL_COLOR_WITH_GC_FOREGROUND (context, gc); | 1047 CG_SET_FILL_COLOR_WITH_GC_FOREGROUND (context, gc); |
1050 err = ATSUSetLayoutControls (text_layout, | 1048 err = ATSUSetLayoutControls (text_layout, |
1052 tags, sizes, values); | 1050 tags, sizes, values); |
1053 if (err == noErr) | 1051 if (err == noErr) |
1054 { | 1052 { |
1055 ATSUDrawText (text_layout, | 1053 ATSUDrawText (text_layout, |
1056 kATSUFromTextBeginning, kATSUToTextEnd, | 1054 kATSUFromTextBeginning, kATSUToTextEnd, |
1057 Long2Fix (x), Long2Fix (port_height - y)); | 1055 Long2Fix (x), Long2Fix (-y)); |
1058 if (overstrike_p) | 1056 if (overstrike_p) |
1059 ATSUDrawText (text_layout, | 1057 ATSUDrawText (text_layout, |
1060 kATSUFromTextBeginning, kATSUToTextEnd, | 1058 kATSUFromTextBeginning, kATSUToTextEnd, |
1061 Long2Fix (x + 1), Long2Fix (port_height - y)); | 1059 Long2Fix (x + 1), Long2Fix (-y)); |
1062 } | 1060 } |
1063 #if USE_CG_DRAWING | 1061 #if USE_CG_DRAWING |
1064 mac_end_cg_clip (f); | 1062 mac_end_cg_clip (f); |
1065 context = NULL; | 1063 context = NULL; |
1066 #else | 1064 #else |
1381 GC gc; | 1379 GC gc; |
1382 int x, y; | 1380 int x, y; |
1383 XChar2b *buf; | 1381 XChar2b *buf; |
1384 int nchars, bg_width, overstrike_p; | 1382 int nchars, bg_width, overstrike_p; |
1385 { | 1383 { |
1386 CGFloat port_height, gx, gy; | 1384 CGFloat gx, gy; |
1387 int i; | 1385 int i; |
1388 CGContextRef context; | 1386 CGContextRef context; |
1389 CGGlyph *glyphs; | 1387 CGGlyph *glyphs; |
1390 CGSize *advances; | 1388 CGSize *advances; |
1391 | 1389 |
1392 if (!mac_use_core_graphics || GC_FONT (gc)->cg_font == NULL) | 1390 if (!mac_use_core_graphics || GC_FONT (gc)->cg_font == NULL) |
1393 return 0; | 1391 return 0; |
1394 | 1392 |
1395 port_height = FRAME_PIXEL_HEIGHT (f); | |
1396 gx = x; | 1393 gx = x; |
1397 gy = port_height - y; | 1394 gy = -y; |
1398 glyphs = (CGGlyph *)buf; | 1395 glyphs = (CGGlyph *)buf; |
1399 advances = alloca (sizeof (CGSize) * nchars); | 1396 advances = alloca (sizeof (CGSize) * nchars); |
1400 if (advances == NULL) | 1397 if (advances == NULL) |
1401 return 0; | 1398 return 0; |
1402 for (i = 0; i < nchars; i++) | 1399 for (i = 0; i < nchars; i++) |
1413 context = mac_begin_cg_clip (f, gc); | 1410 context = mac_begin_cg_clip (f, gc); |
1414 #else | 1411 #else |
1415 QDBeginCGContext (GetWindowPort (FRAME_MAC_WINDOW (f)), &context); | 1412 QDBeginCGContext (GetWindowPort (FRAME_MAC_WINDOW (f)), &context); |
1416 if (gc->n_clip_rects || bg_width) | 1413 if (gc->n_clip_rects || bg_width) |
1417 { | 1414 { |
1418 CGContextTranslateCTM (context, 0, port_height); | 1415 CGContextTranslateCTM (context, 0, FRAME_PIXEL_HEIGHT (f)); |
1419 CGContextScaleCTM (context, 1, -1); | 1416 CGContextScaleCTM (context, 1, -1); |
1420 if (gc->n_clip_rects) | 1417 if (gc->n_clip_rects) |
1421 CGContextClipToRects (context, gc->clip_rects, gc->n_clip_rects); | 1418 CGContextClipToRects (context, gc->clip_rects, gc->n_clip_rects); |
1422 #endif | 1419 #endif |
1423 if (bg_width) | 1420 if (bg_width) |
1427 (context, | 1424 (context, |
1428 mac_rect_make (f, gx, y - FONT_BASE (GC_FONT (gc)), | 1425 mac_rect_make (f, gx, y - FONT_BASE (GC_FONT (gc)), |
1429 bg_width, FONT_HEIGHT (GC_FONT (gc)))); | 1426 bg_width, FONT_HEIGHT (GC_FONT (gc)))); |
1430 } | 1427 } |
1431 CGContextScaleCTM (context, 1, -1); | 1428 CGContextScaleCTM (context, 1, -1); |
1432 CGContextTranslateCTM (context, 0, -port_height); | |
1433 #if !USE_CG_DRAWING | 1429 #if !USE_CG_DRAWING |
1434 } | 1430 } |
1435 #endif | 1431 #endif |
1436 CG_SET_FILL_COLOR_WITH_GC_FOREGROUND (context, gc); | 1432 CG_SET_FILL_COLOR_WITH_GC_FOREGROUND (context, gc); |
1437 CGContextSetFont (context, GC_FONT (gc)->cg_font); | 1433 CGContextSetFont (context, GC_FONT (gc)->cg_font); |