fonttools / fontbakery

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

com.google.fonts/check/outline_alignment_miss ERROR if OS/2 version too low #4623

Closed drj11 closed 2 months ago

drj11 commented 3 months ago

(NOTE: Please include the check-id in the issue's title.)

Observed behaviour

Is the OS/2 table has version number 1, the com.google.fonts/check/outline_alignment_miss has an ERROR:


 >> com.google.fonts/check/outline_alignment_miss
    Are there any misaligned on-curve points?
    with jam8.ttf

      Rationale:                                                                
      This check heuristically looks for on-curve points which are close to, but
      do not sit on, significant boundary coordinates. For example, a point     
      which has a Y-coordinate of 1 or -1 might be a misplaced baseline point.  
      As well as the baseline, here we also check for points near the x-height  
      (but only for lower case Latin letters), cap-height, ascender and         
      descender Y coordinates.                                                  

      Not all such misaligned curve points are a mistake, and sometimes the     
      design may call for points in locations near the boundaries. As this check
      is liable to generate significant numbers of false positives, it will pass
      if there are more than 100 reported misalignments.                        

    ERROR Failed with AttributeError: 'table_O_S_2f_2' object                   
          has no attribute 'sxHeight' File                                      
          "/usr/local/lib/python3.9/site-packages/fontbakery/checkrunner.py",   
          line 193, in _exec_check ↳     for sub_result in result:  # Might     
          raise. ↳   File "/usr/local/lib/python3.9/site-packages/fontbakery/pro
          files/outline.py", line 50, in                                        
          com_google_fonts_check_outline_alignment_miss ↳     "x-height":       
          ttFont["OS/2"].sxHeight, ↳                                            

    Result: ERROR

Expected behaviour

Skip, or proceed with the check? I have a vague memory that this used to work, so maybe an older version didn't use the xHeight metrics and hence didn't need to go fishing around in the OS/2 table so much.

Can it avoid using the xHeight if it's not available?

Resources and steps needed to reproduce

It is a font file with a version 1 OS/2 table. I can provide such a font file, but the one i am currently investigation also induces other fontbakery ERRORs that would be a distraction at this time.

Discussion

Because of the experimental nature of some of my work, i have fonts with special characteristics that would ordinarily make them unsuitable for much work. I'm still interested in using fontbakery on these fonts, but you may not be.

So my question is, are you interested in me patching things so that checks continue to work (or are skipped) if the OS/2 version is too low?

(PS: you might be surprised at how well a font can work with a low version OS/2 table or even a missing one)

felipesanches commented 3 months ago

If you feel like sending a PR, I'll be happy to review it.

Otherwise, let me know, and I can spend some time trying to address the issue.

drj11 commented 3 months ago

I will investigate and see how it goes. I suspect i'm really the only person who is troubled by this.

Should there be a blanket policy for requesting fields that, due to different versions of OpenType tables, might not exist? In this particular case i can use getattr or hasattr but maybe in general such fields should evaluate to None? Then a genuinely missing attribute would mean either a typo in your code or that the library code predates the publication of a newer table.

drj11 commented 2 months ago

has this check moved from check-universal to check-googlefonts ? Hmm, i wonder how old my previous fontbakery was.

Note to self:

fontbakery check-googlefonts -c com.google.fonts/check/outline_alignment_miss ranalina.ttf