Add wide font support to Core Text renderer

This commit is contained in:
Bjorn Winckler
2010-02-14 01:23:59 +01:00
parent 3f6c885564
commit c9a95e68f9
2 changed files with 15 additions and 3 deletions
+1
View File
@@ -23,6 +23,7 @@
NSColor *defaultForegroundColor;
NSSize cellSize;
NSFont *font;
NSFont *fontWide;
float linespace;
// From NSTextView
+14 -3
View File
@@ -159,6 +159,7 @@ defaultAdvanceForFont(CTFontRef fontRef)
- (void)dealloc
{
[font release]; font = nil;
[fontWide release]; fontWide = nil;
[defaultBackgroundColor release]; defaultBackgroundColor = nil;
[defaultForegroundColor release]; defaultForegroundColor = nil;
[drawData release]; drawData = nil;
@@ -335,6 +336,16 @@ defaultAdvanceForFont(CTFontRef fontRef)
- (void)setWideFont:(NSFont *)newFont
{
if (!newFont) {
// Use the normal font as the wide font (note that the normal font may
// very well include wide characters.)
if (font) [self setWideFont:font];
} else if (newFont != fontWide) {
// NOTE: No need to set point size etc. since this is taken from the
// regular font when drawing.
[fontWide release];
fontWide = [newFont retain];
}
}
- (NSFont *)font
@@ -344,7 +355,7 @@ defaultAdvanceForFont(CTFontRef fontRef)
- (NSFont *)fontWide
{
return nil;
return fontWide;
}
- (NSSize)cellSize
@@ -1156,8 +1167,8 @@ recurseDraw(const unichar *chars, CGGlyph *glyphs, CGSize *advances,
for (i = 0; i < length; ++i)
advances[i].width = w;
CTFontRef fontRef = (CTFontRef)[font retain];
CTFontRef fontRef = (CTFontRef)(flags & DRAW_WIDE ? [fontWide retain]
: [font retain]);
unsigned traits = 0;
if (flags & DRAW_ITALIC)
traits |= kCTFontItalicTrait;