[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 05:53:45 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit a14d0834613507c46f693f6f66cb209e384e7ca2
Author: rjw <rjw at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Fri Dec 21 03:02:36 2001 +0000
More tweaks to text underlining.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@522 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog-2002-12-03 b/WebCore/ChangeLog-2002-12-03
index c965510..68d2027 100644
--- a/WebCore/ChangeLog-2002-12-03
+++ b/WebCore/ChangeLog-2002-12-03
@@ -1,3 +1,14 @@
+2001-12-20 Richard Williamson <rjw at apple.com>
+
+ More tweaks to text layout and underlining.
+
+ * src/kdelibs/khtml/rendering/render_text.cpp: (TextSlave::printDecoration):
+ * src/kwq/KWQFontMetrics.mm: (QFontMetrics::baselineOffset),
+ (QFontMetrics::ascent), (QFontMetrics::descent), (QFontMetrics::height),
+ (QFontMetrics::width):
+ * src/kwq/KWQPainter.mm: (QPainter::drawText):
+ * src/kwq/qt/qfontmetrics.h:
+
2001-12-18 Maciej Stachowiak <mjs at apple.com>
* src/kwq/KWQCString.mm: (QCString::QCString),
diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index c965510..68d2027 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,14 @@
+2001-12-20 Richard Williamson <rjw at apple.com>
+
+ More tweaks to text layout and underlining.
+
+ * src/kdelibs/khtml/rendering/render_text.cpp: (TextSlave::printDecoration):
+ * src/kwq/KWQFontMetrics.mm: (QFontMetrics::baselineOffset),
+ (QFontMetrics::ascent), (QFontMetrics::descent), (QFontMetrics::height),
+ (QFontMetrics::width):
+ * src/kwq/KWQPainter.mm: (QPainter::drawText):
+ * src/kwq/qt/qfontmetrics.h:
+
2001-12-18 Maciej Stachowiak <mjs at apple.com>
* src/kwq/KWQCString.mm: (QCString::QCString),
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index c965510..68d2027 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,14 @@
+2001-12-20 Richard Williamson <rjw at apple.com>
+
+ More tweaks to text layout and underlining.
+
+ * src/kdelibs/khtml/rendering/render_text.cpp: (TextSlave::printDecoration):
+ * src/kwq/KWQFontMetrics.mm: (QFontMetrics::baselineOffset),
+ (QFontMetrics::ascent), (QFontMetrics::descent), (QFontMetrics::height),
+ (QFontMetrics::width):
+ * src/kwq/KWQPainter.mm: (QPainter::drawText):
+ * src/kwq/qt/qfontmetrics.h:
+
2001-12-18 Maciej Stachowiak <mjs at apple.com>
* src/kwq/KWQCString.mm: (QCString::QCString),
diff --git a/WebCore/khtml/rendering/render_image.cpp b/WebCore/khtml/rendering/render_image.cpp
index 35fafd3..ffa0812 100644
--- a/WebCore/khtml/rendering/render_image.cpp
+++ b/WebCore/khtml/rendering/render_image.cpp
@@ -170,6 +170,11 @@ void RenderImage::printObject(QPainter *p, int /*_x*/, int /*_y*/, int /*_w*/, i
if(cWidth > 2 && cHeight > 2)
{
//qDebug("qDrawShadePanel %d/%d/%d/%d", _tx + leftBorder, _ty + topBorder, cWidth, cHeight);
+#ifdef _KWQ_
+ p->setPen (Qt::lightGray);
+ p->setBrush (Qt::NoBrush);
+ p->drawRect (_tx, _ty, cWidth, cHeight);
+#else
qDrawShadePanel( p, _tx + leftBorder + leftPad, _ty + topBorder + topPad, cWidth, cHeight,
KApplication::palette().inactive(), true, 1 );
if(berrorPic && !pix.isNull() && (cWidth >= pix.width()+4) && (cHeight >= pix.height()+4) )
@@ -191,6 +196,7 @@ void RenderImage::printObject(QPainter *p, int /*_x*/, int /*_y*/, int /*_w*/, i
if (aw>15 && ah>fm.height())
p->drawText(ax, ay, aw, ah , Qt::WordBreak, text );
}
+#endif
}
}
else if (image && !image->isTransparent())
diff --git a/WebCore/khtml/rendering/render_text.cpp b/WebCore/khtml/rendering/render_text.cpp
index dc090b1..87508ac 100644
--- a/WebCore/khtml/rendering/render_text.cpp
+++ b/WebCore/khtml/rendering/render_text.cpp
@@ -114,10 +114,7 @@ void TextSlave::printDecoration( QPainter *pt, RenderText* p, int _tx, int _ty,
#ifdef _KWQ_
- int underlineOffset = pt->fontMetrics().height();
- int descent = pt->fontMetrics().descent();
- if (descent >= 3)
- underlineOffset -= (descent - 2);
+ int underlineOffset = pt->fontMetrics().baselineOffset() + 2;
#else
int underlineOffset = ( pt->fontMetrics().height() + m_baseline ) / 2;
if(underlineOffset <= m_baseline) underlineOffset = m_baseline+1;
@@ -126,6 +123,8 @@ void TextSlave::printDecoration( QPainter *pt, RenderText* p, int _tx, int _ty,
if(deco & UNDERLINE){
//fprintf (stderr, "UNDERLINE (%d, %d) to (%d, %d)\n", _tx, _ty + underlineOffset, _tx + width, _ty + underlineOffset );
pt->drawLine(_tx, _ty + underlineOffset, _tx + width, _ty + underlineOffset );
+ //pt->drawLine(_tx, _ty, _tx + width, _ty );
+ //pt->drawLine(_tx, _ty + pt->fontMetrics().height(), _tx + width, _ty + pt->fontMetrics().height() );
}
if(deco & OVERLINE)
pt->drawLine(_tx, _ty, _tx + width, _ty );
diff --git a/WebCore/kwq/KWQFontMetrics.h b/WebCore/kwq/KWQFontMetrics.h
index 1bae0a1..6a0525e 100644
--- a/WebCore/kwq/KWQFontMetrics.h
+++ b/WebCore/kwq/KWQFontMetrics.h
@@ -81,6 +81,7 @@ public:
// protected -------------------------------------------------------------------
// private ---------------------------------------------------------------------
#ifdef _KWQ_
+ int baselineOffset();
void _initialize();
#if (defined(__APPLE__) && defined(__OBJC__) && defined(__cplusplus))
//void _initializeWithData(QFontMetricsPrivate *);
diff --git a/WebCore/kwq/KWQFontMetrics.mm b/WebCore/kwq/KWQFontMetrics.mm
index fb0d8ac..556a4ba 100644
--- a/WebCore/kwq/KWQFontMetrics.mm
+++ b/WebCore/kwq/KWQFontMetrics.mm
@@ -32,8 +32,9 @@
#import <KWQTextStorage.h>
#import <KWQTextContainer.h>
-
-#define ROUND_TO_INT(f) ((int)rint((f)))
+#define FLOOR_TO_INT(x) (int)(floor(x))
+#define ROUND_TO_INT(x) (int)(((x) > (floor(x) + .5)) ? ceil(x) : floor(x))
+//#define ROUND_TO_INT(f) ((int)(rint(f)))
const float LargeNumberForText = 1.0e7;
@@ -250,23 +251,29 @@ QFontMetrics::~QFontMetrics()
}
+int QFontMetrics::baselineOffset()
+{
+ return ascent();
+}
+
int QFontMetrics::ascent() const
{
- // Qt seems to use [font defaultLineHeightForFont] + [font descender] instead
- // of what seems more natural [font ascender].
- // Remember that descender is negative.
- //return ROUND_TO_INT([data->font defaultLineHeightForFont] + [data->font descender]);
return ROUND_TO_INT([data->font ascender]);
}
+
+int QFontMetrics::descent() const
+{
+ return ROUND_TO_INT(-[data->font descender]);
+}
+
+
int QFontMetrics::height() const
{
// According to Qt documentation:
// "This is always equal to ascent()+descent()+1 (the 1 is for the base line)."
- // However, the [font defaultLineHeightForFont] seems more appropriate.
- //return ROUND_TO_INT([data->font defaultLineHeightForFont]);
- return ROUND_TO_INT([data->font ascender] - [data->font descender] + 1);
+ return ascent() + descent() + 1;
}
@@ -301,12 +308,6 @@ int QFontMetrics::width(const QString &qstring, int len) const
}
-int QFontMetrics::descent() const
-{
- return -ROUND_TO_INT([data->font descender]);
-}
-
-
QRect QFontMetrics::boundingRect(const QString &qstring, int len) const
{
NSString *string;
diff --git a/WebCore/kwq/KWQPainter.mm b/WebCore/kwq/KWQPainter.mm
index 4721a00..8b6c93e 100644
--- a/WebCore/kwq/KWQPainter.mm
+++ b/WebCore/kwq/KWQPainter.mm
@@ -451,6 +451,9 @@ void QPainter::drawTiledPixmap( int x, int y, int w, int h,
@end
#endif
+#define FLOOR_TO_INT(x) (int)(floor(x))
+#define ROUND_TO_INT(x) (int)(((x) > floor(x) + .5) ? ceil(x) : floor(x))
+
// y is the baseline
void QPainter::drawText(int x, int y, const QString &qstring, int len)
{
@@ -469,8 +472,8 @@ void QPainter::drawText(int x, int y, const QString &qstring, int len)
// This will draw the text from the top of the bounding box down.
// Qt expects to draw from the baseline.
- y = y - (int)([font defaultLineHeightForFont] + [font descender]);
- //y = y - (int)([font defaultLineHeightForFont]);
+ // Remember that descender is negative.
+ y = y - (ROUND_TO_INT([font defaultLineHeightForFont]) - FLOOR_TO_INT(-[font descender]));
#ifdef SLOW_SAFE_DRAWING
diff --git a/WebCore/kwq/qt/qfontmetrics.h b/WebCore/kwq/qt/qfontmetrics.h
index 1bae0a1..6a0525e 100644
--- a/WebCore/kwq/qt/qfontmetrics.h
+++ b/WebCore/kwq/qt/qfontmetrics.h
@@ -81,6 +81,7 @@ public:
// protected -------------------------------------------------------------------
// private ---------------------------------------------------------------------
#ifdef _KWQ_
+ int baselineOffset();
void _initialize();
#if (defined(__APPLE__) && defined(__OBJC__) && defined(__cplusplus))
//void _initializeWithData(QFontMetricsPrivate *);
diff --git a/WebCore/src/kdelibs/khtml/rendering/render_image.cpp b/WebCore/src/kdelibs/khtml/rendering/render_image.cpp
index 35fafd3..ffa0812 100644
--- a/WebCore/src/kdelibs/khtml/rendering/render_image.cpp
+++ b/WebCore/src/kdelibs/khtml/rendering/render_image.cpp
@@ -170,6 +170,11 @@ void RenderImage::printObject(QPainter *p, int /*_x*/, int /*_y*/, int /*_w*/, i
if(cWidth > 2 && cHeight > 2)
{
//qDebug("qDrawShadePanel %d/%d/%d/%d", _tx + leftBorder, _ty + topBorder, cWidth, cHeight);
+#ifdef _KWQ_
+ p->setPen (Qt::lightGray);
+ p->setBrush (Qt::NoBrush);
+ p->drawRect (_tx, _ty, cWidth, cHeight);
+#else
qDrawShadePanel( p, _tx + leftBorder + leftPad, _ty + topBorder + topPad, cWidth, cHeight,
KApplication::palette().inactive(), true, 1 );
if(berrorPic && !pix.isNull() && (cWidth >= pix.width()+4) && (cHeight >= pix.height()+4) )
@@ -191,6 +196,7 @@ void RenderImage::printObject(QPainter *p, int /*_x*/, int /*_y*/, int /*_w*/, i
if (aw>15 && ah>fm.height())
p->drawText(ax, ay, aw, ah , Qt::WordBreak, text );
}
+#endif
}
}
else if (image && !image->isTransparent())
diff --git a/WebCore/src/kdelibs/khtml/rendering/render_text.cpp b/WebCore/src/kdelibs/khtml/rendering/render_text.cpp
index dc090b1..87508ac 100644
--- a/WebCore/src/kdelibs/khtml/rendering/render_text.cpp
+++ b/WebCore/src/kdelibs/khtml/rendering/render_text.cpp
@@ -114,10 +114,7 @@ void TextSlave::printDecoration( QPainter *pt, RenderText* p, int _tx, int _ty,
#ifdef _KWQ_
- int underlineOffset = pt->fontMetrics().height();
- int descent = pt->fontMetrics().descent();
- if (descent >= 3)
- underlineOffset -= (descent - 2);
+ int underlineOffset = pt->fontMetrics().baselineOffset() + 2;
#else
int underlineOffset = ( pt->fontMetrics().height() + m_baseline ) / 2;
if(underlineOffset <= m_baseline) underlineOffset = m_baseline+1;
@@ -126,6 +123,8 @@ void TextSlave::printDecoration( QPainter *pt, RenderText* p, int _tx, int _ty,
if(deco & UNDERLINE){
//fprintf (stderr, "UNDERLINE (%d, %d) to (%d, %d)\n", _tx, _ty + underlineOffset, _tx + width, _ty + underlineOffset );
pt->drawLine(_tx, _ty + underlineOffset, _tx + width, _ty + underlineOffset );
+ //pt->drawLine(_tx, _ty, _tx + width, _ty );
+ //pt->drawLine(_tx, _ty + pt->fontMetrics().height(), _tx + width, _ty + pt->fontMetrics().height() );
}
if(deco & OVERLINE)
pt->drawLine(_tx, _ty, _tx + width, _ty );
diff --git a/WebCore/src/kwq/KWQFontMetrics.mm b/WebCore/src/kwq/KWQFontMetrics.mm
index fb0d8ac..556a4ba 100644
--- a/WebCore/src/kwq/KWQFontMetrics.mm
+++ b/WebCore/src/kwq/KWQFontMetrics.mm
@@ -32,8 +32,9 @@
#import <KWQTextStorage.h>
#import <KWQTextContainer.h>
-
-#define ROUND_TO_INT(f) ((int)rint((f)))
+#define FLOOR_TO_INT(x) (int)(floor(x))
+#define ROUND_TO_INT(x) (int)(((x) > (floor(x) + .5)) ? ceil(x) : floor(x))
+//#define ROUND_TO_INT(f) ((int)(rint(f)))
const float LargeNumberForText = 1.0e7;
@@ -250,23 +251,29 @@ QFontMetrics::~QFontMetrics()
}
+int QFontMetrics::baselineOffset()
+{
+ return ascent();
+}
+
int QFontMetrics::ascent() const
{
- // Qt seems to use [font defaultLineHeightForFont] + [font descender] instead
- // of what seems more natural [font ascender].
- // Remember that descender is negative.
- //return ROUND_TO_INT([data->font defaultLineHeightForFont] + [data->font descender]);
return ROUND_TO_INT([data->font ascender]);
}
+
+int QFontMetrics::descent() const
+{
+ return ROUND_TO_INT(-[data->font descender]);
+}
+
+
int QFontMetrics::height() const
{
// According to Qt documentation:
// "This is always equal to ascent()+descent()+1 (the 1 is for the base line)."
- // However, the [font defaultLineHeightForFont] seems more appropriate.
- //return ROUND_TO_INT([data->font defaultLineHeightForFont]);
- return ROUND_TO_INT([data->font ascender] - [data->font descender] + 1);
+ return ascent() + descent() + 1;
}
@@ -301,12 +308,6 @@ int QFontMetrics::width(const QString &qstring, int len) const
}
-int QFontMetrics::descent() const
-{
- return -ROUND_TO_INT([data->font descender]);
-}
-
-
QRect QFontMetrics::boundingRect(const QString &qstring, int len) const
{
NSString *string;
diff --git a/WebCore/src/kwq/KWQPainter.mm b/WebCore/src/kwq/KWQPainter.mm
index 4721a00..8b6c93e 100644
--- a/WebCore/src/kwq/KWQPainter.mm
+++ b/WebCore/src/kwq/KWQPainter.mm
@@ -451,6 +451,9 @@ void QPainter::drawTiledPixmap( int x, int y, int w, int h,
@end
#endif
+#define FLOOR_TO_INT(x) (int)(floor(x))
+#define ROUND_TO_INT(x) (int)(((x) > floor(x) + .5) ? ceil(x) : floor(x))
+
// y is the baseline
void QPainter::drawText(int x, int y, const QString &qstring, int len)
{
@@ -469,8 +472,8 @@ void QPainter::drawText(int x, int y, const QString &qstring, int len)
// This will draw the text from the top of the bounding box down.
// Qt expects to draw from the baseline.
- y = y - (int)([font defaultLineHeightForFont] + [font descender]);
- //y = y - (int)([font defaultLineHeightForFont]);
+ // Remember that descender is negative.
+ y = y - (ROUND_TO_INT([font defaultLineHeightForFont]) - FLOOR_TO_INT(-[font descender]));
#ifdef SLOW_SAFE_DRAWING
diff --git a/WebCore/src/kwq/qt/qfontmetrics.h b/WebCore/src/kwq/qt/qfontmetrics.h
index 1bae0a1..6a0525e 100644
--- a/WebCore/src/kwq/qt/qfontmetrics.h
+++ b/WebCore/src/kwq/qt/qfontmetrics.h
@@ -81,6 +81,7 @@ public:
// protected -------------------------------------------------------------------
// private ---------------------------------------------------------------------
#ifdef _KWQ_
+ int baselineOffset();
void _initialize();
#if (defined(__APPLE__) && defined(__OBJC__) && defined(__cplusplus))
//void _initializeWithData(QFontMetricsPrivate *);
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list