提交 cf203af8 编写于 作者: B Behdad Esfahbod

Implement space fallback in vertical direction

Fixes https://github.com/harfbuzz/harfbuzz/issues/1343
上级 e0125023
...@@ -476,11 +476,9 @@ _hb_ot_shape_fallback_spaces (const hb_ot_shape_plan_t *plan HB_UNUSED, ...@@ -476,11 +476,9 @@ _hb_ot_shape_fallback_spaces (const hb_ot_shape_plan_t *plan HB_UNUSED,
hb_font_t *font, hb_font_t *font,
hb_buffer_t *buffer) hb_buffer_t *buffer)
{ {
if (!HB_DIRECTION_IS_HORIZONTAL (buffer->props.direction))
return;
hb_glyph_info_t *info = buffer->info; hb_glyph_info_t *info = buffer->info;
hb_glyph_position_t *pos = buffer->pos; hb_glyph_position_t *pos = buffer->pos;
bool horizontal = HB_DIRECTION_IS_HORIZONTAL (buffer->props.direction);
unsigned int count = buffer->len; unsigned int count = buffer->len;
for (unsigned int i = 0; i < count; i++) for (unsigned int i = 0; i < count; i++)
if (_hb_glyph_info_is_unicode_space (&info[i]) && !_hb_glyph_info_ligated (&info[i])) if (_hb_glyph_info_is_unicode_space (&info[i]) && !_hb_glyph_info_ligated (&info[i]))
...@@ -501,27 +499,40 @@ _hb_ot_shape_fallback_spaces (const hb_ot_shape_plan_t *plan HB_UNUSED, ...@@ -501,27 +499,40 @@ _hb_ot_shape_fallback_spaces (const hb_ot_shape_plan_t *plan HB_UNUSED,
case t::SPACE_EM_5: case t::SPACE_EM_5:
case t::SPACE_EM_6: case t::SPACE_EM_6:
case t::SPACE_EM_16: case t::SPACE_EM_16:
if (horizontal)
pos[i].x_advance = (font->x_scale + ((int) space_type)/2) / (int) space_type; pos[i].x_advance = (font->x_scale + ((int) space_type)/2) / (int) space_type;
else
pos[i].y_advance = (font->y_scale + ((int) space_type)/2) / (int) space_type;
break; break;
case t::SPACE_4_EM_18: case t::SPACE_4_EM_18:
if (horizontal)
pos[i].x_advance = (int64_t) font->x_scale * 4 / 18; pos[i].x_advance = (int64_t) font->x_scale * 4 / 18;
else
pos[i].y_advance = (int64_t) font->y_scale * 4 / 18;
break; break;
case t::SPACE_FIGURE: case t::SPACE_FIGURE:
for (char u = '0'; u <= '9'; u++) for (char u = '0'; u <= '9'; u++)
if (font->get_nominal_glyph (u, &glyph)) if (font->get_nominal_glyph (u, &glyph))
{ {
if (horizontal)
pos[i].x_advance = font->get_glyph_h_advance (glyph); pos[i].x_advance = font->get_glyph_h_advance (glyph);
else
pos[i].y_advance = font->get_glyph_v_advance (glyph);
break; break;
} }
break; break;
case t::SPACE_PUNCTUATION: case t::SPACE_PUNCTUATION:
if (font->get_nominal_glyph ('.', &glyph)) if (font->get_nominal_glyph ('.', &glyph) ||
pos[i].x_advance = font->get_glyph_h_advance (glyph); font->get_nominal_glyph (',', &glyph))
else if (font->get_nominal_glyph (',', &glyph)) {
if (horizontal)
pos[i].x_advance = font->get_glyph_h_advance (glyph); pos[i].x_advance = font->get_glyph_h_advance (glyph);
else
pos[i].y_advance = font->get_glyph_v_advance (glyph);
}
break; break;
case t::SPACE_NARROW: case t::SPACE_NARROW:
...@@ -530,7 +541,10 @@ _hb_ot_shape_fallback_spaces (const hb_ot_shape_plan_t *plan HB_UNUSED, ...@@ -530,7 +541,10 @@ _hb_ot_shape_fallback_spaces (const hb_ot_shape_plan_t *plan HB_UNUSED,
* However, in my testing, many fonts have their regular space being about that * However, in my testing, many fonts have their regular space being about that
* size. To me, a percentage of the space width makes more sense. Half is as * size. To me, a percentage of the space width makes more sense. Half is as
* good as any. */ * good as any. */
if (horizontal)
pos[i].x_advance /= 2; pos[i].x_advance /= 2;
else
pos[i].y_advance /= 2;
break; break;
} }
} }
......
...@@ -15,3 +15,20 @@ ...@@ -15,3 +15,20 @@
../fonts/1c2c3fc37b2d4c3cb2ef726c6cdaaabd4b7f3eb9.ttf:--font-funcs=ot:U+202F:[gid1=0+280] ../fonts/1c2c3fc37b2d4c3cb2ef726c6cdaaabd4b7f3eb9.ttf:--font-funcs=ot:U+202F:[gid1=0+280]
../fonts/1c2c3fc37b2d4c3cb2ef726c6cdaaabd4b7f3eb9.ttf:--font-funcs=ot:U+205F:[gid1=0+455] ../fonts/1c2c3fc37b2d4c3cb2ef726c6cdaaabd4b7f3eb9.ttf:--font-funcs=ot:U+205F:[gid1=0+455]
../fonts/1c2c3fc37b2d4c3cb2ef726c6cdaaabd4b7f3eb9.ttf:--font-funcs=ot:U+3000:[gid1=0+2048] ../fonts/1c2c3fc37b2d4c3cb2ef726c6cdaaabd4b7f3eb9.ttf:--font-funcs=ot:U+3000:[gid1=0+2048]
../fonts/1c2c3fc37b2d4c3cb2ef726c6cdaaabd4b7f3eb9.ttf:--font-funcs=ot --direction=ttb:U+0020:[gid1=0@-280,0+0,-2048]
../fonts/1c2c3fc37b2d4c3cb2ef726c6cdaaabd4b7f3eb9.ttf:--font-funcs=ot --direction=ttb:U+00A0:[gid1=0@-280,0+0,-2048]
../fonts/1c2c3fc37b2d4c3cb2ef726c6cdaaabd4b7f3eb9.ttf:--font-funcs=ot --direction=ttb:U+1680:[gid0=0@-346,0+0,-2048]
../fonts/1c2c3fc37b2d4c3cb2ef726c6cdaaabd4b7f3eb9.ttf:--font-funcs=ot --direction=ttb:U+2000:[gid1=0@-280,0+0,1024]
../fonts/1c2c3fc37b2d4c3cb2ef726c6cdaaabd4b7f3eb9.ttf:--font-funcs=ot --direction=ttb:U+2001:[gid1=0@-280,0+0,2048]
../fonts/1c2c3fc37b2d4c3cb2ef726c6cdaaabd4b7f3eb9.ttf:--font-funcs=ot --direction=ttb:U+2002:[gid1=0@-280,0+0,1024]
../fonts/1c2c3fc37b2d4c3cb2ef726c6cdaaabd4b7f3eb9.ttf:--font-funcs=ot --direction=ttb:U+2003:[gid1=0@-280,0+0,2048]
../fonts/1c2c3fc37b2d4c3cb2ef726c6cdaaabd4b7f3eb9.ttf:--font-funcs=ot --direction=ttb:U+2004:[gid1=0@-280,0+0,683]
../fonts/1c2c3fc37b2d4c3cb2ef726c6cdaaabd4b7f3eb9.ttf:--font-funcs=ot --direction=ttb:U+2005:[gid1=0@-280,0+0,512]
../fonts/1c2c3fc37b2d4c3cb2ef726c6cdaaabd4b7f3eb9.ttf:--font-funcs=ot --direction=ttb:U+2006:[gid1=0@-280,0+0,341]
../fonts/1c2c3fc37b2d4c3cb2ef726c6cdaaabd4b7f3eb9.ttf:--font-funcs=ot --direction=ttb:U+2007:[gid1=0@-280,0+0,-2048]
../fonts/1c2c3fc37b2d4c3cb2ef726c6cdaaabd4b7f3eb9.ttf:--font-funcs=ot --direction=ttb:U+2008:[gid1=0@-280,0+0,-2048]
../fonts/1c2c3fc37b2d4c3cb2ef726c6cdaaabd4b7f3eb9.ttf:--font-funcs=ot --direction=ttb:U+2009:[gid1=0@-280,0+0,410]
../fonts/1c2c3fc37b2d4c3cb2ef726c6cdaaabd4b7f3eb9.ttf:--font-funcs=ot --direction=ttb:U+200A:[gid1=0@-280,0+0,128]
../fonts/1c2c3fc37b2d4c3cb2ef726c6cdaaabd4b7f3eb9.ttf:--font-funcs=ot --direction=ttb:U+202F:[gid1=0@-280,0+0,-1024]
../fonts/1c2c3fc37b2d4c3cb2ef726c6cdaaabd4b7f3eb9.ttf:--font-funcs=ot --direction=ttb:U+205F:[gid1=0@-280,0+0,455]
../fonts/1c2c3fc37b2d4c3cb2ef726c6cdaaabd4b7f3eb9.ttf:--font-funcs=ot --direction=ttb:U+3000:[gid1=0@-280,0+0,2048]
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册