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

Add filename to Match #11

Open
Elara6331 opened this issue Aug 12, 2021 · 1 comment · May be fixed by #28
Open

Add filename to Match #11

Elara6331 opened this issue Aug 12, 2021 · 1 comment · May be fixed by #28

Comments

@Elara6331
Copy link

I tried this library and noticed that it misses some of my fonts. I then used List to list all the fonts, and noticed some of them had no Name or Family field. If you add the filename to the Match function criteria, it will be able to match some fonts even without a Family or Name field present. Thank you.

@gmlewis
Copy link

gmlewis commented Aug 5, 2022

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.

@gmlewis gmlewis linked a pull request Aug 5, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants