Commit 92f3789b authored by rjw's avatar rjw
Browse files

Obey the font smoothing size preference (3137618).

        Reviewed by Don and Darin.

        * WebCoreSupport.subproj/WebTextRenderer.m:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@3230 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 51e8fadc
2003-01-01 Richard Williamson <rjw@apple.com>
Obey the font smoothing size preference (3137618).
Reviewed by Don and Darin.
* WebCoreSupport.subproj/WebTextRenderer.m:
2002-12-31 Maciej Stachowiak <mjs@apple.com>
Reviewed by Darin.
......
......@@ -294,11 +294,25 @@ + (BOOL)shouldBufferTextDrawing
return bufferTextDrawing;
}
static float _WebAntiAliasingThreshold = 9.0;
+ (void)_updateAntialiasingThreshold {
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
id val;
[userDefaults synchronize];
val = [userDefaults objectForKey:@"AppleAntiAliasingThreshold"];
_WebAntiAliasingThreshold = (val ? [val floatValue] : _WebAntiAliasingThreshold);
}
+ (void)initialize
{
WebKitInitializeUnicode();
nonBaseChars = CFCharacterSetGetPredefined(kCFCharacterSetNonBase);
bufferTextDrawing = [[[NSUserDefaults standardUserDefaults] stringForKey:@"BufferTextDrawing"] isEqual: @"YES"];
[[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(_updateAntialiasingThreshold) name:@"AppleAquaAntiAliasingChanged" object:nil suspensionBehavior:NSNotificationSuspensionBehaviorDeliverImmediately];
[WebTextRenderer _updateAntialiasingThreshold];
}
static inline BOOL _fontContainsString (NSFont *font, NSString *string)
......@@ -614,12 +628,17 @@ - (float)xHeight
return [font xHeight];
}
// Useful page for testing http://home.att.net/~jameskass
static void _drawGlyphs(NSFont *font, NSColor *color, CGGlyph *glyphs, CGSize *advances, float x, float y, int numGlyphs)
{
NSGraphicsContext *gc = [NSGraphicsContext currentContext];
CGContextRef cgContext;
BOOL flag = [gc shouldAntialias];
if ([font pointSize] <= _WebAntiAliasingThreshold)
[gc setShouldAntialias: NO];
if ([WebTextRenderer shouldBufferTextDrawing] && [[WebTextRendererFactory sharedFactory] coalesceTextDrawing]){
// Add buffered glyphs and advances
// FIXME: If we ever use this again, need to add RTL.
......@@ -627,7 +646,7 @@ static void _drawGlyphs(NSFont *font, NSColor *color, CGGlyph *glyphs, CGSize *a
[gBuffer addGlyphs: glyphs advances: advances count: numGlyphs at: x : y];
}
else {
cgContext = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
cgContext = (CGContextRef)[gc graphicsPort];
// Setup the color and font.
[color set];
[font set];
......@@ -635,6 +654,7 @@ static void _drawGlyphs(NSFont *font, NSColor *color, CGGlyph *glyphs, CGSize *a
CGContextSetTextPosition (cgContext, x, y);
CGContextShowGlyphsWithAdvances (cgContext, glyphs, advances, numGlyphs);
}
[gc setShouldAntialias: flag];
}
- (void)drawCharacters:(const UniChar *)characters stringLength: (unsigned int)length fromCharacterPosition: (int)from toCharacterPosition: (int)to atPoint:(NSPoint)point withPadding: (int)padding withTextColor:(NSColor *)textColor backgroundColor: (NSColor *)backgroundColor rightToLeft: (BOOL)rtl letterSpacing: (int)letterSpacing wordSpacing: (int)wordSpacing fontFamilies: (NSString **)families
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment