MCPcopy Create free account
hub / github.com/LibPDF-js/core / parseCidRange

Method parseCidRange

src/fontbox/cmap/parser.ts:365–400  ·  view source on GitHub ↗
(count: number, result: CMap)

Source from the content-addressed store, hash-verified

363 }
364
365 private parseCidRange(count: number, result: CMap): void {
366 for (let i = 0; i < count; i++) {
367 const startToken = this.parseNextToken();
368
369 if (isOperator(startToken)) {
370 break;
371 }
372
373 if (!(startToken instanceof Uint8Array)) {
374 throw new Error("Expected hex string for cidrange start");
375 }
376
377 const endToken = this.parseNextToken();
378
379 if (!(endToken instanceof Uint8Array)) {
380 throw new Error("Expected hex string for cidrange end");
381 }
382
383 const cidToken = this.parseNextToken();
384
385 if (typeof cidToken !== "number") {
386 throw new Error("Expected integer for cidrange CID");
387 }
388
389 if (startToken.length !== endToken.length) {
390 throw new Error("cidrange start and end must have same length");
391 }
392
393 // Check if it's a single value (some CMaps use ranges for single values)
394 if (arraysEqual(startToken, endToken)) {
395 result.addCIDMapping(startToken, cidToken);
396 } else {
397 result.addCIDRange(startToken, endToken, cidToken);
398 }
399 }
400 }
401
402 // =========================================================================
403 // Tokenizer

Callers 1

parseMethod · 0.95

Calls 5

parseNextTokenMethod · 0.95
isOperatorFunction · 0.85
arraysEqualFunction · 0.85
addCIDMappingMethod · 0.80
addCIDRangeMethod · 0.80

Tested by

no test coverage detected