@@ -277,14 +277,14 @@ function makeCmapTable(glyphs) {
277
277
] ;
278
278
279
279
if ( ! isPlan0Only )
280
- cmapTable = cmapTable . concat ( [
280
+ cmapTable . push ( ... [
281
281
// CMAP 12 header
282
282
{ name : 'cmap12PlatformID' , type : 'USHORT' , value : 3 } , // We encode only for PlatformID = 3 (Windows) because it is supported everywhere
283
283
{ name : 'cmap12EncodingID' , type : 'USHORT' , value : 10 } ,
284
284
{ name : 'cmap12Offset' , type : 'ULONG' , value : 0 }
285
285
] ) ;
286
286
287
- cmapTable = cmapTable . concat ( [
287
+ cmapTable . push ( ... [
288
288
// CMAP 4 Subtable
289
289
{ name : 'format' , type : 'USHORT' , value : 4 } ,
290
290
{ name : 'cmap4Length' , type : 'USHORT' , value : 0 } ,
@@ -303,11 +303,10 @@ function makeCmapTable(glyphs) {
303
303
for ( let j = 0 ; j < glyph . unicodes . length ; j += 1 ) {
304
304
addSegment ( t , glyph . unicodes [ j ] , i ) ;
305
305
}
306
-
307
- t . segments = t . segments . sort ( function ( a , b ) {
308
- return a . start - b . start ;
309
- } ) ;
310
306
}
307
+ t . segments . sort ( function ( a , b ) {
308
+ return a . start - b . start ;
309
+ } ) ;
311
310
312
311
addTerminatorSegment ( t ) ;
313
312
@@ -334,12 +333,12 @@ function makeCmapTable(glyphs) {
334
333
335
334
// CMAP 4
336
335
if ( segment . end <= 65535 && segment . start <= 65535 ) {
337
- endCounts = endCounts . concat ( { name : 'end_' + i , type : 'USHORT' , value : segment . end } ) ;
338
- startCounts = startCounts . concat ( { name : 'start_' + i , type : 'USHORT' , value : segment . start } ) ;
339
- idDeltas = idDeltas . concat ( { name : 'idDelta_' + i , type : 'SHORT' , value : segment . delta } ) ;
340
- idRangeOffsets = idRangeOffsets . concat ( { name : 'idRangeOffset_' + i , type : 'USHORT' , value : segment . offset } ) ;
336
+ endCounts . push ( { name : 'end_' + i , type : 'USHORT' , value : segment . end } ) ;
337
+ startCounts . push ( { name : 'start_' + i , type : 'USHORT' , value : segment . start } ) ;
338
+ idDeltas . push ( { name : 'idDelta_' + i , type : 'SHORT' , value : segment . delta } ) ;
339
+ idRangeOffsets . push ( { name : 'idRangeOffset_' + i , type : 'USHORT' , value : segment . offset } ) ;
341
340
if ( segment . glyphId !== undefined ) {
342
- glyphIds = glyphIds . concat ( { name : 'glyph_' + i , type : 'USHORT' , value : segment . glyphId } ) ;
341
+ glyphIds . push ( { name : 'glyph_' + i , type : 'USHORT' , value : segment . glyphId } ) ;
343
342
}
344
343
} else {
345
344
// Skip Unicode > 65535 (16bit unsigned max) for CMAP 4, will be added in CMAP 12
@@ -349,9 +348,9 @@ function makeCmapTable(glyphs) {
349
348
// CMAP 12
350
349
// Skip Terminator Segment
351
350
if ( ! isPlan0Only && segment . glyphIndex !== undefined ) {
352
- cmap12Groups = cmap12Groups . concat ( { name : 'cmap12Start_' + i , type : 'ULONG' , value : segment . start } ) ;
353
- cmap12Groups = cmap12Groups . concat ( { name : 'cmap12End_' + i , type : 'ULONG' , value : segment . end } ) ;
354
- cmap12Groups = cmap12Groups . concat ( { name : 'cmap12Glyph_' + i , type : 'ULONG' , value : segment . glyphIndex } ) ;
351
+ cmap12Groups . push ( { name : 'cmap12Start_' + i , type : 'ULONG' , value : segment . start } ) ;
352
+ cmap12Groups . push ( { name : 'cmap12End_' + i , type : 'ULONG' , value : segment . end } ) ;
353
+ cmap12Groups . push ( { name : 'cmap12Glyph_' + i , type : 'ULONG' , value : segment . glyphIndex } ) ;
355
354
}
356
355
}
357
356
@@ -361,12 +360,22 @@ function makeCmapTable(glyphs) {
361
360
t . entrySelector = Math . log ( t . searchRange / 2 ) / Math . log ( 2 ) ;
362
361
t . rangeShift = t . segCountX2 - t . searchRange ;
363
362
364
- t . fields = t . fields . concat ( endCounts ) ;
363
+ for ( let i = 0 ; i < endCounts . length ; i ++ ) {
364
+ t . fields . push ( endCounts [ i ] ) ;
365
+ }
365
366
t . fields . push ( { name : 'reservedPad' , type : 'USHORT' , value : 0 } ) ;
366
- t . fields = t . fields . concat ( startCounts ) ;
367
- t . fields = t . fields . concat ( idDeltas ) ;
368
- t . fields = t . fields . concat ( idRangeOffsets ) ;
369
- t . fields = t . fields . concat ( glyphIds ) ;
367
+ for ( let i = 0 ; i < startCounts . length ; i ++ ) {
368
+ t . fields . push ( startCounts [ i ] ) ;
369
+ }
370
+ for ( let i = 0 ; i < idDeltas . length ; i ++ ) {
371
+ t . fields . push ( idDeltas [ i ] ) ;
372
+ }
373
+ for ( let i = 0 ; i < idRangeOffsets . length ; i ++ ) {
374
+ t . fields . push ( idRangeOffsets [ i ] ) ;
375
+ }
376
+ for ( let i = 0 ; i < glyphIds . length ; i ++ ) {
377
+ t . fields . push ( glyphIds [ i ] ) ;
378
+ }
370
379
371
380
t . cmap4Length = 14 + // Subtable header
372
381
endCounts . length * 2 +
@@ -382,15 +391,18 @@ function makeCmapTable(glyphs) {
382
391
cmap12Groups . length * 4 ;
383
392
384
393
t . cmap12Offset = 12 + ( 2 * 2 ) + 4 + t . cmap4Length ;
385
- t . fields = t . fields . concat ( [
394
+ t . fields . push ( ... [
386
395
{ name : 'cmap12Format' , type : 'USHORT' , value : 12 } ,
387
396
{ name : 'cmap12Reserved' , type : 'USHORT' , value : 0 } ,
388
397
{ name : 'cmap12Length' , type : 'ULONG' , value : cmap12Length } ,
389
398
{ name : 'cmap12Language' , type : 'ULONG' , value : 0 } ,
390
399
{ name : 'cmap12nGroups' , type : 'ULONG' , value : cmap12Groups . length / 3 }
391
400
] ) ;
392
401
393
- t . fields = t . fields . concat ( cmap12Groups ) ;
402
+ for ( let i = 0 ; i < cmap12Groups . length ; i ++ ) {
403
+ t . fields . push ( cmap12Groups [ i ] ) ;
404
+ }
405
+
394
406
}
395
407
396
408
return t ;
0 commit comments