googlefonts / picosvg

Helps simplify SVG files. Intended for use as part of a font build.
Apache License 2.0
142 stars 12 forks source link

Throws `AssertionError: line_length 0.0 must be > 0` on OpenMoji `1F5FE` #278

Closed JeppeKlitgaard closed 2 years ago

JeppeKlitgaard commented 2 years ago

I am trying to use nanoemoji to compile the OpenMoji set into a font, but I am running into issues with a particular SVG that triggers the assertion error: line_length 0.0 must be > 0.

I have managed to narrow it down to the 1F5FE emoji and produce the following minimal example of the fault:

example.toml

family = "An Emoji Family"
output_file = "example.picosvgz.ttf"
color_format = "picosvgz"
upem = 1024
width = 1275
ascender = 1045
descender = -275
linegap = 0
transform = "translate(0, 0)"
version_major = 1
version_minor = 0
reuse_tolerance = 0.1
ignore_reuse_error = true
keep_glyph_names = false
clip_to_viewbox = true
pretty_print = false
fea_file = "features.fea"
glyphmap_generator = "nanoemoji.write_glyphmap"
bitmap_resolution = 128
use_zopflipng = true
use_pngquant = true
pngquant_flags = "--speed 1 --skip-if-larger --quality 85-95"

[axis.wght]
name = "Weight"
default = 400

[master.regular]
style_name = "Regular"
srcs = ["1F5FE.svg",]

[master.regular.position]
wght = 400

1F5FE.svg

<svg xmlns="http://www.w3.org/2000/svg" id="emoji" viewBox="0 0 72 72">
  <defs/>
  <path fill="#92d3f5" d="M11.011,11 L61,11 A0 0 0 0 1 61,11 L61,60.767 A0.233 0.233 0 0 1 60.767,61 L11.233,61 A0.233 0.233 0 0 1 11,60.767 L11,11.011 A0.011 0.011 0 0 1 11.011,11 Z"/>
  <path fill="#d22f27" d="M54.462,47.429 L54.462,52.703 L56.529,52.703 L54.462,47.429 Z"/>
  <path fill="#d0cfce" d="M54.462,57.485 L54.462,52.703 L56.529,52.703 L54.462,57.485 Z"/>
  <path fill="#ea5a47" d="M52.394,52.703 L54.462,47.429 L54.462,52.703"/>
  <path fill="#fff" d="M52.394,52.703 L54.462,57.485 L54.462,52.703"/>
  <path fill="#b1cc33" d="M25.06,50.701 C25.298,51.176 25.734,51.123 25.91,51.551 C26.079,51.961 25.823,52.362 25.91,52.401 C26.077,52.477 26.613,50.828 27.61,50.701 C27.95,50.658 28.084,50.825 28.46,50.701 A1.384 1.384 0 0 0 29.31,49.851 C29.364,49.697 29.515,49.264 29.31,49.001 C29.002,48.605 28.074,48.828 27.61,49.001 C26.719,49.335 26.606,49.838 25.91,49.851 C25.492,49.859 25.237,49.683 25.06,49.851 C24.879,50.023 24.92,50.423 25.06,50.701 Z"/>
  <path fill="#b1cc33" d="M22.51,48.151 C22.436,48.406 22.317,48.811 22.51,49.001 C22.806,49.293 23.605,48.853 25.06,48.151 A20.166 20.166 0 0 1 29.31,46.451 C29.406,46.429 31.634,45.926 31.86,46.451 C32.01,46.799 31.102,47.179 31.01,48.151 A1.706 1.706 0 0 0 31.86,49.851 A1.445 1.445 0 0 0 32.71,49.851 A4.048 4.048 0 0 0 34.41,49.001 C34.995,48.591 35.286,48.381 35.26,48.151 C35.223,47.828 34.659,47.834 34.41,47.301 A0.905 0.905 0 0 1 34.41,46.451 C34.695,46.051 35.559,46.104 36.11,46.451 C36.637,46.784 36.555,47.182 36.96,47.301 C37.624,47.497 38.493,46.62 38.66,46.451 C39.145,45.961 39.242,45.585 39.51,45.601 C39.9,45.625 39.99,46.441 40.36,46.451 C40.676,46.46 40.701,45.869 41.21,45.601 C41.821,45.28 42.332,45.844 42.91,45.601 C43.254,45.457 43.399,45.121 43.76,43.901 A18.23 18.23 0 0 0 44.61,40.501 C44.674,39.05 44.277,38.838 44.61,37.951 C44.888,37.213 45.269,37.08 45.46,36.251 C45.636,35.489 45.362,35.391 45.46,34.551 C45.62,33.175 46.408,32.98 46.31,32.001 C46.257,31.476 46.035,31.578 45.46,30.301 C44.942,29.15 44.952,28.688 44.61,28.601 C44.043,28.458 43.547,29.606 42.91,29.451 C42.43,29.335 42.413,28.613 42.06,28.601 C41.668,28.589 41.167,29.461 41.21,30.301 C41.25,31.09 41.747,31.413 42.06,32.001 C43.167,34.08 40.829,37.304 40.36,37.951 C39.01,39.813 37.522,40.498 36.96,40.501 C36.346,40.505 36.11,40.501 36.11,40.501 C35.395,40.49 35.374,40.461 35.26,40.501 C34.849,40.648 34.809,41.147 34.41,42.201 A4.916 4.916 0 0 1 33.56,43.901 A3.254 3.254 0 0 1 31.86,44.751 C30.057,45.193 29.484,44.501 27.61,44.751 A7.421 7.421 0 0 0 25.06,45.601 A4.69 4.69 0 0 0 22.51,48.151 Z"/>
  <path fill="#b1cc33" d="M44.61,26.051 C44.248,26.338 42.988,27.337 42.06,26.901 C41.23,26.511 41.071,25.163 41.21,24.351 A3.993 3.993 0 0 1 42.06,22.651 C42.397,22.188 42.574,21.945 42.91,21.801 C43.659,21.48 44.211,22.074 44.61,21.801 C44.924,21.586 44.849,21.035 44.61,19.251 C44.369,17.449 44.256,16.534 44.61,15.851 C44.752,15.577 45.042,15.019 45.46,15.001 C46.377,14.96 46.362,17.577 48.01,18.401 C49.652,19.221 51.645,17.613 52.26,18.401 C52.769,19.053 51.757,20.611 52.26,20.951 C52.529,21.132 52.947,20.776 53.11,20.951 C53.317,21.173 52.974,22.107 52.26,22.651 C51.29,23.389 50.442,22.796 49.71,23.501 C49.048,24.138 49.396,24.955 48.86,25.201 C48.137,25.532 47.352,24.119 46.31,24.351 C45.613,24.506 45.678,25.204 44.61,26.051 Z"/>
  <path fill="#b1cc33" d="M16.985,51.127 A1.41 1.41 0 0 0 17.835,52.827 C18.197,52.936 18.348,52.713 18.685,52.827 A1.688 1.688 0 0 1 19.535,54.527 C19.415,55.664 18.132,55.983 18.26,56.652 C18.357,57.165 19.228,57.579 19.96,57.502 C21.621,57.327 22.361,54.64 22.51,54.102 C22.761,53.192 23.025,52.232 22.51,51.552 C22.08,50.985 21.315,50.883 19.96,50.702 A6.798 6.798 0 0 0 18.26,50.702 C17.539,50.791 17.154,50.838 16.985,51.127 Z"/>
  <path fill="#000" d="M9.5,61.5 L9.5,10.5 Q9.5,9.5 10.5,9.5 L61.5,9.5 Q62.5,9.5 62.5,10.5 L62.5,61.5 Q62.5,62.5 61.5,62.5 L10.5,62.5 Q9.5,62.5 9.5,61.5 Z M11.5,11.5 L11.5,60.5 L60.5,60.5 L60.5,11.5 Z"/>
  <path fill="#000" d="M24.613,50.926 L24.613,50.925 Q24.158,50.02 24.715,49.489 Q25.006,49.212 25.576,49.316 Q25.786,49.354 25.9,49.351 Q26.121,49.347 26.456,49.095 Q26.966,48.708 27.435,48.533 Q29.096,47.912 29.705,48.694 Q30.076,49.172 29.782,50.016 Q29.482,50.874 28.616,51.176 Q28.279,51.287 27.876,51.214 Q27.741,51.189 27.673,51.197 Q27.241,51.252 26.622,52.297 Q26.166,53.066 25.704,52.857 Q25.295,52.672 25.43,52.107 Q25.491,51.848 25.447,51.741 Q25.422,51.678 25.248,51.57 Q24.796,51.291 24.613,50.926 Z M25.507,50.477 Q25.563,50.59 25.774,50.72 Q26.059,50.897 26.224,51.108 Q26.872,50.291 27.547,50.205 Q27.768,50.177 28.056,50.23 Q28.209,50.258 28.304,50.226 Q28.697,50.089 28.838,49.686 Q28.953,49.357 28.915,49.308 Q28.758,49.106 27.785,49.47 Q27.453,49.594 27.059,49.892 Q26.465,50.341 25.92,50.351 Q25.715,50.355 25.426,50.305 Q25.452,50.369 25.507,50.477 Z M25.403,50.235 L25.405,50.214 Q25.4,50.218 25.403,50.235 Z"/>
  <path fill="#000" d="M22.03,48.011 L22.048,47.961 Q22.866,45.976 24.843,45.15 Q26.11,44.457 27.544,44.256 Q28.481,44.131 29.7,44.309 Q30.867,44.48 31.741,44.266 L31.759,44.261 L31.777,44.258 Q32.587,44.121 33.188,43.565 Q33.702,42.889 33.928,42.068 L33.934,42.046 L33.942,42.024 Q34.043,41.758 34.188,41.327 Q34.559,40.221 35.092,40.031 Q35.253,39.973 35.569,39.986 Q35.849,39.997 36.118,40.001 Q36.349,40.005 36.957,40.001 Q38.262,39.994 39.955,37.658 Q42.579,34.04 41.619,32.236 Q41.535,32.08 41.32,31.79 Q40.745,31.013 40.711,30.327 Q40.673,29.579 41.029,28.899 Q41.459,28.082 42.076,28.102 Q42.529,28.116 42.861,28.72 Q42.991,28.957 43.028,28.965 Q43.097,28.982 43.472,28.641 Q44.197,27.981 44.733,28.117 Q45.208,28.237 45.532,29.134 Q45.735,29.695 45.916,30.096 Q46.182,30.687 46.49,31.146 Q46.768,31.56 46.808,31.952 Q46.873,32.609 46.406,33.391 Q46.024,34.033 45.957,34.609 Q45.919,34.935 45.977,35.311 Q46.063,35.864 45.947,36.364 Q45.818,36.922 45.422,37.503 Q45.178,37.861 45.078,38.127 Q44.937,38.503 45.023,39.071 Q45.14,39.838 45.11,40.524 L45.108,40.55 L45.104,40.575 Q44.837,42.358 44.236,44.056 Q43.716,45.805 43.104,46.062 Q42.674,46.243 41.99,46.067 Q41.593,45.965 41.443,46.044 Q41.306,46.116 41.134,46.4 Q40.791,46.963 40.346,46.951 Q39.88,46.939 39.51,46.282 L39.479,46.1 L39.489,46.239 Q39.232,46.584 39.015,46.803 L39.015,46.803 Q37.769,48.061 36.819,47.781 Q36.43,47.667 36.153,47.215 Q36.007,46.977 35.843,46.874 Q35.099,46.405 34.837,46.717 Q34.758,46.892 34.851,47.067 L34.858,47.078 L34.863,47.09 Q34.93,47.233 35.202,47.394 Q35.711,47.696 35.757,48.094 Q35.817,48.619 34.715,49.398 Q33.888,50.089 32.839,50.335 Q32.276,50.503 31.713,50.329 L31.661,50.313 L31.613,50.286 Q30.33,49.558 30.513,48.096 Q30.583,47.393 31.228,46.646 L31.401,46.649 Q31.335,46.498 29.432,46.936 Q27.27,47.528 25.297,48.592 L25.287,48.597 L25.277,48.602 Q25.123,48.676 24.835,48.816 Q22.675,49.866 22.159,49.357 Q21.754,48.958 22.03,48.011 Z M22.983,48.317 Q22.923,48.523 22.91,48.627 Q23.135,48.53 24.398,47.917 Q24.678,47.781 24.833,47.706 Q26.906,46.59 29.178,45.969 L29.188,45.966 L29.198,45.964 Q31.923,45.335 32.319,46.253 Q32.509,46.693 31.985,47.299 Q31.545,47.81 31.508,48.199 L31.507,48.207 L31.506,48.215 Q31.407,48.989 32.058,49.388 Q32.31,49.451 32.563,49.374 L32.58,49.368 L32.598,49.364 Q33.433,49.172 34.088,48.619 L34.104,48.605 L34.123,48.592 Q34.473,48.346 34.633,48.219 Q34.151,47.917 33.963,47.525 Q33.62,46.871 33.969,46.217 L33.984,46.188 L34.003,46.161 Q34.805,45.037 36.377,46.028 Q36.737,46.255 37.004,46.691 Q37.081,46.816 37.101,46.822 Q37.479,46.933 38.305,46.1 L38.305,46.099 Q38.472,45.931 38.688,45.641 Q39.109,45.076 39.541,45.102 Q39.995,45.13 40.36,45.754 Q40.643,45.335 40.977,45.159 Q41.469,44.9 42.239,45.098 Q42.597,45.19 42.716,45.14 Q42.894,45.066 43.281,43.759 L43.284,43.747 L43.289,43.734 Q43.857,42.133 44.112,40.454 Q44.134,39.877 44.034,39.221 Q43.909,38.396 44.142,37.775 Q44.285,37.396 44.596,36.94 Q44.886,36.514 44.973,36.139 Q45.045,35.827 44.989,35.464 Q44.91,34.954 44.963,34.494 Q45.055,33.704 45.548,32.879 Q45.845,32.38 45.812,32.051 Q45.798,31.909 45.66,31.703 Q45.304,31.174 45.004,30.507 Q44.808,30.071 44.592,29.474 Q44.498,29.216 44.451,29.11 Q44.375,29.17 44.145,29.38 Q43.378,30.079 42.792,29.937 Q42.336,29.827 41.998,29.225 Q41.956,29.285 41.915,29.364 Q41.685,29.801 41.709,30.276 Q41.729,30.661 42.124,31.195 Q42.383,31.545 42.501,31.766 Q43.756,34.121 40.765,38.245 Q38.774,40.99 36.963,41.001 Q36.344,41.005 36.102,41.001 Q35.821,40.997 35.528,40.985 L35.428,40.972 Q35.353,40.999 35.136,41.645 Q34.991,42.078 34.886,42.357 Q34.601,43.372 33.956,44.207 L33.932,44.237 L33.904,44.264 Q33.08,45.047 31.961,45.241 Q30.905,45.496 29.555,45.299 Q28.474,45.141 27.676,45.247 Q26.418,45.424 25.301,46.039 L25.277,46.053 L25.25,46.064 Q23.649,46.723 22.983,48.317 Z"/>
  <path fill="#000" d="M44.921,26.442 Q43.056,27.922 41.847,27.353 Q40.313,26.633 40.717,24.267 L40.719,24.253 L40.722,24.24 Q40.964,23.176 41.667,22.342 Q42.255,21.538 42.713,21.341 Q43.276,21.1 44.087,21.318 Q44.269,21.367 44.334,21.374 Q44.368,21.211 44.117,19.336 L44.114,19.317 Q43.732,16.458 44.166,15.62 L44.166,15.62 Q44.731,14.533 45.438,14.501 Q46.207,14.467 46.845,15.999 Q47.507,17.591 48.233,17.954 Q48.943,18.308 50.553,17.888 Q52.166,17.467 52.654,18.093 Q53.067,18.622 52.735,19.964 Q52.653,20.294 52.628,20.461 Q53.195,20.308 53.476,20.61 Q53.872,21.035 53.486,21.887 Q53.168,22.587 52.563,23.049 Q51.957,23.51 50.926,23.588 Q50.291,23.636 50.057,23.861 Q49.831,24.078 49.724,24.617 Q49.562,25.429 49.068,25.655 Q48.463,25.933 47.465,25.255 Q46.746,24.766 46.419,24.839 Q46.247,24.877 45.984,25.265 Q45.49,25.991 44.921,26.442 Z M44.299,25.659 Q44.749,25.303 45.157,24.702 Q45.643,23.987 46.201,23.863 Q46.95,23.696 48.027,24.428 Q48.559,24.789 48.652,24.746 Q48.681,24.733 48.743,24.422 Q48.911,23.576 49.363,23.141 Q49.857,22.665 50.851,22.59 Q51.587,22.535 51.957,22.253 Q52.355,21.95 52.568,21.49 Q52.215,21.524 51.98,21.365 Q51.448,21.005 51.764,19.724 Q51.979,18.854 51.866,18.708 Q51.782,18.601 50.805,18.855 Q48.832,19.37 47.787,18.848 Q46.727,18.319 45.921,16.383 Q45.553,15.497 45.482,15.5 Q45.352,15.506 45.054,16.081 L45.054,16.081 Q44.765,16.638 45.106,19.184 L45.108,19.204 Q45.459,21.825 44.893,22.213 Q44.519,22.469 43.827,22.283 Q43.352,22.155 43.107,22.26 Q42.897,22.35 42.464,22.945 L42.464,22.945 L42.453,22.96 L42.441,22.974 Q41.892,23.622 41.701,24.448 Q41.431,26.053 42.273,26.448 Q42.92,26.753 44.299,25.659 Z"/>
  <path fill="#000" d="M16.504,50.99 L16.521,50.929 L16.553,50.874 Q16.847,50.372 18.197,50.205 Q19.11,50.09 20.026,50.206 L20.026,50.206 Q22.353,50.517 22.908,51.25 Q23.573,52.127 22.992,54.234 Q22.013,57.788 20.012,57.999 Q18.047,58.206 17.768,56.745 Q17.658,56.164 18.398,55.461 Q18.993,54.896 19.037,54.474 L19.038,54.467 L19.039,54.459 Q19.143,53.691 18.498,53.296 Q18.457,53.295 18.379,53.313 Q17.997,53.398 17.69,53.305 L17.672,53.3 L17.655,53.293 Q16.029,52.667 16.504,50.99 Z M17.442,51.359 Q17.29,52.068 17.991,52.351 Q18.048,52.362 18.162,52.337 Q18.544,52.252 18.844,52.353 L18.888,52.367 L18.928,52.39 Q20.227,53.115 20.031,54.587 Q19.945,55.372 19.087,56.186 Q18.742,56.513 18.751,56.558 Q18.857,57.115 19.907,57.004 Q21.23,56.865 22.028,53.969 Q22.477,52.337 22.111,51.853 Q21.808,51.453 19.894,51.197 L19.893,51.197 Q19.11,51.098 18.322,51.198 Q17.573,51.29 17.442,51.359 Z"/>
  <path fill="#000" d="M51.655,52.576 L54.141,47.261 Q54.309,46.902 54.668,47.07 Q54.801,47.132 54.861,47.265 L57.271,52.58 Q57.35,52.754 57.264,52.923 L54.854,57.679 Q54.675,58.033 54.321,57.854 Q54.207,57.796 54.148,57.684 L51.662,52.928 Q51.571,52.754 51.655,52.576 Z M52.457,52.734 L54.495,56.633 L56.47,52.734 L54.494,48.377 L52.457,52.734 Z"/>
</svg>

When run with nanoemoji example.toml it gives the following output:

I1116 10:24:05.891201 139969406056256 nanoemoji.py:639] Proceeding with 1 config(s)
I1116 10:24:05.892331 139969406056256 nanoemoji.py:602] Wrote build/example.picosvgz.toml
I1116 10:24:05.892566 139969406056256 nanoemoji.py:645] Generating build.ninja
I1116 10:24:05.895651 139969406056256 ninja.py:113] ninja -C /home/jeppe/Code/emoji_test/openmoji/color2/mwe/build
ninja: Entering directory `/home/jeppe/Code/emoji_test/openmoji/color2/mwe/build'
[6/6] /home/jeppe/Code/emoji_test/.venv/bin/python -m nanoemoji.write_font -v 0 --config...le.picosvgz.fea --glyphmap_file example.picosvgz.glyphmap --part_file parts-merged.json 
FAILED: example.picosvgz.ttf 
/home/jeppe/Code/emoji_test/.venv/bin/python -m nanoemoji.write_font -v 0 --config_file example.picosvgz.toml --fea_file example.picosvgz.fea --glyphmap_file example.picosvgz.glyphmap --part_file parts-merged.json 
I1116 10:24:08.360525 139921954416448 __init__.py:50] Pre-processing glyphs
I1116 10:24:08.361337 139921954416448 base.py:183] Running DecomposeComponentsFilter on AnEmojiFamily-Regular
I1116 10:24:08.361514 139921954416448 base.py:183] Running CubicToQuadraticFilter on AnEmojiFamily-Regular
I1116 10:24:08.361693 139921954416448 cubicToQuadratic.py:46] New spline lengths: 
I1116 10:24:08.361789 139921954416448 __init__.py:249] Building OpenType tables
Traceback (most recent call last):
  File "/home/linuxbrew/.linuxbrew/opt/python@3.10/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/home/linuxbrew/.linuxbrew/opt/python@3.10/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/jeppe/Code/emoji_test/.venv/lib/python3.10/site-packages/nanoemoji/write_font.py", line 838, in <module>
    app.run(main)
  File "/home/jeppe/Code/emoji_test/.venv/lib/python3.10/site-packages/absl/app.py", line 308, in run
    _run_main(main, args)
  File "/home/jeppe/Code/emoji_test/.venv/lib/python3.10/site-packages/absl/app.py", line 254, in _run_main
    sys.exit(main(argv))
  File "/home/jeppe/Code/emoji_test/.venv/lib/python3.10/site-packages/nanoemoji/write_font.py", line 831, in main
    ufo, ttfont = _generate_color_font(font_config, inputs)
  File "/home/jeppe/Code/emoji_test/.venv/lib/python3.10/site-packages/nanoemoji/write_font.py", line 772, in _generate_color_font
    _COLOR_FORMAT_GENERATORS[config.color_format].apply_ttfont(
  File "/home/jeppe/Code/emoji_test/.venv/lib/python3.10/site-packages/nanoemoji/write_font.py", line 145, in <lambda>
    lambda *args: _svg_ttfont(*args, picosvg=True, compressed=True),
  File "/home/jeppe/Code/emoji_test/.venv/lib/python3.10/site-packages/nanoemoji/write_font.py", line 672, in _svg_ttfont
    make_svg_table(config, ttfont, color_glyphs, picosvg, compressed)
  File "/home/jeppe/Code/emoji_test/.venv/lib/python3.10/site-packages/nanoemoji/svg.py", line 779, in make_svg_table
    doc_list = _picosvg_docs(config, ttfont, color_glyphs)
  File "/home/jeppe/Code/emoji_test/.venv/lib/python3.10/site-packages/nanoemoji/svg.py", line 687, in _picosvg_docs
    reuse_groups = _glyph_groups(config, color_glyphs, reuse_cache)
  File "/home/jeppe/Code/emoji_test/.venv/lib/python3.10/site-packages/nanoemoji/svg.py", line 162, in _glyph_groups
    reuse_result = reuse_cache.glyph_cache.try_reuse(
  File "/home/jeppe/Code/emoji_test/.venv/lib/python3.10/site-packages/nanoemoji/glyph_reuse.py", line 60, in try_reuse
    norm_path = normalize(SVGPath(d=path), self._normalize_tolerance).d
  File "/home/jeppe/Code/emoji_test/.venv/lib/python3.10/site-packages/picosvg/svg_reuse.py", line 261, in normalize
    _, vecy = _first_significant(_vectors(path), lambda v: v.y, tolerance)
  File "/home/jeppe/Code/emoji_test/.venv/lib/python3.10/site-packages/picosvg/svg_reuse.py", line 168, in _first_significant
    for idx, vec in enumerate(vectors):
  File "/home/jeppe/Code/emoji_test/.venv/lib/python3.10/site-packages/picosvg/svg_reuse.py", line 122, in _vectors
    y_max = _farthest(rx, ry, large_arc, abs(end_x))
  File "/home/jeppe/Code/emoji_test/.venv/lib/python3.10/site-packages/picosvg/svg_reuse.py", line 56, in _farthest
    assert line_length > 0, f"line_length {line_length} must be > 0"
AssertionError: line_length 0.0 must be > 0
picosvg/clipped/1F5FE.svg
ninja: build stopped: subcommand failed.
Traceback (most recent call last):
  File "/home/jeppe/Code/emoji_test/.venv/bin/nanoemoji", line 8, in <module>
    sys.exit(main())
  File "/home/jeppe/Code/emoji_test/.venv/lib/python3.10/site-packages/nanoemoji/nanoemoji.py", line 761, in main
    app.run(_run)
  File "/home/jeppe/Code/emoji_test/.venv/lib/python3.10/site-packages/absl/app.py", line 308, in run
    _run_main(main, args)
  File "/home/jeppe/Code/emoji_test/.venv/lib/python3.10/site-packages/absl/app.py", line 254, in _run_main
    sys.exit(main(argv))
  File "/home/jeppe/Code/emoji_test/.venv/lib/python3.10/site-packages/nanoemoji/nanoemoji.py", line 756, in _run
    maybe_run_ninja(build_file)
  File "/home/jeppe/Code/emoji_test/.venv/lib/python3.10/site-packages/nanoemoji/ninja.py", line 114, in maybe_run_ninja
    subprocess.run(ninja_cmd, check=True)
  File "/home/linuxbrew/.linuxbrew/opt/python@3.10/lib/python3.10/subprocess.py", line 526, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['ninja', '-C', '/home/jeppe/Code/emoji_test/openmoji/color2/mwe/build']' returned non-zero exit status 1.

Running picosvg 1F5FE.svg doesn't lead to an error.

I don't fully understand why we need to assert that the line length must be positive. Was the intention perhaps assert that the distance was not negative? Removing the assert statement doesn't lead to any other errors.

anthrotype commented 2 years ago

interesting, thanks for the report. we shall take a look

JeppeKlitgaard commented 2 years ago

I've found an even more minimal example:

<svg xmlns="http://www.w3.org/2000/svg" id="emoji" viewBox="0 0 72 72">
  <defs/>
  <path fill="#92d3f5"
    d="
      M11.011,11
      L61,11
      A0 0 0 0 1 61,11
      L61,60.767
      Z"/>
</svg>
anthrotype commented 2 years ago

thanks. Whatever is happening, I believe the code simply should bail out of attempting to reuse the svg paths that we fail to normalize.

JeppeKlitgaard commented 2 years ago

I'm working on a quick PR that introduces a test. Would it be acceptable to fix this issue by simply converting the definite positive in the assertion to >= 0?

anthrotype commented 2 years ago

i'm not sure that's the right fix, but feel free to send a PR! We'll take a look

That A0 0 0 0 1 61,11 arc coming right after L61,11 look very suspicious. What does it look like when rendered? Does it even paint?

JeppeKlitgaard commented 2 years ago

Admittedly I know very little about SVG. The full SVG is: https://openmoji.org/library/emoji-1F5FE/

Not sure if that particular path is actually rendered though?