Open Rishab-1065 opened 6 years ago
What is the code you're trying atm? Are you using https://github.com/devongovett/fontkit#collectiongetfontpostscriptname to get a contained font?
function getTtcFile(filePath, fontPostScriptName) {
fontkit.open(
"/Library/Fonts/AmericanTypewriter.ttc",
"AmericanTypewriter-Bold",
(err, font) => {
const str = iconv.decode(font.stream.buffer, "base64");
fs.writeFile(
"$(USER_ROOTDIR)/AmericanTypewriter-Bold.ttf",
font.stream.buffer
);
}
);
}
I am getting the buffer for all the fonts not for the specific one.
Having the same issue. Trying to save a single TTF file from a TTC collection. The code below saves the entire original collection and not just the selected font ([0]).
const fs = require('fs');
const fontkit = require('fontkit');
const ttfFont = fontkit.openSync('/System/Library/Fonts/Avenir.ttc').fonts[0];
fs.writeFileSync('Avenir-Book.ttf', ttfFont.stream.buffer);
Could you try this again but rather than accessing .fonts[0]
after loading, directly grabbing the font in question by using its postscript name? (mostly in order to find clues on what might be going wrong)
Same results of course. Below is the code from TrueTypeCollection.js I think the stream should be sliced somehow before assigned to each new TTFFont (sorry, my knowledge in buffers and streams is weak..). Also, and regardless, in case of DFonts, the getFont(postcriptName) doesn't work. WDYT?
getFont(name) {
for (let offset of this.header.offsets) {
let stream = new r.DecodeStream(this.stream.buffer);
stream.pos = offset;
let font = new TTFFont(stream);
if (font.postscriptName === name) {
return font;
}
}
return null;
}
get fonts() {
let fonts = [];
for (let offset of this.header.offsets) {
let stream = new r.DecodeStream(this.stream.buffer);
stream.pos = offset;
fonts.push(new TTFFont(stream));
}
return fonts;
}
do you have solution?? i got same problem
Still not working
is there any resolution?
I am trying to read a ttc font file and get the buffer for particular font but the font object gives the buffer for all fonts. Is there any way I can get particular font buffer.