dog dog dog

jul gordon's picture

I have a problem that was alredy discussed in the typophile forum, but the answer I found didn't work in my case.
It´s about using the calt feature to have different glyphs for each charakter. the code I used:
feature calt {
sub @default @default' by @alt1;
sub @alt1 @default' by @alt2;
sub @alt2 @default' by @alt3;

sub @default space @default' by @alt1;
sub @alt1 space @default' by @alt2;
sub @alt2 space @default' by @alt3;
} calt;


typing f.e. "dog dog dog"
gives me:
d1 o2 g3 space d1 o2 g3 space d1 o2 g3 space.
I would like it to work like this:
d1 o2 g3 space4 d5 o1 g2 space3 d4 o5 g1
I tried inserting the space character into all of the sets but that didn't work.

How does it work?

The second question I have: Now I created four opentype classes for EACH character. So I have four different glyphs for each charakter. BUT: for example for the character "e", I' d prefer to have at least six alternatives. Is there a way to do this without creating alternative glyphs for the whole set?
Thanks

mskala's picture

Most software does not treat "space" as a glyph for the purposes of substitution. If your text is "d o g space c a t", your software will probably treat that as two completely separate chunks: "d o g" and "c a t". Substitution is performed on "d o g"; substitution is performed on "c a t"; but there is no rule that gets to see both the "g" of "d o g" and the "c" of "c a t". Those two substitutions are performed completely independently. The space between the words is handled by some other mechanism - deciding where to put the words on the page - and not as a glyph passed through the substitution rules.

This kind of question comes up sometimes when people want to detect the start or end of a word; and the answer in that case is that instead of looking for a space, you need to look for the absence of a non-space. A rule that matches any "c", preceded by an "ignore" rule that matches any "c" that has a letter before it, will end up matching "c" only at the start of a word. There was some discussion of this recently on the XeTeX mailing list. Unfortunately, I don't think that that kind of solution will work for you because you want to not only match the start of the word, but also carry over state information from the previous word. I'm not sure that what you want is possible.

I suspect that you may be misusing the calt feature. As I understand it, when you have multiple forms of a glyph, those are better placed in the "salt" (stylistic alternates) feature. The calt feature is intended for substitutions that genuinely depend on context - such as "don't put two swash glyphs together in such a way that they collide."

Rules in the salt feature should produce a list of possible substitutions for each character, with "sub from". Then it is up to the software and/or the user to choose which substitution to use for each character. I don't know how that choice is made - some sources I've seen imply that the list is presented to the user to choose from, and others say that the software makes a random choice. There's some discussion of it in this document from Microsoft.

The feature file might look like this:

feature salt {
sub d from [d.1 d.2 d.3];
sub o from [o.1 o.2 o.3];
sub g from [g.1 g.2 g.3];
}

Then "d o g" might be transformed to "d3 o1 g2" or "d1 o3 g2" or any of the 25 other possibilities, with the decision either being random, cyclic, or somehow made by the user.

Nick Shinn's picture

You should make alternates for the space character, e.g. "space.1" etc.

I don't think you need so many sets of alternates.
I had put four sets of alternates in Duffy Script, for a pseudo-random effect (four sets of every character, including all punctuation, space, symbols), but subsequently reasoned that only two sets of alternates (the default and one other) might do the job, with appropriate coding, as explained in this document:

http://fontshopblog.files.wordpress.com/2011/01/fontesque_display1.pdf

mekka's picture

[deleted because of a misunderstanding, sorry]

Syndicate content Syndicate content