|
32 | 32 | MAX_TEXT_HEIGHT = 512 |
33 | 33 | }; |
34 | 34 |
|
35 | | -#define APPLE_FONT "Helvetica" |
| 35 | +#define APPLE_FONT "Roboto-Condensed" |
| 36 | + |
| 37 | +// for future OpenEmu support |
| 38 | +#ifndef PPSSPP_FONT_BUNDLE |
| 39 | +#define PPSSPP_FONT_BUNDLE [NSBundle mainBundle] |
| 40 | +#endif |
36 | 41 |
|
37 | 42 | class TextDrawerFontContext { |
38 | 43 | public: |
|
41 | 46 | } |
42 | 47 |
|
43 | 48 | void Create() { |
| 49 | + // Register font with CoreText |
| 50 | + // We only need to do this once. |
| 51 | + static dispatch_once_t onceToken; |
| 52 | + dispatch_once(&onceToken, ^{ |
| 53 | + NSURL *fontURL = [PPSSPP_FONT_BUNDLE URLForResource:@"Roboto-Condensed" withExtension:@"ttf" subdirectory:@"assets"]; |
| 54 | + CTFontManagerRegisterFontsForURL((CFURLRef)fontURL, kCTFontManagerScopeProcess, NULL); |
| 55 | + }); |
44 | 56 | // Create an attributed string with string and font information |
45 | 57 | CGFloat fontSize = ceilf((height / dpiScale) * 1.25f); |
46 | 58 | INFO_LOG(Log::G3D, "Creating cocoa typeface '%s' size %d (effective size %0.1f)", APPLE_FONT, height, fontSize); |
47 | | - // CTFontRef font = CTFontCreateWithName(CFSTR(APPLE_FONT), fontSize, nil); |
48 | | - CTFontRef font = CTFontCreateUIFontForLanguage(kCTFontUIFontSystem, fontSize, nil); |
| 59 | + CTFontRef font = CTFontCreateWithName(CFSTR(APPLE_FONT), fontSize, nil); |
| 60 | + // CTFontRef font = CTFontCreateUIFontForLanguage(kCTFontUIFontSystem, fontSize, nil); |
49 | 61 | attributes = [NSDictionary dictionaryWithObjectsAndKeys: |
50 | 62 | (__bridge id)font, kCTFontAttributeName, |
51 | 63 | kCFBooleanTrue, kCTForegroundColorFromContextAttributeName, // Lets us specify the color later. |
52 | 64 | nil]; |
53 | 65 | CFRelease(font); |
54 | 66 | } |
55 | 67 | void Destroy() { |
56 | | - //CFRelease(font); |
57 | | - font = {}; |
58 | 68 | } |
59 | 69 |
|
60 | 70 | NSDictionary* attributes = nil; |
61 | | - CTFontRef font = nil; |
62 | 71 | std::string fname; |
63 | 72 | int height; |
64 | 73 | int bold; |
|
0 commit comments