@@ -49,6 +49,34 @@ describe('Face', function () {
4949} ) ;
5050
5151describe ( 'Font' , function ( ) {
52+ it ( 'subFont creates a sub font' , function ( ) {
53+ blob = hb . createBlob ( fs . readFileSync ( path . join ( __dirname , 'fonts/noto/NotoSans-Regular.ttf' ) ) ) ;
54+ face = hb . createFace ( blob ) ;
55+ font = hb . createFont ( face ) ;
56+ let subFont = font . subFont ( ) ;
57+ expect ( subFont . ptr ) . to . not . equal ( font . ptr ) ;
58+ subFont . destroy ( ) ;
59+ } ) ;
60+
61+ it ( 'subFont font funcs fallback to parent' , function ( ) {
62+ blob = hb . createBlob ( fs . readFileSync ( path . join ( __dirname , 'fonts/noto/NotoSans-Regular.ttf' ) ) ) ;
63+ face = hb . createFace ( blob ) ;
64+ font = hb . createFont ( face ) ;
65+ let subFont = font . subFont ( ) ;
66+ expect ( subFont . ptr ) . to . not . equal ( font . ptr ) ;
67+
68+ fontFuncs = hb . createFontFuncs ( ) ;
69+ fontFuncs . setGlyphNameFunc ( function ( font_ , glyph ) {
70+ expect ( font_ . ptr ) . to . equal ( subFont . ptr ) ;
71+ return null ;
72+ } ) ;
73+ subFont . setFuncs ( fontFuncs ) ;
74+
75+ expect ( subFont . glyphName ( 20 ) ) . to . equal ( "gid20" ) ;
76+ expect ( subFont . glyphHAdvance ( 20 ) ) . to . equal ( font . glyphHAdvance ( 20 ) ) ;
77+ subFont . destroy ( ) ;
78+ } ) ;
79+
5280 it ( 'hExtents returns extents for the font' , function ( ) {
5381 blob = hb . createBlob ( fs . readFileSync ( path . join ( __dirname , 'fonts/noto/NotoSans-Regular.ttf' ) ) ) ;
5482 face = hb . createFace ( blob ) ;
0 commit comments