diff --git a/src/hb-ot-face.cc b/src/hb-ot-face.cc index 202619c3e..1bc68d366 100644 --- a/src/hb-ot-face.cc +++ b/src/hb-ot-face.cc @@ -31,7 +31,6 @@ #include "hb-ot-hmtx-table.hh" #include "hb-ot-kern-table.hh" #include "hb-ot-post-table.hh" -#include "hb-ot-vorg-table.hh" #include "hb-ot-color-cbdt-table.hh" #include "hb-ot-layout-gdef-table.hh" #include "hb-ot-layout-gsub-table.hh" diff --git a/src/hb-ot-font.cc b/src/hb-ot-font.cc index e6df038d3..f0b620898 100644 --- a/src/hb-ot-font.cc +++ b/src/hb-ot-font.cc @@ -37,6 +37,7 @@ #include "hb-ot-kern-table.hh" #include "hb-ot-post-table.hh" #include "hb-ot-glyf-table.hh" +#include "hb-ot-vorg-table.hh" #include "hb-ot-color-cbdt-table.hh" @@ -138,9 +139,15 @@ hb_ot_get_glyph_v_origin (hb_font_t *font, *x = font->get_glyph_h_advance (glyph) / 2; + const OT::VORG &VORG = *ot_face->VORG.get (); + if (VORG.has_data ()) + { + *y = font->em_scale_y (VORG.get_y_origin (glyph)); + return true; + } + hb_glyph_extents_t extents = {0}; - bool ret = ot_face->glyf->get_extents (glyph, &extents); - if (ret) + if (ot_face->glyf->get_extents (glyph, &extents)) { const OT::vmtx_accelerator_t &vmtx = *ot_face->vmtx.get (); hb_position_t tsb = vmtx.get_side_bearing (glyph); diff --git a/src/hb-ot-vorg-table.hh b/src/hb-ot-vorg-table.hh index 0baaf2e0e..b6494b51f 100644 --- a/src/hb-ot-vorg-table.hh +++ b/src/hb-ot-vorg-table.hh @@ -39,7 +39,7 @@ namespace OT { struct VertOriginMetric { - inline int cmp (hb_codepoint_t g) const { return -glyph.cmp (g); } + inline int cmp (hb_codepoint_t g) const { return glyph.cmp (g); } inline bool sanitize (hb_sanitize_context_t *c) const { @@ -63,7 +63,9 @@ struct VORG inline int get_y_origin (hb_codepoint_t glyph) const { - vertYOrigins.bsearch (glyph); + int i = vertYOrigins.bsearch (glyph); + if (i != -1) + return vertYOrigins[i].vertOriginY; return defaultVertOriginY; } diff --git a/test/shaping/data/in-house/fonts/4cbbc461be066fccc611dcc634af6e8cb2705537.ttf b/test/shaping/data/in-house/fonts/4cbbc461be066fccc611dcc634af6e8cb2705537.ttf new file mode 100644 index 000000000..03166b0c8 Binary files /dev/null and b/test/shaping/data/in-house/fonts/4cbbc461be066fccc611dcc634af6e8cb2705537.ttf differ diff --git a/test/shaping/data/in-house/tests/vertical.tests b/test/shaping/data/in-house/tests/vertical.tests index b18119225..395881338 100644 --- a/test/shaping/data/in-house/tests/vertical.tests +++ b/test/shaping/data/in-house/tests/vertical.tests @@ -1,3 +1,4 @@ ../fonts/191826b9643e3f124d865d617ae609db6a2ce203.ttf:--direction=t --font-funcs=ft:U+300C:[uni300C.vert=0@-512,-578+0,-1024] ../fonts/f9b1dd4dcb515e757789a22cb4241107746fd3d0.ttf:--direction=t --font-funcs=ft:U+0041,U+0042:[gid1=0@-654,-2128+0,-2789|gid2=1@-665,-2125+0,-2789] ../fonts/f9b1dd4dcb515e757789a22cb4241107746fd3d0.ttf:--direction=t --font-funcs=ot:U+0041,U+0042:[gid1=0@-654,-1468+0,-2048|gid2=1@-665,-1462+0,-2048] +../fonts/4cbbc461be066fccc611dcc634af6e8cb2705537.ttf:--direction=t --font-funcs=ot:U+FF38:[gid2=0@-500,-867+0,-1000]