proper implementation of numr and dnom OpenType features

ahleman
20.Mar.2007 6.30pm
ahleman's picture

Greetings. I can’t seem to get the typophile search function to work, or I probably would have already found the answer to my question. It also doesn’t appear to be in the Fontlab 4.6 manual.

Can anyone show me an example of proper implementation of the numr and dnom OpenType features? I can get the frac feature to do basic substitutions for the standard set of fractions, but it seems that the frac feature can call the numr and dnom features, but I haven’t seen anywhere a specific example of how to make that work. I’d be most grateful for some insight into that mysterious process.

Below is the code I’m currently using to get the frac feature to work, in case it gives you some idea where I’m at.

feature frac {
sub [one one.lnum] [slash fraction] [two two.lnum] by onehalf;
sub [one one.lnum] [slash fraction] [four four.lnum] by onequarter;
sub [one one.lnum] [slash fraction] [three three.lnum] by onethird;
sub [one one.lnum] [slash fraction] [eight eight.lnum] by oneeighth;
sub [two two.lnum] [slash fraction] [three three.lnum] by twothirds;
sub [three three.lnum] [slash fraction] [four four.lnum] by threequarters;
sub [three three.lnum] [slash fraction] [eight eight.lnum] by threeeighths;
sub [five five.lnum] [slash fraction] [eight eight.lnum] by fiveeighths;
sub [seven seven.lnum] [slash fraction] [eight eight.lnum] by seveneighths;
} frac;



Christopher Slye
21.Mar.2007 11.01pm
Christopher Slye's picture

Hi Andrew. I’m a little confused by your message. I don’t think you want to try to call ’numr’ and ’dnom’ with ’frac’ — at least for simple, prebuilt fractions like in your example. Your code seems fine for what you’re trying to do.

It can be useful to “call” the ’numr’ feature in ’frac’ with arbitrary fractions. This is an example of what I mean:

feature frac {
lookup NUMR;
sub [@SLASH @FIG_DENOMINATOR] @FIG_NUMERATOR' by @FIG_DENOMINATOR;
} frac;

The ’numr’ and ’dnom’ features are starting to look unnecessary, since there is usually little reason to create numerators or denominators without creating a whole fraction — which is what ’frac’ does all by itself. So I recommend putting ’numr’ and ’dnom’ in fonts, but not consider them components or “sub-features” of ’frac’.


John Hudson
22.Mar.2007 11.55pm
John Hudson's picture

but it seems that the frac feature can call the numr and dnom features

The official feature descriptions are a bit confusing in this regard. When Adobe first registered the frac, numr and dnom features, they had this idea that frac would ’call’ the other two features. And this combination of features would allow for arbitrary fractions. As I understand it, the idea was that the application or layout engine would perform the feature calls to the numr and dnom features, based on a character level analysis (numerals before the slash get the numr feature applied to them, numerals after the slash get the denominator feature applied to them). But no one had got around to implementing this in a layout engine by the time I came along with a scheme building arbitrary fractions contextually, directly within the frac feature. Which is what pretty much everyone has been doing ever since.

I believe Adobe make the arbitrary fraction code available with the FDK.


Nick Shinn
23.Mar.2007 7.46am
Nick Shinn's picture

Doesn’t Quark do it differently?
I haven’t checked this recently, but I recall that in the demo of Quark 7, the fraction feature was ignored, and the fractions built on the fly from numr, fraction character, and dnom. At least that was my understanding, and I assumed it was done for backwards-compatability of older files.


Mark Simonson
23.Mar.2007 8.31am
Mark Simonson's picture

The font I’m working on has frac but not numr or dnom and the fraction feature works fine in Quark 7.


twardoch
23.Mar.2007 12.57pm
twardoch's picture

IMO, “numr” and “dnom” should implement simple subsitutions: digits by numerator figures in “numr” and digits by denominator figures in “dnom”. The “frac” feature can be implemented completely separately. It may or may not re-use some lookups that were also used in numr or dnom.

A.