Menu

#5779 SVG: Permit 'e' to appear in SVG font glyph paths

Fixed
2020-02-27
2020-02-21
No

On 20/02/2020 18:33, Simon Tatham wrote:

A user of my notation font Gonville reported to me this week that they
had tried to use the Lilypond SVG backend with Gonville, and had found
that everything worked fine except that the sharp signs were
mysteriously missing from the output.

I debugged the problem and found that this happened because Fontforge
had generated the SVG path string for that glyph in a way that happened
to include the floating-point literal "9.91821e-05", written in
scientific notation, and that the 'glyph-path-regexp' definition in
output-svg.scm was failing to match the path string as a result, because
it doesn't permit the letter 'e'.

I was able to work around the issue by editing my SVG font file to
re-express that number as 0.0000991821, without the 'e'. But as far as I
can see, scientific notation of that form is legal per the SVG spec:
https://www.w3.org/TR/2011/REC-SVG11-20110816/paths.html#PathDataBNF

Applying the attached patch against output-svg.scm also solved the
problem for me, and I think it's a better fix.

Cheers,
Simon

1 Attachments

Discussion

  • Jonas Hahnfeld

    Jonas Hahnfeld - 2020-02-21

    Looks good, thanks for the detailed explanation. Looking further into https://www.w3.org/TR/2011/REC-SVG11-20110816/paths.html#PathDataBNF, we're also missing the characters +Aa,? Does it make sense to fuse attached patch with the original one?

     
    • Jonas Hahnfeld

      Jonas Hahnfeld - 2020-02-21

      Am Freitag, den 21.02.2020, 11:33 +0000 schrieb Simon Tatham:

      Jonas Hahnfeld <
      hahnjo@hahnjo.de

      wrote:
      looking at
      https://sourceforge.net/p/testlilyissues/issues/5779/
      and
      the grammar you linked, I think the regular expression is also missing
      '+Aa,'. Does it make sense to fuse attached patch?

      The idea looks sensible to me, but I think you've made a mistake in the
      regular expression syntax. The character '-' has to appear immediately
      after the open bracket, otherwise it's taken to be the punctuation in a
      range such as "A-Z". So the character class
      [+-MmZzLlHhVvCcSsQqTtAa0-9,.Ee\n ] will match (at least) any character
      between '+' and 'M'.

      If you start the brackets with [-+Mm...] instead of [+-Mm...] then I
      think it does what you intended.

      Absolutely correct, good spot. Luckily (for my testing) '-' is between
      '+' and 'M', but that's actually too broad. Will fix the patch.

      Thanks
      Jonas

       
  • Jonas Hahnfeld

    Jonas Hahnfeld - 2020-02-21

    SVG: Permit 'e' to appear in SVG font glyph paths

    The definition of 'glyph-path-regexp' will only match a <path d="...">
    element if the contents of the 'd' attribute do not include the letter
    e. But the SVG spec permits coordinates to be given in C-style
    exponential notation such as 9.8e-5. If a glyph in an SVG font uses
    that ability, extract-glyph will fail, and the glyph will be silently
    omitted from the output file.</path>

    by Simon Tatham anakin@pobox.com

    Follow-up: Also allow '+Aa,' in SVG path descriptions

    See https://www.w3.org/TR/2011/REC-SVG11-20110816/paths.html#PathDataBNF
    Note that - must be first in the character class or it will specify
    a range of characters (as the first version of this patch did).

    http://codereview.appspot.com/561460044

     
  • Anonymous

    Anonymous - 2020-02-21
    • assigned_to: pkx166h --> Jonas Hahnfeld
    • Needs: -->
    • Type: -->
     
  • Anonymous

    Anonymous - 2020-02-21

    Passes make, make check and a full make doc.

     
  • Anonymous

    Anonymous - 2020-02-21
    • Patch: new --> review
     
  • Anonymous

    Anonymous - 2020-02-21

    Passes make, make check and a full make doc.

     
  • Anonymous

    Anonymous - 2020-02-24
    • Patch: review --> countdown
     
  • Anonymous

    Anonymous - 2020-02-24

    Patch on countdown for Feb 26th.

     
  • Anonymous

    Anonymous - 2020-02-26
    • Patch: countdown --> push
     
  • Anonymous

    Anonymous - 2020-02-26

    Patch counted down - please push

     
  • Jonas Hahnfeld

    Jonas Hahnfeld - 2020-02-27
    • labels: --> Fixed_2_21_0
    • status: Started --> Fixed
    • Patch: push -->
     
  • Jonas Hahnfeld

    Jonas Hahnfeld - 2020-02-27

    pushed as

    commit 915ccbf455aac0e0e597435ae85fc1015da84e13
    Author:     Jonas Hahnfeld <hahnjo@hahnjo.de>
    AuthorDate: Fri Feb 21 12:20:25 2020 +0100
    Commit:     Jonas Hahnfeld <hahnjo@hahnjo.de>
    CommitDate: Thu Feb 27 16:55:52 2020 +0100
    
        Issue 5779/2: Also allow '+Aa,' in SVG path descriptions
    
        See https://www.w3.org/TR/2011/REC-SVG11-20110816/paths.html#PathDataBNF
        Note that - must be first in the character class or it will specify
        a range of characters (as the first version of this patch did).
    
    commit e45b5186b25e4ec4077621d917aaa014be342535
    Author:     Simon Tatham <anakin@pobox.com>
    AuthorDate: Thu Feb 20 18:24:52 2020 +0000
    Commit:     Jonas Hahnfeld <hahnjo@hahnjo.de>
    CommitDate: Thu Feb 27 16:55:48 2020 +0100
    
        Issue 5779/1: [SVG] Permit 'e' to appear in SVG font glyph paths.
    
        The definition of 'glyph-path-regexp' will only match a <path d="...">
        element if the contents of the 'd' attribute do not include the letter
        e. But the SVG spec permits coordinates to be given in C-style
        exponential notation such as 9.8e-5. If a glyph in an SVG font uses
        that ability, extract-glyph will fail, and the glyph will be silently
        omitted from the output file.
    
     
  • Jonas Hahnfeld

    Jonas Hahnfeld - 2020-02-27

    @dakas if not too late, this could be worth picking into 2.20