Skip to content

Commit

Permalink
add simpler test case as per review comment
Browse files Browse the repository at this point in the history
  • Loading branch information
anthrotype committed Apr 13, 2021
1 parent 1e07712 commit 2894d4f
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/reused_shape_2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 53 additions & 0 deletions tests/reused_shape_2_picosvg.ttx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<ttFont sfntVersion="\x00\x01\x00\x00">

<GlyphOrder>
<!-- The 'id' attribute is only for humans; it is ignored when parsed. -->
<GlyphID id="0" name=".notdef"/>
<GlyphID id="1" name=".space"/>
<GlyphID id="2" name="e000"/>
</GlyphOrder>

<hmtx>
<mtx name=".notdef" width="0" lsb="0"/>
<mtx name=".space" width="100" lsb="0"/>
<mtx name="e000" width="100" lsb="0"/>
</hmtx>

<cmap>
<tableVersion version="0"/>
<cmap_format_4 platformID="0" platEncID="3" language="0">
<map code="0x20" name=".space"/><!-- SPACE -->
<map code="0xe000" name="e000"/><!-- ???? -->
</cmap_format_4>
<cmap_format_4 platformID="3" platEncID="1" language="0">
<map code="0x20" name=".space"/><!-- SPACE -->
<map code="0xe000" name="e000"/><!-- ???? -->
</cmap_format_4>
</cmap>

<loca>
<!-- The 'loca' table will be calculated by the compiler -->
</loca>

<glyf>

<!-- The xMin, yMin, xMax and yMax values
will be recalculated by the compiler. -->

<TTGlyph name=".notdef"/><!-- contains no outline data -->

<TTGlyph name=".space"/><!-- contains no outline data -->

<TTGlyph name="e000"/><!-- contains no outline data -->

</glyf>

<SVG>

<svgDoc endGlyphID="2" startGlyphID="2">
<![CDATA[<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1"><defs/><g id="glyph2" transform="matrix(0.5 0 0 0.5 0 -100)"><path d="M200,100 A100 100 0 1 1 0,100 A100 100 0 1 1 200,100 Z" fill="#F49924"/><path d="M74.545,71.818 A15 21.818 0 1 1 44.545,71.818 A15 21.818 0 1 1 74.545,71.818 Z" fill="#7E4418" id="glyph2::1"/><use xlink:href="#glyph2::1" x="80.91"/></g></svg>]]>
</svgDoc>
</SVG>

</ttFont>
7 changes: 7 additions & 0 deletions tests/write_font_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,13 @@ def test_vertical_metrics(ascender, descender, linegap):
"width": 120,
},
),
# Check that we use xlink:href to reuse shapes with <use> elements
# https://github.com/googlefonts/nanoemoji/issues/266
(
("reused_shape_2.svg",),
"reused_shape_2_picosvg.ttx",
{"color_format": "picosvg"},
),
],
)
def test_write_font_binary(svgs, expected_ttx, config_overrides):
Expand Down

0 comments on commit 2894d4f

Please sign in to comment.