Can't find font family on Google Fonts API if family name contains multiple words, e.g. Libre Caslon Text
See original GitHub issueObserved behaviour
At https://github.com/google/fonts/pull/2432, one of the WARN
s is
WARN: METADATA.pb: Fontfamily is listed on Google Fonts API?
However, Libre Caslon Text is listed on the API.
I believe this issue may come from the faulty assumption that family names are a single word. The check that throws this warn ultimately depends on proper splitting in the following function:
If I’m following correctly, for LibreCaslonText[wght].ttf
, it:
- gets the string before
.ttf
- splits at
[
- ends up as [“LibreCaslonText”]
- (unsuccessfully) tries to replace
" "
with"+"
- searches for
http://fonts.googleapis.com/css?family=LibreCaslonText
when it should actually search forhttp://fonts.googleapis.com/css?family=Libre+Caslon+Text
Expected behaviour
We need to find a reliable way to search for the correct CSS URL, e.g. http://fonts.googleapis.com/css?family=Libre+Caslon+Text
. I’m not sure what approach would be best between all families.
Maybe we should seek out camel-casing, and split the family name where there are capital letters? I’m not quite sure what spillover effects that might have, or what the best approach might be.
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (8 by maintainers)
Top GitHub Comments
Hey @felipesanches, thanks for so clearly documenting the process of fixing this! It’s really interesting to read now, and I’m bookmarking it for the future when I try to make a similar fix myself. Thanks also for fixing this so quickly. 😃
@arrowtype, I am being more verbose than usual here in the hope of illustrating the way I typically deal with these issues and how I like to fix them by first capturing the bad behaviour in our code-tests.