From 48ed598a356983f4623029dd5e87254fb59e3691 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 23 Oct 2018 02:19:32 -0700 Subject: [PATCH] [VORG] Hook up to hb-ot-font's v_origin Fixes https://github.com/harfbuzz/harfbuzz/issues/544 Test added with NotoSansCJK, eg. with U+FF38. --- src/hb-ot-face.cc | 1 - src/hb-ot-font.cc | 11 +++++++++-- src/hb-ot-vorg-table.hh | 6 ++++-- .../4cbbc461be066fccc611dcc634af6e8cb2705537.ttf | Bin 0 -> 2808 bytes test/shaping/data/in-house/tests/vertical.tests | 1 + 5 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 test/shaping/data/in-house/fonts/4cbbc461be066fccc611dcc634af6e8cb2705537.ttf 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 0000000000000000000000000000000000000000..03166b0c884aa515d80280afa0d5c365f063a1c5 GIT binary patch literal 2808 zcma)8Yitx%6h3!nclsLoqOGk!8K6{XptQAMq4+3mX(^8_-3r=N=yZ3wJ9J-}9ZFY< z5HU!k_y|VOAVM?{2uO{BMEGG$h{PX~5dEn!(HMRpYADRqFB2%9)4RFn-t)ZY zp6}kd>+bAyLpJOI4tg3_uNJEhD475-3gGywrQPlMx%T>DfHV<+9c}SEzsg_R5dcWP zg8aDKv!rHo@S+#M*^WLvo7^2OT#WMpWTGAfZ%B$l>G%x*{y6CavgG6ID_#KLenWm) z00qJy{7Lj*gnU^bqzwv;y@dQsSlYNz9Log_IkZDZpkYlnsKtkGqsKi7`)KtkQha|OM zjP!{uk%&JiQ-DfQ3j4&66c>ACQI-7)hE`>tsDwqYtZEXD+qSDp%%^xYB@&KRS`n!z zB31=gva0fsaFVJmZU{yLQm?Ej-pRBra#&U;SG8_dd|F^Kr*<`hd#9wNAi=x*_fz+F za5jF70|%ZW2Xaov94_~}+3Uqj{l%g`c|BL}I&uEQ$f-*uZ}F$LeA0KqujiXx#dmr0 zpdsil>!xcVZ>F0Y2b6e7?J0Skk6au)J#fy<(l-{D@%m14%$5CV(M|q_?m2w^!^-xSzjybDNQ=cjJC4_=ToBuIvi#phRL9hRzJ0 zdqQ^?&*$}S^ByL`uzc9BuHVzQHD~2r;JBMq(d*yec`iBrTV&qMil*fvZ`GFMXytP} z4S6_TWuq{UVsO#Kem0tQ3GJn=3BTtP^Cm*g;yL=J<9?l(1=%@CjwdKFLBE?gp8{$D=uM$!*^mX! z=>%9Uv6tSFNgAz`2`5<{q&2Nx*9nWfaWx1l{i@s#>jF~P58X%=2=+^135J4_7KULf zXM7T@=xKNwX%9BfARTg2cn4%aZVFF(%1hy$kOlcEybA=Fp2G7m4GN&JUsl7gXDT!* z1vS_=6*_=MFgz8Co1;1rrIA^6O-Hob=sS&kI*!Fw)}>I2bCTMPJW_v2YZ1R8EO9#F zL2XhdU~L%8NQ_t>^tuu@U$B9PuzAM9rrpA(*TP1#u-Ru}bL4*Q2ou7lFhydcQF!X)7-Gudxy(n530rzW=#J8yu(jv*t+mfWrllh-^+z?_ xgomw7qE9~dNwL=;Ile~}gY#N1+9CX}_YUQh3v6^;u-~afE51{fEz)FT{{in!iR1tP literal 0 HcmV?d00001 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]