Page 1 of 2

Chaining Context: Ligatures following numerals

Posted: Sun May 28, 2017 4:20 pm
by PJMiller
SHOCK ... HORROR :shock: :roll:

Ordinals and Fractions don't play well together in many other fonts including professionally designed expensive fonts which really ought to know better !!

Many of them turn all lower case text to superscript inappropriately.

I am still stumbling about in the dark with Chaining Contexts, the ones that I have so far have been experiments trying to copy what other people have done, they have worked more by trial and error than planning.

Am I right in thinking that I can get a Ligature substitution to work only if it follows a particular character (i.e. a numeral) ?

Re: Chaining Context: Ligatures following numerals

Posted: Sun May 28, 2017 4:56 pm
by Bhikkhu Pesala
PJMiller wrote:SHOCK ... HORROR :shock: :roll:

Ordinals and Fractions don't play well together in many other fonts including professionally designed expensive fonts which really ought to know better !!

Many of them turn all lower case text to superscript inappropriately.
Yes. I took the trouble to write to the developer of Open Sans about this problem, but he said that it was intentional. I don't think there is any point in adding an Ordinals feature unless it is context sensitive.
PJMiller wrote:Am I right in thinking that I can get a Ligature substitution to work only if it follows a particular character (i.e. a numeral) ?
You should be able to do something similar with ligatures that only get substituted when they follow numerals by using a chaining context.

Code: Select all

lookup Ordinals {
  context (@Ordinals) @Alphas;
  sub 0 Super;
}

Re: Chaining Context: Ligatures following numerals

Posted: Sun May 28, 2017 7:26 pm
by MikeW
When it comes right down to it, ordn shouldn't be turned on globally. It should be turned on for the run of text to which it applies.

This is easy enough to trap and apply using GREP in applications that support it like ID and conditional styles like in QXP. Same applies to both using XML & tagged text input (like most all major publishers).

Smarter application layout engines may one day arrive but I wouldn't count on it any time soon.

Even the now dead PagePlus (as regards future development) cannot fully process chaining contexts in certain OT Features. Though AD at first also failed it has been fixed as far as I have tested.

Re: Chaining Context: Ligatures following numerals

Posted: Sun May 28, 2017 7:46 pm
by Bhikkhu Pesala
MikeW wrote:When it comes right down to it, ordn shouldn't be turned on globally. It should be turned on for the run of text to which it applies.
What do you mean by "the run of text to which it applies"?

Is it not the case that ordinals are required to be used consistently through a story if they are used in one place? One would not use them in the 1st paragraph, then fail to apply them to the 2nd or later paragraphs.

Re: Chaining Context: Ligatures following numerals

Posted: Sun May 28, 2017 7:47 pm
by PJMiller
Basically I want to substitute a glyph for two letters but only after a number, simples yes ? :lol:

The question is, can I make a Ligature substitution lookup dependent upon a chaining context ?

what I have at the moment is --

Code: Select all

lookup ChainingContext2 {
  context (@th_num) @lc_alpha;
  sub 0 Ligature6;
}
Where @th_num is a list of numerals (0,4,5,6,7,8,9)
@lc_alpha is a list of all lower case letters (a -> z)
and Ligature6 is the ligature substitution table I want to activate after the numerals 0,4,5,6,7,8,9.

But it doesn't work, any ideas ? :?

Re: Chaining Context: Ligatures following numerals

Posted: Sun May 28, 2017 10:20 pm
by MikeW
Yes, makes perfect sense. I'm not at a computer at the moment but will post some code later if you would like.

Re: Chaining Context: Ligatures following numerals

Posted: Sun May 28, 2017 10:33 pm
by MikeW
Bhikkhu Pesala wrote:
MikeW wrote:When it comes right down to it, ordn shouldn't be turned on globally. It should be turned on for the run of text to which it applies.
What do you mean by "the run of text to which it applies"?

Is it not the case that ordinals are required to be used consistently through a story if they are used in one place? One would not use them in the 1st paragraph, then fail to apply them to the 2nd or later paragraphs.
Typically OT features such as fractions and ordinals are manually applied to the run of text or automated process to do so.

That layout engines have gotten better at using contextual lookups and font makers have begun taking advantage of that by writing contextual lookups that in the main work, they are not currently in widespread use for the simple fact that there can, and are, contextual circumstances where the features break. With an automated process or explicitly tagging such text runs to apply the fraction or ordinal features via character styles, this breakdown doesn't occur.

The only reason I went through the exercise of handling the medial s according to early 19th century rules was because I could write the code and,ost importantly I was in control of the layout.

Re: Chaining Context: Ligatures following numerals

Posted: Sun May 28, 2017 11:43 pm
by PJMiller
I have just done an implementation of ordinals which uses a simple brute force and ignorance approach to the problem, nothing fancy and no chained context. Just a Ligature substitution table and 20 extra composite glyphs in the font (10 for ordinary numbers and 10 for old style numbers).

This implementation works well and doesn't interfere with fractions, also fractions don't upset the ordinals. :D

No interactions as far as I can tell, but I would still like to see MikeW's code.

Re: Chaining Context: Ligatures following numerals

Posted: Sun May 28, 2017 11:55 pm
by MikeW
The ordn feature uses 5 "rules" in the chaining context...

Code: Select all

lookup ChainingContext15 {
  context (@Numerals) @ords;
  sub 0 MultipleSubstitution2;
  context (@ords2) @Numerals;
  sub 0 MultipleSubstitution3;
  context (@ords) @Numerals;
  sub 0 MultipleSubstitution3;
  context (@CG_2) @Numerals;
  sub 0 MultipleSubstitution3;
  context (@ords2) @ords;
  sub 0 MultipleSubstitution2;
}
There are 3 multiple subs for the lookups. One contains contain two classes for what should be an ordinal...

Code: Select all

class @ords [parenleft parenright plus hyphen asterisk slash a b c d e f g h i j k l m n o p q r s t u v w x y z];

class @ords2 [parenleft.sups parenright.sups plus.sups minus.sups ordtimes orddivide orda ordb ordc ordd orde ordf ordg ordh ordi ordj ordk ordl ordm ordn ordo ordp ordq ordr ords ordt ordu ordv ordw ordx ordy ordz];
One of the multiple subs uses a class with super scripted numerals and letters...

Code: Select all

class @CG_2 [zero.numr one.numr two.numr three.numr four.numr five.numr six.numr seven.numr eight.numr nine.numr orda ordb ordc ordd orde ordf ordg ordh ordi ordj ordk ordl ordm ordn ordo ordp ordq ordr ords ordt ordu ordv ordw ordx ordy ordz plus.sups minus.sups parenleft.sups parenright.sups];
All in all it works fine, but I would still turn in on in runs of applicable text rather than globally.

Re: Chaining Context: Ligatures following numerals

Posted: Mon May 29, 2017 12:02 am
by MikeW
Though I would upload the script in total. Took out the kerning though it wasn't very large.

Mike

Re: Chaining Context: Ligatures following numerals

Posted: Mon May 29, 2017 8:30 am
by PJMiller
MikeW wrote:Though I would upload the script in total. Took out the kerning though it wasn't very large.

Mike
I have looked at the code and it is good, but if you don't mind I think I will stick with my simple solution, at least I understand what is going on and there is absolutely no interaction with the fractions feature or the old style figures feature, they can appear in any order and the ordinals still work and don't cause any problems for any other feature.

Thanks anyway. :)

Re: Chaining Context: Ligatures following numerals

Posted: Mon May 29, 2017 1:34 pm
by PJMiller
Thanks to a very helpful answer by our very own Erwin, not here but on the Type Draweres forum :? I found out what I was doing wrong with the Chaining Context and fixed it.

The new version also works well with the Fractions feature and does both the English ordinals st, nd, rd, th and the spanish ordinals ­­ª º so thats that.

Thanks for the help. :D

Re: Chaining Context: Ligatures following numerals

Posted: Mon May 29, 2017 1:39 pm
by Erwin Denissen
PJMiller wrote:Thanks to a very helpful answer by our very own Erwin, not here but on the Type Draweres forum :? I found out what I was doing wrong with the Chaining Context and fixed it.

The new version also works well with the Fractions feature and does both the English ordinals st, nd, rd, th and the spanish ordinals ­­ª º so thats that.

Thanks for the help. :D
I noticed your post here and at TD, so I have to choose. I thought it would be best to show other readers at TD I know what I'm talking about.

Maybe next time allow me to have some time to reply here :wink:

And I'm glad I could help!

Re: Chaining Context: Ligatures following numerals

Posted: Mon May 29, 2017 1:50 pm
by MikeW
PJMiller wrote:
MikeW wrote:Though I would upload the script in total. Took out the kerning though it wasn't very large.

Mike
I have looked at the code and it is good, but if you don't mind I think I will stick with my simple solution, at least I understand what is going on and there is absolutely no interaction with the fractions feature or the old style figures feature, they can appear in any order and the ordinals still work and don't cause any problems for any other feature.

Thanks anyway. :)
You're welcome and no worries.

In the font that code came from, the old style numbers were the default figure style. To make it work with pnums, I just added those figures to the @numbers class. Thanks for pointing that out...

Mike

Re: Chaining Context: Ligatures following numerals

Posted: Mon May 29, 2017 1:52 pm
by MikeW
@Erwin,

I think anytime one can post an answer on a place like TD is a good thing. I thought the thread about FC in professional use was OK up until Adam gave his thoughts about the OT Designer in FC--then it was a great thread!