[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:12:12 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 1ad6c6061f0c5991c93ebf4a71a6f45ac2a16d43
Author: rjw <rjw at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Dec 6 04:00:41 2002 +0000

            Don't ceil spaces if not a fixed pitch font.  This make sites
            that have hard coded block widths have less wrapping beyond what the
            designer expected.  Fixes 3117225.
    
            Reviewed by: mjs
    
            * WebCoreSupport.subproj/WebTextRenderer.h:
            * WebCoreSupport.subproj/WebTextRenderer.m:
            (widthForGlyph):
            (-[WebTextRenderer _computeWidthForSpace]):
            (-[WebTextRenderer initWithFont:]):
            (-[WebTextRenderer _floatWidthForCharacters:stringLength:fromCharacterPosition:numberOfCharacters:withPadding:applyRounding:attemptFontSubstitution:widths:fonts:glyphs:numGlyphs:letterSpacing:wordSpacing:fontFamilies:]):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@2955 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 5699fe3..eee9f78 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,18 @@
+2002-12-05  Richard Williamson   <rjw at apple.com>
+
+        Don't ceil spaces if not a fixed pitch font.  This make sites
+        that have hard coded block widths have less wrapping beyond what the
+        designer expected.  Fixes 3117225.
+        
+        Reviewed by: mjs
+
+        * WebCoreSupport.subproj/WebTextRenderer.h:
+        * WebCoreSupport.subproj/WebTextRenderer.m:
+        (widthForGlyph):
+        (-[WebTextRenderer _computeWidthForSpace]):
+        (-[WebTextRenderer initWithFont:]):
+        (-[WebTextRenderer _floatWidthForCharacters:stringLength:fromCharacterPosition:numberOfCharacters:withPadding:applyRounding:attemptFontSubstitution:widths:fonts:glyphs:numGlyphs:letterSpacing:wordSpacing:fontFamilies:]):
+
 2002-12-05  Chris Blumenberg  <cblu at apple.com>
 
 	Added WebDocumentText protocol. Made WebHTMLView and WebTextView implement it.
diff --git a/WebKit/WebCoreSupport.subproj/WebTextRenderer.h b/WebKit/WebCoreSupport.subproj/WebTextRenderer.h
index 3c67433..9ba98c8 100644
--- a/WebKit/WebCoreSupport.subproj/WebTextRenderer.h
+++ b/WebKit/WebCoreSupport.subproj/WebTextRenderer.h
@@ -24,6 +24,8 @@ typedef struct UnicodeGlyphMap UnicodeGlyphMap;
     UnicodeGlyphMap *unicodeCharacterToGlyphMap; 	// Used for surrogates.
     WidthMap *glyphToWidthMap;
     float spaceWidth;
+    float ceiledSpaceWidth;
+    float roundedSpaceWidth;
     float adjustedSpaceWidth;
 }
 
diff --git a/WebKit/WebCoreSupport.subproj/WebTextRenderer.m b/WebKit/WebCoreSupport.subproj/WebTextRenderer.m
index 15e753a..33d0dea 100644
--- a/WebKit/WebCoreSupport.subproj/WebTextRenderer.m
+++ b/WebKit/WebCoreSupport.subproj/WebTextRenderer.m
@@ -193,7 +193,7 @@ static inline WebGlyphWidth widthForGlyph (WebTextRenderer *renderer, WidthMap *
     // the same width as a space in that font.  In practice this is not an issue as the
     // adjustment is always as the sub-pixel level.
     if (width == renderer->spaceWidth)
-        return renderer->adjustedSpaceWidth;
+        return renderer->ceiledSpaceWidth;
 
     return width;
 }
@@ -387,6 +387,42 @@ static BOOL bufferTextDrawing = NO;
     }
 }
 
+// Nasty hack to determine if we should round or ceil space widths.
+// If the font is monospace, or all the ascii characters have the same
+// width as the space character we ceil to ensure that every character
+// and the space are the same width.  Otherwise we round.
+- (void)_computeWidthForSpace
+{
+    ATSGlyphRef glyphID;
+    float aWidth;
+    UniChar i;
+    UniChar c = ' ';
+    float _spaceWidth;
+
+    spaceGlyph = [self extendCharacterToGlyphMapToInclude: c];
+    _spaceWidth = widthForGlyph(self, glyphToWidthMap, spaceGlyph);
+    ceiledSpaceWidth = (float)CEIL_TO_INT(_spaceWidth);
+    roundedSpaceWidth = (float)ROUND_TO_INT(_spaceWidth);
+    if ([font isFixedPitch]){
+        adjustedSpaceWidth = ceiledSpaceWidth;
+    }
+    else {
+        for (i = 0x21; i < 0x7f; i++){
+            glyphID = glyphForCharacter(characterToGlyphMap, i);
+            aWidth = widthForGlyph(self, glyphToWidthMap, glyphID);
+            if (aWidth != 0 && aWidth != _spaceWidth)
+                break;
+        }
+        if (i == 0x7f){
+            adjustedSpaceWidth = ceiledSpaceWidth;
+        }
+        else {
+            adjustedSpaceWidth = roundedSpaceWidth;
+        }
+    }
+    spaceWidth = _spaceWidth;
+}
+
 
 - initWithFont:(NSFont *)f
 {
@@ -415,10 +451,7 @@ static BOOL bufferTextDrawing = NO;
     
     ATSUDisposeStyle(style);
 
-    UniChar c = ' ';
-    spaceGlyph = [self extendCharacterToGlyphMapToInclude: c];
-    spaceWidth = widthForGlyph(self, glyphToWidthMap, spaceGlyph);
-    adjustedSpaceWidth = (float)CEIL_TO_INT(spaceWidth);
+    [self _computeWidthForSpace];
     
     return self;
 }
@@ -912,7 +945,7 @@ static const char *joiningNames[] = {
                     totalWidth += delta;
                     if (widthBuffer)
                         widthBuffer[numGlyphs - 1] += delta;
-                }   
+                } 
                 lastWidth = adjustedSpaceWidth;
                 if (padding > 0){
                     // Only use left over padding if note evenly divisible by 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list