diff options
| author | YAMAMOTO Mitsuharu | 2015-09-30 18:43:25 +0900 |
|---|---|---|
| committer | YAMAMOTO Mitsuharu | 2015-09-30 18:43:25 +0900 |
| commit | ecbb6aeb5f10e0ca4ba404570ee36961273fc139 (patch) | |
| tree | 9d76e65ac7ef78efc14058f55c2aa38178b74ded /src | |
| parent | d1fb5e6c49383c67df136efe2d34a5d3cfed78fd (diff) | |
| download | emacs-ecbb6aeb5f10e0ca4ba404570ee36961273fc139.tar.gz emacs-ecbb6aeb5f10e0ca4ba404570ee36961273fc139.zip | |
* src/macfont.m: Fix compilation with USE_CT_GLYPH_INFO.
Diffstat (limited to 'src')
| -rw-r--r-- | src/macfont.m | 84 |
1 files changed, 40 insertions, 44 deletions
diff --git a/src/macfont.m b/src/macfont.m index 97a255bf018..69640766d4e 100644 --- a/src/macfont.m +++ b/src/macfont.m | |||
| @@ -198,57 +198,53 @@ mac_screen_font_get_advance_width_for_glyph (ScreenFontRef font, CGGlyph glyph) | |||
| 198 | return advancement.width; | 198 | return advancement.width; |
| 199 | } | 199 | } |
| 200 | 200 | ||
| 201 | #if !USE_CT_GLYPH_INFO | ||
| 201 | static CGGlyph | 202 | static CGGlyph |
| 202 | mac_font_get_glyph_for_cid (CTFontRef font, CTCharacterCollection collection, | 203 | mac_font_get_glyph_for_cid (CTFontRef font, CTCharacterCollection collection, |
| 203 | CGFontIndex cid) | 204 | CGFontIndex cid) |
| 204 | { | 205 | { |
| 205 | #if USE_CT_GLYPH_INFO | 206 | CGGlyph result = kCGFontIndexInvalid; |
| 206 | return mac_ctfont_get_glyph_for_cid ((CTFontRef) font, collection, cid); | 207 | NSFont *nsFont = (NSFont *) font; |
| 207 | #else | 208 | unichar characters[] = {0xfffd}; |
| 208 | { | 209 | NSString *string = |
| 209 | CGGlyph result = kCGFontIndexInvalid; | 210 | [NSString stringWithCharacters:characters |
| 210 | NSFont *nsFont = (NSFont *) font; | 211 | length:ARRAYELTS (characters)]; |
| 211 | unichar characters[] = {0xfffd}; | 212 | NSGlyphInfo *glyphInfo = |
| 212 | NSString *string = | 213 | [NSGlyphInfo glyphInfoWithCharacterIdentifier:cid |
| 213 | [NSString stringWithCharacters:characters | 214 | collection:collection |
| 214 | length:ARRAYELTS (characters)]; | 215 | baseString:string]; |
| 215 | NSGlyphInfo *glyphInfo = | 216 | NSDictionary *attributes = |
| 216 | [NSGlyphInfo glyphInfoWithCharacterIdentifier:cid | 217 | [NSDictionary dictionaryWithObjectsAndKeys:nsFont,NSFontAttributeName, |
| 217 | collection:collection | 218 | glyphInfo,NSGlyphInfoAttributeName,nil]; |
| 218 | baseString:string]; | 219 | NSTextStorage *textStorage = |
| 219 | NSDictionary *attributes = | 220 | [[NSTextStorage alloc] initWithString:string |
| 220 | [NSDictionary dictionaryWithObjectsAndKeys:nsFont,NSFontAttributeName, | 221 | attributes:attributes]; |
| 221 | glyphInfo,NSGlyphInfoAttributeName,nil]; | 222 | NSLayoutManager *layoutManager = [[NSLayoutManager alloc] init]; |
| 222 | NSTextStorage *textStorage = | 223 | NSTextContainer *textContainer = [[NSTextContainer alloc] init]; |
| 223 | [[NSTextStorage alloc] initWithString:string | 224 | NSFont *fontInTextStorage; |
| 224 | attributes:attributes]; | ||
| 225 | NSLayoutManager *layoutManager = [[NSLayoutManager alloc] init]; | ||
| 226 | NSTextContainer *textContainer = [[NSTextContainer alloc] init]; | ||
| 227 | NSFont *fontInTextStorage; | ||
| 228 | |||
| 229 | [layoutManager addTextContainer:textContainer]; | ||
| 230 | [textContainer release]; | ||
| 231 | [textStorage addLayoutManager:layoutManager]; | ||
| 232 | [layoutManager release]; | ||
| 233 | |||
| 234 | /* Force layout. */ | ||
| 235 | (void) [layoutManager glyphRangeForTextContainer:textContainer]; | ||
| 236 | |||
| 237 | fontInTextStorage = [textStorage attribute:NSFontAttributeName atIndex:0 | ||
| 238 | effectiveRange:NULL]; | ||
| 239 | if (fontInTextStorage == nsFont | ||
| 240 | || [[fontInTextStorage fontName] isEqualToString:[nsFont fontName]]) | ||
| 241 | { | ||
| 242 | NSGlyph glyph = [layoutManager glyphAtIndex:0]; | ||
| 243 | 225 | ||
| 244 | if (glyph < [nsFont numberOfGlyphs]) | 226 | [layoutManager addTextContainer:textContainer]; |
| 245 | result = glyph; | 227 | [textContainer release]; |
| 246 | } | 228 | [textStorage addLayoutManager:layoutManager]; |
| 229 | [layoutManager release]; | ||
| 247 | 230 | ||
| 248 | [textStorage release]; | 231 | /* Force layout. */ |
| 232 | (void) [layoutManager glyphRangeForTextContainer:textContainer]; | ||
| 249 | 233 | ||
| 250 | return result; | 234 | fontInTextStorage = [textStorage attribute:NSFontAttributeName atIndex:0 |
| 251 | } | 235 | effectiveRange:NULL]; |
| 236 | if (fontInTextStorage == nsFont | ||
| 237 | || [[fontInTextStorage fontName] isEqualToString:[nsFont fontName]]) | ||
| 238 | { | ||
| 239 | NSGlyph glyph = [layoutManager glyphAtIndex:0]; | ||
| 240 | |||
| 241 | if (glyph < [nsFont numberOfGlyphs]) | ||
| 242 | result = glyph; | ||
| 243 | } | ||
| 244 | |||
| 245 | [textStorage release]; | ||
| 246 | |||
| 247 | return result; | ||
| 252 | } | 248 | } |
| 253 | #endif | 249 | #endif |
| 254 | 250 | ||