How to reposition character before sequence of letters?

Get help with FontCreator here. Please do not post feature requests or bug reports here.
Post Reply
Bmeister
Posts: 4
Joined: Sun Sep 02, 2018 1:24 am

How to reposition character before sequence of letters?

Post by Bmeister » Sun Sep 02, 2018 1:49 am

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

Erwin Denissen
Moderator
Moderator
Posts: 7341
Joined: Fri Oct 04, 2002 12:41 am
Location: De Bilt, The Netherlands
Contact:

Re: How to reposition character before sequence of letters?

Post by Erwin Denissen » 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?
Erwin Denissen
High-Logic
Proven Font Technology

Bmeister
Posts: 4
Joined: Sun Sep 02, 2018 1:24 am

Re: How to reposition character before sequence of letters?

Post by Bmeister » Sun Sep 02, 2018 5:29 pm

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

Erwin Denissen
Moderator
Moderator
Posts: 7341
Joined: Fri Oct 04, 2002 12:41 am
Location: De Bilt, The Netherlands
Contact:

Re: How to reposition character before sequence of letters?

Post by Erwin Denissen » 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";
}
Erwin Denissen
High-Logic
Proven Font Technology

Bmeister
Posts: 4
Joined: Sun Sep 02, 2018 1:24 am

Re: How to reposition character before sequence of letters?

Post by Bmeister » Mon Sep 03, 2018 3:49 pm

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

Erwin Denissen
Moderator
Moderator
Posts: 7341
Joined: Fri Oct 04, 2002 12:41 am
Location: De Bilt, The Netherlands
Contact:

Re: How to reposition character before sequence of letters?

Post by Erwin Denissen » Wed Sep 05, 2018 8:47 am

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 162 times
Erwin Denissen
High-Logic
Proven Font Technology

Bmeister
Posts: 4
Joined: Sun Sep 02, 2018 1:24 am

Re: How to reposition character before sequence of letters?

Post by Bmeister » Tue Sep 11, 2018 3:32 am

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!

Post Reply