(glyphs)
| 4116 | } |
| 4117 | |
| 4118 | function makeCmapTable(glyphs) { |
| 4119 | var i; |
| 4120 | var t = new table.Table('cmap', [ |
| 4121 | {name: 'version', type: 'USHORT', value: 0}, |
| 4122 | {name: 'numTables', type: 'USHORT', value: 1}, |
| 4123 | {name: 'platformID', type: 'USHORT', value: 3}, |
| 4124 | {name: 'encodingID', type: 'USHORT', value: 1}, |
| 4125 | {name: 'offset', type: 'ULONG', value: 12}, |
| 4126 | {name: 'format', type: 'USHORT', value: 4}, |
| 4127 | {name: 'length', type: 'USHORT', value: 0}, |
| 4128 | {name: 'language', type: 'USHORT', value: 0}, |
| 4129 | {name: 'segCountX2', type: 'USHORT', value: 0}, |
| 4130 | {name: 'searchRange', type: 'USHORT', value: 0}, |
| 4131 | {name: 'entrySelector', type: 'USHORT', value: 0}, |
| 4132 | {name: 'rangeShift', type: 'USHORT', value: 0} |
| 4133 | ]); |
| 4134 | |
| 4135 | t.segments = []; |
| 4136 | for (i = 0; i < glyphs.length; i += 1) { |
| 4137 | var glyph = glyphs.get(i); |
| 4138 | for (var j = 0; j < glyph.unicodes.length; j += 1) { |
| 4139 | addSegment(t, glyph.unicodes[j], i); |
| 4140 | } |
| 4141 | |
| 4142 | t.segments = t.segments.sort(function(a, b) { |
| 4143 | return a.start - b.start; |
| 4144 | }); |
| 4145 | } |
| 4146 | |
| 4147 | addTerminatorSegment(t); |
| 4148 | |
| 4149 | var segCount; |
| 4150 | segCount = t.segments.length; |
| 4151 | t.segCountX2 = segCount * 2; |
| 4152 | t.searchRange = Math.pow(2, Math.floor(Math.log(segCount) / Math.log(2))) * 2; |
| 4153 | t.entrySelector = Math.log(t.searchRange / 2) / Math.log(2); |
| 4154 | t.rangeShift = t.segCountX2 - t.searchRange; |
| 4155 | |
| 4156 | // Set up parallel segment arrays. |
| 4157 | var endCounts = []; |
| 4158 | var startCounts = []; |
| 4159 | var idDeltas = []; |
| 4160 | var idRangeOffsets = []; |
| 4161 | var glyphIds = []; |
| 4162 | |
| 4163 | for (i = 0; i < segCount; i += 1) { |
| 4164 | var segment = t.segments[i]; |
| 4165 | endCounts = endCounts.concat({name: 'end_' + i, type: 'USHORT', value: segment.end}); |
| 4166 | startCounts = startCounts.concat({name: 'start_' + i, type: 'USHORT', value: segment.start}); |
| 4167 | idDeltas = idDeltas.concat({name: 'idDelta_' + i, type: 'SHORT', value: segment.delta}); |
| 4168 | idRangeOffsets = idRangeOffsets.concat({name: 'idRangeOffset_' + i, type: 'USHORT', value: segment.offset}); |
| 4169 | if (segment.glyphId !== undefined) { |
| 4170 | glyphIds = glyphIds.concat({name: 'glyph_' + i, type: 'USHORT', value: segment.glyphId}); |
| 4171 | } |
| 4172 | } |
| 4173 | |
| 4174 | t.fields = t.fields.concat(endCounts); |
| 4175 | t.fields.push({name: 'reservedPad', type: 'USHORT', value: 0}); |
nothing calls this directly
no test coverage detected