Coder Social home page Coder Social logo

Add filename to Match about sysfont HOT 1 OPEN

Elara6331 avatar Elara6331 commented on July 20, 2024
Add filename to Match

from sysfont.

Comments (1)

gmlewis avatar gmlewis commented on July 20, 2024

I ran across this issue as well. If you install any Google Font, for example, it typically ends up in ${HOME}/.local/sharefonts.
If I List() the fonts, they show up. However, if I try to use one of them, it always provides a substitute because the Family and Name fields are empty.

For example:

$ go run main.go
2022/08/04 20:09:01 Found 108 fonts:
2022/08/04 20:09:01 font #1: Family "", Name "", Filename "/home/glenn/.local/share/fonts/Baloo-Regular.ttf"
2022/08/04 20:09:01 font #2: Family "", Name "", Filename "/home/glenn/.local/share/fonts/BalsamiqSans-Bold.ttf"
2022/08/04 20:09:01 font #3: Family "", Name "", Filename "/home/glenn/.local/share/fonts/BalsamiqSans-BoldItalic.ttf"
2022/08/04 20:09:01 font #4: Family "", Name "", Filename "/home/glenn/.local/share/fonts/BalsamiqSans-Italic.ttf"
2022/08/04 20:09:01 font #5: Family "", Name "", Filename "/home/glenn/.local/share/fonts/BalsamiqSans-Regular.ttf"
2022/08/04 20:09:01 font #6: Family "", Name "", Filename "/home/glenn/.local/share/fonts/BungeeShade-Regular.ttf"
2022/08/04 20:09:01 font #7: Family "", Name "", Filename "/home/glenn/.local/share/fonts/Modak.ttf"
2022/08/04 20:09:01 font #8: Family "", Name "", Filename "/home/glenn/.local/share/fonts/Monoton-Regular.ttf"
2022/08/04 20:09:01 font #9: Family "DejaVu Sans", Name "DejaVu Sans Bold", Filename "/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf"
...

However, stepping through the code, it makes up a family name based on the filename when doing a search, and therefore compares `"bungeeshade"` (for example) to `""` and doesn't find a match. 

I think it is a simple fix of making up a family name for these files (based on their filename) so that when it comes time to make a match, it doesn't ignore fonts that have no family name.

I'll see if I can put together a PR.

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.