diff options
| author | Alan Third | 2020-09-25 14:32:56 +0100 |
|---|---|---|
| committer | Alan Third | 2020-09-25 17:19:00 +0100 |
| commit | dd6876d6e2c57c003edbfe2fb4b12b3dd3e253b8 (patch) | |
| tree | 8054f397ead5567db431c74c3f5bb4bf65da9602 /src | |
| parent | c4c5db3de70b55f8bc03c9fee35e29d60f41f16e (diff) | |
| download | emacs-dd6876d6e2c57c003edbfe2fb4b12b3dd3e253b8.tar.gz emacs-dd6876d6e2c57c003edbfe2fb4b12b3dd3e253b8.zip | |
Remove obsolete macOS support for NS font backend
The ns font backend is has been disabled on macOS for a long time and
doesn't work correctly even if re-enabled.
* src/nsfont.m:
(ns_char_width):
(ns_ascii_average_width):
(ns_get_covering_families):
(nsfont_open):
(nsfont_close):
(nsfont_draw):
(ns_uni_to_glyphs):
(ns_glyph_metrics):
(EmacsGlyphStorage): Remove all Cocoa only code.
* src/nsterm.h (EmacsGlyphStorage): Remove.
(struct nsfont_info): Make GNUstep only.
* src/nsterm.m (ns_compute_glyph_string_overhangs): Remove GNUstep
only code from Cocoa builds.
Diffstat (limited to 'src')
| -rw-r--r-- | src/nsfont.m | 240 | ||||
| -rw-r--r-- | src/nsterm.h | 28 | ||||
| -rw-r--r-- | src/nsterm.m | 2 |
3 files changed, 6 insertions, 264 deletions
diff --git a/src/nsfont.m b/src/nsfont.m index 691becda6da..d1543ec69ce 100644 --- a/src/nsfont.m +++ b/src/nsfont.m | |||
| @@ -39,9 +39,7 @@ Author: Adrian Robert (arobert@cogsci.ucsd.edu) | |||
| 39 | #include "pdumper.h" | 39 | #include "pdumper.h" |
| 40 | 40 | ||
| 41 | /* TODO: Drop once we can assume gnustep-gui 0.17.1. */ | 41 | /* TODO: Drop once we can assume gnustep-gui 0.17.1. */ |
| 42 | #ifdef NS_IMPL_GNUSTEP | ||
| 43 | #import <AppKit/NSFontDescriptor.h> | 42 | #import <AppKit/NSFontDescriptor.h> |
| 44 | #endif | ||
| 45 | 43 | ||
| 46 | #define NSFONT_TRACE 0 | 44 | #define NSFONT_TRACE 0 |
| 47 | #define LCD_SMOOTHING_MARGIN 2 | 45 | #define LCD_SMOOTHING_MARGIN 2 |
| @@ -237,12 +235,6 @@ ns_char_width (NSFont *sfont, int c) | |||
| 237 | CGFloat w = -1.0; | 235 | CGFloat w = -1.0; |
| 238 | NSString *cstr = [NSString stringWithFormat: @"%c", c]; | 236 | NSString *cstr = [NSString stringWithFormat: @"%c", c]; |
| 239 | 237 | ||
| 240 | #ifdef NS_IMPL_COCOA | ||
| 241 | NSGlyph glyph = [sfont glyphWithName: cstr]; | ||
| 242 | if (glyph) | ||
| 243 | w = [sfont advancementForGlyph: glyph].width; | ||
| 244 | #endif | ||
| 245 | |||
| 246 | if (w < 0.0) | 238 | if (w < 0.0) |
| 247 | { | 239 | { |
| 248 | NSDictionary *attrsDictionary = | 240 | NSDictionary *attrsDictionary = |
| @@ -273,12 +265,6 @@ ns_ascii_average_width (NSFont *sfont) | |||
| 273 | ascii_printable = [[NSString alloc] initWithFormat: @"%s", chars]; | 265 | ascii_printable = [[NSString alloc] initWithFormat: @"%s", chars]; |
| 274 | } | 266 | } |
| 275 | 267 | ||
| 276 | #ifdef NS_IMPL_COCOA | ||
| 277 | NSGlyph glyph = [sfont glyphWithName: ascii_printable]; | ||
| 278 | if (glyph) | ||
| 279 | w = [sfont advancementForGlyph: glyph].width; | ||
| 280 | #endif | ||
| 281 | |||
| 282 | if (w < (CGFloat) 0.0) | 268 | if (w < (CGFloat) 0.0) |
| 283 | { | 269 | { |
| 284 | NSDictionary *attrsDictionary = | 270 | NSDictionary *attrsDictionary = |
| @@ -511,10 +497,6 @@ static NSSet | |||
| 511 | } | 497 | } |
| 512 | [charset release]; | 498 | [charset release]; |
| 513 | } | 499 | } |
| 514 | #ifdef NS_IMPL_COCOA | ||
| 515 | if ([families count] == 0) | ||
| 516 | [families addObject: @"LastResort"]; | ||
| 517 | #endif | ||
| 518 | [scriptToFamilies setObject: families forKey: script]; | 500 | [scriptToFamilies setObject: families forKey: script]; |
| 519 | } | 501 | } |
| 520 | 502 | ||
| @@ -734,11 +716,6 @@ nsfont_open (struct frame *f, Lisp_Object font_entity, int pixel_size) | |||
| 734 | traits: traits & ~NSItalicFontMask | 716 | traits: traits & ~NSItalicFontMask |
| 735 | weight: fixLeopardBug size: pixel_size]; | 717 | weight: fixLeopardBug size: pixel_size]; |
| 736 | } | 718 | } |
| 737 | #ifdef NS_IMPL_COCOA | ||
| 738 | /* LastResort not really a family */ | ||
| 739 | if (nsfont == nil && [@"LastResort" isEqualToString: family]) | ||
| 740 | nsfont = [NSFont fontWithName: @"LastResort" size: pixel_size]; | ||
| 741 | #endif | ||
| 742 | 719 | ||
| 743 | if (nsfont == nil) | 720 | if (nsfont == nil) |
| 744 | { | 721 | { |
| @@ -765,12 +742,7 @@ nsfont_open (struct frame *f, Lisp_Object font_entity, int pixel_size) | |||
| 765 | font_info->metrics = xzalloc (0x100 * sizeof *font_info->metrics); | 742 | font_info->metrics = xzalloc (0x100 * sizeof *font_info->metrics); |
| 766 | 743 | ||
| 767 | /* for metrics */ | 744 | /* for metrics */ |
| 768 | #ifdef NS_IMPL_COCOA | ||
| 769 | sfont = [nsfont screenFontWithRenderingMode: | ||
| 770 | NSFontAntialiasedIntegerAdvancementsRenderingMode]; | ||
| 771 | #else | ||
| 772 | sfont = [nsfont screenFont]; | 745 | sfont = [nsfont screenFont]; |
| 773 | #endif | ||
| 774 | 746 | ||
| 775 | if (sfont == nil) | 747 | if (sfont == nil) |
| 776 | sfont = nsfont; | 748 | sfont = nsfont; |
| @@ -797,11 +769,7 @@ nsfont_open (struct frame *f, Lisp_Object font_entity, int pixel_size) | |||
| 797 | * intended. */ | 769 | * intended. */ |
| 798 | CGFloat adjusted_descender = [sfont descender] + 0.0001; | 770 | CGFloat adjusted_descender = [sfont descender] + 0.0001; |
| 799 | 771 | ||
| 800 | #ifdef NS_IMPL_GNUSTEP | ||
| 801 | font_info->nsfont = sfont; | 772 | font_info->nsfont = sfont; |
| 802 | #else | ||
| 803 | font_info->nsfont = nsfont; | ||
| 804 | #endif | ||
| 805 | [font_info->nsfont retain]; | 773 | [font_info->nsfont retain]; |
| 806 | 774 | ||
| 807 | /* set up ns_font (defined in nsgui.h) */ | 775 | /* set up ns_font (defined in nsgui.h) */ |
| @@ -834,32 +802,6 @@ nsfont_open (struct frame *f, Lisp_Object font_entity, int pixel_size) | |||
| 834 | font_info->max_bounds.rbearing = | 802 | font_info->max_bounds.rbearing = |
| 835 | lrint (brect.size.width - (CGFloat) font_info->width); | 803 | lrint (brect.size.width - (CGFloat) font_info->width); |
| 836 | 804 | ||
| 837 | #ifdef NS_IMPL_COCOA | ||
| 838 | /* set up synthItal and the CG font */ | ||
| 839 | font_info->synthItal = synthItal; | ||
| 840 | { | ||
| 841 | ATSFontRef atsFont = ATSFontFindFromPostScriptName | ||
| 842 | ((CFStringRef)[nsfont fontName], kATSOptionFlagsDefault); | ||
| 843 | |||
| 844 | if (atsFont == kATSFontRefUnspecified) | ||
| 845 | { | ||
| 846 | /* see if we can get it by dropping italic (then synthesizing) */ | ||
| 847 | atsFont = ATSFontFindFromPostScriptName ((CFStringRef) | ||
| 848 | [[fontMgr convertFont: nsfont toNotHaveTrait: NSItalicFontMask] | ||
| 849 | fontName], kATSOptionFlagsDefault); | ||
| 850 | if (atsFont != kATSFontRefUnspecified) | ||
| 851 | font_info->synthItal = YES; | ||
| 852 | else | ||
| 853 | { | ||
| 854 | /* last resort fallback */ | ||
| 855 | atsFont = ATSFontFindFromPostScriptName | ||
| 856 | ((CFStringRef)@"Monaco", kATSOptionFlagsDefault); | ||
| 857 | } | ||
| 858 | } | ||
| 859 | font_info->cgfont = CGFontCreateWithPlatformFont ((void *) &atsFont); | ||
| 860 | } | ||
| 861 | #endif | ||
| 862 | |||
| 863 | /* set up metrics portion of font struct */ | 805 | /* set up metrics portion of font struct */ |
| 864 | font->ascent = lrint([sfont ascender]); | 806 | font->ascent = lrint([sfont ascender]); |
| 865 | font->descent = -lrint(floor(adjusted_descender)); | 807 | font->descent = -lrint(floor(adjusted_descender)); |
| @@ -901,9 +843,6 @@ nsfont_close (struct font *font) | |||
| 901 | xfree (font_info->glyphs); | 843 | xfree (font_info->glyphs); |
| 902 | xfree (font_info->metrics); | 844 | xfree (font_info->metrics); |
| 903 | [font_info->nsfont release]; | 845 | [font_info->nsfont release]; |
| 904 | #ifdef NS_IMPL_COCOA | ||
| 905 | CGFontRelease (font_info->cgfont); | ||
| 906 | #endif | ||
| 907 | xfree (font_info->name); | 846 | xfree (font_info->name); |
| 908 | font_info->name = NULL; | 847 | font_info->name = NULL; |
| 909 | } | 848 | } |
| @@ -994,7 +933,6 @@ nsfont_draw (struct glyph_string *s, int from, int to, int x, int y, | |||
| 994 | { | 933 | { |
| 995 | static unsigned char cbuf[1024]; | 934 | static unsigned char cbuf[1024]; |
| 996 | unsigned char *c = cbuf; | 935 | unsigned char *c = cbuf; |
| 997 | #ifdef NS_IMPL_GNUSTEP | ||
| 998 | #if GNUSTEP_GUI_MAJOR_VERSION > 0 || GNUSTEP_GUI_MINOR_VERSION > 22 | 936 | #if GNUSTEP_GUI_MAJOR_VERSION > 0 || GNUSTEP_GUI_MINOR_VERSION > 22 |
| 999 | static CGFloat advances[1024]; | 937 | static CGFloat advances[1024]; |
| 1000 | CGFloat *adv = advances; | 938 | CGFloat *adv = advances; |
| @@ -1002,10 +940,6 @@ nsfont_draw (struct glyph_string *s, int from, int to, int x, int y, | |||
| 1002 | static float advances[1024]; | 940 | static float advances[1024]; |
| 1003 | float *adv = advances; | 941 | float *adv = advances; |
| 1004 | #endif | 942 | #endif |
| 1005 | #else | ||
| 1006 | static CGSize advances[1024]; | ||
| 1007 | CGSize *adv = advances; | ||
| 1008 | #endif | ||
| 1009 | struct face *face; | 943 | struct face *face; |
| 1010 | NSRect r; | 944 | NSRect r; |
| 1011 | struct nsfont_info *font; | 945 | struct nsfont_info *font; |
| @@ -1073,11 +1007,7 @@ nsfont_draw (struct glyph_string *s, int from, int to, int x, int y, | |||
| 1073 | else | 1007 | else |
| 1074 | { | 1008 | { |
| 1075 | cwidth = LGLYPH_WADJUST (glyph); | 1009 | cwidth = LGLYPH_WADJUST (glyph); |
| 1076 | #ifdef NS_IMPL_GNUSTEP | ||
| 1077 | *(adv-1) += LGLYPH_XOFF (glyph); | 1010 | *(adv-1) += LGLYPH_XOFF (glyph); |
| 1078 | #else | ||
| 1079 | (*(adv-1)).width += LGLYPH_XOFF (glyph); | ||
| 1080 | #endif | ||
| 1081 | } | 1011 | } |
| 1082 | } | 1012 | } |
| 1083 | } | 1013 | } |
| @@ -1088,12 +1018,8 @@ nsfont_draw (struct glyph_string *s, int from, int to, int x, int y, | |||
| 1088 | cwidth = font->metrics[hi][lo].width; | 1018 | cwidth = font->metrics[hi][lo].width; |
| 1089 | } | 1019 | } |
| 1090 | twidth += cwidth; | 1020 | twidth += cwidth; |
| 1091 | #ifdef NS_IMPL_GNUSTEP | ||
| 1092 | *adv++ = cwidth; | 1021 | *adv++ = cwidth; |
| 1093 | c += CHAR_STRING (*t, c); /* This converts the char to UTF-8. */ | 1022 | c += CHAR_STRING (*t, c); /* This converts the char to UTF-8. */ |
| 1094 | #else | ||
| 1095 | (*adv++).width = cwidth; | ||
| 1096 | #endif | ||
| 1097 | } | 1023 | } |
| 1098 | len = adv - advances; | 1024 | len = adv - advances; |
| 1099 | r.size.width = twidth; | 1025 | r.size.width = twidth; |
| @@ -1192,61 +1118,6 @@ nsfont_draw (struct glyph_string *s, int from, int to, int x, int y, | |||
| 1192 | DPSgrestore (context); | 1118 | DPSgrestore (context); |
| 1193 | } | 1119 | } |
| 1194 | 1120 | ||
| 1195 | #else /* NS_IMPL_COCOA */ | ||
| 1196 | { | ||
| 1197 | CGContextRef gcontext = | ||
| 1198 | [[NSGraphicsContext currentContext] graphicsPort]; | ||
| 1199 | static CGAffineTransform fliptf; | ||
| 1200 | static BOOL firstTime = YES; | ||
| 1201 | |||
| 1202 | if (firstTime) | ||
| 1203 | { | ||
| 1204 | firstTime = NO; | ||
| 1205 | fliptf = CGAffineTransformMakeScale (1.0, -1.0); | ||
| 1206 | } | ||
| 1207 | |||
| 1208 | CGContextSaveGState (gcontext); | ||
| 1209 | |||
| 1210 | // Used to be Fix2X (kATSItalicQDSkew), but Fix2X is deprecated | ||
| 1211 | // and kATSItalicQDSkew is 0.25. | ||
| 1212 | fliptf.c = font->synthItal ? 0.25 : 0.0; | ||
| 1213 | |||
| 1214 | CGContextSetFont (gcontext, font->cgfont); | ||
| 1215 | CGContextSetFontSize (gcontext, font->size); | ||
| 1216 | if (NILP (ns_antialias_text) || font->size <= ns_antialias_threshold) | ||
| 1217 | CGContextSetShouldAntialias (gcontext, 0); | ||
| 1218 | else | ||
| 1219 | CGContextSetShouldAntialias (gcontext, 1); | ||
| 1220 | |||
| 1221 | CGContextSetTextMatrix (gcontext, fliptf); | ||
| 1222 | |||
| 1223 | if (bgCol != nil) | ||
| 1224 | { | ||
| 1225 | /* foreground drawing; erase first to avoid overstrike */ | ||
| 1226 | [bgCol set]; | ||
| 1227 | CGContextSetTextDrawingMode (gcontext, kCGTextFillStroke); | ||
| 1228 | CGContextSetTextPosition (gcontext, r.origin.x, r.origin.y); | ||
| 1229 | CGContextShowGlyphsWithAdvances (gcontext, s->char2b, advances, len); | ||
| 1230 | CGContextSetTextDrawingMode (gcontext, kCGTextFill); | ||
| 1231 | } | ||
| 1232 | |||
| 1233 | [col set]; | ||
| 1234 | |||
| 1235 | CGContextSetTextPosition (gcontext, r.origin.x, r.origin.y); | ||
| 1236 | CGContextShowGlyphsWithAdvances (gcontext, s->char2b + from, | ||
| 1237 | advances, len); | ||
| 1238 | |||
| 1239 | if (face->overstrike) | ||
| 1240 | { | ||
| 1241 | CGContextSetTextPosition (gcontext, r.origin.x+0.5, r.origin.y); | ||
| 1242 | CGContextShowGlyphsWithAdvances (gcontext, s->char2b + from, | ||
| 1243 | advances, len); | ||
| 1244 | } | ||
| 1245 | |||
| 1246 | CGContextRestoreGState (gcontext); | ||
| 1247 | } | ||
| 1248 | #endif /* NS_IMPL_COCOA */ | ||
| 1249 | |||
| 1250 | unblock_input (); | 1121 | unblock_input (); |
| 1251 | return to-from; | 1122 | return to-from; |
| 1252 | } | 1123 | } |
| @@ -1264,10 +1135,6 @@ nsfont_draw (struct glyph_string *s, int from, int to, int x, int y, | |||
| 1264 | static void | 1135 | static void |
| 1265 | ns_uni_to_glyphs (struct nsfont_info *font_info, unsigned char block) | 1136 | ns_uni_to_glyphs (struct nsfont_info *font_info, unsigned char block) |
| 1266 | { | 1137 | { |
| 1267 | #ifdef NS_IMPL_COCOA | ||
| 1268 | static EmacsGlyphStorage *glyphStorage; | ||
| 1269 | static char firstTime = 1; | ||
| 1270 | #endif | ||
| 1271 | unichar *unichars = xmalloc (0x101 * sizeof (unichar)); | 1138 | unichar *unichars = xmalloc (0x101 * sizeof (unichar)); |
| 1272 | unsigned int i, g, idx; | 1139 | unsigned int i, g, idx; |
| 1273 | unsigned short *glyphs; | 1140 | unsigned short *glyphs; |
| @@ -1278,14 +1145,6 @@ ns_uni_to_glyphs (struct nsfont_info *font_info, unsigned char block) | |||
| 1278 | 1145 | ||
| 1279 | block_input (); | 1146 | block_input (); |
| 1280 | 1147 | ||
| 1281 | #ifdef NS_IMPL_COCOA | ||
| 1282 | if (firstTime) | ||
| 1283 | { | ||
| 1284 | firstTime = 0; | ||
| 1285 | glyphStorage = [[EmacsGlyphStorage alloc] initWithCapacity: 0x100]; | ||
| 1286 | } | ||
| 1287 | #endif | ||
| 1288 | |||
| 1289 | font_info->glyphs[block] = xmalloc (0x100 * sizeof (unsigned short)); | 1148 | font_info->glyphs[block] = xmalloc (0x100 * sizeof (unsigned short)); |
| 1290 | if (!unichars || !(font_info->glyphs[block])) | 1149 | if (!unichars || !(font_info->glyphs[block])) |
| 1291 | emacs_abort (); | 1150 | emacs_abort (); |
| @@ -1299,38 +1158,16 @@ ns_uni_to_glyphs (struct nsfont_info *font_info, unsigned char block) | |||
| 1299 | unichars[0x100] = 0; | 1158 | unichars[0x100] = 0; |
| 1300 | 1159 | ||
| 1301 | { | 1160 | { |
| 1302 | #ifdef NS_IMPL_COCOA | ||
| 1303 | NSString *allChars = [[NSString alloc] | ||
| 1304 | initWithCharactersNoCopy: unichars | ||
| 1305 | length: 0x100 | ||
| 1306 | freeWhenDone: NO]; | ||
| 1307 | NSGlyphGenerator *glyphGenerator = [NSGlyphGenerator sharedGlyphGenerator]; | ||
| 1308 | /* NSCharacterSet *coveredChars = [nsfont coveredCharacterSet]; */ | ||
| 1309 | unsigned int numGlyphs = [font_info->nsfont numberOfGlyphs]; | ||
| 1310 | NSUInteger gInd = 0, cInd = 0; | ||
| 1311 | |||
| 1312 | [glyphStorage setString: allChars font: font_info->nsfont]; | ||
| 1313 | [glyphGenerator generateGlyphsForGlyphStorage: glyphStorage | ||
| 1314 | desiredNumberOfCharacters: glyphStorage->maxChar | ||
| 1315 | glyphIndex: &gInd characterIndex: &cInd]; | ||
| 1316 | #endif | ||
| 1317 | glyphs = font_info->glyphs[block]; | 1161 | glyphs = font_info->glyphs[block]; |
| 1318 | for (i = 0; i < 0x100; i++, glyphs++) | 1162 | for (i = 0; i < 0x100; i++, glyphs++) |
| 1319 | { | 1163 | { |
| 1320 | #ifdef NS_IMPL_GNUSTEP | ||
| 1321 | g = unichars[i]; | 1164 | g = unichars[i]; |
| 1322 | #else | ||
| 1323 | g = glyphStorage->cglyphs[i]; | 1165 | g = glyphStorage->cglyphs[i]; |
| 1324 | /* TODO: is this a good check? Maybe need to use coveredChars. */ | 1166 | /* TODO: is this a good check? Maybe need to use coveredChars. */ |
| 1325 | if (g > numGlyphs || g == NSNullGlyph) | 1167 | if (g > numGlyphs || g == NSNullGlyph) |
| 1326 | g = INVALID_GLYPH; /* Hopefully unused... */ | 1168 | g = INVALID_GLYPH; /* Hopefully unused... */ |
| 1327 | #endif | ||
| 1328 | *glyphs = g; | 1169 | *glyphs = g; |
| 1329 | } | 1170 | } |
| 1330 | |||
| 1331 | #ifdef NS_IMPL_COCOA | ||
| 1332 | [allChars release]; | ||
| 1333 | #endif | ||
| 1334 | } | 1171 | } |
| 1335 | 1172 | ||
| 1336 | unblock_input (); | 1173 | unblock_input (); |
| @@ -1352,19 +1189,12 @@ ns_glyph_metrics (struct nsfont_info *font_info, unsigned char block) | |||
| 1352 | fprintf (stderr, "%p\tComputing metrics for glyphs in block %d\n", | 1189 | fprintf (stderr, "%p\tComputing metrics for glyphs in block %d\n", |
| 1353 | font_info, block); | 1190 | font_info, block); |
| 1354 | 1191 | ||
| 1355 | #ifdef NS_IMPL_GNUSTEP | ||
| 1356 | /* not implemented yet (as of startup 0.18), so punt */ | 1192 | /* not implemented yet (as of startup 0.18), so punt */ |
| 1357 | if (numGlyphs == 0) | 1193 | if (numGlyphs == 0) |
| 1358 | numGlyphs = 0x10000; | 1194 | numGlyphs = 0x10000; |
| 1359 | #endif | ||
| 1360 | 1195 | ||
| 1361 | block_input (); | 1196 | block_input (); |
| 1362 | #ifdef NS_IMPL_COCOA | ||
| 1363 | sfont = [font_info->nsfont screenFontWithRenderingMode: | ||
| 1364 | NSFontAntialiasedIntegerAdvancementsRenderingMode]; | ||
| 1365 | #else | ||
| 1366 | sfont = [font_info->nsfont screenFont]; | 1197 | sfont = [font_info->nsfont screenFont]; |
| 1367 | #endif | ||
| 1368 | 1198 | ||
| 1369 | font_info->metrics[block] = xzalloc (0x100 * sizeof (struct font_metrics)); | 1199 | font_info->metrics[block] = xzalloc (0x100 * sizeof (struct font_metrics)); |
| 1370 | if (!(font_info->metrics[block])) | 1200 | if (!(font_info->metrics[block])) |
| @@ -1397,76 +1227,6 @@ ns_glyph_metrics (struct nsfont_info *font_info, unsigned char block) | |||
| 1397 | } | 1227 | } |
| 1398 | 1228 | ||
| 1399 | 1229 | ||
| 1400 | #ifdef NS_IMPL_COCOA | ||
| 1401 | /* Helper for font glyph setup. */ | ||
| 1402 | @implementation EmacsGlyphStorage | ||
| 1403 | |||
| 1404 | - init | ||
| 1405 | { | ||
| 1406 | return [self initWithCapacity: 1024]; | ||
| 1407 | } | ||
| 1408 | |||
| 1409 | - initWithCapacity: (unsigned long) c | ||
| 1410 | { | ||
| 1411 | self = [super init]; | ||
| 1412 | maxChar = 0; | ||
| 1413 | maxGlyph = 0; | ||
| 1414 | dict = [NSMutableDictionary new]; | ||
| 1415 | cglyphs = xmalloc (c * sizeof (CGGlyph)); | ||
| 1416 | return self; | ||
| 1417 | } | ||
| 1418 | |||
| 1419 | - (void) dealloc | ||
| 1420 | { | ||
| 1421 | if (attrStr != nil) | ||
| 1422 | [attrStr release]; | ||
| 1423 | [dict release]; | ||
| 1424 | xfree (cglyphs); | ||
| 1425 | [super dealloc]; | ||
| 1426 | } | ||
| 1427 | |||
| 1428 | - (void) setString: (NSString *)str font: (NSFont *)font | ||
| 1429 | { | ||
| 1430 | [dict setObject: font forKey: NSFontAttributeName]; | ||
| 1431 | if (attrStr != nil) | ||
| 1432 | [attrStr release]; | ||
| 1433 | attrStr = [[NSAttributedString alloc] initWithString: str attributes: dict]; | ||
| 1434 | maxChar = [str length]; | ||
| 1435 | maxGlyph = 0; | ||
| 1436 | } | ||
| 1437 | |||
| 1438 | /* NSGlyphStorage protocol */ | ||
| 1439 | - (NSUInteger)layoutOptions | ||
| 1440 | { | ||
| 1441 | return 0; | ||
| 1442 | } | ||
| 1443 | |||
| 1444 | - (NSAttributedString *)attributedString | ||
| 1445 | { | ||
| 1446 | return attrStr; | ||
| 1447 | } | ||
| 1448 | |||
| 1449 | - (void)insertGlyphs: (const NSGlyph *)glyphs length: (NSUInteger)length | ||
| 1450 | forStartingGlyphAtIndex: (NSUInteger)glyphIndex | ||
| 1451 | characterIndex: (NSUInteger)charIndex | ||
| 1452 | { | ||
| 1453 | len = glyphIndex+length; | ||
| 1454 | for (i =glyphIndex; i<len; i++) | ||
| 1455 | cglyphs[i] = glyphs[i-glyphIndex]; | ||
| 1456 | if (len > maxGlyph) | ||
| 1457 | maxGlyph = len; | ||
| 1458 | } | ||
| 1459 | |||
| 1460 | - (void)setIntAttribute: (NSInteger)attributeTag value: (NSInteger)val | ||
| 1461 | forGlyphAtIndex: (NSUInteger)glyphIndex | ||
| 1462 | { | ||
| 1463 | return; | ||
| 1464 | } | ||
| 1465 | |||
| 1466 | @end | ||
| 1467 | #endif /* NS_IMPL_COCOA */ | ||
| 1468 | |||
| 1469 | |||
| 1470 | /* Debugging */ | 1230 | /* Debugging */ |
| 1471 | void | 1231 | void |
| 1472 | ns_dump_glyphstring (struct glyph_string *s) | 1232 | ns_dump_glyphstring (struct glyph_string *s) |
diff --git a/src/nsterm.h b/src/nsterm.h index b56bcad4dc1..0bdb78e4436 100644 --- a/src/nsterm.h +++ b/src/nsterm.h | |||
| @@ -718,22 +718,6 @@ typedef id instancetype; | |||
| 718 | 718 | ||
| 719 | ========================================================================== */ | 719 | ========================================================================== */ |
| 720 | 720 | ||
| 721 | #ifdef NS_IMPL_COCOA | ||
| 722 | /* rendering util */ | ||
| 723 | @interface EmacsGlyphStorage : NSObject <NSGlyphStorage> | ||
| 724 | { | ||
| 725 | @public | ||
| 726 | NSAttributedString *attrStr; | ||
| 727 | NSMutableDictionary *dict; | ||
| 728 | CGGlyph *cglyphs; | ||
| 729 | unsigned long maxChar, maxGlyph; | ||
| 730 | long i, len; | ||
| 731 | } | ||
| 732 | - (instancetype)initWithCapacity: (unsigned long) c; | ||
| 733 | - (void) setString: (NSString *)str font: (NSFont *)font; | ||
| 734 | @end | ||
| 735 | #endif /* NS_IMPL_COCOA */ | ||
| 736 | |||
| 737 | extern NSArray *ns_send_types, *ns_return_types; | 721 | extern NSArray *ns_send_types, *ns_return_types; |
| 738 | extern NSString *ns_app_name; | 722 | extern NSString *ns_app_name; |
| 739 | extern EmacsMenu *svcsMenu; | 723 | extern EmacsMenu *svcsMenu; |
| @@ -811,6 +795,7 @@ struct ns_color_table | |||
| 811 | #define GREEN16_FROM_ULONG(color) (GREEN_FROM_ULONG(color) * 0x101) | 795 | #define GREEN16_FROM_ULONG(color) (GREEN_FROM_ULONG(color) * 0x101) |
| 812 | #define BLUE16_FROM_ULONG(color) (BLUE_FROM_ULONG(color) * 0x101) | 796 | #define BLUE16_FROM_ULONG(color) (BLUE_FROM_ULONG(color) * 0x101) |
| 813 | 797 | ||
| 798 | #ifdef NS_IMPL_GNUSTEP | ||
| 814 | /* this extends font backend font */ | 799 | /* this extends font backend font */ |
| 815 | struct nsfont_info | 800 | struct nsfont_info |
| 816 | { | 801 | { |
| @@ -827,14 +812,8 @@ struct nsfont_info | |||
| 827 | float size; | 812 | float size; |
| 828 | #ifdef __OBJC__ | 813 | #ifdef __OBJC__ |
| 829 | NSFont *nsfont; | 814 | NSFont *nsfont; |
| 830 | #if defined (NS_IMPL_COCOA) | ||
| 831 | CGFontRef cgfont; | ||
| 832 | #else /* GNUstep */ | ||
| 833 | void *cgfont; | ||
| 834 | #endif | ||
| 835 | #else /* ! OBJC */ | 815 | #else /* ! OBJC */ |
| 836 | void *nsfont; | 816 | void *nsfont; |
| 837 | void *cgfont; | ||
| 838 | #endif | 817 | #endif |
| 839 | char bold, ital; /* convenience flags */ | 818 | char bold, ital; /* convenience flags */ |
| 840 | char synthItal; | 819 | char synthItal; |
| @@ -844,7 +823,7 @@ struct nsfont_info | |||
| 844 | unsigned short **glyphs; /* map Unicode index to glyph */ | 823 | unsigned short **glyphs; /* map Unicode index to glyph */ |
| 845 | struct font_metrics **metrics; | 824 | struct font_metrics **metrics; |
| 846 | }; | 825 | }; |
| 847 | 826 | #endif | |
| 848 | 827 | ||
| 849 | /* Initialized in ns_initialize_display_info (). */ | 828 | /* Initialized in ns_initialize_display_info (). */ |
| 850 | struct ns_display_info | 829 | struct ns_display_info |
| @@ -1107,7 +1086,7 @@ extern void ns_term_shutdown (int sig); | |||
| 1107 | #define NS_DUMPGLYPH_MOUSEFACE 3 | 1086 | #define NS_DUMPGLYPH_MOUSEFACE 3 |
| 1108 | 1087 | ||
| 1109 | 1088 | ||
| 1110 | 1089 | #ifdef NS_IMPL_GNUSTEP | |
| 1111 | /* In nsfont, called from fontset.c */ | 1090 | /* In nsfont, called from fontset.c */ |
| 1112 | extern void nsfont_make_fontset_for_font (Lisp_Object name, | 1091 | extern void nsfont_make_fontset_for_font (Lisp_Object name, |
| 1113 | Lisp_Object font_object); | 1092 | Lisp_Object font_object); |
| @@ -1115,6 +1094,7 @@ extern void nsfont_make_fontset_for_font (Lisp_Object name, | |||
| 1115 | /* In nsfont, for debugging */ | 1094 | /* In nsfont, for debugging */ |
| 1116 | struct glyph_string; | 1095 | struct glyph_string; |
| 1117 | void ns_dump_glyphstring (struct glyph_string *s) EXTERNALLY_VISIBLE; | 1096 | void ns_dump_glyphstring (struct glyph_string *s) EXTERNALLY_VISIBLE; |
| 1097 | #endif | ||
| 1118 | 1098 | ||
| 1119 | /* Implemented in nsterm, published in or needed from nsfns. */ | 1099 | /* Implemented in nsterm, published in or needed from nsfns. */ |
| 1120 | extern Lisp_Object ns_list_fonts (struct frame *f, Lisp_Object pattern, | 1100 | extern Lisp_Object ns_list_fonts (struct frame *f, Lisp_Object pattern, |
diff --git a/src/nsterm.m b/src/nsterm.m index 4b1cf65964c..ec96be3d2f6 100644 --- a/src/nsterm.m +++ b/src/nsterm.m | |||
| @@ -3194,10 +3194,12 @@ ns_compute_glyph_string_overhangs (struct glyph_string *s) | |||
| 3194 | else | 3194 | else |
| 3195 | { | 3195 | { |
| 3196 | s->left_overhang = 0; | 3196 | s->left_overhang = 0; |
| 3197 | #ifdef NS_IMPL_GNUSTEP | ||
| 3197 | if (EQ (font->driver->type, Qns)) | 3198 | if (EQ (font->driver->type, Qns)) |
| 3198 | s->right_overhang = ((struct nsfont_info *)font)->ital ? | 3199 | s->right_overhang = ((struct nsfont_info *)font)->ital ? |
| 3199 | FONT_HEIGHT (font) * 0.2 : 0; | 3200 | FONT_HEIGHT (font) * 0.2 : 0; |
| 3200 | else | 3201 | else |
| 3202 | #endif | ||
| 3201 | s->right_overhang = 0; | 3203 | s->right_overhang = 0; |
| 3202 | } | 3204 | } |
| 3203 | } | 3205 | } |