summaryrefslogtreecommitdiffstats
path: root/src/gui/text
diff options
context:
space:
mode:
authorKonstantin Ritt <ritt.ks@gmail.com>2015-04-01 10:56:39 +0400
committerKonstantin Ritt <ritt.ks@gmail.com>2015-04-07 13:09:27 +0000
commit237cb0d082b5518cecf42f1a2186134799de745e (patch)
tree2da1b2526da68a008aa4c2e989be6e8a4151c0c7 /src/gui/text
parent550fb85b65549d1fc62aba214971578112431c92 (diff)
[QFontEngineFT::loadGlyph] Consolidate paths for fetchMetricsOnly cases
Use GlyphInfo as a temporary buffer for storing the glyph metrics and go through the same code for fetchMetricsOnly and !fetchMetricsOnly. Change-Id: If8bb85056e5f09588cc3956b43dc51a54d5aecfe Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/gui/text')
-rw-r--r--src/gui/text/qfontengine_ft.cpp51
-rw-r--r--src/gui/text/qfontengine_ft_p.h1
2 files changed, 27 insertions, 25 deletions
diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp
index be98e8005f..f8ce7112bc 100644
--- a/src/gui/text/qfontengine_ft.cpp
+++ b/src/gui/text/qfontengine_ft.cpp
@@ -801,6 +801,17 @@ int QFontEngineFT::loadFlags(QGlyphSet *set, GlyphFormat format, int flags,
return load_flags;
}
+static inline bool areMetricsTooLarge(const QFontEngineFT::GlyphInfo &info)
+{
+ // false if exceeds QFontEngineFT::Glyph metrics
+ return (short)(info.linearAdvance) == info.linearAdvance
+ && (signed char)(info.xOff) == info.xOff
+ && (uchar)(info.width) == info.width
+ && (uchar)(info.height) == info.height
+ && (signed char)(info.x) == info.x
+ && (signed char)(info.y) == info.y;
+}
+
QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph,
QFixed subPixelPosition,
GlyphFormat format,
@@ -885,6 +896,7 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph,
}
GlyphInfo info;
+ info.linearAdvance = slot->linearHoriAdvance >> 10;
info.xOff = TRUNC(ROUND(slot->advance.x));
info.yOff = 0;
@@ -893,27 +905,23 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph,
int right = CEIL(slot->metrics.horiBearingX + slot->metrics.width);
int top = CEIL(slot->metrics.horiBearingY);
int bottom = FLOOR(slot->metrics.horiBearingY - slot->metrics.height);
- int width = right-left;
- int height = top-bottom;
+ info.x = TRUNC(left);
+ info.y = TRUNC(top);
+ info.width = TRUNC(right - left);
+ info.height = TRUNC(top - bottom);
// If any of the metrics are too large to fit, don't cache them
- if (qAbs(info.xOff) >= 128
- || qAbs(TRUNC(top)) >= 128
- || TRUNC(width) >= 256
- || TRUNC(height) >= 256
- || qAbs(TRUNC(left)) >= 128
- || qAbs(TRUNC(ROUND(slot->advance.x))) >= 128) {
+ if (areMetricsTooLarge(info))
return 0;
- }
g = new Glyph;
g->data = 0;
- g->linearAdvance = slot->linearHoriAdvance >> 10;
- g->width = TRUNC(width);
- g->height = TRUNC(height);
- g->x = TRUNC(left);
- g->y = TRUNC(top);
- g->advance = TRUNC(ROUND(slot->advance.x));
+ g->linearAdvance = info.linearAdvance;
+ g->width = info.width;
+ g->height = info.height;
+ g->x = info.x;
+ g->y = info.y;
+ g->advance = info.xOff;
g->format = format;
if (set)
@@ -1014,16 +1022,9 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph,
info.x -= 1;
}
- bool large_glyph = (((short)(slot->linearHoriAdvance>>10) != slot->linearHoriAdvance>>10)
- || ((uchar)(info.width) != info.width)
- || ((uchar)(info.height) != info.height)
- || ((signed char)(info.x) != info.x)
- || ((signed char)(info.y) != info.y)
- || ((signed char)(info.xOff) != info.xOff));
-
- if (large_glyph) {
+ // If any of the metrics are too large to fit, don't cache them
+ if (areMetricsTooLarge(info))
return 0;
- }
int pitch = (format == Format_Mono ? ((info.width + 31) & ~31) >> 3 :
(format == Format_A8 ? (info.width + 3) & ~3 : info.width * 4));
@@ -1136,7 +1137,7 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph,
g->data = 0;
}
- g->linearAdvance = slot->linearHoriAdvance >> 10;
+ g->linearAdvance = info.linearAdvance;
g->width = info.width;
g->height = info.height;
g->x = info.x;
diff --git a/src/gui/text/qfontengine_ft_p.h b/src/gui/text/qfontengine_ft_p.h
index e9d058d50c..7b28a4064f 100644
--- a/src/gui/text/qfontengine_ft_p.h
+++ b/src/gui/text/qfontengine_ft_p.h
@@ -143,6 +143,7 @@ public:
};
struct GlyphInfo {
+ int linearAdvance;
unsigned short width;
unsigned short height;
short x;