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

Name table entries contain null bytes #74

Closed
RoelN opened this issue Sep 4, 2020 · 6 comments
Closed

Name table entries contain null bytes #74

RoelN opened this issue Sep 4, 2020 · 6 comments
Labels
bug For code that is demonstrably wrong.

Comments

@RoelN
Copy link
Collaborator

RoelN commented Sep 4, 2020

If my text is "Wakamai Fondue rules!", font.opentype.tables.name.get(19) will return:

\x00W\x00a\x00k\x00a\x00m\x00a\x00i\x00 \x00F\x00o\x00n\x00d\x00u\x00e\x00 \x00r\x00u\x00l\x00e\x00s\x00!

I could filter them out here but I guess there is a neater solution, probably involving getting the data at the right amount of bits?

@Pomax
Copy link
Owner

Pomax commented Sep 8, 2020

this feels like it's because of the mac/microsoft string difference... we'd need to check which format the name record uses, and compensate for the two-byte string format that either the mac or windows platforms use. I forget which of the two was short and which was long off hand, but that should be something we can solve on the line you highlighted, by consoluting the record's platform/encoding

@Pomax
Copy link
Owner

Pomax commented Sep 8, 2020

Do you have a test font we can use to debug this one?

@khaledhosny
Copy link

khaledhosny commented Sep 9, 2020

Windows platform name strings are UTF-16 encoded, aren’t they?

@Pomax
Copy link
Owner

Pomax commented Sep 9, 2020

I couldn't remember which of the two was an 8 bit ansi-like and which was utf16, but yes.

@Pomax Pomax added the bug For code that is demonstrably wrong. label Sep 9, 2020
@Pomax
Copy link
Owner

Pomax commented Sep 9, 2020

landed in https://github.com/Pomax/Font.js/blob/master/src/opentype/tables/simple/name.js#L51-L92 as unicode parsing for platforms 0 and 3, and "ascii" byte parsing for everything else. That's certainly not perfect, but I'll be filing a followup issue around line 91:

// TODO: if someone wants to finesse this/implement all the other string encodings, have at it!

@Pomax
Copy link
Owner

Pomax commented Sep 10, 2020

#85

@Pomax Pomax closed this as completed Sep 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug For code that is demonstrably wrong.
Projects
None yet
Development

No branches or pull requests

3 participants