PHP 8.2.30
Preview: cmap.js Size: 3.93 KB
/home/byroehnu/.trash/node_modules11/fontkit/src/tables/cmap.js

import * as r from 'restructure';

let SubHeader = new r.Struct({
  firstCode:      r.uint16,
  entryCount:     r.uint16,
  idDelta:        r.int16,
  idRangeOffset:  r.uint16
});

let CmapGroup = new r.Struct({
  startCharCode:  r.uint32,
  endCharCode:    r.uint32,
  glyphID:        r.uint32
});

let UnicodeValueRange = new r.Struct({
  startUnicodeValue:  r.uint24,
  additionalCount:    r.uint8
});

let UVSMapping = new r.Struct({
  unicodeValue: r.uint24,
  glyphID:      r.uint16
});

let DefaultUVS = new r.Array(UnicodeValueRange, r.uint32);
let NonDefaultUVS = new r.Array(UVSMapping, r.uint32);

let VarSelectorRecord = new r.Struct({
  varSelector:    r.uint24,
  defaultUVS:     new r.Pointer(r.uint32, DefaultUVS, {type: 'parent'}),
  nonDefaultUVS:  new r.Pointer(r.uint32, NonDefaultUVS, {type: 'parent'})
});

let CmapSubtable = new r.VersionedStruct(r.uint16, {
  0: { // Byte encoding
    length:     r.uint16,   // Total table length in bytes (set to 262 for format 0)
    language:   r.uint16,   // Language code for this encoding subtable, or zero if language-independent
    codeMap:    new r.LazyArray(r.uint8, 256)
  },

  2: { // High-byte mapping (CJK)
    length:           r.uint16,
    language:         r.uint16,
    subHeaderKeys:    new r.Array(r.uint16, 256),
    subHeaderCount:   t => Math.max.apply(Math, t.subHeaderKeys),
    subHeaders:       new r.LazyArray(SubHeader, 'subHeaderCount'),
    glyphIndexArray:  new r.LazyArray(r.uint16, 'subHeaderCount')
  },

  4: { // Segment mapping to delta values
    length:           r.uint16,              // Total table length in bytes
    language:         r.uint16,              // Language code
    segCountX2:       r.uint16,
    segCount:         t => t.segCountX2 >> 1,
    searchRange:      r.uint16,
    entrySelector:    r.uint16,
    rangeShift:       r.uint16,
    endCode:          new r.LazyArray(r.uint16, 'segCount'),
    reservedPad:      new r.Reserved(r.uint16),       // This value should be zero
    startCode:        new r.LazyArray(r.uint16, 'segCount'),
    idDelta:          new r.LazyArray(r.int16, 'segCount'),
    idRangeOffset:    new r.LazyArray(r.uint16, 'segCount'),
    glyphIndexArray:  new r.LazyArray(r.uint16, t => (t.length - t._currentOffset) / 2)
  },

  6: { // Trimmed table
    length:         r.uint16,
    language:       r.uint16,
    firstCode:      r.uint16,
    entryCount:     r.uint16,
    glyphIndices:   new r.LazyArray(r.uint16, 'entryCount')
  },

  8: { // mixed 16-bit and 32-bit coverage
    reserved: new r.Reserved(r.uint16),
    length:   r.uint32,
    language: r.uint16,
    is32:     new r.LazyArray(r.uint8, 8192),
    nGroups:  r.uint32,
    groups:   new r.LazyArray(CmapGroup, 'nGroups')
  },

  10: { // Trimmed Array
    reserved:       new r.Reserved(r.uint16),
    length:         r.uint32,
    language:       r.uint32,
    firstCode:      r.uint32,
    entryCount:     r.uint32,
    glyphIndices:   new r.LazyArray(r.uint16, 'numChars')
  },

  12: { // Segmented coverage
    reserved: new r.Reserved(r.uint16),
    length:   r.uint32,
    language: r.uint32,
    nGroups:  r.uint32,
    groups:   new r.LazyArray(CmapGroup, 'nGroups')
  },

  13: { // Many-to-one range mappings (same as 12 except for group.startGlyphID)
    reserved: new r.Reserved(r.uint16),
    length:   r.uint32,
    language: r.uint32,
    nGroups:  r.uint32,
    groups:   new r.LazyArray(CmapGroup, 'nGroups')
  },

  14: { // Unicode Variation Sequences
    length:       r.uint32,
    numRecords:   r.uint32,
    varSelectors: new r.LazyArray(VarSelectorRecord, 'numRecords')
  }
});

let CmapEntry = new r.Struct({
  platformID:  r.uint16,  // Platform identifier
  encodingID:  r.uint16,  // Platform-specific encoding identifier
  table:       new r.Pointer(r.uint32, CmapSubtable, {type: 'parent', lazy: true})
});

// character to glyph mapping
export default new r.Struct({
  version:      r.uint16,
  numSubtables: r.uint16,
  tables:       new r.Array(CmapEntry, 'numSubtables')
});

Directory Contents

Dirs: 0 × Files: 49

Name Size Perms Modified Actions
4.07 KB lrw-r--r-- 2026-02-14 19:19:20
Edit Download
405 B lrw-r--r-- 2026-02-14 19:19:20
Edit Download
3.02 KB lrw-r--r-- 2026-02-14 19:19:20
Edit Download
754 B lrw-r--r-- 2026-02-14 19:19:20
Edit Download
3.93 KB lrw-r--r-- 2026-02-14 19:19:22
Edit Download
1.29 KB lrw-r--r-- 2026-02-14 19:19:22
Edit Download
757 B lrw-r--r-- 2026-02-14 19:19:22
Edit Download
167 B lrw-r--r-- 2026-02-14 19:19:22
Edit Download
1.38 KB lrw-r--r-- 2026-02-14 19:19:22
Edit Download
696 B lrw-r--r-- 2026-02-14 19:19:22
Edit Download
1.50 KB lrw-r--r-- 2026-02-14 19:19:22
Edit Download
1.85 KB lrw-r--r-- 2026-02-14 19:19:24
Edit Download
825 B lrw-r--r-- 2026-02-14 19:19:24
Edit Download
348 B lrw-r--r-- 2026-02-14 19:19:24
Edit Download
864 B lrw-r--r-- 2026-02-14 19:19:26
Edit Download
531 B lrw-r--r-- 2026-02-14 19:19:26
Edit Download
1.73 KB lrw-r--r-- 2026-02-14 19:19:28
Edit Download
103 B lrw-r--r-- 2026-02-14 19:19:28
Edit Download
6.41 KB lrw-r--r-- 2026-02-14 19:19:36
Edit Download
2.75 KB lrw-r--r-- 2026-02-14 19:19:38
Edit Download
859 B lrw-r--r-- 2026-02-14 19:19:38
Edit Download
496 B lrw-r--r-- 2026-02-14 19:19:38
Edit Download
1.25 KB lrw-r--r-- 2026-02-14 19:19:38
Edit Download
1.01 KB lrw-r--r-- 2026-02-14 19:19:38
Edit Download
324 B lrw-r--r-- 2026-02-14 19:19:38
Edit Download
1.28 KB lrw-r--r-- 2026-02-14 19:19:38
Edit Download
2.25 KB lrw-r--r-- 2026-02-14 19:19:38
Edit Download
1.74 KB lrw-r--r-- 2026-02-14 19:19:38
Edit Download
2.17 KB lrw-r--r-- 2026-02-14 19:19:38
Edit Download
3.07 KB lrw-r--r-- 2026-02-14 19:19:38
Edit Download
625 B lrw-r--r-- 2026-02-14 19:19:38
Edit Download
321 B lrw-r--r-- 2026-02-14 19:19:38
Edit Download
1.19 KB lrw-r--r-- 2026-02-14 19:19:40
Edit Download
2.03 KB lrw-r--r-- 2026-02-14 19:19:40
Edit Download
3.24 KB lrw-r--r-- 2026-02-14 19:19:40
Edit Download
303 B lrw-r--r-- 2026-02-14 19:19:40
Edit Download
6.67 KB lrw-r--r-- 2026-02-14 19:19:40
Edit Download
3.56 KB lrw-r--r-- 2026-02-14 19:19:40
Edit Download
733 B lrw-r--r-- 2026-02-14 19:19:40
Edit Download
1.38 KB lrw-r--r-- 2026-02-14 19:19:40
Edit Download
199 B lrw-r--r-- 2026-02-14 19:19:40
Edit Download
604 B lrw-r--r-- 2026-02-14 19:19:40
Edit Download
2.40 KB lrw-r--r-- 2026-02-14 19:19:40
Edit Download
1.73 KB lrw-r--r-- 2026-02-14 19:19:40
Edit Download
1.13 KB lrw-r--r-- 2026-02-14 19:19:40
Edit Download
421 B lrw-r--r-- 2026-02-14 19:19:40
Edit Download
382 B lrw-r--r-- 2026-02-14 19:19:40
Edit Download
2.28 KB lrw-r--r-- 2026-02-14 19:19:40
Edit Download
977 B lrw-r--r-- 2026-02-14 19:19:40
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).