Recommendations for monospaced .numr/.dnom .sups/.subs and fractions?

For a monospaced font, what are recommended ways to create fractions?

What I was originally planning:

  1. Glyphs for zero.numr through nine.numr, visually centered and spaced, appropriately. Same for .dnom glyphs.
  2. Glyphs for zero.sups through nine.sups made from components of zero.numr through nine.numr. Same for .subs and .dnom, perhaps. Similar for .sinf, adjusting vertical positioning.
  3. Fraction glyph, appropriately angled and centered.
  4. Build fraction glyphs such as onequarter, fiveeighths, etc. from components, keeping within the monospaced width.
  5. Use OpenType frac feature to build additional fractions (with single digit for numeral and denominator) on the fly that aren’t prebuilt, when feature is enabled.

Since this is a monospaced font, all of the glyphs have the same width (600).

For building a glyph like fiveeighths, one way seems to be:

  1. create the five.numr, fraction, and eight.dnom glyphs,
  2. add glyph fiveeighths (which creates a glyph (1800 width) of those three components,
  3. disable automatic alignment for each component by right (control-) clicking on each component and selecting,
  4. then move the five.numr and eight.dnom to appropriate spots.

For the frac feature side, since the glyphs are mostly visually centered, I assume I’ll need to play with OpenType positioning.

If this weren’t a monospaced font, I’d probably consider adjusting side bearings on the fraction glyph, perhaps kern the fraction and .numr/.dnom glyphs.

What do others do or recommend? Thanks.

One idea: you can use the afrc feature for the precomposed fractions. This way you could keep them at 600 and perhaps design them as nut fractions.

Set up the dnom and numr figures as you said.

Then add classes for dnom and numr contain each.

Then add a kern feature containing this:
pos @numr’ fraction <-120 0 -600 0>;
pos fraction @dnom’ <-480 0 -600 0>;

You need to add at least one regular kerning pair. This is a bug that I will fix with the next update. And the manual kerning feature only works in the version 1.3.19.

Export your font and test the fractions. The preview in Glyphs will not work.

Thanks, Georg. I’ll look into that idea, too.

One possible bug I noticed: if one has both .subs and .sinf glyphs, automatic feature generation puts both in the sinf feature. If you have, for example, zero.subs and zero.sinf, then the feature won’t compile since there would be two substitution lines:

sub zero by zero.sinf;
sub zero by zero.subs;

in the same feature. For now, I just disable automatic generation for that feature and remove the extraneous .subs substitutions.

The reasoning for having both .subs and .sinf glyphs.
.subs sit on the baseline for shilling fractions.
.sinf are shifted further below for scientific use, etc.

fyi.

It would be lovely if Mekka or Georg or somebody who knows Python would automate this boring part of the process.

…or if the Make Component command would generate the fraction automatically once the fraction glyph is created.

It does that already, i.e. compose precomposed fractions from their dnom and numr parts. Does it not work for you?

.subs glyphs are supposed to go below the base line for things like H₂O. To build fractions you should use the .dnom and .numr as mekkablue suggested.

im confused, why are we adding a kerning feature to a monospaced font?

it all glyph are monospace, typed fractions would look awful wide. Then you do some positioning to make them look more compact.

Hi! I’m trying to figure out how to set up pre-composed fractions in a mono font properly. Auto compose does not work because it adds up the widths, so I thought using anchors was a way to go to, but apparently two things do not work:

  1. with top and bottom anchors, it ignores both. So instead of giving the choice of the anchor, it auto aligns as if there are no anchors.
  2. one.numr, being a component of one.dnom, does not inherit the anchors at all. I guess I could use only dnoms, but see problem 1.

Is that expected? Is that not how you’d do it?
Version 3220.
mono fractions.glyphs (4.9 KB)

Anchors are not helping here.
I would move the numerators to the left and the denominators to the right. Then change the component order to one.numr fraction two.dnom and add kerning of -600 between the numerators and the fraction and the fraction and denominators.
Have a look at the file:
mono fractions.glyphs (4.9 KB)

1 Like

Thank you! Are there any potential problems with the glyphs not being centered though?

Still curious why anchors don’t work here — wasn’t a choice between two anchors allowed, or am I missing some difference here?

who says that they need to be centered?