[NTG-context] square in Cambria font

Sietse Brouwer sbbrouwer at gmail.com
Wed May 1 00:17:37 CEST 2013

Hello Hans,

The bad news: I think it's the font. The good news: here comes
MetaPost to the rescue!

I don't have Cambria, so I plucked a cambria.ttf file off the Internet
somewhere, which contains both Cambria and Cambria Math. I don't know
whether you have the same file/version, so YMMV, but it does exhibit
the problem you describe.

According to the lovely and free FontForge,
* the WHITE SQUARE glyph (U+25A1) is 1060 units high
* the SQUARED PLUS glyph (U+229E) is 1630 units high (of which 230
below the baseline).

This is in Cambria Math — Cambria does does not have either of these
glyphs. I suspect the square size is a design decision: that the
designers decided they wanted the white square to match the letters
rather than the 'squared *' operators.

Anyway, here's a very close MetaPost approximation of the 'squared
plus' square, made by looking in with FontForge and copying the glyph
dimensions. (And then tweaking them because some things still didn't
look right; didn't manage to fix everything, alas.) It scales with the
font size.




    numeric u, strokewd, strokeht, sqwd, sqht;
    u        := BodyFontSize / 2083;
    strokewd := 128u;
    strokeht := 123u;
    sqwd     := 1506u;
    sqht     := 1533u;
    offset   := 200u;
    pickup pensquare xscaled strokewd yscaled strokeht;
    draw unitsquare xscaled sqwd yscaled sqht;

    setbounds currentpicture to
        boundingbox currentpicture
        leftenlarged offset rightenlarged offset;

    \lower \dimexpr \bodyfontsize / 2083 * 234

%%%% try it out %%%%


$\square+\mysquare\boxplus$ \crlf


$+ \ruledhbox{\boxplus}$  \crlf
$+ \ruledhbox{\mysquare}$ \crlf
$\ruledhbox{\boxplus}$  \crlf


More information about the ntg-context mailing list