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

Problems loading some fonts (e.g. Google fonts) #2

Open
RedFantom opened this issue Apr 16, 2021 · 2 comments
Open

Problems loading some fonts (e.g. Google fonts) #2

RedFantom opened this issue Apr 16, 2021 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@RedFantom
Copy link
Member

Loading some fonts, in this case tested with the Google fonts Roboto and Noto Sans, is not possible with the package. This is due to problems in the fontnameinfo.tcl file, which is unable to parse the required information from the font files.

Additional complications arise with these fonts as they are split into multiple separate files. Loading the fonts with extrafont::core::load works just fine, but only one weight can be loaded at the same time. This can be avoided by merging the different files into a single file using fonttools.

If fonttools is already added as a dependency to make the package work with many different fonts, a rewrite of the Tcl files into Python seems appropriate to make the package more maintainable.

@RedFantom RedFantom added the bug Something isn't working label Apr 16, 2021
@RedFantom RedFantom self-assigned this Apr 16, 2021
@rdbende
Copy link
Member

rdbende commented Apr 21, 2022

Hi!

a rewrite of the Tcl files into Python seems appropriate to make the package more maintainable.

In tukaan I use the extrafont package, and there I rewrote the Tcl files into Python, which actually wasn't a big deal, and made the package indeed much more maintainable.

I experimented a bit with Google fonts and found the problem with their name info. Actually this problem seems to be Unix-specific, though I haven't tried if Google fonts work on Windows with it.
Normal font files contain name records in latin-1 (for *nix) and UTF 16 BigEndian (for Windows). The problem is that these Google fonts store the records in the name table only in utf16be, however extrafont reads records encoded in utf16be only under Windows.

if { $::tcl_platform(platform) == "windows" } {
set baseTriplet [binary format "SSS" 3 1 0x0409]
} else {
set baseTriplet [binary format "SSS" 1 0 0]
}

So if you remove the triplet and platform checking stuff from fontnameinfo.tcl, it works just fine with Google fonts too.

@RedFantom
Copy link
Member Author

Hey!

That is super cool, thank you for letting me know you looked into this! If you are okay with it, I might at some point back-port your changes to this repository, for the sake of the tkextrafont package.

For now I am regularly looking at your progress on tukaan, which is a much more radical approach to what I tried to accomplish with TkinterEP, but it looks really promising. Unfortunately I have very little time for hobby-programming at the moment, but I am eager to see what you create.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants