How to reposition character before sequence of letters?

Get help with FontCreator here. Please do not post feature requests or bug reports here.
Bernie Cossentino
Posts: 65
Joined: Sun Sep 02, 2018 1:24 am

How to reposition character before sequence of letters?

Post by Bernie Cossentino »

Hello,

I'm trying to have a character reposition itself prior to a followed sequence of characters (no matter now many).

eg: Assume I've created a mark to base pairing of |^
With this pairing, I would like to be able to type in any sequence of characters before and after the ^ eg ABC ^EFG
This would then be followed by entering | (for my purposes, the | must be entered after the G)
I would want the character | to reposition itself before the ^ (as in its mark to base pairing) so that the sequence above results as ABC|^EFG

So in essence, I need to type ABC^EFG|
But need the result to display ABC|^EFG

Could someone please tell me if and how I could achieve the above with Font Creator?

Your help is very much appreciated
Font Creator 13
Windows 7 and 10 Pro
Erwin Denissen
Moderator
Moderator
Posts: 11108
Joined: Fri Oct 04, 2002 12:41 am
Location: Bilthoven, The Netherlands
Contact:

Re: How to reposition character before sequence of letters?

Post by Erwin Denissen »

It looks like something that isn't meant to happen, but if it can be done with OpenType layout feature code, then I'm sure it can be done with FontCreator.

Why would you like to reorder?
Erwin Denissen
High-Logic
Proven Font Technology
Bernie Cossentino
Posts: 65
Joined: Sun Sep 02, 2018 1:24 am

Re: How to reposition character before sequence of letters?

Post by Bernie Cossentino »

Erwin Denissen wrote: Sun Sep 02, 2018 4:06 pm It looks like something that isn't meant to happen, but if it can be done with OpenType layout feature code, then I'm sure it can be done with FontCreator.

Why would you like to reorder?
Hi,

Thanks for your reply.

I'm trying to define a rule whereby, if a ^ appears within a sequence of text, then place the | next to it (as in its mark to base setting)...no matter what letters follow.
So, for example. If I were to type ABCEFG|, then the | remains where it is and the rule would not apply. However, if I were to type ABC^EFG|, then I would need a rule to reposition (kern?) the | next to the ^ so that it displays ABC^|EFG. This is needed because the program I'm working with requires that the | character be typed last. The program needs to think the | character is last in the typing sequence. Yet I need it to display as stated above.

How would one approach this in Font Creator? I know it needs to be done in the open type designer, and I'm guessing maybe chained context positioning has something to do with it, although I'm not sure how to use this feature properly. The manual doesn't explain much here.

Appreciate your feedback
Font Creator 13
Windows 7 and 10 Pro
Erwin Denissen
Moderator
Moderator
Posts: 11108
Joined: Fri Oct 04, 2002 12:41 am
Location: Bilthoven, The Netherlands
Contact:

Re: How to reposition character before sequence of letters?

Post by Erwin Denissen »

Given that your software supports OpenType layout features, this might work:

Code: Select all

script latn {
  feature ContextualAlternates;
}

feature ContextualAlternates calt {
  lookup ChainingContextReposition;
}

lookup ChainingContextReposition {
  context (A B C) asciicircum E F G bar;
  sub 0 MultipleSubstitutionCopy;
  sub 5 SingleSubstitutionHide;
}

lookup MultipleSubstitutionCopy {
  sub asciicircum -> asciicircum bar;
}

lookup SingleSubstitutionHide {
  sub bar -> ".null";
}
Erwin Denissen
High-Logic
Proven Font Technology
Bernie Cossentino
Posts: 65
Joined: Sun Sep 02, 2018 1:24 am

Re: How to reposition character before sequence of letters?

Post by Bernie Cossentino »

Erwin Denissen wrote: Mon Sep 03, 2018 12:20 pm Given that your software supports OpenType layout features, this might work:

Code: Select all

script latn {
  feature ContextualAlternates;
}

feature ContextualAlternates calt {
  lookup ChainingContextReposition;
}

lookup ChainingContextReposition {
  context (A B C) asciicircum E F G bar;
  sub 0 MultipleSubstitutionCopy;
  sub 5 SingleSubstitutionHide;
}

lookup MultipleSubstitutionCopy {
  sub asciicircum -> asciicircum bar;
}

lookup SingleSubstitutionHide {
  sub bar -> ".null";
}
Hello,

Thanks once again for your reply.

I don't quite understand what all this code means or where I need to put it. I thought the solution could be achieved with the graphical interface within Font Creator?
In any case, if I'm understanding what your code says to some extent, are you specifying a particular context of characters (i.e. ABCEFG)? I don't want to filter particular characters for this to work. Only to specify that whenever a ^ is among the sequence of any set of characters, that the | be positioned beside it.

I apologize if I didn't make this clear.

Thank you once again
Font Creator 13
Windows 7 and 10 Pro
Erwin Denissen
Moderator
Moderator
Posts: 11108
Joined: Fri Oct 04, 2002 12:41 am
Location: Bilthoven, The Netherlands
Contact:

Re: How to reposition character before sequence of letters?

Post by Erwin Denissen »

Here is some more complex code that should do it, but unfortunately it isn't working within the OpenType Designer preview.

It uses (the undocumented :oops: ) class0 which is a special class that contains all glyphs except the ones used within the context.

Code: Select all

script latn {
  feature ContextualAlternates;
}

feature ContextualAlternates calt {
  lookup ChainingContextReposition;
}

lookup ChainingContextReposition {
  context (A B C) asciicircum @class0 @class0 @class0 bar;
  sub 0 MultipleSubstitutionCopy;
  sub 5 SingleSubstitutionHide;
}

lookup MultipleSubstitutionCopy {
  sub asciicircum -> asciicircum bar;
}

lookup SingleSubstitutionHide {
  sub bar -> ".null";
}
So here class0 is all glyphs except asciicircum and bar. So
^EF|| won't work, but ^EFQ| will work.

You can use the Code Editor button at the bottom of the OpenType Designer to use this code. It will then be shown visually, it is just an easy way to exchange OpenType layout feature code.
class0.png
class0.png (52.37 KiB) Viewed 8265 times
Erwin Denissen
High-Logic
Proven Font Technology
Bernie Cossentino
Posts: 65
Joined: Sun Sep 02, 2018 1:24 am

Re: How to reposition character before sequence of letters?

Post by Bernie Cossentino »

Thank you for all your help.
Although I tried entering your code, it didn't work somehow.

Strangely, I did succeed in getting what I needed through a simple multiple substitution (at least within Font Creator itself). Sadly though, my application doesn't recognize anything within a gsub table.
Can what I'm looking for be done with just the gpos method? Through chained context positioning? If so, what does this look in the designer window?

Again, thank you kindly!
Font Creator 13
Windows 7 and 10 Pro
Bernie Cossentino
Posts: 65
Joined: Sun Sep 02, 2018 1:24 am

Re: How to reposition character before sequence of letters?

Post by Bernie Cossentino »

I believe I've found the solution to my problem through the use of chained context positioning and simply substituting single glyph adjustments.
However, while the exported font with these settings works well on Windows, it's not properly recognized on Mac.

Is there a program setting I need to check so that the Mac platform will recognize these subs properly?

Thank you kindly
Font Creator 13
Windows 7 and 10 Pro
Bernie Cossentino
Posts: 65
Joined: Sun Sep 02, 2018 1:24 am

Re: How to reposition character before sequence of letters?

Post by Bernie Cossentino »

Bmeister wrote: Mon Sep 24, 2018 10:37 pm I believe I've found the solution to my problem through the use of chained context positioning and simply substituting single glyph adjustments.
However, while the exported font with these settings works well on Windows, it's not properly recognized on Mac.

Is there a program setting I need to check so that the Mac platform will recognize these subs properly?

Thank you kindly
Problem solved.
For those who wish to know, I had set the contextual positioning with ss01 tags. These needed to be calt instead. These now work on both Windows and Mac.

Thank you all for reading.
Font Creator 13
Windows 7 and 10 Pro
Bernie Cossentino
Posts: 65
Joined: Sun Sep 02, 2018 1:24 am

Re: How to reposition character(s) in a sequence?

Post by Bernie Cossentino »

Hello again,

I've removed my previous post as I think I found a way of getting the results I'm after.
The attached image below is part of a script I'm testing.

I'm looking for a way to condense it. Particularly, I'm trying to reduce the number of multiple subs I have to address the letters following the bar, as I'll need to add several more letter combinations here (not just the three ABC caps abc smalls in my script). I tried combining classes, but the results were negative. Please take a look at the script below. I welcome your comments on whether, if and how, the code can be condensed.

Many thanks

Code: Select all

script latn {
  feature StandardLigatures1;
  feature CursivePositioning1;
}

class @numbers [zero-nine];
class @ABC [A-C];
class @abc [a-c];

feature StandardLigatures1 liga {
  lookup ChainingContext1;
}

feature CursivePositioning1 curs {
  lookup SingleAdjustment1;
  lookup ChainedContextPositioning1;
  lookup CursiveAttachment1;
  lookup CursiveAttachment2;
}

lookup ChainingContext1 {
  context parenleft @numbers @numbers parenright bar A a;
  sub 0 MultipleSubstitution_Aa;
  sub 7 Ligature1;
  context parenleft @numbers @numbers parenright bar A b;
  sub 0 MultipleSubstitution_Ab;
  sub 7 Ligature2;
  context parenleft @numbers @numbers parenright bar A c;
  sub 0 MultipleSubstitution_Ac;
  sub 7 Ligature3;
  context parenleft @numbers @numbers parenright bar B a;
  sub 0 MultipleSubstitution_Ba;
  sub 7 Ligature1;
  context parenleft @numbers @numbers parenright bar B b;
  sub 0 MultipleSubstitution_Bb;
  sub 7 Ligature2;
  context parenleft @numbers @numbers parenright bar B c;
  sub 0 MultipleSubstitution_Bc;
  sub 7 Ligature3;
  context parenleft @numbers @numbers parenright bar C a;
  sub 0 MultipleSubstitution_Ca;
  sub 7 Ligature1;
  context parenleft @numbers @numbers parenright bar C b;
  sub 0 MultipleSubstitution_Cb;
  sub 7 Ligature2;
  context parenleft @numbers @numbers parenright bar C c;
  sub 0 MultipleSubstitution_Cc;
  sub 7 Ligature3;
}

lookup MultipleSubstitution_Aa {
  sub parenleft -> bar A a parenleft;
}

lookup MultipleSubstitution_Ab {
  sub parenleft -> bar A b parenleft;
}

lookup MultipleSubstitution_Ac {
  sub parenleft -> bar A c parenleft;
}

lookup MultipleSubstitution_Ba {
  sub parenleft -> bar B a parenleft;
}

lookup MultipleSubstitution_Bb {
  sub parenleft -> bar B b parenleft;
}

lookup MultipleSubstitution_Bc {
  sub parenleft -> bar B c parenleft;
}

lookup MultipleSubstitution_Ca {
  sub parenleft -> bar C a parenleft;
}

lookup MultipleSubstitution_Cb {
  sub parenleft -> bar C b parenleft;
}

lookup MultipleSubstitution_Cc {
  sub parenleft -> bar C c parenleft;
}

lookup Ligature1 {
  sub bar @ABC a -> ".null";
}

lookup Ligature2 {
  sub bar @ABC b -> ".null";
}

lookup Ligature3 {
  sub bar @ABC c -> ".null";
}

lookup SingleAdjustment1 {
  pos bar <250 -2200 0 0>;
}

lookup ChainedContextPositioning1 {
  context (@abc) parenleft;
  sub 0 SingleAdjustment2;
}

lookup CursiveAttachment1 {
  cursive A entry -700 400;
  cursive B entry -700 400;
  cursive C entry -700 400;
  cursive bar exit 0 0;
}

lookup CursiveAttachment2 {
  cursive a entry -1300 0;
  cursive b entry -1300 0;
  cursive c entry -1300 0;
  cursive A exit 0 0;
  cursive B exit 0 0;
  cursive C exit 0 0;
}

lookup SingleAdjustment2 {
  pos parenleft <-3250 0 -3250 0>;
}
Attachments
BM test multiple sub.PNG
BM test multiple sub.PNG (8.4 KiB) Viewed 7413 times
Font Creator 13
Windows 7 and 10 Pro
Bernie Cossentino
Posts: 65
Joined: Sun Sep 02, 2018 1:24 am

Re: How to reposition character before sequence of letters?

Post by Bernie Cossentino »

Hello,

So, I attempted to condense my ligature code from my previous post above.

Font creator's Open Type designer window appears to show and render the code as functional.

Font Creator preview.PNG
Font Creator preview.PNG (10.03 KiB) Viewed 7376 times

Yet, when I tested the font as a web font (in Firefox), it shows an error (the last 3 characters in each string should be hidden).
Is Font Creator's inability to show it correctly a bug?

Firefox preview.PNG
Firefox preview.PNG (7.89 KiB) Viewed 7376 times

I'll have to assume the web preview is correct, as testing the font in my application reveals the same results.
Can anyone help me as to why the Ligature1 lookup in my code (below) doesn't work?

Thank you for reading

Code: Select all

script latn {
  feature StandardLigatures1;
  feature CursivePositioning1;
}

class @numbers [zero-nine];
class @ABC [A-C];
class @abc [a-c];

feature StandardLigatures1 liga {
  lookup ChainingContext1;
}

feature CursivePositioning1 curs {
  lookup SingleAdjustment1;
  lookup ChainedContextPositioning1;
  lookup CursiveAttachment1;
  lookup CursiveAttachment2;
}

lookup ChainingContext1 {
  context parenleft @numbers @numbers parenright bar A a;
  sub 0 MultipleSubstitution_Aa;
  sub 7 Ligature1;
  context parenleft @numbers @numbers parenright bar A b;
  sub 0 MultipleSubstitution_Ab;
  sub 7 Ligature1;
  context parenleft @numbers @numbers parenright bar A c;
  sub 0 MultipleSubstitution_Ac;
  sub 7 Ligature1;
  context parenleft @numbers @numbers parenright bar B a;
  sub 0 MultipleSubstitution_Ba;
  sub 7 Ligature1;
  context parenleft @numbers @numbers parenright bar B b;
  sub 0 MultipleSubstitution_Bb;
  sub 7 Ligature1;
  context parenleft @numbers @numbers parenright bar B c;
  sub 0 MultipleSubstitution_Bc;
  sub 7 Ligature1;
  context parenleft @numbers @numbers parenright bar C a;
  sub 0 MultipleSubstitution_Ca;
  sub 7 Ligature1;
  context parenleft @numbers @numbers parenright bar C b;
  sub 0 MultipleSubstitution_Cb;
  sub 7 Ligature1;
  context parenleft @numbers @numbers parenright bar C c;
  sub 0 MultipleSubstitution_Cc;
  sub 7 Ligature1;
}

lookup MultipleSubstitution_Aa {
  sub parenleft -> bar A a parenleft;
}

lookup MultipleSubstitution_Ab {
  sub parenleft -> bar A b parenleft;
}

lookup MultipleSubstitution_Ac {
  sub parenleft -> bar A c parenleft;
}

lookup MultipleSubstitution_Ba {
  sub parenleft -> bar B a parenleft;
}

lookup MultipleSubstitution_Bb {
  sub parenleft -> bar B b parenleft;
}

lookup MultipleSubstitution_Bc {
  sub parenleft -> bar B c parenleft;
}

lookup MultipleSubstitution_Ca {
  sub parenleft -> bar C a parenleft;
}

lookup MultipleSubstitution_Cb {
  sub parenleft -> bar C b parenleft;
}

lookup MultipleSubstitution_Cc {
  sub parenleft -> bar C c parenleft;
}

lookup Ligature1 {
  sub bar @ABC @abc -> ".null";
}

lookup SingleAdjustment1 {
  pos bar <250 -2200 0 0>;
}

lookup ChainedContextPositioning1 {
  context (@abc) parenleft;
  sub 0 SingleAdjustment2;
}

lookup CursiveAttachment1 {
  cursive A entry -700 400;
  cursive B entry -700 400;
  cursive C entry -700 400;
  cursive bar exit 0 0;
}

lookup CursiveAttachment2 {
  cursive a entry -1300 0;
  cursive b entry -1300 0;
  cursive c entry -1300 0;
  cursive A exit 0 0;
  cursive B exit 0 0;
  cursive C exit 0 0;
}

lookup SingleAdjustment2 {
  pos parenleft <-3250 0 -3250 0>;
}
Font Creator 13
Windows 7 and 10 Pro
Erwin Denissen
Moderator
Moderator
Posts: 11108
Joined: Fri Oct 04, 2002 12:41 am
Location: Bilthoven, The Netherlands
Contact:

Re: How to reposition character before sequence of letters?

Post by Erwin Denissen »

When I test the initial feature code with another font, it seems to work just fine in Firefox. I'll run another test with the updated code.
Erwin Denissen
High-Logic
Proven Font Technology
Erwin Denissen
Moderator
Moderator
Posts: 11108
Joined: Fri Oct 04, 2002 12:41 am
Location: Bilthoven, The Netherlands
Contact:

Re: How to reposition character before sequence of letters?

Post by Erwin Denissen »

It is a bug because we try to make FontCreator more flexible than the specs allow.

In the final font classes within a ligature item are not allowed. Right now FontCreator will store it as one item. For example
sub bar @ABC @abc -> ".null";
will end up in the font as:
sub bar A a -> ".null";

We'll have this fixed with the next upcoming release.

For now you'll have to provide the individual items:
lookup Ligature1 {
sub bar A a -> ".null";
sub bar A b -> ".null";
sub bar A c -> ".null";
sub bar B a -> ".null";
sub bar B b -> ".null";
sub bar B c -> ".null";
sub bar C a -> ".null";
sub bar C b -> ".null";
sub bar C c -> ".null";
}
Erwin Denissen
High-Logic
Proven Font Technology
Bernie Cossentino
Posts: 65
Joined: Sun Sep 02, 2018 1:24 am

Re: How to reposition character before sequence of letters?

Post by Bernie Cossentino »

Erwin Denissen wrote: Fri Dec 14, 2018 8:56 am It is a bug because we try to make FontCreator more flexible than the specs allow.

In the final font classes within a ligature item are not allowed. Right now FontCreator will store it as one item. For example
sub bar @ABC @abc -> ".null";
will end up in the font as:
sub bar A a -> ".null";

We'll have this fixed with the next upcoming release.

For now you'll have to provide the individual items:
lookup Ligature1 {
sub bar A a -> ".null";
sub bar A b -> ".null";
sub bar A c -> ".null";
sub bar B a -> ".null";
sub bar B b -> ".null";
sub bar B c -> ".null";
sub bar C a -> ".null";
sub bar C b -> ".null";
sub bar C c -> ".null";
}
Thanks for your reply. But I must say this news is very discouraging. Seems like a significant program bug to me.
My target font (stemming from the test above) would have to contain over 80 "individual" sub entries for the ligature lookup instead of just one (when using classes).

How soon is the upcoming release?
Font Creator 13
Windows 7 and 10 Pro
Bernie Cossentino
Posts: 65
Joined: Sun Sep 02, 2018 1:24 am

Re: How to reposition character before sequence of letters?

Post by Bernie Cossentino »

Hello again,

Thank you for your help on this font. I've got things working the way I need it. In essence, introducing the bar places it and characters following it below the baseline. However, I'm trying to add an additional function to have all output (with and without bar) to always rest above the baseline (as in the mock-up below). Based on the script I've submitted above, is this possible?

above baseline.png
above baseline.png (7.49 KiB) Viewed 7187 times

I've asked this question on another typography forum but have not gotten any replies. So I apologize for asking the same here.

Appreciate your thoughts.
Font Creator 13
Windows 7 and 10 Pro
Post Reply