Skip to content

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

Description

@RedFantom

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.

Activity

  1. self-assigned this
    on Apr 16, 2021
  2. rdbende commented on Apr 21, 2022

    @rdbende
    Member

    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.

  3. RedFantom commented on Apr 22, 2022

    @RedFantom
    MemberAuthor

    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

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions