Skip to content

Commit

Permalink
Shuffling
Browse files Browse the repository at this point in the history
  • Loading branch information
rsheeter committed Apr 4, 2020
1 parent d20b54b commit 02c3d5b
Show file tree
Hide file tree
Showing 17 changed files with 55 additions and 19 deletions.
24 changes: 24 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""Just a toy, enough setuptools to be able to install.
"""
from setuptools import setup, find_packages

setup(
name="nanoemoji",
version="0.1",
package_dir={'': 'src'},
packages=find_packages(where='src'),
entry_points={
'console_scripts': [
'nanoemoji=nanoemoji.nanoemoji:main',
],
},

install_requires=["lxml>=4.0", "skia-pathops>=0.3",],

# metadata to display on PyPI
author="Rod S",
author_email="rsheeter",
description=(
"Exploratory utility for COLR fonts"
),
)
Empty file added src/nanoemoji/__init__.py
Empty file.
6 changes: 3 additions & 3 deletions color_glyph.py → src/nanoemoji/color_glyph.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from absl import logging
from fontTools.misc.transform import Transform
import collections
from colors import Color
import glyph
from itertools import chain
from lxml import etree
from paint import (
from nanoemoji.colors import Color
from nanoemoji import glyph
from nanoemoji.paint import (
Extend,
ColorStop,
PaintLinearGradient,
Expand Down
File renamed without changes.
File renamed without changes.
16 changes: 12 additions & 4 deletions make_emoji_font.py → src/nanoemoji/nanoemoji.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
from absl import flags
from absl import logging
import collections
from color_glyph import ColorGlyph
from fontTools import ttLib
from fontTools.pens.transformPen import TransformPen
from glyph import glyph_name
import io
from itertools import chain
from nanoemoji.color_glyph import ColorGlyph
from nanoemoji.glyph import glyph_name
from nanosvg.svg import SVG
from nanosvg.svg_pathops import skia_path
import os
Expand Down Expand Up @@ -319,7 +319,7 @@ def _generate_color_font(config, glyph_inputs):
return ufo, ttfont


def main(argv):
def _run(argv):
config = ColorFontConfig(
upem=FLAGS.upem,
family=FLAGS.family,
Expand All @@ -328,6 +328,9 @@ def main(argv):
)

inputs = list(_inputs(argv[1:]))
if not inputs:
sys.exit('Please provide at least one svg filename')

logging.info(f"{len(inputs)}/{len(argv[1:])} inputs prepared successfully")

ufo, ttfont = _generate_color_font(config, inputs)
Expand All @@ -336,5 +339,10 @@ def main(argv):
logging.info("Wrote %s" % FLAGS.output_file)


def main():
# We don't seem to be __main__ when run as cli tool installed by setuptools
app.run(_run)


if __name__ == "__main__":
app.run(main)
app.run(_run)
4 changes: 2 additions & 2 deletions paint.py → src/nanoemoji/paint.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
Based on https://github.com/googlefonts/colr-gradients-spec/blob/master/colr-gradients-spec.md#structure-of-gradient-colr-v1-extensions.
"""
from colors import Color, css_color
import dataclasses
from enum import Enum
from typing import ClassVar, Tuple
from nanoemoji.colors import Color, css_color
from nanosvg.geometric_types import Point
from typing import ClassVar, Tuple


class Extend(Enum):
Expand Down
6 changes: 3 additions & 3 deletions color_glyph_test.py → tests/color_glyph_test.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from colors import Color
from color_glyph import ColorGlyph
from fontTools.misc.transform import Transform
from nanoemoji.colors import Color
from nanoemoji.color_glyph import ColorGlyph
from nanoemoji.paint import *
from nanosvg.svg import SVG
import os
from paint import *
import pytest
import ufoLib2

Expand Down
2 changes: 1 addition & 1 deletion colors_test.py → tests/colors_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from colors import Color
from nanoemoji.colors import Color
import pytest


Expand Down
File renamed without changes
File renamed without changes.
16 changes: 10 additions & 6 deletions make_emoji_font_test.py → tests/make_emoji_font_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,22 @@
import os
import re
import sys
import make_emoji_font
from nanoemoji import nanoemoji
from nanosvg.svg import SVG
import pytest


def _locate_test_file(filename):
return os.path.join(os.path.dirname(__file__), filename)


def _nsvg(filename):
return SVG.parse(filename).tonanosvg()
return SVG.parse(_locate_test_file(filename)).tonanosvg()


def _color_font_config(color_format, svg_in, output_format):
return (
make_emoji_font.ColorFontConfig(
nanoemoji.ColorFontConfig(
upem=100,
family="UnitTest",
color_format=color_format,
Expand All @@ -37,7 +41,7 @@ def _check_ttx(svg_in, ttfont, expected_ttx):
# Elide ttFont attributes because ttLibVersion may change
actual = re.sub(r'\s+ttLibVersion="[^"]+"', "", actual_ttx.getvalue())

with open(expected_ttx) as f:
with open(_locate_test_file(expected_ttx)) as f:
expected = f.read()

if actual != expected:
Expand Down Expand Up @@ -76,7 +80,7 @@ def _check_ttx(svg_in, ttfont, expected_ttx):
],
)
def test_codepoints_from_filename(filename, codepoints):
assert codepoints == make_emoji_font._codepoints_from_filename(filename)
assert codepoints == nanoemoji._codepoints_from_filename(filename)


# TODO test that width, height are removed from svg
Expand All @@ -103,5 +107,5 @@ def test_codepoints_from_filename(filename, codepoints):
)
def test_make_emoji_font(svg_in, expected_ttx, color_format, output_format):
config, glyph_inputs = _color_font_config(color_format, svg_in, output_format)
_, ttfont = make_emoji_font._generate_color_font(config, glyph_inputs)
_, ttfont = nanoemoji._generate_color_font(config, glyph_inputs)
_check_ttx(svg_in, ttfont, expected_ttx)
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.

0 comments on commit 02c3d5b

Please sign in to comment.