13rac1 / scfbuild Goto Github PK
View Code? Open in Web Editor NEWCreate OpenType-SVG color fonts from a set of SVG source files.
License: GNU General Public License v3.0
Create OpenType-SVG color fonts from a set of SVG source files.
License: GNU General Public License v3.0
Details in 13rac1/emojione-color-font#50
Solution is probably to transform all SVGs to 2048x2048 glyph scale and use transform="scale(1,-1)"
as described in #4
Given a set of PNGs adding a SBIX table shouldn't be a problem.
Hi there,
I'm from the Direct2D/DirectWrite team at Microsoft. As you may know, we've recently added support for OpenType SVG fonts in Windows.
I noticed an issue in a recent version of LapisLegit, which is built with scfbuild
.
The add_color_svg
method of the Builder
class currently passes encoding='utf8'
to ET.tostring
. This is an invalid encoding string, and strict XML parsers might not permit it. The correct string is 'UTF-8'
.
For more info:
Long term, I can see actually parsing the SVG with a XML parser, but for now just stripping any id
on the <svg>
tag should work.
This is what I get when I try to open the font that installs with the AUR ttf-twemoji font (which works on the system):
When I generate a new twemoji font with scfbuild, it is all black and white, also too small. Fontforge opens it happily, so there is definitely a difference between what I get from yay -S ttf-twemoji
and a manual build. Any ideas?
Right now if you need to display the same glyph for a different codepoint or ligature, the glyph needs to be added a second time. This could be configured the YAML.
Python 2 is less than a year from end of life. https://pythonclock.org/
We should update this project to Python 3
To compensate for SVG's upside-down Y axis, a transform is done on the <svg>
tag. This is not valid and is likely to cause problems in non-Firefox implementations: https://lists.w3.org/Archives/Public/public-svgopentype/2016Mar/0002.html Firefox will turn a blind eye for now, but if this gets fixed fonts generated with scfbuild will be flipped upside down there too.
If fixed this for ChromaCheck and Bixa Color by wrapping the SVG's contents in a <g>
and doing the transform on that.
Hi there! Currently looking into ways to create a colorfont for our http://openmoji.org/ project. Very happy that I found scfbuild! Our svg file structure seems also work nicely out of the box with it ... Just I'm having trouble to get it to run :)
$ bin/scfbuild
Traceback (most recent call last):
File "bin/scfbuild", line 14, in <module>
from scfbuild.main import main
File "/Users/bene/Documents/scfbuild/scfbuild/main.py", line 15, in <module>
import yaml
ImportError: No module named yaml
As pip search yaml
yields a lot of yaml python modules ... I wondering which one to pick. Any setup hints are very welcome. Thanks.
I'm using TTX/FontTools compiled from source instead if through pip, and I get an error on the version number:
Traceback (most recent call last):
File "/Users/roel/code/scfbuild/bin/scfbuild", line 14, in <module>
from scfbuild.main import main
File "/Users/roel/code/scfbuild/scfbuild/main.py", line 18, in <module>
from .builder import Builder
File "/Users/roel/code/scfbuild/scfbuild/builder.py", line 31, in <module>
if StrictVersion('2.5') > StrictVersion(fontTools.version):
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/version.py", line 40, in __init__
self.parse(vstring)
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/version.py", line 107, in parse
raise ValueError, "invalid version number '%s'" % vstring
ValueError: invalid version number '3.5.0.dev0'
This is to document how to use scfbuild with Docker.
Add a Dockerfile
with (to the folder containing scfbuild):
FROM ubuntu:18.04
RUN apt-get update && apt-get upgrade -y
RUN apt-get install python-pip -y
RUN pip install --trusted-host=pypi.org --trusted-host=files.pythonhosted.org fonttools
RUN pip install --trusted-host=pypi.org --trusted-host=files.pythonhosted.org pyyaml
RUN apt-get install fontforge python-fontforge -y
In terminal:
# Create container; named "openmoji" (could be any other name):
$ docker build -t openmoji .
# Share folder between host computer and docker container
# Run bash "inside" of the container (think of it as being logged in to remote server)
$ docker run --interactive --tty --rm --volume "$PWD":/wd --workdir /wd "openmoji:latest" bash
# Now you can run scfbuild to create a colorfont with the contents of the shared folder e.g.:
$ bin/scfbuild -c scfbuild.yml
@13rac1 Thanks for the hints! Worked nearly out of the box :) Happy to do a PR documenting this ... if helpful.
So far, glyph naming leads to the following errors:
OpenMoji-14.0-log.txt
TwitterColorEmoji-13.1.0-log.txt
When opening the exported font liga
feature is corrupted:
Tested on FontLab 7 & FontLab 8
Similar issues:
https://forum.glyphsapp.com/t/hyphens-in-glyph-names-are-illegal/2684
googlefonts/fontmake#455
googlefonts/robotoslab#10
Reason: Hyphen is not allowed in production glyph names, hyphen is used as a range indicator.
Solution: Glyph name should be u1F1E6_1F1E8
instead of 1F1E6-1F1E8
and etc.
Color SVG files shouldn't require a viewbox attribute. Assume 2048x2048 viewbox attribute if missing.
Note: Viewbox is required in B&W SVGs to calculate glyph width for proportional fonts.
Found while working on: 13rac1/emojione-color-font#50
Traceback (most recent call last):
File "SCFBuild/bin/scfbuild", line 17, in <module>
sys.exit(main())
File "/home/example/development/emojione-color-font/SCFBuild/scfbuild/main.py", line 124, in main
return builder.run()
File "/home/example/development/emojione-color-font/SCFBuild/scfbuild/builder.py", line 74, in run
self.add_color_svg()
File "/home/example/development/emojione-color-font/SCFBuild/scfbuild/builder.py", line 102, in add_color_svg
svg_transform = self.create_color_transform(filepath)
File "/home/example/development/emojione-color-font/SCFBuild/scfbuild/builder.py", line 186, in create_color_transform
svg_height, svg_width = util.get_dimensions(filepath)
File "/home/example/development/emojione-color-font/SCFBuild/scfbuild/util.py", line 60, in get_dimensions
dims = root.attrib['viewBox'].split(' ')
KeyError: u'viewBox'
Hi there!
I'm having trouble to generate fonts with complex ligatures like 🏳️🌈1F3F3-FE0F-200D-1F308
or 👩⚕️1F469-200D-2695-FE0F
. Is there a special file convention I'm not aware of?
It works out of the box for simple ones like 🏝1F3DD
or 🎣1F3A3
, yay!!
Here is also a self containing folder with my issue in an isolated way: OpenMoji-Colorfont-POC.zip
Sorry to bother again!
Log:
$ scfbuild/bin/scfbuild -c scfbuild.yml
INFO:scfbuild.builder:Creating a new font
DEBUG:scfbuild.fforge:Space character width: 561
INFO:scfbuild.builder:Adding glyphs and ligatures
DEBUG:scfbuild.fforge:Creating glyph at 0xa9 for black/svg/00A9.svg
DEBUG:scfbuild.util:Found SVG width/height (72.00/72.00)
DEBUG:scfbuild.fforge:Set glyph width/height (2048/2048)
DEBUG:scfbuild.fforge:Translate glyph (0, 0)
DEBUG:scfbuild.fforge:Creating glyph at 0x1f3a3 for black/svg/1F3A3.svg
DEBUG:scfbuild.util:Found SVG width/height (72.00/72.00)
DEBUG:scfbuild.fforge:Set glyph width/height (2048/2048)
DEBUG:scfbuild.fforge:Translate glyph (0, 0)
DEBUG:scfbuild.fforge:Creating glyph at 0x1f3dd for black/svg/1F3DD.svg
DEBUG:scfbuild.util:Found SVG width/height (72.00/72.00)
DEBUG:scfbuild.fforge:Set glyph width/height (2048/2048)
DEBUG:scfbuild.fforge:Translate glyph (0, 0)
DEBUG:scfbuild.fforge:Creating ligature glyph 1F3F3-FE0F-200D-1F308
Traceback (most recent call last):
File "scfbuild/bin/scfbuild", line 17, in <module>
sys.exit(main())
File "/Users/bene/Desktop/OpenMoji Colorfont Test/scfbuild/scfbuild/main.py", line 124, in main
return builder.run()
File "/Users/bene/Desktop/OpenMoji Colorfont Test/scfbuild/scfbuild/builder.py", line 58, in run
fforge.add_glyphs(ff_font, svg_filepaths, self.conf)
File "/Users/bene/Desktop/OpenMoji Colorfont Test/scfbuild/scfbuild/fforge.py", line 87, in add_glyphs
u_str = ''.join(map(unichr, u_ids))
ValueError: unichr() arg not in range(0x10000) (narrow Python build)
DEBUG:scfbuild.builder:Found Ligature Glyph: 1f4aa-1f3fe
DEBUG:scfbuild.util:Found SVG width/height (128.00/128.00)
DEBUG:scfbuild.builder:Set SVG transform: translate(0 -6.75) translate(0,-1638.4) scale(16.0)
DEBUG:scfbuild.builder:Glyph ID: 878 Adding SVG: build/svg-color/1f4aa-1f3fe.svg
DEBUG:scfbuild.builder:Found regular Glyph: u1F64E
DEBUG:scfbuild.util:Found SVG width/height (128.00/128.00)
DEBUG:scfbuild.builder:Set SVG transform: translate(0 -6.75) translate(0,-1638.4) scale(16.0)
DEBUG:scfbuild.builder:Glyph ID: 616 Adding SVG: build/svg-color/1f64e.svg
DEBUG:scfbuild.builder:Found Ligature Glyph: 1f47c-1f3ff
DEBUG:scfbuild.util:Found SVG width/height (128.00/128.00)
DEBUG:scfbuild.builder:Set SVG transform: translate(0 -6.75) translate(0,-1638.4) scale(16.0)
Traceback (most recent call last):
File "SCFBuild/bin/scfbuild", line 17, in <module>
sys.exit(main())
File "/home/mint/noto-color-emoji-font/SCFBuild/scfbuild/main.py", line 124, in main
return builder.run()
File "/home/mint/noto-color-emoji-font/SCFBuild/scfbuild/builder.py", line 74, in run
self.add_color_svg()
File "/home/mint/noto-color-emoji-font/SCFBuild/scfbuild/builder.py", line 139, in add_color_svg
data = ET.tostring(svg_root, encoding='UTF-8')
File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1127, in tostring
return "".join(data)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position 5: ordinal not in range(128)
Makefile:94: recipe for target 'build/NotoColorEmoji-SVGinOT-OSX.ttf' failed
make: *** [build/NotoColorEmoji-SVGinOT-OSX.ttf] Error 1
I've been working on this for a bit, and I've been running into this issue. When I try to build Noto Color Emoji, with SVGs from Google's 'Noto Emoji' repo, I get errors and it (SCFBuild) doesn't output the font files. I'd be happy to give more details if they're needed.
With standardized emoji sequences, the author is responsible for the correct order of emoji characters, possibly mandatory variation selectors and zero-width joiners. For most cases and emoji input GUIs, this just works, though. If these sequences are not handled on the system level, Opentype fonts probably employ the rlig
‘required ligatures’ feature which is enabled (or enforced) by default.
It may be useful sometimes, for a reader or designer to control (additional) ligation. This would be handled by the liga
or clig
‘contextual ligatures’ OTF features which can be enabled on demand.
Possible use cases: ligature aliases, e.g. Woman+Man+Child = Man+Woman+Child = Child+Man+Woman = Woman+Child+Man …, and non-standard ligatures, e.g. Police Car 🚓 + Woman 👩 = Police Woman = Police Officer 👮 + Female Sign ♀️.
#5 should be fixed first, of course.
bin/scfbuild -o testfont.ttf -g ./src/svg -s ./src/svg
Traceback (most recent call last):
File "/Users/roel/code/scfbuild/bin/scfbuild", line 17, in <module>
sys.exit(main())
File "/Users/roel/code/scfbuild/scfbuild/main.py", line 123, in main
builder = Builder(conf)
File "/Users/roel/code/scfbuild/scfbuild/builder.py", line 47, in __init__
if self.conf['verbose']:
KeyError: u'verbose'
Adding the -v
flag works.
Add an argument to generate a demo HTML page for the font
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.