What's the rectangle surrounding a font glyph, including its sidebearings, called?

What's the rectangle surrounding a font glyph, including its sidebearings, called? I Googled the words "bounding box" and got conflicting results, where some sources say it's the rectangle that bound the glyph tightly (without sidebearings), and others say it includes sidebearings.


Comments

  • K PeaseK Pease Posts: 182
    If we are to take terminology from metal type, it should be called the body. Otherwise, I think there isn't a term because the idea is not particularly meaningful. The vertical metrics are not "bearings" per se and they don't work in the same way.
  • arrybarryarrybarry Posts: 4
    edited June 2022
    K Pease said:
    If we are to take terminology from metal type, it should be called the body.
    The reason I'm asking this is that in Japanese typesetting, there is a thing called 仮想ボディ (kasō bodi, "imaginary body"). I've heard of this term from a behind-the-scene video (in English) made by the type foundry Morisawa. The reason it's called "body" (the Japanese term is borrowed straight from English) is because, like you said, metal sorts did have bodies. Japanese typefaces, when it comes to CJK characters, are strictly monospace, so this so-called "imaginary body" is always a square with the dimension equal to 1em in all fonts, and it seems a lot like the concept of the em square. This makes "imaginary body" seem suspiciously generic, unlike than the specific "body" of, say, a very narrow letter i in the Latin alphabet. If you open a Japanese font or any East Asian font for that matter, you'll see the widths of all CJK characters conform to exactly 1em, while the widths of non-CJK characters are proportional. Because of this, I'm not 100% sure if "imaginary body" also applies to proportional, non-CJK characters, given that in my Google research, I haven't found any illustration for "imaginary body" that is specifcally about those characters, especially in Western text. It doesn't help that the translation "imaginary body" used by Morisawa doesn't seem to be genuinely in use in English sources. Adobe, for instance, translates it as "embox", which makes it sound even more like "em square".
    K Pease said:
    The vertical metrics are not "bearings" per se and they don't work in the same way.
    I'm not sure if "bearing" is the best term, but the "top side bearing" and the "bottom side bearing", in vertical text, work exactly the same as the left side bearing and the right side bearing in horizontal text. For instance, one thing you can do is use something call ツメ (tsume, "fitting" or "packing"), by reducing the spacing between glyphs based on percentages of their side bearings. Whether you use left/right bearings in horizontal text or top/bottom bearings in vertical text, the result is exactly the same.

    Notice in this illustration, the vertical text is much more cramped than the horizontal one. This is all because of the character 一 (in red): it has very little space for its horizontal bearings, but lots of space for its vertical bearings. All that space is completely collapsed here with tsume set at 100%, meaning 100% of all bearings is discarded.
  • Bounding box, abbreviated bbox, is used in image processing for a simple geometric hull in the shape of a rectangle parallel to the coordinate system of the background ("canvas").

    It should be used only in this meaning to avoid confusion.


  • K PeaseK Pease Posts: 182
    I see, that makes sense. Having a strictly left-to-right script with ascenders, descenders, and diacritics makes our ideas of a font's full vertical dimension much more unclear, which is why digital type contains multiple values for vertical metrics that do not necessarily agree with one another, made to accommodate different computer systems and subsystems.
    I was surprised by your example of tsume, because one thing I thought I had learned from my extremely brief experience with setting Japanese was that the 一 character was supposed to be turned to a vertical line in vertical text. Is that not true?

  • arrybarryarrybarry Posts: 4
    K Pease said:
    the 一 character was supposed to be turned to a vertical line in vertical text. Is that not true?

    No, it's a Han character, and Han characters never change their rotation. It's actually the character ー, or chōonpu, that rotates. These two characters look almost indistinguishable in a Gothic/sans-serif font in horizontal text, but they look very different in a serif font or in vertical text.

  • John HudsonJohn Hudson Posts: 2,955
    edited June 2022
    @K Pease
    If we are to take terminology from metal type, it should be called the body. Otherwise, I think there isn't a term because the idea is not particularly meaningful. The vertical metrics are not "bearings" per se and they don't work in the same way.

    In a key and specific sense, body height works exactly the same way in metal type and digital type, in that it is the height of the body that equals the nominal size of the type. So 10pt metal type has a body that measures 10 points in height, regardless of the size of the character image on that body, and 10pt digital type has a body that has been scaled to 10 points in height, regardless of the size of the glyph relative to that body.

    So I still refer to the rectangle defined by left sidebearing and advance width and by em height as the ‘body’.
  • Ruixi ZhangRuixi Zhang Posts: 29
    edited June 2022
    Yehang Yin posted an excerpt from 《排版知识问答》(Typography Q&A’s, by 罗树宝, 1987) in this twitter thread:
    Although this particular Q&A is on “kerns” (in metal types), the first sentence in the answer actually reads “the form of a [metal] type in which the strokes [of the letter] protrude the body is called a kerned type.” The word 字身 means literally “character body”. The illustration shows an italic lowercase f, which is clearly proportional-spaced. The “kerns” in metal types are somewhat equivalent to “negative side-bearings” in digital types. So, the rectangle that includes side-bearings (even if they are negative) is indeed called “body”.
    In proportional Latin (metal) types, the width of each letter differs, but the height of the body on which each letter is casted remains constant—this height equals 1em. It is actually very common for the baseline to vary within the body, between typefaces of the same size. This agrees with John’s terminology.
    “Bounding box” usually refers to the minimum rectangle that covers the “ink” of the letter, so to speak. For letters that have positive side-bearings on all four sides, their bounding boxes will be completely inside their bodies. Stacked accents on uppercase or fancy swash in italic can protrude the body, on any sides, so these will have bounding boxes that also protrude the bodies.
  • K Pease said:
    […] the 一 character was supposed to be turned to a vertical line in vertical text.
    arrybarry said:
    It's actually the character ー, or chōonpu, that rotates.
    The first character 一 (U+4E00, “one”) is an ideograph, and it stays upright in vertical text. The second character ー (U+30FC, prolonged sound mark) is a kana, and it becomes a vertical line in vertical text. The latter, however, doesn’t really “rotate” though.
    U30FC in horizontal and vertical text
    The constructions of U+30FC in the Mincho style follow ink brush calligraphy in horizontal and vertical text—how one would actually write it. They are not simply 90-degree rotations of each other.
    Bounding box typically refers to the smallest rectangle that contains all of the glyphs control points.
    This generally yields an overly large rectangle (see the following illustration on the left), which is usually unintended. Bounding box covers the curve, not necessarily the curve’s control points (illustration on the right).
    Bounding box does not necessarily cover control points
    Source: tikz-bbox manual.
  • arrybarryarrybarry Posts: 4
    Ruixi Zhang said:The constructions of U+30FC in the Mincho style follow ink brush calligraphy in horizontal and vertical text—how one would actually write it. 
    I never paid that close attention but it makes total sense. When you write with a brush you almost always start from the left, not right.
  • Craig EliasonCraig Eliason Posts: 1,397
    Bounding box typically refers to the smallest rectangle that contains all of the glyphs control points.
    This generally yields an overly large rectangle (see the following illustration on the left), which is usually unintended. Bounding box covers the curve, not necessarily the curve’s control points (illustration on the right).
    Bounding box does not necessarily cover control points
    Source: tikz-bbox manual.
    For what it's worth, if that curve had nodes at the horizontal and vertical extrema (common and recommended practice), all would fit inside that box on the right.
  • From the OT spec:
    "Note that the bounding rectangle from each character is defined as the rectangle with a lower left corner of (xMin, yMin) and an upper right corner of (xMax, yMax). These values are obtained directly from the point coordinate data for the glyph, comparing all on-curve and off-curve points."

    That certainly doesn't ensure a box that's tight to the curve, but it's very quick to compute.
  • From the OT spec:
    "Note that the bounding rectangle from each character is defined as the rectangle with a lower left corner of (xMin, yMin) and an upper right corner of (xMax, yMax). These values are obtained directly from the point coordinate data for the glyph, comparing all on-curve and off-curve points."

    That certainly doesn't ensure a box that's tight to the curve, but it's very quick to compute.
    Shall we call such OpenType spec-complied box an “actually-implemented bounding box”, while a tight-around-curve box a “mathematically-defined bounding box”? The former is obtained by applying—in my opinion—a lazy (but fast) algorithm which simply checks all on- and off-curve points. The latter is what we really want (in determining the boundaries of an arbitrary cubic Bézier curve in 3D rendering, for instance), but it requires the algorithm to do much more work (that is, to figure out the extrema by solving a number of quadratic equations and then comparing the solutions with all on-curve points).
    For what it's worth, if that curve had nodes at the horizontal and vertical extrema (common and recommended practice), all would fit inside that box on the right.
    I always thought this recommended practice is a direct consequence of the lazy algorithm: Instead of asking engineers to implement an algorithm that is mathematically correct, we ask designers to add on-curve points at extrema and to make sure that off-curve points stay within those triangular areas.
  • An important question to consider is what the purpose is for obtaining a bounding box. For some purposes, it may or may not be worth the perf cost to calculate a tight box.
  • John HudsonJohn Hudson Posts: 2,955
    I always thought this recommended practice is a direct consequence of the lazy algorithm: Instead of asking engineers to implement an algorithm that is mathematically correct, we ask designers to add on-curve points at extrema and to make sure that off-curve points stay within those triangular areas.
    Yes, the extrema recommendation is partly to enable this quick and easy calculation of an accurate bounding box, but the other important reason for it has been hinting.
  • Nick ShinnNick Shinn Posts: 2,131
    It’s very important to have a bounding box of consistent height throughout a type family. (This may require some funny business, such as positioning a light weight cap accent higher than it really should be.)

    Two reasons for this:

    1) For consistent positioning of the baseline within a formatted text box, whatever weight or style of a typeface is used.

    2) For precise alignment of layers, in layered font effects.

    I don’t understand why the baseline isn’t used by layout apps to position type.
  • Thomas PhinneyThomas Phinney Posts: 2,731

    I don’t understand why the baseline isn’t used by layout apps to position type.

    I have never seen a layout app that did NOT use the baseline to position type, in any app that allows one to switch fonts or point sizes on the same line.

    I am sure you know this, so you must mean… something else. I am curious as to what that something else is, exactly.
  • John HudsonJohn Hudson Posts: 2,955
    I am guessing that Nick is referring to the way in which the distance of the baseline from the top of the text frame is generally determined by metrics that are not standardised across font families, and hence will vary between text frames if one inserts a character from a font with taller metrics into the top line of text.
  • Thomas PhinneyThomas Phinney Posts: 2,731
    Right, that makes sense. I don’t really see a good alternative to that status quo, unless the app deals with it by reserving a really large amount of space above, or allows the text to exceed the top of the frame. I am sure both those options (and perhaps others) have been considered and discarded.
  • Nick ShinnNick Shinn Posts: 2,131
    edited June 2022
    True. But that doesn’t stop me from being uncomfortable with layout software that positions type according to a hard-to-visualize “guide line” determined by a rarely-used upper case diacritic, rather than the baseline the major letters stand upon.

    On a positive note, certain distributors, notably Adobe and Monotype, have rigorous font-testing apps applied to typeface submissions, which flag inconsistencies in vertical metrics within a font family. This addresses bounding box issues, putting the onus on foundries to “get it right”.
  • Thomas PhinneyThomas Phinney Posts: 2,731
    Nick Shinn said:
    True. But that doesn’t stop me from being uncomfortable with layout software that positions type according to a hard-to-visualize “guide line” determined by a rarely-used upper case diacritic, rather than the baseline the major letters stand upon.

    Rarely-used by us English-speakers, maybe. But since you agree that there is no viable alternative, maybe you need to get comfortable with it?

    On a positive note, certain distributors, notably Adobe and Monotype, have rigorous font-testing apps applied to typeface submissions, which flag inconsistencies in vertical metrics within a font family. This addresses bounding box issues, putting the onus on foundries to “get it right”.

    Such tests have been around a long time, and are used by many others as well. But they don’t make fonts perfectly consistent _across_ families, only within families.
  • Nick ShinnNick Shinn Posts: 2,131
    Rarely-used by us English-speakers…

    I was alluding to characters such as Aringacute.
    And Abrevehook, which is comparatively rare in Vietnamese—that is the tallest Latin character I’ve had to deal with, especially in Bold weight.

    But since you agree that there is no viable alternative, 

    I agreed with you that options had been tried and discarded, not that there is no other way to do things.
    maybe you need to get comfortable with it?

    I’m more comfortable with analogue, and software that bears some resemblance to the physical world, you’ll never get me in a VR headset!

  • John HudsonJohn Hudson Posts: 2,955
    Right, that makes sense. I don’t really see a good alternative to that status quo, unless the app deals with it by reserving a really large amount of space above, or allows the text to exceed the top of the frame. I am sure both those options (and perhaps others) have been considered and discarded.
    A lot of line layout in software is really dumb and can’t paint glyphs outside the text frame and allows subsequent lines to overwrite white space on previous lines, causing clipping if tight linespacing is used.

    InDesign has an option to define the distance from the top of the text frame in terms of leading, which gives a fixed distance to the first baseline regardless of what mix of fonts is used. That is sensible and also means that one can set up an easy text frame baseline grid (unlike the utterly annoying baseline grid that InDesign tries to apply at the document level). Of course, this presumes a line layout model that is able to handle painting glyphs that extend beyond the text frame.
  • I’ve always called this space the “window” or “glyph window.” It never occurred to me that it would have a different name, though I can’t remember ever discussing it with anyone or hearing it called something else.

  • True. But that doesn’t stop me from being uncomfortable with layout software that positions type according to a hard-to-visualize “guide line” determined by a rarely-used upper case diacritic, rather than the baseline the major letters stand upon.
    In metal type setting the printing surface can be outside the body in any direction, called undercut, overlap or kerning. We can see this in historical prints, that descenders of one line can be deeper than the top of ascenders of the next line. Or in horizontal direction descenders of Italic \f fade away (not enough pressure).

    They also had combining accents as separate characters for Hebrew and puzzled them together with non printing material. That's documented in the layouts of the wooden matrices e.g. in Gessner, 1744.

    TextEdit on Mac allows the definition of line distance and seems to add or subtract space on top of the virtual body. Vertical alinement is along the base line.

    Looks like this:


  • An important question to consider is what the purpose is for obtaining a bounding box. For some purposes, it may or may not be worth the perf cost to calculate a tight box.
    For me tight bounding boxes are important to calculate metrics of micro typography, like hight, width, density, aspect, position to the baseline, x-line, H-line, accent zone, hp-size, spacing, and at least similarity between glyphs of the same font, or between fonts.

    In image processing with rasterised images (pixels) it is simple to get a bounding box. It also can be done from a scanned page of text.
  • An important question to consider is what the purpose is for obtaining a bounding box. For some purposes, it may or may not be worth the perf cost to calculate a tight box.
    For me tight bounding boxes are important to calculate metrics of micro typography...
    Sure. There are also other kinds of processing in which that precision isn't needed.
  • Ray LarabieRay Larabie Posts: 1,376
    I call that box the metrics because it's the maximum limit of a glyph's metrics in four directions. When I'm dealing with some TV caption fonts, I keep my italics inside the metrics. Sometimes my Vietnamese cap accents go outside the metrics.
Sign In or Register to comment.