Menu

#5806 Tweak mf files to avoid FontForge internal overlap error

Fixed
2020-03-05
2020-02-28
No

https://codereview.appspot.com/571780043

Overlapping mf paths

In some cases, overlapping mf paths will cause errors in FontForge processing, even if the resulting glyphs seem to be OK.
Currently, we have 352 error messages being produced during make, which is quite annoying..
Please find the corresponding log extract attached.

Remedy: Slightly adapt mf code (where needed), keeping the resulting glyph outline unchanged, but avoid problematic crossing angles for FontForge.
* slight path adaptions inside overlapping areas (not affecting the resulting glyph outline at all!)
* In some cases (braces, arowheads, segno/turns) now using one single outline rather than combinng two overlapping ones (with the exact same result).

FontForge issue

This has been a pain in the neck for many years now, but it doesn't seem to be easy to fix in FontForge, though. Werner has created a (FontForge) issue: https://github.com/fontforge/fontforge/issues/4184.

Nevertheless, it'd probably be a good idea to make our mf files a bit easier to handle.

Changes to mf files

The mf files have only been changed where needed, using all the original mf control points and directions, keeping the resulting character outline unaltered.
I'll attach PFB files of feta11.pfb and feta.braces-a.pfb so that Werner (and others, of course) can have a look at the final FontForge output.

Overview: Internal Error (overlap) in [...]

The errors are being caused by just a few glyphs in just a couple of mf files. Most of the time, there fixing one macro will fix all the glyphs using that macro.

feta-arrowheads.mf -> Internal Error (overlap) in arrowheads.*
  • macro set_arrow_path: now one single outline. Fixes glyphs open.01, open.0M1, open.11, open.1M1
feta-numbers.mf -> Internal Error (overlap) in two, seven
  • Character defintions "two" and "seven" chnged. Fixes glyphs two, seven
feta-scripts.mf -> Internal Error (overlap) in scripts.*
  • macro draw_turn: "ploops" removed, now one single outline. Fixes glyphs reverseturn, turn, slashturn
  • char def "segno": similar case as in draw_turn. Fixes glyph segno
feta-timesignatures.mf -> Internal Error (overlap) in timesig.*
  • macro draw_C: smooth .. instead of straight -- within overlapping area. Fixes glyphs C44, C22
feta-clefs.mf -> Internal Error (overlap) in clefs.*
  • macro draw_gclef: Fixes glyphs G, GG, tenorG
  • macro draw_tab_B: Starting angle of one stroke in lower handwriting style "B" of "TAB" slightly changed (invisible difference). Fixes glyph tab
feta-braces.mf -> Internal Error (overlap) in brace*
  • macro draw_brace: Even simplified a bit and now drawing one single outline without any overlaps.
parmesan-clefs.mf -> Internal Error (overlap) in clefs.*
  • macro draw_neomensural_c_clef: Fixes glyphs neomensural.c, neomensural.c_change
  • macro draw_petrucci_c_clef: Fixes glyphs petrucci.c1, c2, c2_change, c3, c3_change, c4, c5, c5_change
parmesan-rests.mf -> Internal Error (overlap) in rests.*
  • char def "2neomensural" changed: Fixes glyph rests.2neomensural

Examle: two overlaping outline -> single outline

In many symmetric cases, such as arrowheads braces, the glyphs had been constructed by separately drawing half and a mirrored version of itself, thus creating an overlap that might be problematic for FontForge.

Original mf code (with overlap)

   fill path;
   fill path yscaled -1;

New mf code (one single outline)
After determining the intersection point and using the appropriate subpath only, we are able to draw one single cyclic outine by joining one half part and its reversed/mirrored counterpart:
Using subpaths helps keeping the exact original control points and slopes, thus keeping the resulting glyph exactly identical to the original glyph..

   fill path
      .. reverse path yscaled -1
      .. cycle;
5 Attachments

Discussion

  • Torsten Hämmerle

    • Attachments has changed:

    Diff:

    --- old
    +++ new
    @@ -1 +1,2 @@
    +feta11.pfb (52.8 kB; application/x-font-type1)
     internal-error-overlap-log.txt (15.9 kB; text/plain)
    
     
  • Torsten Hämmerle

    • Attachments has changed:

    Diff:

    --- old
    +++ new
    @@ -1,2 +1,3 @@
    +feta-braces-a.pfb (24.8 kB; application/x-font-type1)
     feta11.pfb (52.8 kB; application/x-font-type1)
     internal-error-overlap-log.txt (15.9 kB; text/plain)
    
     
  • Werner LEMBERG

    Werner LEMBERG - 2020-02-28

    Thanks for working on that! Will check it soon. Note that I've created four FontForge issues (#4184-#4187) reporting the warnings and errors with Feta and Parmesan.

     
  • Torsten Hämmerle

    • Attachments has changed:

    Diff:

    --- old
    +++ new
    @@ -1,3 +1,2 @@
     feta-braces-a.pfb (24.8 kB; application/x-font-type1)
    -feta11.pfb (52.8 kB; application/x-font-type1)
     internal-error-overlap-log.txt (15.9 kB; text/plain)
    

    I've found more cases concerning petrucci etc.
    Work in progress...

     

    Last edit: Torsten Hämmerle 2020-02-28
  • Torsten Hämmerle

    Issue 5806: Tweak mf files to avoid FontForge internal overlap error

    When compiling LilyPond, there were 352 error messages caused by
    FontForge trying to resolve overlapping path problems:

    Internal Error (overlap) in [...]

    Fortunately, the resulting glyphs had been OK, though.
    FontForge should be able to cope with this, but, alas, it isn't.

    I've now tweaked all the mf files causing these problems so that the
    annoying error messages can be avoided without while keeping the
    original resulting glyph outlines.

    modified:   mf/feta-arrowheads.mf
    
    • former def_set_arrow_paths (returning both open_path and close_path)
      has been replaced by def_set_arrow_path returning one path arrow_path
      depending on additional boolean parameter CLOSED
    • No need to draw two overlapping mirrored half-paths anymore.
    • Char definitions adapted accordingly
      FIXES arrowheads.open.01
      arrowheads.open.0M1
      arrowheads.open.11
      arrowheads.open.1M1

      modified: mf/feta-braces.mf

    • now draw one single cyclic path rather than overlaying two
      separate, mirrored half-paths

    • using intersection and subpaths to exaclty retain the original
      slopes.
      FIXES brace4 - brace507

      modified: mf/feta-clefs.mf

    • draw_gclef: just one control point changed (hidden in overlapping area)
      FIXES clefs.G
      clefs.GG
      clefs.tenorG

    • draw_tab_B: lower arc of the B in "TAB", angle slighty changed by 1°
      FIXES clefs.tab

      modified: mf/feta-numbers.mf

    • original paths in char definition re-arranged, intersected, joined,
      in order to create one single outline (two glyphs concerned):

    • two char definitions affected:
      FIXES two
      FIXES seven

      modified: mf/feta-scripts.mf

    • draw_turn: "ploop" overlay completely removed, using joined sub-
      paths instead
      FIXES scripts.reverseturn
      scripts.turn
      scripts.slashturn

    • "Segno" char definition: similar to draw_turn change
      FIXES scripts.segno

      modified: mf/feta-timesignatures.mf

    • draw_C: .. instead of -- (hidden in overlapping area)
      FIXES timesig.C44
      timesig.C22

      modified: mf/parmesan-clefs.mf

    • draw_neomensural_c_clef: .. instead of -- (hidden in overlap area)
      FIXES clefs.neomensural.c
      clefs.neomensural.c_change

    • draw_petrucci_c_clef: .. instead of .. (hidden in overlap area)
      FIXES clefs.petrucci.c1
      clefs.petrucci.c2
      clefs.petrucci.c2_change
      clefs.petrucci.c3
      clefs.petrucci.c3_change
      clefs.petrucci.c4
      clefs.petrucci.c5
      clefs.petrucci.c5_change

      modified: mf/parmesan-rests.mf

    • "2neomensural" char definition: one additional auxiliary point
      inserted in overlap area
      FIXES rests.2neomensural

    RESULT: same glyphs, no FontForge errors anymore

    https://codereview.appspot.com/571780043

     
  • Torsten Hämmerle

    • Attachments has changed:

    Diff:

    --- old
    +++ new
    @@ -1,2 +1 @@
     feta-braces-a.pfb (24.8 kB; application/x-font-type1)
    -internal-error-overlap-log.txt (15.9 kB; text/plain)
    
     
  • Torsten Hämmerle

    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,6 +1,7 @@
    +[https://codereview.appspot.com/571780043](https://codereview.appspot.com/571780043)
     #Overlapping mf paths
     In some cases, overlapping mf paths will cause errors in FontForge processing, even if the resulting glyphs seem to be OK.
    -Currently, we have **142 error messages** being produced during make, which is quite annoying..
    +Currently, we have **352 error messages** being produced during make, which is quite annoying..
     Please find the corresponding log extract attached.
    
     **Remedy:**  Slightly adapt mf code (where needed), keeping the resulting glyph outline unchanged, but avoid problematic  crossing angles for FontForge.
    @@ -22,6 +23,8 @@
    
     #####feta-arrowheads.mf -> Internal Error (overlap) in arrowheads.*
     * macro **set_arrow_path**: now one single outline.  Fixes glyphs **open.01, open.0M1, open.11, open.1M1**
    +#####feta-numbers.mf -> Internal Error (overlap) in two, seven
    +* Character defintions "two" and "seven" chnged.  Fixes glyphs **two, seven**
     ##### feta-scripts.mf -> Internal Error (overlap) in scripts.*
     * macro **draw_turn**: "ploops" removed, now one single outline.  Fixes glyphs **reverseturn, turn, slashturn**
     *  char def **"segno"**: similar case as in draw_turn. Fixes glyph **segno**
    @@ -32,6 +35,11 @@
     * macro **draw_tab_B**:  Starting angle of one stroke in lower handwriting style "B" of "TAB" slightly changed (invisible difference).  Fixes glyph **tab**
     ##### feta-braces.mf -> Internal Error (overlap) in brace*
     * macro **draw_brace**:  Even simplified a bit and now drawing one single outline without any overlaps.
    +##### parmesan-clefs.mf -> Internal Error (overlap) in clefs.*
    +* macro **draw_neomensural_c_clef**:  Fixes glyphs **neomensural.c, neomensural.c_change**
    +* macro **draw_petrucci_c_clef**:  Fixes glyphs **petrucci.c1, c2, c2_change, c3, c3_change, c4, c5, c5_change**
    +##### parmesan-rests.mf -> Internal Error (overlap) in rests.*
    +* char def "2neomensural" changed:  Fixes glyph **rests.2neomensural**
    
     #### Examle: two overlaping outline -> single outline
    
    • Attachments has changed:

    Diff:

    --- old
    +++ new
    @@ -1 +1,2 @@
     feta-braces-a.pfb (24.8 kB; application/x-font-type1)
    +internal-error-overlap-log.txt (41.5 kB; text/plain)
    
    • Needs: -->
    • Type: -->
     
  • Torsten Hämmerle

    • Attachments has changed:

    Diff:

    --- old
    +++ new
    @@ -1,2 +1,3 @@
    +feta-alphabet11.pfb (12.6 kB; application/x-font-type1)
     feta-braces-a.pfb (24.8 kB; application/x-font-type1)
     internal-error-overlap-log.txt (41.5 kB; text/plain)
    
     
  • Torsten Hämmerle

    • Attachments has changed:

    Diff:

    --- old
    +++ new
    @@ -1,3 +1,4 @@
     feta-alphabet11.pfb (12.6 kB; application/x-font-type1)
     feta-braces-a.pfb (24.8 kB; application/x-font-type1)
    +feta11.pfb (53.8 kB; application/x-font-type1)
     internal-error-overlap-log.txt (41.5 kB; text/plain)
    
     
  • Torsten Hämmerle

    • Attachments has changed:

    Diff:

    --- old
    +++ new
    @@ -2,3 +2,4 @@
     feta-braces-a.pfb (24.8 kB; application/x-font-type1)
     feta11.pfb (53.8 kB; application/x-font-type1)
     internal-error-overlap-log.txt (41.5 kB; text/plain)
    +parmesan11.pfb (39.4 kB; application/x-font-type1)
    
     
  • Anonymous

    Anonymous - 2020-02-29

    Passes make, make check and a full make doc.

     
  • Torsten Hämmerle

    Indentation and separating spaces

    https://codereview.appspot.com/571780043

     
  • Torsten Hämmerle

     
  • Anonymous

    Anonymous - 2020-03-02
    • Needs: -->
    • Patch: new --> review
    • Type: -->
     
  • Anonymous

    Anonymous - 2020-03-02

    Passes make, make check and a full make doc.

     
  • Anonymous

    Anonymous - 2020-03-03
    • Patch: review --> countdown
     
  • Anonymous

    Anonymous - 2020-03-03

    Patch on countdown for March 5th

     
  • Anonymous

    Anonymous - 2020-03-05
    • Patch: countdown --> push
     
  • Anonymous

    Anonymous - 2020-03-05

    Patch counted down - please push.

     
    • Torsten Hämmerle

      Patch formatted against current master attached.
      (This time with a reasonably stripped-down commit message)
      Please push it for me.

      Thanks,
      Torsten

       
  • Werner LEMBERG

    Werner LEMBERG - 2020-03-05
    • labels: --> Fixed_2_21_0
    • status: Started --> Fixed
    • Patch: push -->
     
  • Werner LEMBERG

    Werner LEMBERG - 2020-03-05

    Pushed to staging as
    commit 06b5ac8389b5cc3c9afbb2c84e2e5c02d0c9dca0
    Author: Torsten Hämmerle torsten.haemmerle@web.de
    Date: Mon Feb 24 10:45:35 2020 +0100

    Issue 5806: Tweak mf files to avoid FontForge internal overlap error
    
    When compiling LilyPond, there were 352 error messages caused by
    FontForge trying to resolve overlapping path problems:
    
    >>> Internal Error (overlap) in [...]
    
    mf files changed to avoid FontForge error messages.