1
1
const fs = require ( 'fs' ) ;
2
2
const path = require ( 'path' ) ;
3
- const { expect} = require ( 'chai' ) ;
3
+ const { expect } = require ( 'chai' ) ;
4
4
let hb ;
5
5
6
6
before ( async function ( ) {
@@ -36,8 +36,8 @@ describe('Face', function () {
36
36
this . blob = hb . createBlob ( fs . readFileSync ( path . join ( __dirname , 'fonts/noto/NotoSansArabic-Variable.ttf' ) ) ) ;
37
37
this . face = hb . createFace ( this . blob ) ;
38
38
expect ( this . face . getAxisInfos ( ) ) . to . deep . equal ( {
39
- wght : { min : 100 , default : 400 , max : 900 } ,
40
- wdth : { min : 62.5 , default : 100 , max : 100 }
39
+ wght : { min : 100 , default : 400 , max : 900 } ,
40
+ wdth : { min : 62.5 , default : 100 , max : 100 }
41
41
} ) ;
42
42
} ) ;
43
43
@@ -73,7 +73,7 @@ describe('Font', function () {
73
73
this . blob = hb . createBlob ( fs . readFileSync ( path . join ( __dirname , 'fonts/noto/NotoSansArabic-Variable.ttf' ) ) ) ;
74
74
this . face = hb . createFace ( this . blob ) ;
75
75
this . font = hb . createFont ( this . face ) ;
76
- this . font . setVariations ( { 'wght' : 789 } ) ;
76
+ this . font . setVariations ( { 'wght' : 789 } ) ;
77
77
this . buffer = hb . createBuffer ( ) ;
78
78
this . buffer . addText ( 'آلو' ) ;
79
79
this . buffer . guessSegmentProperties ( ) ;
@@ -165,9 +165,9 @@ describe('shape', function () {
165
165
this . buffer . guessSegmentProperties ( ) ;
166
166
hb . shape ( this . font , this . buffer )
167
167
const glyphs = this . buffer . json ( ) ;
168
- expect ( glyphs [ 0 ] ) . to . deep . equal ( { cl : 0 , g : 68 , ax : 561 , ay : 0 , dx : 0 , dy : 0 , flags : 0 } /* a */ ) ;
169
- expect ( glyphs [ 1 ] ) . to . deep . equal ( { cl : 1 , g : 69 , ax : 615 , ay : 0 , dx : 0 , dy : 0 , flags : 0 } /* b */ ) ;
170
- expect ( glyphs [ 2 ] ) . to . deep . equal ( { cl : 2 , g : 70 , ax : 480 , ay : 0 , dx : 0 , dy : 0 , flags : 0 } /* c */ ) ;
168
+ expect ( glyphs [ 0 ] ) . to . deep . equal ( { cl : 0 , g : 68 , ax : 561 , ay : 0 , dx : 0 , dy : 0 , flags : 0 } /* a */ ) ;
169
+ expect ( glyphs [ 1 ] ) . to . deep . equal ( { cl : 1 , g : 69 , ax : 615 , ay : 0 , dx : 0 , dy : 0 , flags : 0 } /* b */ ) ;
170
+ expect ( glyphs [ 2 ] ) . to . deep . equal ( { cl : 2 , g : 70 , ax : 480 , ay : 0 , dx : 0 , dy : 0 , flags : 0 } /* c */ ) ;
171
171
} ) ;
172
172
173
173
it ( 'shape Arabic string' , function ( ) {
@@ -179,10 +179,10 @@ describe('shape', function () {
179
179
this . buffer . guessSegmentProperties ( ) ;
180
180
hb . shape ( this . font , this . buffer )
181
181
const glyphs = this . buffer . json ( ) ;
182
- expect ( glyphs [ 0 ] ) . to . deep . equal ( { cl : 3 , g : 213 , ax : 532 , ay : 0 , dx : 0 , dy : 0 , flags : 1 } /* د */ ) ;
183
- expect ( glyphs [ 1 ] ) . to . deep . equal ( { cl : 2 , g : 529 , ax : 637 , ay : 0 , dx : 0 , dy : 0 , flags : 1 } /* ج */ ) ;
184
- expect ( glyphs [ 2 ] ) . to . deep . equal ( { cl : 1 , g : 101 , ax : 269 , ay : 0 , dx : 0 , dy : 0 , flags : 0 } /* ب */ ) ;
185
- expect ( glyphs [ 3 ] ) . to . deep . equal ( { cl : 0 , g : 50 , ax : 235 , ay : 0 , dx : 0 , dy : 0 , flags : 0 } /* أ */ ) ;
182
+ expect ( glyphs [ 0 ] ) . to . deep . equal ( { cl : 3 , g : 213 , ax : 532 , ay : 0 , dx : 0 , dy : 0 , flags : 1 } /* د */ ) ;
183
+ expect ( glyphs [ 1 ] ) . to . deep . equal ( { cl : 2 , g : 529 , ax : 637 , ay : 0 , dx : 0 , dy : 0 , flags : 1 } /* ج */ ) ;
184
+ expect ( glyphs [ 2 ] ) . to . deep . equal ( { cl : 1 , g : 101 , ax : 269 , ay : 0 , dx : 0 , dy : 0 , flags : 0 } /* ب */ ) ;
185
+ expect ( glyphs [ 3 ] ) . to . deep . equal ( { cl : 0 , g : 50 , ax : 235 , ay : 0 , dx : 0 , dy : 0 , flags : 0 } /* أ */ ) ;
186
186
} ) ;
187
187
188
188
it ( 'shape with tracing' , function ( ) {
@@ -198,18 +198,18 @@ describe('shape', function () {
198
198
"m" : "start table GSUB script tag 'latn'" ,
199
199
"glyphs" : true ,
200
200
"t" : [
201
- { cl : 0 , g : 68 } ,
202
- { cl : 1 , g : 69 } ,
203
- { cl : 2 , g : 70 } ,
201
+ { cl : 0 , g : 68 } ,
202
+ { cl : 1 , g : 69 } ,
203
+ { cl : 2 , g : 70 } ,
204
204
] ,
205
205
} ) ;
206
206
expect ( result [ 41 ] ) . to . deep . equal ( {
207
207
"m" : "end table GPOS script tag 'latn'" ,
208
208
"glyphs" : true ,
209
209
"t" : [
210
- { cl : 0 , g : 68 , ax : 561 , ay : 0 , dx : 0 , dy : 0 } ,
211
- { cl : 1 , g : 69 , ax : 615 , ay : 0 , dx : 0 , dy : 0 } ,
212
- { cl : 2 , g : 70 , ax : 480 , ay : 0 , dx : 0 , dy : 0 } ,
210
+ { cl : 0 , g : 68 , ax : 561 , ay : 0 , dx : 0 , dy : 0 } ,
211
+ { cl : 1 , g : 69 , ax : 615 , ay : 0 , dx : 0 , dy : 0 } ,
212
+ { cl : 2 , g : 70 , ax : 480 , ay : 0 , dx : 0 , dy : 0 } ,
213
213
] ,
214
214
} ) ;
215
215
} ) ;
@@ -227,25 +227,69 @@ describe('shape', function () {
227
227
"m" : "start table GSUB script tag 'latn'" ,
228
228
"glyphs" : true ,
229
229
"t" : [
230
- { cl : 0 , g : 73 } ,
231
- { cl : 1 , g : 76 } ,
232
- { cl : 2 , g : 3 } ,
233
- { cl : 3 , g : 36 } ,
234
- { cl : 4 , g : 57 } ,
230
+ { cl : 0 , g : 73 } ,
231
+ { cl : 1 , g : 76 } ,
232
+ { cl : 2 , g : 3 } ,
233
+ { cl : 3 , g : 36 } ,
234
+ { cl : 4 , g : 57 } ,
235
235
] ,
236
236
} ) ;
237
237
expect ( result [ 28 ] ) . to . deep . equal ( {
238
238
"m" : "end table GPOS script tag 'latn'" ,
239
239
"glyphs" : true ,
240
240
"t" : [
241
- { cl : 0 , g : 73 , ax : 344 , ay : 0 , dx : 0 , dy : 0 } ,
242
- { cl : 1 , g : 76 , ax : 258 , ay : 0 , dx : 0 , dy : 0 } ,
243
- { cl : 2 , g : 3 , ax : 260 , ay : 0 , dx : 0 , dy : 0 } ,
244
- { cl : 3 , g : 36 , ax : 639 , ay : 0 , dx : 0 , dy : 0 } ,
245
- { cl : 4 , g : 57 , ax : 600 , ay : 0 , dx : 0 , dy : 0 } ,
241
+ { cl : 0 , g : 73 , ax : 344 , ay : 0 , dx : 0 , dy : 0 } ,
242
+ { cl : 1 , g : 76 , ax : 258 , ay : 0 , dx : 0 , dy : 0 } ,
243
+ { cl : 2 , g : 3 , ax : 260 , ay : 0 , dx : 0 , dy : 0 } ,
244
+ { cl : 3 , g : 36 , ax : 639 , ay : 0 , dx : 0 , dy : 0 } ,
245
+ { cl : 4 , g : 57 , ax : 600 , ay : 0 , dx : 0 , dy : 0 } ,
246
246
] ,
247
247
} ) ;
248
248
} ) ;
249
+
250
+ it ( 'shape with 3-letter languae tag' , function ( ) {
251
+ this . blob = hb . createBlob ( fs . readFileSync ( path . join ( __dirname , 'fonts/noto/NotoSansDevanagari-Regular.otf' ) ) ) ;
252
+ this . face = hb . createFace ( this . blob ) ;
253
+ this . font = hb . createFont ( this . face ) ;
254
+ this . buffer = hb . createBuffer ( ) ;
255
+ this . buffer . addText ( '५ल' ) ;
256
+ this . buffer . guessSegmentProperties ( ) ;
257
+ hb . shape ( this . font , this . buffer )
258
+ var glyphs = this . buffer . json ( ) ;
259
+ expect ( glyphs ) . to . have . lengthOf ( 2 ) ;
260
+ expect ( glyphs [ 0 ] . g ) . to . equal ( 118 ) ;
261
+
262
+ this . buffer = hb . createBuffer ( ) ;
263
+ this . buffer . addText ( '५ल' ) ;
264
+ this . buffer . setLanguage ( 'dty' ) ;
265
+ this . buffer . guessSegmentProperties ( ) ;
266
+ hb . shape ( this . font , this . buffer )
267
+ var glyphs = this . buffer . json ( ) ;
268
+ expect ( glyphs ) . to . have . lengthOf ( 2 ) ;
269
+ expect ( glyphs [ 0 ] . g ) . to . equal ( 123 ) ;
270
+ } ) ;
271
+
272
+ it ( 'shape with OpenType language tag' , function ( ) {
273
+ this . blob = hb . createBlob ( fs . readFileSync ( path . join ( __dirname , 'fonts/noto/NotoSansDevanagari-Regular.otf' ) ) ) ;
274
+ this . face = hb . createFace ( this . blob ) ;
275
+ this . font = hb . createFont ( this . face ) ;
276
+ this . buffer = hb . createBuffer ( ) ;
277
+ this . buffer . addText ( '५ल' ) ;
278
+ this . buffer . guessSegmentProperties ( ) ;
279
+ hb . shape ( this . font , this . buffer )
280
+ var glyphs = this . buffer . json ( ) ;
281
+ expect ( glyphs ) . to . have . lengthOf ( 2 ) ;
282
+ expect ( glyphs [ 0 ] . g ) . to . equal ( 118 ) ;
283
+
284
+ this . buffer = hb . createBuffer ( ) ;
285
+ this . buffer . addText ( '५ल' ) ;
286
+ this . buffer . setLanguage ( 'x-hbot-4e455020' ) ; // 'NEP '
287
+ this . buffer . guessSegmentProperties ( ) ;
288
+ hb . shape ( this . font , this . buffer )
289
+ var glyphs = this . buffer . json ( ) ;
290
+ expect ( glyphs ) . to . have . lengthOf ( 2 ) ;
291
+ expect ( glyphs [ 0 ] . g ) . to . equal ( 123 ) ;
292
+ } ) ;
249
293
} ) ;
250
294
251
295
describe ( 'misc' , function ( ) {
0 commit comments