Figures: fractions
Add numerators, denominators and a fraction slash to your font, and you can type any fraction you want. Neat, isn’t it? Well, you can accomplish this easily with the following step by step tutorial!
So you have nicely done all your figures. Now it is time to add fraction figures. The good thing is, you only have to draw the numerators once, and you can re-use them as your denominators. Just shift them down a bit. Let’s go through that step-by-step.
Add denominators
First, you make copies of your lining figures, e.g., by simply duplicating them with the Glyph > Duplicate Glyph command, and then changing their suffix from .001
to .dnom
with Edit > Find > Find and Replace while they are still selected. Then, scale them down. But don’t scale them down too much. Fraction figures do not need to be super-tiny. Approximately two thirds will do nicely in most cases.
If you have a Multiple Master set-up, you can make use of tools like the Scaler in Tim Ahrens’ Remix Tools for Glyphs. If you have a single-master set-up, then you can scale them down with Path> Transform, and then compensate for the loss of stroke thickness with Filter > Offset Path.
This will get you pretty far. Don’t forget to go through all of them, and fix manually what needs to be fixed. Repeat until you are satisfied.
Congratulations! Now, we have an additional set of figures: denominators!
Add numerators
On to the numerators. They should look the same as your denominators, just placed higher, usually bumped against the height of your lining figures. To achieve that, all we need to do is to create composite copies of the denominators. Choose Glyph > Add Glyphs (Cmd-Shift-G) and type (or copy and paste) this into the dialog that appears on the screen:
zero.dnom=zero.numr
one.dnom=one.numr
two.dnom=two.numr
three.dnom=three.numr
four.dnom=four.numr
five.dnom=five.numr
six.dnom=six.numr
seven.dnom=seven.numr
eight.dnom=eight.numr
nine.dnom=nine.numr
Press the Generate button, and you have numerator glyphs in your font! The only problem is, they are still hanging too low. So let’s push them upwards a bit. Make sure your numerators are selected and choose Filter > Transformations > Transform and shift them up along the y axis:
You can see a live preview in the main window, so you should be able to check right away if you have already reached an appropriate height.
Add a fraction glyph
The fraction
glyph (Unicode U+2044
) is different from the slash
. For one thing, it has negative sidebearings. So the numr
and dnom
figures can space nicely into it. Also, the thickness of the stroke is tuned towards the small figures. In most cases, that implies that the fraction
is thinner than the slash
. Finally, the fraction
usually has a much flatter angle, i.e. it is not as steep as a slash.
Type a string like /zero.numr/zero.numr/zero.numr/fraction/zero.dnom/zero.dnom/zero.dnom
and adjust your fraction
glyph to nicely reach below the numerators and above the denominators:
You may need to kern seven.numr
with fraction
, and fraction
with four.dnom
. Some designs also need a little tweaking between nine.numr
and fraction
, and fraction
and six.dnom
. Your mileage may vary.
Precomposed fractions
For backwards compatibility, you can also add precomposed fractions because some of them happen to have a Unicode. While you’re at it, you can generate them easily via the sidebar or by adding these glyphs:
onefraction onehalf zerothird onethird twothirds onequarter threequarters onefifth twofifths threefifths fourfifths onesixth fivesixths oneseventh oneeighth threeeighths fiveeighths seveneighths oneninth onetenth
Generate the feature
Now, go to File > Font Info > Features and press the Refresh button, i.e., the one with the circled arrow in the lower left corner of the window. You will notice that Glyphs automatically adds numr
, dnom
and frac
to your list of OpenType features:
Press Compile to see if your feature code is alright. If it is, you can export it to the Adobe Fonts folder and try the Fraction function in InDesign. FTW!
In a nutshell, the fraction feature does this: First, it changes all figures into numerators and slash
into fraction
. Then, it replaces any numerator following a fraction
by a denominator. Finally, it replaces any numerator following a denominator by a denominator.
The downside of this approach is that the user must specifically select the number/slash combos and activate the fraction feature. If he or she just turns it on and starts typing, all numbers are indiscriminately turned into numerators. But hey, that’s how it is implemented in most fonts.
Tal leming’s fraction fever
There’s still one more thing I’d like to point you to. If you want to overcome the shortcomings of the standard implementation with a more sophisticated frac
feature, try Tal Leming’s Fraction Fever 2, which, amongst other things, recognizes dates like ‘2012/4/12’ and excludes them from the fraction feature, and nicely renders number/fraction combos like two and a half. So, a user can always leave on the Fraction option in InDesign and just type away. The feature will figure out what to turn into a fraction and what to leave as it is.
To use the code in your font, follow these steps:
- Make sure you have these glyphs in your font:
thinspace
(likespace
, but much thinner),hyphen
,slash
- Uncheck automatic feature generation for
frac
and delete the code that is still there - Insert Tal’s code in the feature
- Replace (Cmd-F) the suffixes
.numerator
and.denominator
by.numr
and.dnom
- Remove the two lines
feature frac {
and} frac;
from the feature code
Now your fraction feature does stuff like this:
The only downside is that you can only have a pre-specified maximum number of numerators. By default, that number is ten, so you cannot type a quadrillion quintillionths. Bummer. If you didn’t understand these last sentences, or you do not care, well, never mind.
Useful scripts
In the mekkablue scripts, you will find two useful scripts:
- Features > Fraction Fever 2: builds the Fraction Fever code automatically.
- Build Glyphs > Build Small Figures: if you have (path-based) denominators on the baseline, this script helps you build all the other small figures (superiors, inferiors and numerators) as composites in one go. Read about it in [the tutorial about subscript and superscript figures], there is one section dedicated to how to use the script.
SAMPLE FONT: MARTHA, COURTESY OF LISA SCHULTZ.
Update 2013-11-13: Updated the link to Tal Leming’s blogpost about Fraction Fever 2.
Update 2020-03-25: changed title. Added Useful Scripts.
Update 2020-03-27: updated name of command Glyph > Duplicate Glyph.
Update 2022-08-02: updated title, related articles, minor formatting.