question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

charToGlyphIndex() in encoding.js never returns null

See original GitHub issue

So the hasChar() always returns true if this.encoding is an object of CmapEncoding.

// font.js
Font.prototype.hasChar = function(c) {
    return this.encoding.charToGlyphIndex(c) !== null;
};

Below code, this.cmap.glyphIndexMap[c.charCodeAt(0)] never returns null. Maybe the caller of charToGlyphIndex() except hasChar() want to receive 0(zero) for using it as index value if there were no mapping glyph.

// encoding.js
CmapEncoding.prototype.charToGlyphIndex = function(c) {
    return this.cmap.glyphIndexMap[c.charCodeAt(0)] || 0;
};

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
tomvdbusschecommented, Dec 3, 2019

Are there still plans to implement this fix? This bug caused a lot of confusion until I found out about this issue.

1reaction
Jolg42commented, Mar 14, 2018

@debussy2k Indeed…! @fpirsch Your solution looks good, should we add this in a next patch or minor version?

Read more comments on GitHub >

github_iconTop Results From Across the Web

When JavaScript returns null & undefined? - Stack Overflow
null is used to indicate an unknown or don't care value. undefined on the other hand is designed to indicate that the propery...
Read more >
Null vs. Undefined - TypeScript Deep Dive - Gitbook
When JSON-encoding an object with an attribute that is null , the attribute will be included with its null value, whereas an attribute...
Read more >
Util | Node.js v19.3.0 Documentation
The util.debuglog() method is used to create a function that conditionally writes debug messages to stderr based on the existence of the NODE_DEBUG...
Read more >
Documentation - TypeScript 3.7
Note that if bar is null or undefined , our code will still hit an error ... Unfortunately in TypeScript these checks could...
Read more >
Check if a Value Is Null or Undefined in JavaScript or Node.js
Both values, null and undefined , are valuable in JavaScript. ... How to Base64 Encode/Decode a Value in Node.js; Check if a Value...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found