Giter Site home page Giter Site logo

13rac1 / scfbuild Goto Github PK

View Code? Open in Web Editor NEW
75.0 10.0 11.0 82 KB

Create OpenType-SVG color fonts from a set of SVG source files.

License: GNU General Public License v3.0

Python 100.00%
svginot color-fonts svg-in-opentype font-build opentype-svg-fonts color-opentype color-glyphs generated-fonts

scfbuild's People

Contributors

13rac1 avatar crissov avatar deedeeg avatar earboxer avatar mavit avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

scfbuild's Issues

XML encoding should be 'UTF-8' rather than 'utf8'

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:

Strip any existing svg IDs

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.

Generating black and white font only

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):
image

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?

Move transform attribute to something in the document

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.

No module named yaml

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.

scfbuild fails on TTX/FontTools version number

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'

scfbuild with Docker

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.

'Incorrect fea-syntax of glyph name' issue

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:
image
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.

SVG viewbox shouldn't be required, default to 2048x2048.

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'

Error: unichr() arg not in range

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)

Build issue: "UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position 5: ordinal not in range(128)"

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.

Ligation without ZWJ and VS16

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.

Error when not running in verbose mode

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.