fonttools / fontbakery

🧁 A font quality assurance tool for everyone
https://fontbakery.readthedocs.io
Apache License 2.0
551 stars 102 forks source link

[empty_letters] failing with error "TypeError: object of type 'NoneType' has no len()" #4850

Open arrowtype opened 1 month ago

arrowtype commented 1 month ago

Observed behaviour

I’m running FontBakery from a checks profile, which includes Adobe Fonts checks.

One of the checks is giving me an error, and I’m not sure why, or if it’s only happening on my particular environment. But, it’s happened in two separate projects, in separate venvs, with separate, fresh installations of fontbakery, so it may be a genuine issue. (Or if not, I’d be very grateful to be pointed in the right direction!)

 >> com.adobe.fonts/check/find_empty_letters
    Letters in font have glyphs that are not empty?
    with familyname.otf

    Rationale:                                                                

    Font language, script, and character set tagging approaches typically have an underlying assumption that letters (i.e. characters with Unicode general category 'Ll', 'Lm', 'Lo', 'Lt', or 'Lu', which includes CJK ideographs and Hangul syllables) with entries in the 'cmap' table have glyphs with ink (with a few exceptions, notably the four Hangul    
    "filler" characters: U+115F, U+1160, U+3164, U+FFA0).                                                                                                                                                                                                                                                                                                         

    This check is intended to identify fonts in which such letters have been mapped to empty glyphs (typically done as a form of subsetting). Letters with empty glyphs should have their entries removed from the 'cmap' table, even if the empty glyphs are left in place (e.g. for CID consistency).                                                           

    The check will yield only a WARN if the blank glyph maps to a character in the range of Korean hangul syllable code-points, which are known to be used by font designers as a workaround to undesired behavior from InDesign's Korean IME (Input Method Editor). More details available at https://github.com/fonttools/fontbakery/issues/2894                

    More info: https://github.com/fonttools/fontbakery/pull/2460

    ERROR Failed with TypeError: object of type 'NoneType' has no len()                                                                                                                                                                                                                                                                                           

            File "/Users/stephennixon/type-repos/projectname/familyname/venv/lib/python3.11/site-packages/fontbakery/checkrunner.py", line 213, in _run_check                                                                                                                                                                          
              subresults = list(subresults)                                                                                                                                                                                                                                                                                                                       
                           ^^^^^^^^^^^^^^^^                                                                                                                                                                                                                                                                                                                       
            File "/Users/stephennixon/type-repos/projectname/familyname/venv/lib/python3.11/site-packages/fontbakery/checks/adobefonts.py", line 108, in com_adobe_fonts_check_find_empty_letters                                                                                                                                      
              glyph_is_empty = _quick_and_dirty_glyph_is_empty(ttFont, glyph_name)                                                                                                                                                                                                                                                                                
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                                                                                                                                                                                
            File "/Users/stephennixon/type-repos/projectname/familyname/venv/lib/python3.11/site-packages/fontbakery/checks/adobefonts.py", line 56, in _quick_and_dirty_glyph_is_empty                                                                                                                                                
              if len(char_string.bytecode) <= 1:                                                                                                                                                                                                                                                                                                                  
                 ^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                                                                                                                                                                                                                        

          ``` [code: failed-check]                                                                                                                                                                                                                                                                                                                                

    Result: ERROR

Expected behaviour

I expect the check to run and tell me about empty glyphs.

Resources and steps needed to reproduce

I can’t provide the fonts publicly, but I could share them directly, if it’s necessary to debug this.

Please let me know if any further details would be helpful here.

Thanks!

felipesanches commented 2 weeks ago

The code that is causing this error is only reachable when checking CFF/OTF fonts.

I've tested it with data/test/rokkitt/Rokkitt-*.otf and it worked fine for both the latest git main branch as well as for the tagged v0.12.10 release.

@arrowtype in order to reproduce this I'll need access to a few sample files.

arrowtype commented 1 week ago

Hi @felipesanches, so sorry for my delay in responding here. I’ve emailed you one of the fonts in question, as it is a non-public font. I’m pretty perplexed on this – thanks for any pointers on it!

felipesanches commented 1 week ago

thanks, I'll take a look at the files and see if I can figure this out