.getImageForSize(100) returns "null" using "Apple Color Emoji.ttc"
axwt opened this issue · 2 comments
Hi there, I'm trying to extract the image for emoji using the following code:
const fontkit = require('fontkit');
const font = fontkit.openSync('./Apple Color Emoji.ttc').fonts[0];
let run = font.layout("1");
let glyph = run.glyphs[0];
let imageData = glyph.getImageForSize(100); // returns null
From debugging, I can see that the glyph is still in the SBIX table.
Test tech specs:
macOS — 13.5.1 Ventura
.ttc file — 18.3d3e1 version
I saw this method worked previously. Any suggestion on why it doesn't work now?
After some debugging I can tell that it's either Apple changed their file format, or
src/tables/sbix.js
has an issue with the table parser.
getImageForSize()
function here src/glyph/SBIXGlyph.js
gets the proper table for the desired image size and then gets start and end offset to extract the image from the stream. The problem is imageOffsets
table include the same numbers for all glyphs and that's why the function doesn't work.
Ok, getImageForSize()
works correctly. It is just the first 113 glyphs have the same numbers.