[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677
rjw
rjw at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:16:00 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit 4df709aeb237034590436cd78f18a8f30df4f929
Author: rjw <rjw at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Dec 17 22:53:54 2002 +0000
Fixed 3128794. Use CG directy to get font metrics rather than the appkit. The appkit
has a bug that sometimes causes line height to be 20% too large.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@3105 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index af9dab1..2797a8e 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,16 @@
+2002-12-17 Richard Williamson <rjw at apple.com>
+
+ Fixed 3128794. Use CG directy to get font metrics rather than the appkit. The appkit
+ has a bug (3129490) that sometimes causes line height to be 20% too large.
+
+ Reviewed by hyatt.
+
+ * WebCoreSupport.subproj/WebTextRenderer.m:
+ (-[WebTextRenderer initWithFont:]):
+ (-[WebTextRenderer ascent]):
+ (-[WebTextRenderer descent]):
+ (-[WebTextRenderer lineSpacing]):
+
2002-12-17 Trey Matteson <trey at apple.com>
Reworking the code to update the page icon led me to roll the WebIconDB API
diff --git a/WebKit/WebCoreSupport.subproj/WebTextRenderer.m b/WebKit/WebCoreSupport.subproj/WebTextRenderer.m
index 8a08ab1..55f89f5 100644
--- a/WebKit/WebCoreSupport.subproj/WebTextRenderer.m
+++ b/WebKit/WebCoreSupport.subproj/WebTextRenderer.m
@@ -446,7 +446,6 @@ static inline BOOL _fontContainsString (NSFont *font, NSString *string)
spaceWidth = _spaceWidth;
}
-
- initWithFont:(NSFont *)f
{
if ([f glyphPacking] != NSNativeShortGlyphPacking &&
@@ -456,9 +455,6 @@ static inline BOOL _fontContainsString (NSFont *font, NSString *string)
[super init];
font = [f retain];
- ascent = -1;
- descent = -1;
- lineSpacing = -1;
OSStatus errCode;
ATSUStyle style;
@@ -475,6 +471,44 @@ static inline BOOL _fontContainsString (NSFont *font, NSString *string)
ATSUDisposeStyle(style);
[self _computeWidthForSpace];
+
+ // We emulate the appkit metrics by applying rounding as is done
+ // in the appkit.
+ CGFontRef cgFont = [f _backingCGSFont];
+ const CGFontHMetrics *metrics = CGFontGetHMetrics(cgFont);
+ unsigned int unitsPerEm = CGFontGetUnitsPerEm(cgFont);
+ float pointSize = [f pointSize];
+ float asc = (ScaleEmToUnits(metrics->ascent, unitsPerEm)*pointSize);
+ float dsc = (-ScaleEmToUnits(metrics->descent, unitsPerEm)*pointSize);
+ float lineGap = ScaleEmToUnits(metrics->lineGap, unitsPerEm)*pointSize;
+
+ ascent = ROUND_TO_INT(asc);
+ descent = ROUND_TO_INT(dsc);
+ lineSpacing = ascent + descent + (int)(lineGap > 0.0 ? floor(lineGap + 0.5) : 0.0);
+
+#ifdef COMPARE_APPKIT_CG_METRICS
+ if ((int)ROUND_TO_INT([f ascender]) != ascent ||
+ (int)ROUND_TO_INT(-[f descender]) != descent ||
+ (int)ROUND_TO_INT([font defaultLineHeightForFont]) != lineSpacing){
+ printf ("\nCG/Appkit mismatched metrics for font %s, %f (%s)\n", [[f displayName] cString], [f pointSize],
+ ([f screenFont] ? [[[f screenFont] displayName] cString] : "none"));
+ printf ("ascent(%s), descent(%s), lineSpacing(%s)\n",
+ ((int)ROUND_TO_INT([f ascender]) != ascent) ? "different" : "same",
+ ((int)ROUND_TO_INT(-[f descender]) != descent) ? "different" : "same",
+ ((int)ROUND_TO_INT([font defaultLineHeightForFont]) != lineSpacing) ? "different" : "same");
+ printf ("CG: ascent %f, ", asc);
+ printf ("descent %f, ", dsc);
+ printf ("lineGap %f, ", lineGap);
+ printf ("lineSpacing %d\n", lineSpacing);
+
+ printf ("NSFont: ascent %f, ", [f ascender]);
+ printf ("descent %f, ", [f descender]);
+ printf ("lineSpacing %f\n", [font defaultLineHeightForFont]);
+ }
+ else {
+ printf ("\nCG/Appkit matched metrics for font %s, %f\n", [[f displayName] cString], [f pointSize]);
+ }
+#endif
return self;
}
@@ -527,27 +561,18 @@ static inline BOOL _fontContainsString (NSFont *font, NSString *string)
- (int)ascent
{
- if (ascent < 0) {
- ascent = ROUND_TO_INT([font ascender]);
- }
return ascent;
}
- (int)descent
{
- if (descent < 0) {
- descent = ROUND_TO_INT(-[font descender]);
- }
return descent;
}
- (int)lineSpacing
{
- if (lineSpacing < 0) {
- lineSpacing = ROUND_TO_INT([font defaultLineHeightForFont]);
- }
return lineSpacing;
}
@@ -748,8 +773,8 @@ static void _drawGlyphs(NSFont *font, NSColor *color, CGGlyph *glyphs, CGSize *a
lineWidth = size.width;
}
CGContextSetLineWidth(cgContext, lineWidth);
- CGContextMoveToPoint(cgContext, point.x, point.y + [font defaultLineHeightForFont] + 1.5 - [self descent] + yOffset);
- CGContextAddLineToPoint(cgContext, point.x + width, point.y + [font defaultLineHeightForFont] + 1.5 - [self descent] + yOffset);
+ CGContextMoveToPoint(cgContext, point.x, point.y + [self lineSpacing] + 1.5 - [self descent] + yOffset);
+ CGContextAddLineToPoint(cgContext, point.x + width, point.y + [self lineSpacing] + 1.5 - [self descent] + yOffset);
CGContextStrokePath(cgContext);
[graphicsContext setShouldAntialias: flag];
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list