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 parsing is incorrect #16322

Open
kekekeks opened this issue Jul 15, 2024 · 5 comments
Open

Name table parsing is incorrect #16322

kekekeks opened this issue Jul 15, 2024 · 5 comments
Assignees
Labels

Comments

@kekekeks
Copy link
Member

Describe the bug

Was looking at this PR and noticed that while LCIDs map nicely to platformID=3, we pretty much ignore other platform IDs. E. g. platformID = 1 has its own set of language codes.

While being generally safe to do when filtering language IDs we can't ignore the platformID when selecting the encoding here, since non-windows fonts have different encoding identifiers and it will cause exceptions.

@Gillibald

To Reproduce

Try loading some font with mac/unicode platform in its name table

Expected behavior

No response

Avalonia version

master

OS

No response

Additional context

No response

@kekekeks
Copy link
Member Author

We should also probably fall back to using PostScript font names if name table is unavailable or unreadable.

@Gillibald
Copy link
Contributor

Gillibald commented Jul 15, 2024

Such ancient encodings require a reference to https://learn.microsoft.com/en-us/dotnet/api/system.text.codepagesencodingprovider?view=net-8.0
Modern fonts only use the Unicode encoding.

To make this work we need some feature flag to enable support for older platforms

@kekekeks
Copy link
Member Author

We need to explicitly skip reading them and explicitly fall back to PS font name then. Right now we are simply ignoring the relevant encoding field.

@MIRIMIRIM
Copy link

I think correctly parsing old fonts' name record is a troublesome job, they may use different encoding from name record.

If you just want to get the correct language code when platformID=3, you can do a simple conversion, such as https://github.com/HinTak/Font-Validator/blob/aa6d6bc0f1b5eb257877a998f97dbb323f7ddabb/OTFontFile/Table_name.cs#L102

@kekekeks
Copy link
Member Author

The thing is, we can't rely on all encodings to be available in the published app. So we still need to silently ignore the name table entries we can't decode properly.

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

No branches or pull requests

3 participants