diff options
author | Jiang Jiang <jiang.jiang@nokia.com> | 2011-02-22 13:15:43 (GMT) |
---|---|---|
committer | Jiang Jiang <jiang.jiang@nokia.com> | 2011-03-22 11:03:51 (GMT) |
commit | 037e632d4b3884d06bf9e92de77d726c75fe7898 (patch) | |
tree | 6834662159359112e2b2b8acf43f574990dda0e3 /src/3rdparty | |
parent | 23098630c94e6655a33042bee0caa6c933c0c7d9 (diff) | |
download | Qt-037e632d4b3884d06bf9e92de77d726c75fe7898.zip Qt-037e632d4b3884d06bf9e92de77d726c75fe7898.tar.gz Qt-037e632d4b3884d06bf9e92de77d726c75fe7898.tar.bz2 |
Implement subpixel positioning with FreeType
QFontEngineFT are used in raster/OpenGL paint engine and QGLWidget,
also in Symbian, etc. We want to make sure it works well in raster
and QGLWidget first. Regardless subpixel antialiasing (LCD filtering)
is enabled or not (though it does look better when subpixel
antialiasing is on). We also need to support transformations.
The tricky part here is that, under X11, we have a different code
path for QFontEngineFT and other font engines in raster engine,
which uses QFontEngineFT's own glyph cache system. While in other
platforms (Windows and Mac) and QGLWidget, we will use the generic
QTextureGlyphCache.
The generic QTextureGlyphCache already has support for subpixel
positions, this solution is ported to QFontEngineFT for its
QGlyphSet: the key for QGlyphSet hash table has been extended from
glyph_t to <glyph_t, QFixed subPixelPosition> pair.
The real work to enable subpixel positioning with FreeType is in
fact really simple, we just set the horizontal translation to the
subpixel position * 64 (FreeType uses a coordinate system of 1/64
of a pixel resolution internally) immediately before loading the
glyph. A slight tweek to bitmap width is applied when we are
getting the bitmap ourselves instead of using FT_Render_Glyph to
accommodate the subpixel translation, which will only be used in
non-LCD filtering cases (grayscale antialiasing).
From what we have observed, FreeType can generate different bitmaps
for at least 12 different subpixel positions (each with a slight
difference). To limit the memory consumption, we restrict the
number of subpixel positions to be 4 (hardcoded), which should be
good enough for most low resolution displays.
Subpixel positioning (and fractional glyph advances) will only be
enabled when the hintingPreference for the font being used is
PreferNoHinting or PreferVerticalHinting. We will use fontconfig
hintstyle setting by default when no hintingPreference is set for
the font.
Task-number: QTBUG-12279
Reviewed-by: Eskil
Diffstat (limited to 'src/3rdparty')
-rw-r--r-- | src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp b/src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp index 6c4d9f1..c202e1f 100644 --- a/src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp +++ b/src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp @@ -1052,16 +1052,16 @@ HB_Bool HB_SelectScript(HB_ShaperItem *shaper_item, const HB_OpenTypeFeature *fe { HB_Script script = shaper_item->item.script; - if (!shaper_item->face->supported_scripts[script]) - return false; - HB_Face face = shaper_item->face; if (face->current_script == script && face->current_flags == shaper_item->shaperFlags) - return true; + return shaper_item->face->supported_scripts[script] ? true : false; face->current_script = script; face->current_flags = shaper_item->shaperFlags; + if (!shaper_item->face->supported_scripts[script]) + return false; + assert(script < HB_ScriptCount); // find script in our list of supported scripts. unsigned int tag = ot_scripts[script].tag; |