openmoji icon indicating copy to clipboard operation
openmoji copied to clipboard

Build COLR TTFs with nanoemoji

Open mavit opened this issue 3 years ago • 55 comments

This is done via the container at https://gitlab.com/mavit/nanoemoji-container.

For me, the resulting COLR TTFs work in Firefox and in the Gnome desktop on Fedora 32 ~~(although they display rather small)~~.

Caveats:

  • It may be premature to replace scfbuild for SVG builds. If we decide to go ahead without scfbuild, then we’ll want to remove the remaining files related to it. If we decide to keep scfbuild, then we’ll want to revert those parts of this patch. In either case we’ll want to update the readme to link to the new outputs.
  • I’ve tested this with Podman, not Docker.

Relates to #93.

mavit avatar Aug 21 '20 14:08 mavit

Any feedback?

mavit avatar Oct 13 '20 14:10 mavit

This is super cool! I think @b-g would be responsible for testing this with the other fonts.

In the meantime, could you attach some screenshots?

Thanks so much!

carlinmack avatar Oct 13 '20 22:10 carlinmack

image Screenshot from 2020-10-14 11-02-56 Screenshot from 2020-10-14 11-03-02

mavit avatar Oct 14 '20 10:10 mavit

wow the quality is so much higher than we've ever had! Thank you for making them larger too, we still need to figure out what option we want to choose (#112 #257), but I think the size you have used is pretty good

carlinmack avatar Oct 14 '20 10:10 carlinmack

I took the 1.3 scaling factor from d66343ea2cb92a33bb8f969b8eff0cc5976d4d70, although I think it looks a little cramped and would be tempted to go for something smaller.

mavit avatar Oct 14 '20 10:10 mavit

Dear @mavit! This is mega!

My apologies for the very long radio silence over the summer ... but I needed a break with the OpenMoji project :)

I totally would love to swap scfbuildwith your version of nanoemoji! scfbuild is no longer actively maintained and this in contrast with a very active nanoemoji project (backed/funded by Google) makes at least for me the decision very easy.

I've tried to build the fonts with npm run generate-font but failed. It would be important that the colorfont generator stays accessible in terms complexity and operation systems. A lot of the people on the project are not coding experts but eventually need to generate the fonts.

Could you check ./helpers/generate-fonts.sh: line 39: OpenMoji-${saturation^}: bad substitution so that I could give it a try as well?

bene@zwei-207 openmoji % npm run generate-font

> [email protected] generate-font /Users/bene/Documents/openmoji
> ./helpers/generate-fonts.sh

👉 generate-font-css.js
master: Pulling from mavit/nanoemoji-container
c7def56d621e: Pull complete 
f2931b91d78b: Pull complete 
f6b4b8ceb868: Pull complete 
Digest: sha256:77b71ae860417e531c72870d17128e878b87a8989479e7010073e607d04a937c
Status: Downloaded newer image for registry.gitlab.com/mavit/nanoemoji-container:master
registry.gitlab.com/mavit/nanoemoji-container:master
./helpers/generate-fonts.sh: line 39: OpenMoji-${saturation^}: bad substitution
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] generate-font: `./helpers/generate-fonts.sh`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] generate-font script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/bene/.npm/_logs/2020-10-15T07_18_22_557Z-debug.log

b-g avatar Oct 15 '20 07:10 b-g

I'm guessing you're using MacOS, here, because it turns out that that has an ancient version of bash which doesn't support the ${variable^} feature. I'll move this substitution into the container, where we have a known version.

mavit avatar Oct 15 '20 11:10 mavit

you should shellcheck your bash scripts, it's helpful for catching stuff like this :)

carlinmack avatar Oct 15 '20 11:10 carlinmack

you should shellcheck your bash scripts, it's helpful for catching stuff like this :)

This is good advice, but I do, and it doesn't help here: ShellCheck knows that ${variable^} needs Bash, but we are using Bash, so it doesn't warn.

mavit avatar Oct 15 '20 12:10 mavit

Yes I'm on macOS, using zsh (note: 10.15 Cataline replaced bash with zsh).

% zsh --version
zsh 5.7.1 (x86_64-apple-darwin19.0)

Still the same error.

Yes would be great to move as much as possible inside a fully controlled docker image.

b-g avatar Oct 15 '20 13:10 b-g

Yes I'm on macOS, using zsh (note: 10.15 Cataline replaced bash with zsh).

/bin/bash will get used anyway, here, since that's what's specified on the #! line of the script.

Still the same error.

Sorry, I overlooked a second place where this syntax was used. Please try it again.

mavit avatar Oct 15 '20 14:10 mavit

Many thanks for the recent fixes! I'm able to run it now!

First impression is good! Can't spot any difference if I use demo.html:

scfbuild nanoemoji
Screen Shot 2020-10-16 at 12 22 09 Screen Shot 2020-10-16 at 14 11 34

However if I'm using your generated demos I get some bugs (why?):

  • Big color emojis are cropped
  • Black notebook is broken
  • Black stroke weight is not always the same
Screen Shot 2020-10-16 at 14 03 57 Screen Shot 2020-10-16 at 14 04 17

Will also ask @dnlutz to import the files in a font editor to cross check everything ...

OpenMoji-exported_nanoemoji.zip

And it is worth pointing out that the font files have a massively smaller footprint in terms of files size:

  • OpenMoji-Black.ttf 9.4 MB vs 1.4 MB
  • OpenMoji-Color.ttf 13.6 MB vs 2.2 MB

This seems to almost magic :)

b-g avatar Oct 16 '20 12:10 b-g

However if I'm using your generated demos I get some bugs (why?):

* Big color emojis are cropped
* Black notebook is broken

I don't see these issues in Firefox for Fedora Linux. I wonder if this is related to the capabilities of the OS's font rendering. Are you using the SVG or the COLR/CPAL font, here?

Scaling the glyphs up to 130% causes them to overspill their bounding boxes, so, to be honest, I was surprised when I tried it and they didn't appear cropped for me.

* Black stroke weight is not always the same

I do see this issue. I've tried building with nanoemoji's untouchedsvgz format (edit line 50 of generate-fonts.sh) and it seems to fix the stoke weight issue for me for the SVG font. Hence, this seems to be a bug in picosvg.

mavit avatar Oct 16 '20 16:10 mavit

the overall curve quality looks much better now, thank you very much ; )

on my mac the color version works in textedit … but not in all those adobe applications (indesign, illustrator, photoshop). the black version is working perfect but it doesn't display the color version.

generally all major adobe applications should support ot-svg-color fonts by now: https://helpx.adobe.com/fonts/user-guide.html/fonts/using/ot-svg-color-fonts.ug.html

do you have any idea what might cause this error?

dnlutz avatar Oct 19 '20 09:10 dnlutz

on my mac the color version works in textedit … but not in all those adobe applications (indesign, illustrator, photoshop).

Is this with the COPR/CPAL TTF, or the SVG TTF? I think it’s likely that we’ll want to recommend one format of TTF for certain OSs/applications and another for others.

the black version is working perfect but it doesn't display the color version.

I'm not sure what you mean by this?

mavit avatar Oct 19 '20 10:10 mavit

it's the OpenMoji-Color.ttf font from OpenMoji-exported_nanoemoji.zip that doesn't work in the adobe applications.

it shows up the font menu but it doesn't display any glyphs : /

dnlutz avatar Oct 19 '20 11:10 dnlutz

@dnlutz please check again the newly exported fonts, especially the CPAL ones: exported-openmoji-fonts-21-oct-2020.zip

@mavit Great! Building the fonts works nicely now. But we have to double check the quality ... and the maybe settle down on a single approach? Hence here is a list of how the current fonts are rendered in various browsers

Current OpenMoji fonts of 12.4

(firefox, chrome, safari) Screen Shot 2020-10-20 at 14 05 39 Screen Shot 2020-10-20 at 14 06 11 Screen Shot 2020-10-20 at 14 05 55

Work in progress OpenMoji fonts of this PR

(firefox, safari, chrome)

Screen Shot 2020-10-20 at 11 24 30 Screen Shot 2020-10-20 at 11 24 05 Screen Shot 2020-10-20 at 11 24 56 Screen Shot 2020-10-20 at 11 26 41

b-g avatar Oct 21 '20 12:10 b-g

unfortunately nothing works in indesign : / the only version that shows up in the glyphs-palette is from the folder "untouchedsvgz" but if it type something there are only empty white glyphs. and if i rescale the glyphs-palette the glyphs also disappear. Bildschirmfoto 2020-10-22 um 11 51 47

dnlutz avatar Oct 22 '20 09:10 dnlutz

maybe we should reach out to @pauldhunt from adobe? @RoelN also seems to be quite familiar with the subject …

dnlutz avatar Oct 22 '20 10:10 dnlutz

@dnlutz but the one of OpenMoji 12.4 works in Adobe CC?

b-g avatar Oct 22 '20 10:10 b-g

yes … after a reboot it works again ; )

dnlutz avatar Oct 22 '20 10:10 dnlutz

The stroke width issue described in https://github.com/hfg-gmuend/openmoji/pull/260#issuecomment-710012849 turned out to be a bug in picosvg which is now fixed.

Hereʼs a summary of what I believe to be the current situation:

  • Both the colour COPR/CPAL TTFs and black and white TTFs built by nanoemoji work well on Linux, but do not work well on MacOS. ~~I donʼt believe theyʼve been tested on Windows.~~ They work on Windows too.
  • The colour SVG TTFs built using nanoemoji work adequately in Firefox but not sufficiently well in other applications. They're probably not useful to us at the current time.
  • The existing TTFs generated by scfbuild are much larger than those generated by nanoemoji, but are more compatible with various applications.

~~Does anyone have a computer running Windows they could test on?~~

mavit avatar Nov 28 '20 16:11 mavit

The CPAL font looks fine on Windows (shown here in Wakamai Fondue in Edge 87 on Windows 10)

image

RoelN avatar Nov 30 '20 08:11 RoelN

Hi @mavit, that's good news + Many thanks for the update!

Just wanted to give it a try as well ... but getting this error now (see below).

Also could you do me a favor and make the filenames of the resulting fonts more verbose? I feel it is not so clear what for instance the file picosvgz/OpenMoji-Color.ttf actually holds in terms of standards. I think a filename like OpenMoji-Color-COPR-CPAL, OpenMoji-Color-SVG could streamline a little bit our discussion here. What do you think?

bene@zwei-207 openmoji % npm run generate-font

> [email protected] generate-font /Users/bene/Documents/openmoji
> ./helpers/generate-fonts.sh

master: Pulling from mavit/nanoemoji-container
ae7b613df528: Pull complete 
9970cf8663a9: Pull complete 
8f542e7556d7: Pull complete 
Digest: sha256:a38cd4692f0a104a9b2e002566a041d0d3f5fe012e10d4a8ab1de180674664af
Status: Downloaded newer image for registry.gitlab.com/mavit/nanoemoji-container:master
registry.gitlab.com/mavit/nanoemoji-container:master
FATAL Flags parsing error: Unknown command line flag 'color_format'
Pass --helpshort or --helpfull to see help on flags.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] generate-font: `./helpers/generate-fonts.sh`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] generate-font script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/bene/.npm/_logs/2020-11-30T10_23_51_450Z-debug.log

full log file: 2020-11-30T10_23_51_450Z-debug.log.zip

b-g avatar Nov 30 '20 10:11 b-g

Dear @mavit, just a random thought in terms of the bbox crop issue the COPR-CPAL fonts seem to have (at least on macOS).

Could it simply be that in helpers/generate-ttf.sh we have to alter the viewBox attribute from 72 to 1.3 * 72 = 94 ... in order to make it display nicely everywhere. Did you try that?

96722316-86fe1300-13ad-11eb-985a-f3aa6163e1de

2020-12-03 at 11 21

b-g avatar Dec 03 '20 10:12 b-g

but getting this error now (see below).

Are you using the latest commit on this branch?

Also could you do me a favor and make the filenames of the resulting fonts more verbose?

Done.

Could it simply be that in helpers/generate-ttf.sh we have to alter the viewBox attribute from 72 to 1.3 * 72 = 94 ... in order to make it display nicely everywhere. Did you try that?

The font is scaled relative to this box, I think, so ultimately it doesn't help. It cures the clipping issue, but takes us back to the situation where the characters are too small.

mavit avatar Dec 03 '20 22:12 mavit

Hi @mavit, Many thanks for the latest improvements, this helps! I'm able to run it again on macOS. Could you also at the scaling up of the viewbox attribute to 72 to 1.3 * 72 = 94? I think it still worth to look into it and double check what the outcome would be exactly. Thanks!!

b-g avatar Dec 11 '20 12:12 b-g

Could you also at the scaling up of the viewbox attribute to 72 to 1.3 * 72 = 94

I tried it and it was as I described: the characters are too small.

mavit avatar Dec 11 '20 14:12 mavit

FYI, I have tested the COLR/CPAL font in Emoji.Wpf, a library that adds emoji support to WPF applications on Windows, and they work pretty well except for the bounding box issues. Here are two screenshots:

image image

samhocevar avatar Mar 08 '21 13:03 samhocevar

Hi @samhocevar, very nice! Emoji.Wpf 👍 ! I guess the bounding box issue could potentially be fixed by altering the viewBox attribute, see https://github.com/hfg-gmuend/openmoji/pull/260#issuecomment-737849368 ... I currently don't have time for it, but we are planing to re-visit the issue this summer. Feel free to propose something if you are by any chance into it ;)

b-g avatar Mar 09 '21 10:03 b-g