Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Newest version of restructure doesn't support all string encodings #331

Closed
timmyL17 opened this issue Apr 3, 2024 · 6 comments · Fixed by foliojs/restructure#62
Closed

Comments

@timmyL17
Copy link

timmyL17 commented Apr 3, 2024

It appears that the newest version of restructure does not support all string encodings. When I tried to open a font file on my mac, the font name fields were all null because restructure does not support the x-mac-roman encoding. Perhaps fontkit should depend strictly on restructure v3.0.0 until restructure updates?

foliojs/restructure#60 (comment)

@srl295
Copy link

srl295 commented Apr 5, 2024

Can you reproduce this here? Noting that this may be related to diegomura/react-pdf#2675

@srl295
Copy link

srl295 commented Apr 5, 2024

Repro!

var fontkit = require('fontkit');

// open a font synchronously
var font = fontkit.openSync('src/arial-bold.ttf');

// layout a string, using default shaping features.
// returns a GlyphRun, describing glyphs and positions.
var run = font.layout('hello world!');

// get an SVG path for a glyph
var svg = run.glyphs[0].path.toSVG();

// create a font subset
var subset = font.createSubset();
run.glyphs.forEach(function(glyph) {
  subset.includeGlyph(glyph);
});

console.log('name:'+font.getName());
console.log('fullname:'+font.fullName);


let buffer = subset.encode();
console.dir({buffer});

fullnae is Arial Bold under restructure@3.0.0, null for restructure@3.0.1

@srl295
Copy link

srl295 commented Apr 6, 2024

also repro:

  • clone fontkit
  • npm i
  • npm t (passes)
  • npm i --save restructure@3.0.1
  • npm t (fails)

@srl295
Copy link

srl295 commented Apr 6, 2024

Here https://github.com/foliojs/fontkit/blob/master/src/tables/name.js#L13

Is where random encodings are passed to restructure.

@timmyL17
Copy link
Author

timmyL17 commented Apr 6, 2024

Thanks, you beat me to it. That was essentially my repro. I should have posted it at the beginning.

@devongovett
Copy link
Member

Fixed by foliojs/restructure#62

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants