Danish OpenType Numerals

Frode Bo Helland's picture

I wonder, could OpenType automatically convert regular numerals to spelled-out Danish numerals without a crazy number of ligatures? Can OT do one-to-many and many-to-many?

More on the Danish counting system: http://www.olestig.dk/dansk/numbers.html

John Hudson's picture

OT does one-to-many (type 2 GSUB lookup) easily enough. In theory, it can be made to do many-to-many, but in fact this is nowhere supported in either tools or apps. So you'd probably have to do some clever contextual one-to-many substitutions. In other words, you would have to analyse the decimal positions in the number, and substitute the appropriate word for the letters in each position. So, for an English example you might have a number '625', and you would need context to isolate the initial numeral and capture that it is in the hundreds position (followed by two integers), then substitute

six -> s i x space h u n d r e d space a n d

then you would capture the 2 in the tens position:

two -> t w e n t y hyphen

and finally the five in the ones position:

five -> f i v e

The biggest risk in this kind of approach is failure of context, which means you need to carefully think through all the permutations of situations in which a number might occur. I think the feature would need to be like the 'frac' feature, i.e. explicitly applied by a user to a selected string of characters, and not the sort of feature one could safely turn on for an entire document.

Frode Bo Helland's picture

Correct me if I’m wrong, but here’s an example: The number “78” in Danish is “otteoghalvfjers”. The ordinal version (the 78th) is “otteoghalvfjerssindstyvende”. It’s a bit complicated.

(Edit: John, I wrote this before I saw your post.)

clauses's picture

He he he.

charles ellertson's picture

Nothing of substance, but the usual editorial style with English numbers spelled out does not use "and," so the replacement string would be

six -> s i x space h u n d r e d space

E.g., 625 written out is, "six hundred twenty five" ...

Frode Bo Helland's picture

Hmm, there’s the flip: In Danish it’s not “seventy-eight”, it’s “eight and seventy”.

charles ellertson's picture

There is a problem with the zero in any language -- in English, 70 is not "seventy-zero," and I'd bet in Danish, it's not "zero and seventy."

That aside, with some work, you could probably get the font to do the job, even in Danish. But if you're working on a document, it might be better to do search & replaces. If you do the work in the font, what's in the underlying document (say, the XML exported from an InDesign file...)?

John Hudson's picture

BTW, I think this is a really bad idea. 'Six hundred twenty five' is not a glyph variant of the character string '625', it is a different character string, a different convention for recording a number in writing.

Frode Bo Helland's picture

We all know it’s a bad idea, John. These are the very same people who decided to name the biggest ice flake in the world Greenland.

clauses's picture

Even back then they knew a thing or two about marketing. Tip of the helmet gentlemen.

Sindre's picture

No way, it was called Greenland (or rather Grœnland) by its first settler, the Norwegian-born Icelander Eirikr hinn rauði (Erik the Red). But it was a marketing ploy, yes.

Frode Bo Helland's picture

Thanks for clearing that up, Sindre.

hrant's picture

He was there.


Frode Bo Helland's picture

Is there a way to change the order of glyphs?

dnum {
sub @lnum' by @dnum;
sub @dnum' @dnum by @dnum_tens;
??? swap @dnum for @dnum_tens and vice versa ???

John Hudson's picture

Reordering glyphs using GSUB is a bit tricky. I do it sometimes in order to be able to ligate reordered characters in Indic fonts, but I'm never entirely comfortable doing so. You have to do it in two steps: contextually insert the new glyph where you want it, and then contextually delete the old glyph from the unwanted location. Since there are no insert/delete GSUB lookup types per se, what you need to do is first use a one-to-many lookup, and then a many-to-one lookups. So, for example, let's say I want to reorder the glyphs in the sequence ABC so that they are BAC, I would first have a lookup (VOLT syntax; sorry the Adobe stuff makes no sense to me).

A -> B A

which would result in BABC; then a second lookup something like

A B -> A

resulting in BAC.

Frode Bo Helland's picture

I can’t seem to get one-to-many working with classes.

clauses's picture

Wait, didn’t I post a comment here about how Danish cheques are formatted in the Swedish style of cardinal numbers? Or was that on twitter? I can find it neither place, so let me put it up here again for posterity’s sake: On Danish cheques, when writing out the cardinal, eg. kr. 768,32 you would write syvhundredesekstiottekronerogtretitoøre (like in Swedish common use), and not syvhundredeottetredskronerogtoogtrediveøre (like in Danish common use).

Syndicate content Syndicate content