summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xconfigure6
-rw-r--r--src/3rdparty/harfbuzz-ng/src/hb-coretext.cc36
-rw-r--r--src/3rdparty/harfbuzz-ng/src/hb-coretext.h4
-rw-r--r--src/3rdparty/harfbuzz-ng/src/hb-shaper-list.hh8
-rw-r--r--src/gui/text/qharfbuzzng.cpp2
-rw-r--r--src/gui/text/qtextengine.cpp7
-rw-r--r--src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm2
7 files changed, 57 insertions, 8 deletions
diff --git a/configure b/configure
index f3e09fcc3d..5979935d33 100755
--- a/configure
+++ b/configure
@@ -5471,6 +5471,7 @@ fi
# harfbuzz support
[ "$XPLATFORM_MINGW" = "yes" ] && [ "$CFG_HARFBUZZ" = "auto" ] && CFG_HARFBUZZ=no
+[ "$XPLATFORM_MAC" = "yes" ] && [ "$CFG_HARFBUZZ" = "auto" ] && CFG_HARFBUZZ=yes
if [ "$CFG_HARFBUZZ" = "auto" ]; then
if compileTest unix/harfbuzz "HarfBuzz"; then
CFG_HARFBUZZ=system
@@ -5478,6 +5479,11 @@ if [ "$CFG_HARFBUZZ" = "auto" ]; then
CFG_HARFBUZZ=yes
fi
fi
+if [ "$XPLATFORM_MAC" = "yes" -a "$CFG_HARFBUZZ" = "system" ]; then
+ echo
+ echo "WARNING: AAT is not supported with -system-harfbuzz on Mac OS X."
+ echo
+fi
if ! compileTest unix/stl "STL" &&
[ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
diff --git a/src/3rdparty/harfbuzz-ng/src/hb-coretext.cc b/src/3rdparty/harfbuzz-ng/src/hb-coretext.cc
index 87dd779751..ef6798d380 100644
--- a/src/3rdparty/harfbuzz-ng/src/hb-coretext.cc
+++ b/src/3rdparty/harfbuzz-ng/src/hb-coretext.cc
@@ -31,6 +31,9 @@
#include "hb-coretext.h"
+#include "hb-face-private.hh"
+#include <private/qfontengine_p.h>
+
#ifndef HB_DEBUG_CORETEXT
#define HB_DEBUG_CORETEXT (HB_DEBUG+0)
@@ -61,10 +64,34 @@ release_data (void *info, const void *data, size_t size)
hb_coretext_shaper_face_data_t *
_hb_coretext_shaper_face_data_create (hb_face_t *face)
{
+ hb_blob_t *mort_blob = face->reference_table (HB_CORETEXT_TAG_MORT);
+ /* Umm, we just reference the table to check whether it exists.
+ * Maybe add better API for this? */
+ if (!hb_blob_get_length (mort_blob))
+ {
+ hb_blob_destroy (mort_blob);
+ mort_blob = face->reference_table (HB_CORETEXT_TAG_MORX);
+ if (!hb_blob_get_length (mort_blob))
+ {
+ hb_blob_destroy (mort_blob);
+ return NULL;
+ }
+ }
+ hb_blob_destroy (mort_blob);
+
hb_coretext_shaper_face_data_t *data = (hb_coretext_shaper_face_data_t *) calloc (1, sizeof (hb_coretext_shaper_face_data_t));
if (unlikely (!data))
return NULL;
+ QFontEngine *fe = (QFontEngine *) face->user_data;
+ if (fe->type () == QFontEngine::Mac)
+ {
+ data->cg_font = (CGFontRef) fe->userData ().value<void *> ();
+ if (likely (data->cg_font))
+ CFRetain (data->cg_font);
+ }
+ else
+ {
hb_blob_t *blob = hb_face_reference_blob (face);
unsigned int blob_length;
const char *blob_data = hb_blob_get_data (blob, &blob_length);
@@ -74,6 +101,7 @@ _hb_coretext_shaper_face_data_create (hb_face_t *face)
CGDataProviderRef provider = CGDataProviderCreateWithData (blob, blob_data, blob_length, &release_data);
data->cg_font = CGFontCreateWithDataProvider (provider);
CGDataProviderRelease (provider);
+ }
if (unlikely (!data->cg_font)) {
DEBUG_MSG (CORETEXT, face, "Face CGFontCreateWithDataProvider() failed");
@@ -120,7 +148,7 @@ _hb_coretext_shaper_font_data_create (hb_font_t *font)
hb_face_t *face = font->face;
hb_coretext_shaper_face_data_t *face_data = HB_SHAPER_DATA_GET (face);
- data->ct_font = CTFontCreateWithGraphicsFont (face_data->cg_font, font->y_scale, NULL, NULL);
+ data->ct_font = CTFontCreateWithGraphicsFont (face_data->cg_font, font->y_scale / 64, NULL, NULL);
if (unlikely (!data->ct_font)) {
DEBUG_MSG (CORETEXT, font, "Font CTFontCreateWithGraphicsFont() failed");
free (data);
@@ -691,7 +719,7 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
* hb-uniscribe.cc for example. */
info->cluster = j;
- info->mask = advance;
+ info->mask = advance * 64;
info->var1.u32 = 0;
info->var2.u32 = 0;
@@ -747,9 +775,9 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
info->cluster = string_indices[j];
/* Currently, we do all x-positioning by setting the advance, we never use x-offset. */
- info->mask = advance;
+ info->mask = advance * 64;
info->var1.u32 = 0;
- info->var2.u32 = positions[j].y;
+ info->var2.u32 = positions[j].y * 64;
buffer->len++;
}
diff --git a/src/3rdparty/harfbuzz-ng/src/hb-coretext.h b/src/3rdparty/harfbuzz-ng/src/hb-coretext.h
index c4954fa1b2..bcf1de7141 100644
--- a/src/3rdparty/harfbuzz-ng/src/hb-coretext.h
+++ b/src/3rdparty/harfbuzz-ng/src/hb-coretext.h
@@ -34,6 +34,10 @@
HB_BEGIN_DECLS
+#define HB_CORETEXT_TAG_MORT HB_TAG('m','o','r','t')
+#define HB_CORETEXT_TAG_MORX HB_TAG('m','o','r','x')
+
+
CGFontRef
hb_coretext_face_get_cg_font (hb_face_t *face);
diff --git a/src/3rdparty/harfbuzz-ng/src/hb-shaper-list.hh b/src/3rdparty/harfbuzz-ng/src/hb-shaper-list.hh
index da6d8e0be9..5713e057a0 100644
--- a/src/3rdparty/harfbuzz-ng/src/hb-shaper-list.hh
+++ b/src/3rdparty/harfbuzz-ng/src/hb-shaper-list.hh
@@ -35,6 +35,11 @@
HB_SHAPER_IMPLEMENT (graphite2)
#endif
+#ifdef HAVE_CORETEXT
+/* Only picks up fonts that have a "mort" or "morx" table. */
+HB_SHAPER_IMPLEMENT (coretext)
+#endif
+
#ifdef HAVE_OT
HB_SHAPER_IMPLEMENT (ot) /* <--- This is our main OpenType shaper. */
#endif
@@ -48,9 +53,6 @@ HB_SHAPER_IMPLEMENT (icu_le)
#ifdef HAVE_UNISCRIBE
HB_SHAPER_IMPLEMENT (uniscribe)
#endif
-#ifdef HAVE_CORETEXT
-HB_SHAPER_IMPLEMENT (coretext)
-#endif
#ifdef HAVE_FALLBACK
HB_SHAPER_IMPLEMENT (fallback) /* <--- This should be last. */
diff --git a/src/gui/text/qharfbuzzng.cpp b/src/gui/text/qharfbuzzng.cpp
index c5bedecbfe..bf34c74b49 100644
--- a/src/gui/text/qharfbuzzng.cpp
+++ b/src/gui/text/qharfbuzzng.cpp
@@ -698,7 +698,7 @@ _hb_qt_font_create(QFontEngine *fe)
const int x_ppem = (fe->fontDef.pixelSize * fe->fontDef.stretch) / 100;
hb_font_set_funcs(font, hb_qt_get_font_funcs(), (void *)fe, NULL);
- hb_font_set_scale(font, QFixed(x_ppem).value(), -QFixed(y_ppem).value());
+ hb_font_set_scale(font, QFixed(x_ppem).value(), QFixed(y_ppem).value());
hb_font_set_ppem(font, x_ppem, y_ppem);
return font;
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index 79d56df7f2..739935fdd5 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -1195,6 +1195,13 @@ int QTextEngine::shapeTextWithHarfbuzzNG(const QScriptItem &si, const ushort *st
g.glyphs[i] |= (engineIdx << 24);
}
+#ifdef Q_OS_MAC
+ if (actualFontEngine->fontDef.styleStrategy & QFont::ForceIntegerMetrics) {
+ for (uint i = 0; i < num_glyphs; ++i)
+ g.advances[i] = g.advances[i].round();
+ }
+#endif
+
glyphs_shaped += num_glyphs;
}
diff --git a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm
index 570e841d52..31a015ae9f 100644
--- a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm
+++ b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm
@@ -188,6 +188,8 @@ void QCoreTextFontEngine::init()
avgCharWidth = QFontEngine::averageCharWidth();
cache_cost = (CTFontGetAscent(ctfont) + CTFontGetDescent(ctfont)) * avgCharWidth.toInt() * 2000;
+
+ setUserData(QVariant::fromValue((void *)cgFont));
}
bool QCoreTextFontEngine::stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs,