[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 06:59:20 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit 16de661486e28872b2b684a2fa8715408ca2868e
Author: rjw <rjw at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Wed Nov 13 01:07:09 2002 +0000
Implemented letter-spacing and word-spacing CSS properties.
* khtml/rendering/font.cpp:
(Font::drawText):
(Font::floatWidth):
(Font::floatCharacterWidths):
* kwq/KWQFontMetrics.h:
* kwq/KWQFontMetrics.mm:
(QFontMetrics::width):
(QFontMetrics::floatWidth):
(QFontMetrics::floatCharacterWidths):
* kwq/KWQPainter.h:
* kwq/KWQPainter.mm:
(QPainter::drawText):
* kwq/WebCoreTextRenderer.h:
Implemented letter-spacing and word-spacing CSS properties.
* Misc.subproj/WebStringTruncator.m:
(+[WebStringTruncator rightTruncateString:toWidth:withFont:]):
(+[WebStringTruncator centerTruncateString:toWidth:withFont:]):
* WebCoreSupport.subproj/WebTextRenderer.h:
* WebCoreSupport.subproj/WebTextRenderer.m:
(-[WebTextRenderer widthForCharacters:length:]):
(-[WebTextRenderer drawCharacters:stringLength:fromCharacterPosition:toCharacterPosition:atPoint:withPadding:withTextColor:backgroundColor:rightToLeft:letterSpacing:wordSpacing:]):
(-[WebTextRenderer floatWidthForCharacters:stringLength:characterPosition:]):
(-[WebTextRenderer floatWidthForCharacters:stringLength:fromCharacterPosition:numberOfCharacters:]):
(-[WebTextRenderer floatWidthForCharacters:stringLength:fromCharacterPosition:numberOfCharacters:withPadding:applyRounding:attemptFontSubstitution:widths:letterSpacing:wordSpacing:]):
(-[WebTextRenderer _floatWidthForCharacters:stringLength:fromCharacterPosition:numberOfCharacters:withPadding:applyRounding:attemptFontSubstitution:widths:fonts:glyphs:numGlyphs:letterSpacing:wordSpacing:]):
Changed to reflect method name change.
* EtchedStringView.m:
(-[EtchedStringView drawRect:]):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@2640 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog-2002-12-03 b/WebCore/ChangeLog-2002-12-03
index ef5fddf..c504a39 100644
--- a/WebCore/ChangeLog-2002-12-03
+++ b/WebCore/ChangeLog-2002-12-03
@@ -1,3 +1,21 @@
+2002-11-12 Richard Williamson <rjw at apple.com>
+
+ Implemented letter-spacing and word-spacing CSS properties.
+
+ * khtml/rendering/font.cpp:
+ (Font::drawText):
+ (Font::floatWidth):
+ (Font::floatCharacterWidths):
+ * kwq/KWQFontMetrics.h:
+ * kwq/KWQFontMetrics.mm:
+ (QFontMetrics::width):
+ (QFontMetrics::floatWidth):
+ (QFontMetrics::floatCharacterWidths):
+ * kwq/KWQPainter.h:
+ * kwq/KWQPainter.mm:
+ (QPainter::drawText):
+ * kwq/WebCoreTextRenderer.h:
+
2002-11-12 David Hyatt <hyatt at apple.com>
Revert floats so that they don't use layers any more.
diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index ef5fddf..c504a39 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,21 @@
+2002-11-12 Richard Williamson <rjw at apple.com>
+
+ Implemented letter-spacing and word-spacing CSS properties.
+
+ * khtml/rendering/font.cpp:
+ (Font::drawText):
+ (Font::floatWidth):
+ (Font::floatCharacterWidths):
+ * kwq/KWQFontMetrics.h:
+ * kwq/KWQFontMetrics.mm:
+ (QFontMetrics::width):
+ (QFontMetrics::floatWidth):
+ (QFontMetrics::floatCharacterWidths):
+ * kwq/KWQPainter.h:
+ * kwq/KWQPainter.mm:
+ (QPainter::drawText):
+ * kwq/WebCoreTextRenderer.h:
+
2002-11-12 David Hyatt <hyatt at apple.com>
Revert floats so that they don't use layers any more.
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index ef5fddf..c504a39 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,21 @@
+2002-11-12 Richard Williamson <rjw at apple.com>
+
+ Implemented letter-spacing and word-spacing CSS properties.
+
+ * khtml/rendering/font.cpp:
+ (Font::drawText):
+ (Font::floatWidth):
+ (Font::floatCharacterWidths):
+ * kwq/KWQFontMetrics.h:
+ * kwq/KWQFontMetrics.mm:
+ (QFontMetrics::width):
+ (QFontMetrics::floatWidth):
+ (QFontMetrics::floatCharacterWidths):
+ * kwq/KWQPainter.h:
+ * kwq/KWQPainter.mm:
+ (QPainter::drawText):
+ * kwq/WebCoreTextRenderer.h:
+
2002-11-12 David Hyatt <hyatt at apple.com>
Revert floats so that they don't use layers any more.
diff --git a/WebCore/khtml/rendering/font.cpp b/WebCore/khtml/rendering/font.cpp
index 80fbbb5..242050d 100644
--- a/WebCore/khtml/rendering/font.cpp
+++ b/WebCore/khtml/rendering/font.cpp
@@ -41,7 +41,8 @@ void Font::drawText( QPainter *p, int x, int y, QChar *str, int slen, int pos, i
int toAdd, QPainter::TextDirection d, int from, int to, QColor bg ) const
{
#if APPLE_CHANGES
- p->drawText(x, y, str + pos, std::min(slen - pos, len), from, to, toAdd, bg, d);
+ printf ("for string length %d, letterSpacing = %d\n", slen, letterSpacing);
+ p->drawText(x, y, str + pos, std::min(slen - pos, len), from, to, toAdd, bg, d, letterSpacing, wordSpacing);
#else
QString qstr = QConstString(str, slen).string();
@@ -104,13 +105,13 @@ void Font::drawText( QPainter *p, int x, int y, QChar *str, int slen, int pos, i
float Font::floatWidth( QChar *chs, int slen, int pos, int len ) const
{
- return fm.floatWidth(chs, slen, pos, len);
+ return fm.floatWidth(chs, slen, pos, len, letterSpacing, wordSpacing);
}
void Font::floatCharacterWidths( QChar *str, int slen, int pos, int len, int toAdd, float *buffer) const
{
- fm.floatCharacterWidths(str, slen, pos, len, toAdd, buffer);
+ fm.floatCharacterWidths(str, slen, pos, len, toAdd, buffer, letterSpacing, wordSpacing);
}
#endif
diff --git a/WebCore/kwq/KWQFontMetrics.h b/WebCore/kwq/KWQFontMetrics.h
index a2c62c2..3f173ac 100644
--- a/WebCore/kwq/KWQFontMetrics.h
+++ b/WebCore/kwq/KWQFontMetrics.h
@@ -53,8 +53,8 @@ public:
int width(const QString &, int len=-1) const;
int charWidth(const QString &, int pos) const;
int width(const QChar *, int len) const;
- float floatWidth(const QChar *, int slen, int pos, int len) const;
- float floatCharacterWidths(const QChar *, int slen, int pos, int len, int toAdd, float *buffer) const;
+ float floatWidth(const QChar *, int slen, int pos, int len, int letterSpacing, int wordSpacing) const;
+ float floatCharacterWidths(const QChar *, int slen, int pos, int len, int toAdd, float *buffer, int letterSpacing, int wordSpacing) const;
QRect boundingRect(const QString &, int len=-1) const;
QRect boundingRect(int, int, int, int, int, const QString &) const;
diff --git a/WebCore/kwq/KWQFontMetrics.mm b/WebCore/kwq/KWQFontMetrics.mm
index eb58b75..5f211fe 100644
--- a/WebCore/kwq/KWQFontMetrics.mm
+++ b/WebCore/kwq/KWQFontMetrics.mm
@@ -112,7 +112,7 @@ float QFontMetrics::xHeight() const
int QFontMetrics::width(QChar qc) const
{
UniChar c = qc.unicode();
- return ROUND_TO_INT([data->getRenderer() floatWidthForCharacters:&c stringLength:1 fromCharacterPosition:0 numberOfCharacters:1 withPadding: 0 applyRounding:YES attemptFontSubstitution: YES widths: 0]);
+ return ROUND_TO_INT([data->getRenderer() floatWidthForCharacters:&c stringLength:1 fromCharacterPosition:0 numberOfCharacters:1 withPadding: 0 applyRounding:YES attemptFontSubstitution: YES widths:0 letterSpacing:0 wordSpacing:0]);
}
int QFontMetrics::charWidth(const QString &s, int pos) const
@@ -123,27 +123,27 @@ int QFontMetrics::charWidth(const QString &s, int pos) const
int QFontMetrics::width(char c) const
{
UniChar ch = (uchar) c;
- return ROUND_TO_INT([data->getRenderer() floatWidthForCharacters:&ch stringLength:1 fromCharacterPosition:0 numberOfCharacters:1 withPadding: 0 applyRounding:YES attemptFontSubstitution: YES widths: 0]);
+ return ROUND_TO_INT([data->getRenderer() floatWidthForCharacters:&ch stringLength:1 fromCharacterPosition:0 numberOfCharacters:1 withPadding: 0 applyRounding:YES attemptFontSubstitution: YES widths:0 letterSpacing:0 wordSpacing:0]);
}
int QFontMetrics::width(const QString &qstring, int len) const
{
- return ROUND_TO_INT([data->getRenderer() floatWidthForCharacters:(const UniChar *)qstring.unicode() stringLength:len fromCharacterPosition:0 numberOfCharacters:len withPadding: 0 applyRounding:YES attemptFontSubstitution: YES widths: 0]);
+ return ROUND_TO_INT([data->getRenderer() floatWidthForCharacters:(const UniChar *)qstring.unicode() stringLength:len fromCharacterPosition:0 numberOfCharacters:len withPadding: 0 applyRounding:YES attemptFontSubstitution: YES widths: 0 letterSpacing:0 wordSpacing:0]);
}
int QFontMetrics::width(const QChar *uchars, int len) const
{
- return ROUND_TO_INT([data->getRenderer() floatWidthForCharacters:(const UniChar *)uchars stringLength:len fromCharacterPosition:0 numberOfCharacters:len withPadding: 0 applyRounding:YES attemptFontSubstitution: YES widths: 0]);
+ return ROUND_TO_INT([data->getRenderer() floatWidthForCharacters:(const UniChar *)uchars stringLength:len fromCharacterPosition:0 numberOfCharacters:len withPadding: 0 applyRounding:YES attemptFontSubstitution: YES widths: 0 letterSpacing:0 wordSpacing:0]);
}
-float QFontMetrics::floatWidth(const QChar *uchars, int slen, int pos, int len) const
+float QFontMetrics::floatWidth(const QChar *uchars, int slen, int pos, int len, int letterSpacing, int wordSpacing) const
{
- return [data->getRenderer() floatWidthForCharacters:(const UniChar *)uchars stringLength:slen fromCharacterPosition:pos numberOfCharacters:len withPadding: 0 applyRounding: YES attemptFontSubstitution: YES widths: 0];
+ return [data->getRenderer() floatWidthForCharacters:(const UniChar *)uchars stringLength:slen fromCharacterPosition:pos numberOfCharacters:len withPadding: 0 applyRounding: YES attemptFontSubstitution: YES widths: 0 letterSpacing:letterSpacing wordSpacing:wordSpacing];
}
-float QFontMetrics::floatCharacterWidths(const QChar *uchars, int slen, int pos, int len, int toAdd, float *buffer) const
+float QFontMetrics::floatCharacterWidths(const QChar *uchars, int slen, int pos, int len, int toAdd, float *buffer, int letterSpacing, int wordSpacing) const
{
- return [data->getRenderer() floatWidthForCharacters:(const UniChar *)uchars stringLength:slen fromCharacterPosition:pos numberOfCharacters:len withPadding: toAdd applyRounding: YES attemptFontSubstitution: YES widths: (float *)buffer];
+ return [data->getRenderer() floatWidthForCharacters:(const UniChar *)uchars stringLength:slen fromCharacterPosition:pos numberOfCharacters:len withPadding: toAdd applyRounding: YES attemptFontSubstitution: YES widths: (float *)buffer letterSpacing:letterSpacing wordSpacing: wordSpacing];
}
QRect QFontMetrics::boundingRect(const QString &qstring, int len) const
diff --git a/WebCore/kwq/KWQPainter.h b/WebCore/kwq/KWQPainter.h
index 3da9535..004a7ea 100644
--- a/WebCore/kwq/KWQPainter.h
+++ b/WebCore/kwq/KWQPainter.h
@@ -91,7 +91,7 @@ public:
void setRasterOp(RasterOp);
void drawText(int x, int y, int, int, int alignmentFlags, const QString &);
- void drawText(int x, int y, const QChar *, int length, int from, int to, int toAdd, const QColor& backgroundColor, QPainter::TextDirection d);
+ void drawText(int x, int y, const QChar *, int length, int from, int to, int toAdd, const QColor& backgroundColor, QPainter::TextDirection d, int letterSpacing, int wordSpacing);
void drawUnderlineForText(int x, int y, const QChar *, int length);
static QColor selectedTextBackgroundColor();
diff --git a/WebCore/kwq/KWQPainter.mm b/WebCore/kwq/KWQPainter.mm
index 61decbb..9e1fed9 100644
--- a/WebCore/kwq/KWQPainter.mm
+++ b/WebCore/kwq/KWQPainter.mm
@@ -360,7 +360,7 @@ void QPainter::drawText(int x, int y, int, int, int alignmentFlags, const QStrin
const UniChar* str = (const UniChar*)qstring.unicode();
if (alignmentFlags & Qt::AlignRight)
- x -= ROUND_TO_INT([renderer floatWidthForCharacters:(const UniChar *)str stringLength:qstring.length() fromCharacterPosition:0 numberOfCharacters:qstring.length() withPadding: 0 applyRounding:YES attemptFontSubstitution: YES widths: 0]);
+ x -= ROUND_TO_INT([renderer floatWidthForCharacters:(const UniChar *)str stringLength:qstring.length() fromCharacterPosition:0 numberOfCharacters:qstring.length() withPadding: 0 applyRounding:YES attemptFontSubstitution: YES widths: 0 letterSpacing: 0 wordSpacing: 0]);
[renderer drawCharacters:str stringLength:qstring.length()
fromCharacterPosition:0
@@ -369,10 +369,12 @@ void QPainter::drawText(int x, int y, int, int, int alignmentFlags, const QStrin
withPadding: 0
withTextColor:data->state.pen.color().getNSColor()
backgroundColor:nil
- rightToLeft: false];
+ rightToLeft: false
+ letterSpacing: 0
+ wordSpacing: 0];
}
-void QPainter::drawText(int x, int y, const QChar *str, int len, int from, int to, int toAdd, const QColor &backgroundColor, QPainter::TextDirection d)
+void QPainter::drawText(int x, int y, const QChar *str, int len, int from, int to, int toAdd, const QColor &backgroundColor, QPainter::TextDirection d, int letterSpacing, int wordSpacing)
{
if (data->state.paintingDisabled || len <= 0)
return;
@@ -386,7 +388,9 @@ void QPainter::drawText(int x, int y, const QChar *str, int len, int from, int t
withPadding: toAdd
withTextColor:data->state.pen.color().getNSColor()
backgroundColor:backgroundColor.isValid() ? backgroundColor.getNSColor() : nil
- rightToLeft: d == RTL ? true : false];
+ rightToLeft: d == RTL ? true : false
+ letterSpacing: letterSpacing
+ wordSpacing: wordSpacing];
}
void QPainter::drawUnderlineForText(int x, int y, const QChar *str, int len)
diff --git a/WebCore/kwq/WebCoreTextRenderer.h b/WebCore/kwq/WebCoreTextRenderer.h
index 0887534..b89518a 100644
--- a/WebCore/kwq/WebCoreTextRenderer.h
+++ b/WebCore/kwq/WebCoreTextRenderer.h
@@ -38,10 +38,10 @@
- (float)xHeight;
// horizontal metrics
-- (float)floatWidthForCharacters:(const unichar *)characters stringLength:(unsigned)length fromCharacterPosition: (int)pos numberOfCharacters: (int)len withPadding: (int)padding applyRounding: (BOOL)applyRounding attemptFontSubstitution: (BOOL)attemptFontSubstitution widths: (float *)buffer;
+- (float)floatWidthForCharacters:(const unichar *)characters stringLength:(unsigned)length fromCharacterPosition: (int)pos numberOfCharacters: (int)len withPadding: (int)padding applyRounding: (BOOL)applyRounding attemptFontSubstitution: (BOOL)attemptFontSubstitution widths: (float *)buffer letterSpacing: (int)letterSpacing wordSpacing: (int)wordSpacing;
// drawing
-- (void)drawCharacters:(const UniChar *)characters stringLength:(unsigned)length fromCharacterPosition:(int)from toCharacterPosition:(int)to atPoint:(NSPoint)point withPadding: (int)padding withTextColor:(NSColor *)textColor backgroundColor:(NSColor *)backgroundColor rightToLeft: (BOOL)rtl;
+- (void)drawCharacters:(const UniChar *)characters stringLength:(unsigned)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;
- (void)drawUnderlineForCharacters:(const UniChar *)characters stringLength:(unsigned)length atPoint:(NSPoint)point withColor:(NSColor *)color;
@end
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 9584915..e6fbb92 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,19 @@
+2002-11-12 Richard Williamson <rjw at apple.com>
+
+ Implemented letter-spacing and word-spacing CSS properties.
+
+ * Misc.subproj/WebStringTruncator.m:
+ (+[WebStringTruncator rightTruncateString:toWidth:withFont:]):
+ (+[WebStringTruncator centerTruncateString:toWidth:withFont:]):
+ * WebCoreSupport.subproj/WebTextRenderer.h:
+ * WebCoreSupport.subproj/WebTextRenderer.m:
+ (-[WebTextRenderer widthForCharacters:length:]):
+ (-[WebTextRenderer drawCharacters:stringLength:fromCharacterPosition:toCharacterPosition:atPoint:withPadding:withTextColor:backgroundColor:rightToLeft:letterSpacing:wordSpacing:]):
+ (-[WebTextRenderer floatWidthForCharacters:stringLength:characterPosition:]):
+ (-[WebTextRenderer floatWidthForCharacters:stringLength:fromCharacterPosition:numberOfCharacters:]):
+ (-[WebTextRenderer floatWidthForCharacters:stringLength:fromCharacterPosition:numberOfCharacters:withPadding:applyRounding:attemptFontSubstitution:widths:letterSpacing:wordSpacing:]):
+ (-[WebTextRenderer _floatWidthForCharacters:stringLength:fromCharacterPosition:numberOfCharacters:withPadding:applyRounding:attemptFontSubstitution:widths:fonts:glyphs:numGlyphs:letterSpacing:wordSpacing:]):
+
2002-11-12 Maciej Stachowiak <mjs at apple.com>
Removed policy classes and instead use the policy enums directly,
diff --git a/WebKit/ChangeLog-2002-12-03 b/WebKit/ChangeLog-2002-12-03
index 9584915..e6fbb92 100644
--- a/WebKit/ChangeLog-2002-12-03
+++ b/WebKit/ChangeLog-2002-12-03
@@ -1,3 +1,19 @@
+2002-11-12 Richard Williamson <rjw at apple.com>
+
+ Implemented letter-spacing and word-spacing CSS properties.
+
+ * Misc.subproj/WebStringTruncator.m:
+ (+[WebStringTruncator rightTruncateString:toWidth:withFont:]):
+ (+[WebStringTruncator centerTruncateString:toWidth:withFont:]):
+ * WebCoreSupport.subproj/WebTextRenderer.h:
+ * WebCoreSupport.subproj/WebTextRenderer.m:
+ (-[WebTextRenderer widthForCharacters:length:]):
+ (-[WebTextRenderer drawCharacters:stringLength:fromCharacterPosition:toCharacterPosition:atPoint:withPadding:withTextColor:backgroundColor:rightToLeft:letterSpacing:wordSpacing:]):
+ (-[WebTextRenderer floatWidthForCharacters:stringLength:characterPosition:]):
+ (-[WebTextRenderer floatWidthForCharacters:stringLength:fromCharacterPosition:numberOfCharacters:]):
+ (-[WebTextRenderer floatWidthForCharacters:stringLength:fromCharacterPosition:numberOfCharacters:withPadding:applyRounding:attemptFontSubstitution:widths:letterSpacing:wordSpacing:]):
+ (-[WebTextRenderer _floatWidthForCharacters:stringLength:fromCharacterPosition:numberOfCharacters:withPadding:applyRounding:attemptFontSubstitution:widths:fonts:glyphs:numGlyphs:letterSpacing:wordSpacing:]):
+
2002-11-12 Maciej Stachowiak <mjs at apple.com>
Removed policy classes and instead use the policy enums directly,
diff --git a/WebKit/Misc.subproj/WebStringTruncator.m b/WebKit/Misc.subproj/WebStringTruncator.m
index 75b1a58..25a3537 100644
--- a/WebKit/Misc.subproj/WebStringTruncator.m
+++ b/WebKit/Misc.subproj/WebStringTruncator.m
@@ -70,18 +70,18 @@ static float currentEllipsisWidth;
[string getCharacters:stringBuffer];
renderer = [[WebTextRendererFactory sharedFactory] rendererWithFont:font];
width = [renderer floatWidthForCharacters:stringBuffer
- stringLength:truncatedLength fromCharacterPosition: 0 numberOfCharacters: truncatedLength withPadding: 0 applyRounding: NO attemptFontSubstitution: YES widths: 0];
+ stringLength:truncatedLength fromCharacterPosition: 0 numberOfCharacters: truncatedLength withPadding: 0 applyRounding: NO attemptFontSubstitution: YES widths: 0 letterSpacing: 0 wordSpacing: 0];
if (width <= maxWidth)
return string;
ellipsis = ELLIPSIS_CHARACTER;
- ellipsisWidth = [renderer floatWidthForCharacters:&ellipsis stringLength:1 fromCharacterPosition: 0 numberOfCharacters: 1 withPadding: 0 applyRounding: NO attemptFontSubstitution: YES widths: 0];
+ ellipsisWidth = [renderer floatWidthForCharacters:&ellipsis stringLength:1 fromCharacterPosition: 0 numberOfCharacters: 1 withPadding: 0 applyRounding: NO attemptFontSubstitution: YES widths: 0 letterSpacing: 0 wordSpacing: 0];
maxWidth -= ellipsisWidth;
while (width > maxWidth && truncatedLength){
truncatedLength--;
width = [renderer floatWidthForCharacters:stringBuffer
- stringLength:truncatedLength fromCharacterPosition: 0 numberOfCharacters: truncatedLength withPadding: 0 applyRounding: NO attemptFontSubstitution: YES widths: 0];
+ stringLength:truncatedLength fromCharacterPosition: 0 numberOfCharacters: truncatedLength withPadding: 0 applyRounding: NO attemptFontSubstitution: YES widths: 0 letterSpacing: 0 wordSpacing: 0];
}
stringBuffer[truncatedLength++] = ELLIPSIS_CHARACTER;
@@ -111,7 +111,7 @@ static float currentEllipsisWidth;
[WebTextRendererFactory createSharedFactory];
currentRenderer = [[[WebTextRendererFactory sharedFactory] rendererWithFont:font] retain];
ellipsis = ELLIPSIS_CHARACTER;
- currentEllipsisWidth = [currentRenderer floatWidthForCharacters:&ellipsis stringLength:1 fromCharacterPosition: 0 numberOfCharacters: 1 withPadding: 0 applyRounding: NO attemptFontSubstitution: YES widths: 0];
+ currentEllipsisWidth = [currentRenderer floatWidthForCharacters:&ellipsis stringLength:1 fromCharacterPosition: 0 numberOfCharacters: 1 withPadding: 0 applyRounding: NO attemptFontSubstitution: YES widths: 0 letterSpacing: 0 wordSpacing: 0];
}
ASSERT(currentRenderer);
@@ -130,7 +130,7 @@ static float currentEllipsisWidth;
}
width = [currentRenderer floatWidthForCharacters:stringBuffer
- stringLength:truncatedLength fromCharacterPosition: 0 numberOfCharacters: truncatedLength withPadding: 0 applyRounding: NO attemptFontSubstitution: YES widths: 0];
+ stringLength:truncatedLength fromCharacterPosition: 0 numberOfCharacters: truncatedLength withPadding: 0 applyRounding: NO attemptFontSubstitution: YES widths: 0 letterSpacing: 0 wordSpacing: 0];
if (width <= maxWidth) {
return string;
}
@@ -169,8 +169,8 @@ static float currentEllipsisWidth;
length:length
keepCount:keepCount
toBuffer:stringBuffer];
-
- width = [currentRenderer floatWidthForCharacters:stringBuffer stringLength:truncatedLength fromCharacterPosition: 0 numberOfCharacters: truncatedLength withPadding: 0 applyRounding: NO attemptFontSubstitution: YES widths: 0];
+
+ width = [currentRenderer floatWidthForCharacters:stringBuffer stringLength:truncatedLength fromCharacterPosition: 0 numberOfCharacters: truncatedLength withPadding: 0 applyRounding: NO attemptFontSubstitution: YES widths: 0 letterSpacing: 0 wordSpacing: 0];
if (width <= maxWidth) {
keepCountForLargestKnownToFit = keepCount;
widthForLargestKnownToFit = width;
diff --git a/WebKit/WebCoreSupport.subproj/WebTextRenderer.h b/WebKit/WebCoreSupport.subproj/WebTextRenderer.h
index 31554f6..ba7ec88 100644
--- a/WebKit/WebCoreSupport.subproj/WebTextRenderer.h
+++ b/WebKit/WebCoreSupport.subproj/WebTextRenderer.h
@@ -27,6 +27,6 @@ typedef struct GlyphMap GlyphMap;
- initWithFont:(NSFont *)font;
-- (float)_floatWidthForCharacters:(const UniChar *)characters stringLength:(unsigned)stringLength fromCharacterPosition: (int)pos numberOfCharacters: (int)len withPadding: (int)padding applyRounding: (BOOL)applyRounding attemptFontSubstitution: (BOOL)attemptSubstitution widths: (float *)widthBuffer fonts: (NSFont **)fontBuffer glyphs: (CGGlyph *)glyphBuffer numGlyphs: (int *)_numGlyphs;
+- (float)_floatWidthForCharacters:(const UniChar *)characters stringLength:(unsigned)stringLength fromCharacterPosition: (int)pos numberOfCharacters: (int)len withPadding: (int)padding applyRounding: (BOOL)applyRounding attemptFontSubstitution: (BOOL)attemptSubstitution widths: (float *)widthBuffer fonts: (NSFont **)fontBuffer glyphs: (CGGlyph *)glyphBuffer numGlyphs: (int *)_numGlyphs letterSpacing: (int)ls wordSpacing: (int)ws;
@end
diff --git a/WebKit/WebCoreSupport.subproj/WebTextRenderer.m b/WebKit/WebCoreSupport.subproj/WebTextRenderer.m
index 3eb665f..172b06f 100644
--- a/WebKit/WebCoreSupport.subproj/WebTextRenderer.m
+++ b/WebKit/WebCoreSupport.subproj/WebTextRenderer.m
@@ -373,7 +373,7 @@ static BOOL bufferTextDrawing = NO;
- (int)widthForCharacters:(const UniChar *)characters length:(unsigned)stringLength
{
- return ROUND_TO_INT([self floatWidthForCharacters:characters stringLength:stringLength fromCharacterPosition:0 numberOfCharacters:stringLength withPadding: 0 applyRounding:YES attemptFontSubstitution: YES widths: 0]);
+ return ROUND_TO_INT([self floatWidthForCharacters:characters stringLength:stringLength fromCharacterPosition:0 numberOfCharacters:stringLength withPadding: 0 applyRounding:YES attemptFontSubstitution: YES widths: 0 letterSpacing: 0 wordSpacing: 0]);
}
- (int)widthForString:(NSString *)string
@@ -457,7 +457,7 @@ static void _drawGlyphs(NSFont *font, NSColor *color, CGGlyph *glyphs, CGSize *a
}
}
-- (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
+- (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
{
float *widthBuffer, localWidthBuffer[LOCAL_BUFFER_SIZE];
CGGlyph *glyphBuffer, localGlyphBuffer[LOCAL_BUFFER_SIZE];
@@ -469,7 +469,7 @@ static void _drawGlyphs(NSFont *font, NSColor *color, CGGlyph *glyphs, CGSize *a
if (length == 0)
return;
-
+
// WARNING: the character to glyph translation must result in less than
// length glyphs. As of now this is always true.
if (length > LOCAL_BUFFER_SIZE) {
@@ -494,7 +494,9 @@ static void _drawGlyphs(NSFont *font, NSColor *color, CGGlyph *glyphs, CGSize *a
widths: widthBuffer
fonts: fontBuffer
glyphs: glyphBuffer
- numGlyphs: &numGlyphs];
+ numGlyphs: &numGlyphs
+ letterSpacing: letterSpacing
+ wordSpacing: wordSpacing];
if (from == -1)
from = 0;
@@ -619,19 +621,19 @@ static void _drawGlyphs(NSFont *font, NSColor *color, CGGlyph *glyphs, CGSize *a
// Return the width of the first complete character at the specified position. Even though
// the first 'character' may contain more than one unicode characters this method will
// work correctly.
- return [self floatWidthForCharacters:characters stringLength:stringLength fromCharacterPosition:pos numberOfCharacters:1 withPadding: 0 applyRounding: YES attemptFontSubstitution: YES widths: nil];
+ return [self floatWidthForCharacters:characters stringLength:stringLength fromCharacterPosition:pos numberOfCharacters:1 withPadding: 0 applyRounding: YES attemptFontSubstitution: YES widths: nil letterSpacing: 0 wordSpacing: 0];
}
- (float)floatWidthForCharacters:(const UniChar *)characters stringLength:(unsigned)stringLength fromCharacterPosition: (int)pos numberOfCharacters: (int)len
{
- return [self floatWidthForCharacters:characters stringLength:stringLength fromCharacterPosition:pos numberOfCharacters:len withPadding: 0 applyRounding: YES attemptFontSubstitution: YES widths: nil];
+ return [self floatWidthForCharacters:characters stringLength:stringLength fromCharacterPosition:pos numberOfCharacters:len withPadding: 0 applyRounding: YES attemptFontSubstitution: YES widths: nil letterSpacing: 0 wordSpacing: 0];
}
-- (float)floatWidthForCharacters:(const UniChar *)characters stringLength:(unsigned)stringLength fromCharacterPosition: (int)pos numberOfCharacters: (int)len withPadding: (int)padding applyRounding: (BOOL)applyRounding attemptFontSubstitution: (BOOL)attemptSubstitution widths: (float *)widthBuffer
+- (float)floatWidthForCharacters:(const UniChar *)characters stringLength:(unsigned)stringLength fromCharacterPosition: (int)pos numberOfCharacters: (int)len withPadding: (int)padding applyRounding: (BOOL)applyRounding attemptFontSubstitution: (BOOL)attemptSubstitution widths: (float *)widthBuffer letterSpacing: (int)letterSpacing wordSpacing: (int)wordSpacing
{
- return [self _floatWidthForCharacters:characters stringLength:stringLength fromCharacterPosition:pos numberOfCharacters:len withPadding: 0 applyRounding: YES attemptFontSubstitution: YES widths: widthBuffer fonts: nil glyphs: nil numGlyphs: nil];
+ return [self _floatWidthForCharacters:characters stringLength:stringLength fromCharacterPosition:pos numberOfCharacters:len withPadding: 0 applyRounding: YES attemptFontSubstitution: YES widths: widthBuffer fonts: nil glyphs: nil numGlyphs: nil letterSpacing: letterSpacing wordSpacing: wordSpacing];
}
#ifdef DEBUG_COMBINING
@@ -670,7 +672,7 @@ static const char *joiningNames[] = {
};
#endif
-- (float)_floatWidthForCharacters:(const UniChar *)characters stringLength:(unsigned)stringLength fromCharacterPosition: (int)pos numberOfCharacters: (int)len withPadding: (int)padding applyRounding: (BOOL)applyRounding attemptFontSubstitution: (BOOL)attemptSubstitution widths: (float *)widthBuffer fonts: (NSFont **)fontBuffer glyphs: (CGGlyph *)glyphBuffer numGlyphs: (int *)_numGlyphs
+- (float)_floatWidthForCharacters:(const UniChar *)characters stringLength:(unsigned)stringLength fromCharacterPosition: (int)pos numberOfCharacters: (int)len withPadding: (int)padding applyRounding: (BOOL)applyRounding attemptFontSubstitution: (BOOL)attemptSubstitution widths: (float *)widthBuffer fonts: (NSFont **)fontBuffer glyphs: (CGGlyph *)glyphBuffer numGlyphs: (int *)_numGlyphs letterSpacing: (int)letterSpacing wordSpacing: (int)wordSpacing
{
float totalWidth = 0;
unsigned int i, clusterLength;
@@ -726,7 +728,6 @@ static const char *joiningNames[] = {
padPerSpace = CEIL_TO_INT ((((float)padding) / ((float)numSpaces)));
}
- //printf("width: font %s, size %.1f, text \"%s\"\n", [[font fontName] cString], [font pointSize], [[NSString stringWithCharacters:characters length:length] UTF8String]);
for (i = 0; i < stringLength; i++) {
UniChar c = characters[i];
@@ -780,7 +781,9 @@ static const char *joiningNames[] = {
widths: ((widthBuffer != 0 ) ? (&widthBuffer[numGlyphs]) : nil)
fonts: nil
glyphs: ((glyphBuffer != 0 ) ? (&glyphBuffer[numGlyphs]) : nil)
- numGlyphs: &cNumGlyphs];
+ numGlyphs: &cNumGlyphs
+ letterSpacing: letterSpacing
+ wordSpacing: wordSpacing];
if (fontBuffer){
int j;
for (j = 0; j < cNumGlyphs; j++)
@@ -828,6 +831,26 @@ static const char *joiningNames[] = {
fontBuffer[numGlyphs] = font;
if (glyphBuffer)
glyphBuffer[numGlyphs] = glyphID;
+
+ // Account for the letter-spacing. Only add width to base characters.
+ // Combining glyphs should have zero width.
+ if (lastWidth > 0)
+ lastWidth += letterSpacing;
+
+ // Account for word-spacing. Make the size of the last character (grapheme cluster)
+ // in the word wider.
+ if (glyphID == spaceGlyph && numGlyphs > 0 && (characters[i-1] != SPACE || characters[i-1] != NON_BREAKING_SPACE)){
+ // Find the base glyph in the grapheme cluster. Combining glyphs
+ // should have zero width.
+ if (widthBuffer){
+ int ng = numGlyphs-1;
+ while (ng && widthBuffer[ng] == 0)
+ ng--;
+ widthBuffer[ng] += wordSpacing;
+ }
+ totalWidth += wordSpacing;
+ }
+
if (widthBuffer){
widthBuffer[numGlyphs] = lastWidth;
}
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list