googlefonts / nanoemoji

A wee tool to build color fonts.
Apache License 2.0
239 stars 19 forks source link

handle <text> elements in SVGs? #84

Open anthrotype opened 4 years ago

anthrotype commented 4 years ago

some noto-emojis contain element, e.g. this gold medal https://github.com/googlefonts/noto-emoji/blob/master/svg/emoji_u1f947.svg where the number 1 is set in Roboto-Bold.

I am inclined to send these back to the designers to have them converted to regular paths (i think their svg editor should allow to convert text to paths).

Or we could try to support that, provided the referenced font is installed locally.

yisibl commented 3 years ago

Our designers usually convert text into paths in design tools, which helps multi-person collaboration. So I think the priority of supporting automatic conversion of text to path is not high.

anthrotype commented 3 years ago

There is one Noto Emoji regional flag, namely the GS.svg (South Georgia and the South Sandwich Islands) that uses <text> (and associated <tspan>) elements for the inscription at the bottom of its emblem. The typeface used is called "Timmons" but of course that is not available anywhere else than on the personal computer of the author of that SVG flag, which means the browsers will default to the default serif typeface.

<g font-family="Timmons" font-size="14px" font-weight="bold" line-height="100%">
<text y="362.39716" x="-328.34363" transform="rotate(-49.557)">
<tspan y="362.39716" x="-328.34363">L</tspan>
</text>
<text y="384.26642" x="-292.33514" transform="rotate(-45.392)">
<tspan y="384.26642" x="-292.33514">E</tspan>
</text>

Skia SkFont does have a method to extract the paths of a given glyph (see SkFont::getPath), but the SkFont api is not exposed in our skia-pathops and possibly is beyond its scope. There is another Python binding for skia called skia-python, which is also used by Just van Rossum in his drawbot-skia project, which does expose that API. Maybe we should use that one, but I'm concerned to add two separate dependencies (skia-pathops and skia-python) each embedding their own copy of Skia library. Or maybe I should expose that SkFont:getPath API in pathops as well, but will take time.

anthrotype commented 3 years ago

There is one Noto Emoji regional flag, namely the GS.svg (South Georgia and the South Sandwich Islands) that uses <text>...

not anymore -> https://github.com/googlefonts/noto-emoji/pull/343