xMin, xMax, etc.

frederich's picture

Hello everyone,

I was just wondering : since xMix, xMax, yMin, and yMax in the 'glyf' table define a bounding box for glyphs, I was wondering for what size is this bounding box given ?

Let's say, if a 2000*2000 bounding box is - for example - for a 100 pt "M", then I'd like to be able to get the bounding box for another size with a rule of three.

Thanks in advance for your help and your time !


Theunis de Jong's picture

All values of this type inside a font are in 'design units' -- the 'unitsPerEm' value in Opentype font headers (other font types have a similar function defined elsewhere).

"Design units" are a virtual construct. When you start drawing characters, imagine you start with a clean square sheet of paper, and you declare up front "I'm going to draw all characters inside these boundaries." The physical size of the sheet does not matter; what does is how many units you divide it in, to be able to assign x and y coordinates to all of the individual points of your characters. The total size of your paper sheet is "one em", and the number of divisions is your "units per em" value.

(So why a separate 'bounding box'? Well, suppose you draw your average character set well inside the bounds of your em, but then you want to add one single large character that goes 'over the edge'. Of course you could throw everything away at that point and restart with a larger sheet, but at this point it's easier to step away from the "sheet" simile, and just design beyond the page boundaries. After all, it is just a virtual construct anyway.)

To know whether your example, a bounding box of 2000 × 2000 units, is "large" or "small" you need to compare it to the em square size the font was designed on. If this would be a typical Type 1 font, for example, its em square size could be 1000 units. That means that the largest character is twice as large as the em square. On the other hand, if it's a typical Truetype font, its em square size could be 2,048 units and that would make the largest character slightly smaller than a full em width.

Note that none of the above tells you anything about the size of individual characters! They could fill the em square from top to bottom, or they could be very small.

Back to your question. If you know in advance that the size of a 100 pt "M" is 2000 x 2000 design units, then you don't need to know anything else to calculate the bounding box "in units" for any other size. A 300 pt "M" will also have a bounding box of 2000 x 2000 design units. Even weirder, so will a 3 pt "M"!
That is because no matter how big or small you scale your font, design units are only virtual. If you draw a dot on your 'i' at a position of x=10,y=100 in design units and then scale that 'i' up by a factor of 2, the dot will still be at the position x=10,y=100 in design units.

So what about the physical coordinates of that dot then, on screen on or paper? Well, of course these will change when you scale up, but that has nothing to do with design units.

By way of grande finale, an answer to your question: you can scale a font size up and down until you go blue in the face, but its bounding box in design units will always stay the same.

frederich's picture

Thank you so much Theunis for your amazing explanation !

With the 'unitsPerEm' I think I'm actually getting exactly what I was looking for !

Syndicate content Syndicate content