summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/harfbuzz-ng/src/hb-coretext.cc
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2015-11-04 20:18:14 +0100
committerLiang Qi <liang.qi@theqtcompany.com>2015-11-04 20:18:14 +0100
commit4159ee840549df11287294f0928e90f35f3e06ff (patch)
tree4a3947e37d54bdb78b4042e9ced20dbf181b5a2c /src/3rdparty/harfbuzz-ng/src/hb-coretext.cc
parent59dbf1786f22ec4ac88d8f9d38cac5cfb82acaea (diff)
parentc8c39ecc37c156ac2677de09a26548dfc274b564 (diff)
Merge remote-tracking branch 'origin/5.6' into dev
Conflicts: config.tests/unix/ptrsize.test configure src/corelib/global/qnamespace.h src/network/socket/qabstractsocket.cpp tests/auto/other/networkselftest/networkselftest.pro Change-Id: Ic78abb4a34f9068567cea876861d4220f5a07672
Diffstat (limited to 'src/3rdparty/harfbuzz-ng/src/hb-coretext.cc')
-rw-r--r--src/3rdparty/harfbuzz-ng/src/hb-coretext.cc55
1 files changed, 41 insertions, 14 deletions
diff --git a/src/3rdparty/harfbuzz-ng/src/hb-coretext.cc b/src/3rdparty/harfbuzz-ng/src/hb-coretext.cc
index ab9e1d4a93..76c81e48f4 100644
--- a/src/3rdparty/harfbuzz-ng/src/hb-coretext.cc
+++ b/src/3rdparty/harfbuzz-ng/src/hb-coretext.cc
@@ -104,6 +104,7 @@ hb_coretext_shaper_face_data_t *
_hb_coretext_shaper_face_data_create (hb_face_t *face)
{
hb_coretext_shaper_face_data_t *data = NULL;
+
#if 0
if (face->destroy == (hb_destroy_func_t) CGFontRelease)
{
@@ -129,6 +130,7 @@ _hb_coretext_shaper_face_data_create (hb_face_t *face)
CoreTextFontEngineData *coreTextFontEngineData = (CoreTextFontEngineData *) fontEngineFaceData->user_data;
data = CGFontRetain (coreTextFontEngineData->cgFont);
#endif
+
if (unlikely (!data)) {
DEBUG_MSG (CORETEXT, face, "Face CGFontCreateWithDataProvider() failed");
}
@@ -142,6 +144,9 @@ _hb_coretext_shaper_face_data_destroy (hb_coretext_shaper_face_data_t *data)
CFRelease (data);
}
+/*
+ * Since: 0.9.10
+ */
CGFontRef
hb_coretext_face_get_cg_font (hb_face_t *face)
{
@@ -174,6 +179,7 @@ _hb_coretext_shaper_font_data_create (hb_font_t *font)
hb_coretext_shaper_face_data_t *face_data = HB_SHAPER_DATA_GET (face);
/* Choose a CoreText font size and calculate multipliers to convert to HarfBuzz space. */
+ /* TODO: use upem instead of 36? */
CGFloat font_size = 36.; /* Default... */
/* No idea if the following is even a good idea. */
if (font->y_ppem)
@@ -812,6 +818,17 @@ retry:
buffer->len = 0;
uint32_t status_and = ~0, status_or = 0;
double advances_so_far = 0;
+ /* For right-to-left runs, CoreText returns the glyphs positioned such that
+ * any trailing whitespace is to the left of (0,0). Adjust coordinate system
+ * to fix for that. Test with any RTL string with trailing spaces.
+ * https://code.google.com/p/chromium/issues/detail?id=469028
+ */
+ if (HB_DIRECTION_IS_BACKWARD (buffer->props.direction))
+ {
+ advances_so_far -= CTLineGetTrailingWhitespaceWidth (line);
+ if (HB_DIRECTION_IS_VERTICAL (buffer->props.direction))
+ advances_so_far = -advances_so_far;
+ }
const CFRange range_all = CFRangeMake (0, 0);
@@ -929,8 +946,8 @@ retry:
info->cluster = log_clusters[j];
info->mask = advance;
- info->var1.u32 = x_offset;
- info->var2.u32 = y_offset;
+ info->var1.i32 = x_offset;
+ info->var2.i32 = y_offset;
info++;
buffer->len++;
@@ -1022,8 +1039,8 @@ retry:
else /* last glyph */
advance = run_advance - (positions[j].x - positions[0].x);
info->mask = advance * x_mult;
- info->var1.u32 = x_offset;
- info->var2.u32 = positions[j].y * y_mult;
+ info->var1.i32 = x_offset;
+ info->var2.i32 = positions[j].y * y_mult;
info++;
}
}
@@ -1038,8 +1055,8 @@ retry:
else /* last glyph */
advance = run_advance - (positions[j].y - positions[0].y);
info->mask = advance * y_mult;
- info->var1.u32 = positions[j].x * x_mult;
- info->var2.u32 = y_offset;
+ info->var1.i32 = positions[j].x * x_mult;
+ info->var2.i32 = y_offset;
info++;
}
}
@@ -1068,10 +1085,20 @@ retry:
buffer->len += num_glyphs;
}
- /* Make sure all runs had the expected direction. */
- bool backward = HB_DIRECTION_IS_BACKWARD (buffer->props.direction);
- assert (bool (status_and & kCTRunStatusRightToLeft) == backward);
- assert (bool (status_or & kCTRunStatusRightToLeft) == backward);
+ /* Mac OS 10.6 doesn't have kCTTypesetterOptionForcedEmbeddingLevel,
+ * or if it does, it doesn't resepct it. So we get runs with wrong
+ * directions. As such, disable the assert... It wouldn't crash, but
+ * cursoring will be off...
+ *
+ * http://crbug.com/419769
+ */
+ if (0)
+ {
+ /* Make sure all runs had the expected direction. */
+ bool backward = HB_DIRECTION_IS_BACKWARD (buffer->props.direction);
+ assert (bool (status_and & kCTRunStatusRightToLeft) == backward);
+ assert (bool (status_or & kCTRunStatusRightToLeft) == backward);
+ }
buffer->clear_positions ();
@@ -1082,16 +1109,16 @@ retry:
for (unsigned int i = 0; i < count; i++)
{
pos->x_advance = info->mask;
- pos->x_offset = info->var1.u32;
- pos->y_offset = info->var2.u32;
+ pos->x_offset = info->var1.i32;
+ pos->y_offset = info->var2.i32;
info++, pos++;
}
else
for (unsigned int i = 0; i < count; i++)
{
pos->y_advance = info->mask;
- pos->x_offset = info->var1.u32;
- pos->y_offset = info->var2.u32;
+ pos->x_offset = info->var1.i32;
+ pos->y_offset = info->var2.i32;
info++, pos++;
}