@@ -33,10 +33,10 @@ - (instancetype)initFontWithName:(NSString *)name size:(CGFloat)size
33
33
NSBundle * bundle = [MTFont fontBundle ];
34
34
NSString * fontPath = [bundle pathForResource: name ofType: @" otf" ];
35
35
CGDataProviderRef fontDataProvider = CGDataProviderCreateWithFilename (fontPath.UTF8String );
36
- self. defaultCGFont = CGFontCreateWithDataProvider (fontDataProvider);
36
+ _defaultCGFont = CGFontCreateWithDataProvider (fontDataProvider);
37
37
CFRelease (fontDataProvider);
38
38
39
- self. ctFont = CTFontCreateWithGraphicsFont (self.defaultCGFont , size, nil , nil );
39
+ _ctFont = CTFontCreateWithGraphicsFont (self.defaultCGFont , size, nil , nil );
40
40
41
41
NSString * mathTablePlist = [bundle pathForResource: name ofType: @" plist" ];
42
42
NSDictionary * dict = [NSDictionary dictionaryWithContentsOfFile: mathTablePlist];
@@ -77,11 +77,11 @@ - (MTFont *)copyFontWithSize:(CGFloat)size
77
77
{
78
78
MTFont* copyFont = [[[self class ] alloc ] init ];
79
79
copyFont.defaultCGFont = self.defaultCGFont ;
80
- // Retain the font as we are adding another reference to it.
81
- CGFontRetain (copyFont.defaultCGFont );
82
- copyFont.ctFont = CTFontCreateWithGraphicsFont (self.defaultCGFont , size, nil , nil );
80
+ CTFontRef newCtFont = CTFontCreateWithGraphicsFont (self.defaultCGFont , size, nil , nil );
81
+ copyFont.ctFont = newCtFont;
83
82
copyFont.rawMathTable = self.rawMathTable ;
84
83
copyFont.mathTable = [[MTFontMathTable alloc ] initWithFont: copyFont mathTable: copyFont.rawMathTable];
84
+ CFRelease (newCtFont);
85
85
return copyFont;
86
86
}
87
87
0 commit comments