Coder Social home page Coder Social logo

.ttf are missing .Name and .Family about sysfont HOT 1 OPEN

adrg avatar adrg commented on July 20, 2024
.ttf are missing .Name and .Family

from sysfont.

Comments (1)

MilanKladivko avatar MilanKladivko commented on July 20, 2024

Might've found some solution for now:

https://stackoverflow.com/questions/70892173/how-can-i-get-the-font-family-name-from-a-ttf-file-in-golang

So I'll .List() all the fonts to get the paths,
parse those without a .Name by .Filename with the truetype package,
and modify the .Name and .Family accordingly.
Update:
This works fine, but not always -- I have some hackily-made TTFs I downloaded online that, I guess, don't even have proper metadata.

Also, the fontnames can still be off with their whitespace -- the truetype font family is not always the same as the CSS wants -- but it's all about missing spaces (InputSerifMono -> Input Serif Mono, always when it's some [serif|mono] variant-word involved).


Now, my guess when I get pointers to Font from .List() is that I can modify the data under the pointer, it'll get changed for the sysfont lib and the .Match() will now take the parsed TTF name and family into account...
Update:
That doesn't do it -- I have no way to "enhance" the internal "registry" that takes care of the matching with adjusted data. Gotta do my own fuzzy-search, but wanted to do that on the frontend if I could anyway -- I don't like the sysfont API of always returning "closest" font without any signaling that it's not exact anyway -- ideally it would be a short list sorted by score.

from sysfont.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.