Are off-curve points considered for the Bounding Box?

I am hoping that someone can shed light on whether off-curve points are considered when calculating a OpenType glyph's bounding box. There is a check in Font Validator - E1112 - that reads in part:

"The bounding box ... does not agree with the bounding box dimensions defined by the control points at the extremes of the glyph contours ... This problem may be caused by the font creation tool incorrectly using off-curve control points to calculate the bounding box ..."

The citation for this test is 
http://go.microsoft.com/fwlink?LinkID=10348 which is the glyph table specification. I can't glean any information from that spec on whether to consider off-curve points.

Martin Hosken's FontUtils perl code (the Glyph.pm module) does use off-curve points (as far as I can tell). I can't off-hand locate the code in the FontTools Python code.

Any guidance appreciated.

Comments

  • ClintGoss
    ClintGoss Posts: 66
    And what would we do for glyphs with no on-curve points?
  • ClintGoss
    ClintGoss Posts: 66
    edited May 2020
    Did some tests on FontCreator, and it also appears to use the "All-points bounding box" method ... see the next message (with an image) ...
  • ClintGoss
    ClintGoss Posts: 66
    Did some tests on FontCreator, and it also appears to use the "All-points bounding box" method.

    The "On-curve bounding box" approach suggested by FontValidator seems to be ?in error? or maybe overridden by general practice ...
  • I think it could depend on the font format too. I did a quick test and it seems that TTF fonts rely on the off-curve points to set x- and y-Max/Min in the head table. On the other hand, CFF fonts use the virtual extreme point (as you called "inked bounding box") to set these values in the head table.
  • ClintGoss
    ClintGoss Posts: 66
    Interesting! So I'm guessing a font authoring tool would need to run an in-memory rendering algorithm (Freetype?) to determine the bounding box for CFF outlines.

    Is there documentation on this? A search for "virtual extreme point" and related searches turns up nothing ...
  • Rafael Saraiva
    Rafael Saraiva Posts: 31
    edited May 2020
    So I'm guessing a font authoring tool would need to run an in-memory rendering algorithm (Freetype?) to determine the bounding box for CFF outlines.
    I have no clue :) Just did an empirical experiment because I was curious.

    by the way, I made up "virtual extreme point"... the wording makes sense to me, so don't take this term seriously.
  • ClintGoss
    ClintGoss Posts: 66
    I'm a bit flummoxed that all this basic stuff isn't better specified ... If the Federal Aviation Regs were "make it up as you go" and "let's see what other folks are doing" we might be in a pickle.
  • Thomas Phinney
    Thomas Phinney Posts: 2,888
    This is only the tip of the iceberg. A lot in OpenType is like this!
  • RichardW
    RichardW Posts: 100
    The March version of this topic gave some hint as to why one should ensure that the point- and ink-boxes be the same for TrueType outlines.  I remember a statement from Microsoft that they required the globally extreme points to be on-curve points, but I couldn't find it.  So what does one do for a non-empty TrueType outline with no on-curve points?  One adds four on-curve points.

    A font authoring tool doesn't need to call on a renderer to work out the bounds for a CFF outline.  Working out the bounds wouldn't be out of place in a public maths exam at 16, even if there aren't formulas as elegant as the quadratic spline formula (b²-ac)/(2*b-a-c).  (There might be; I haven't had occasion to dig into the matter.)
  • Piotr Grochowski
    Piotr Grochowski Posts: 91
    edited August 2020
    Missing extrema are undefined behavior. The font is not supposed to use missing extrema. But the "On-curve bounding box" method appears to be incorrect, as it ignores the point implied by interpolation, so if the outline consists of only off-curve points this method would not give the correct results. The "All-points bounding box" does give the correct results because the implied point will always be included in the bounds by the off-curve points.
  • RichardW
    RichardW Posts: 100
    I just can't find the Microsoft statement.  But, going back to TrueType, in Chapter 1 we find "A glyph outline should have points on extrema. That is, the curve positions with minimum x-value, minimum y-value, maximum x-value and maximum y-value should be marked by curve points. Some systems for representing outline fonts require an on-curve point at the point of tangency. This is not required in TrueType if the tangency point is midway between the flanking off-curve points."  So, one can defend defining a curved contour by just the 4 points of a rectangle with edges parallel to the axes.  Indeed, the same chapter gives an example of a circle defined by 8 off-curve points and no on-curve points and describes it as 'just right'.

    Of course, these extrema are included in the implicit on-curve points!  They're very different to the extreme points that are neither explicit nor implicit, which do complicate the definition of the bounding box.
  • The extrema being implied by interpolation is allowed because the same x or y position (depending on the extrema axis) is found in the off-curve points and is usable for hinting. They therefore have to be included in the bounding box, making "All-points bounding box" the correct option.
  • RichardW
    RichardW Posts: 100
    And the error revealed by the message would appear to be that there are extrema in TrueType glyphs whose relevant coordinate is not allocated to any point of the contours.

    Where do pure attachment points stand in all this?  (At least, I assume one is permitted one-point contours to define attachment points.)