WordPress / google-fonts-to-wordpress-collection

Gets the Google fonts collection and transform it to a WordPress font library collection, including SVG previews
15 stars 4 forks source link

Provide alternate preview text string for font faces with poor preview results #22

Open ironprogrammer opened 4 months ago

ironprogrammer commented 4 months ago

Follow up to #20.

From https://github.com/WordPress/google-fonts-to-wordpress-collection/pull/20#issuecomment-1942314810:

For problematic fonts without glyphs to support printing existing previews, could the exclusion list include an [optional?] alternate string of existing glyphs to use instead?

E.g. for Chenla, something like ឈិនឡា (Google Translate says that's "Chenla" in Khmer). Perhaps online search and the polyglots community can help identify good strings to use for this relatively short list.

And if there are remaining fonts with missing default glyphs that don't spell anything, then this string could be used to exhibit a sample of glyphs a user would have access to.

The end result would be that the font family name displayed in the UI would be taken from this string, whether as actual text (presuming the font face has been enqueued) or used in place of family.name during the SVG preview generation process.

creativecoder commented 3 months ago

Here's a list of fonts I see that would benefit from alternative preview text (may not be complete!).

Some are clearly meant for non-latin scripts, and should have previews in those scripts. Take the Noto Sans/Serif or Anek families of fonts, for example. The current previews all look nearly identical, you can't really preview the font unless using the characters the font is intended for.

Other fonts were designed to support both latin and a primary script, like Kumar One, so could stay with the current preview text. But there should be some way to indicate that they are designed for another primary script.

With over 300 of these fonts, there's roughly 20% of the collection that seem to be primarily intended for non-latin characters, so this seem fairly high priority to me.

ironprogrammer commented 3 months ago

Thanks, @creativecoder, for identifying other places where this idea could apply! 🙌🏻

Does the subsets metadata provide enough of a hint to narrow down and identify the language/translation needed for non-latin (and non-latin-adjacent) scripts?

Here's an albeit simple result where korean was returned when querying Bagel Fat One, which in this case the preview is legible in English, but not representative of the Hangul (Korean) character set.

{
  "kind": "webfonts#webfontList",
  "items": [
    {
      "family": "Bagel Fat One",
      "variants": [
        "regular"
      ],
      "subsets": [
        "korean",
        "latin",
        "latin-ext"
      ],
      "version": "v1",
      "lastModified": "2023-06-07",
      "files": {
        "regular": "https://fonts.gstatic.com/s/bagelfatone/v1/hYkPPucsQOr5dy02WmQr5Zkd0Btmvv0dSbM.woff2"
      },
      "category": "display",
      "kind": "webfonts#webfont",
      "menu": "https://fonts.gstatic.com/s/bagelfatone/v1/hYkPPucsQOr5dy02WmQr5Zkd4B9svw.woff2"
    }
  ]
}

When a translation or replacement string is in place, then the UI could include the representative string and also the latin-based font name for reference. E.g. this ugly mockup:

Bagel Fat One font sample
creativecoder commented 3 months ago

Does the subsets metadata provide enough of a hint to narrow down and identify the language/translation needed for non-latin (and non-latin-adjacent) scripts?

@ironprogrammer Possibly? What I'm not sure of is how to differential between fonts that are primarily for non-latin scripts and those that happen to support it.

For example, here's Roboto's subsets value

      "subsets": [
        "cyrillic",
        "cyrillic-ext",
        "greek",
        "greek-ext",
        "latin",
        "latin-ext",
        "vietnamese"
      ],

It has a Vietnamese subset, but is more of a general purpose font.

Perhaps a font with only latin(-ext) and one other subset would be an indicator? It needs more investigation.

When a translation or replacement string is in place, then the UI could include the representative string and also the latin-based font name for reference.

I think having both is a good idea.