How to deal with conextual alternatives and separator & punctuations?

Hi there! 
I'm working on a font which is based on the idea of contextual alternates. 
I'm using only the lowercase and the uppercase characters. The idea is that with stylistic set the uppercase and the lowercase letters vary cyclicly by typing only lowercase (not using the 'shift' button).

It looks like this: AaAaAaA

The problem is when there is a space (or any kind of punctuations) between two words the cycle considers the space as a letter(?). 
Looks like this: AaAaAaA AaAaAaA AaAa
What I try to do is that any time a word ends on an uppercase letter the following word should start with a lowercase, and vice versa, so start with always the opposite as the other ends, no matter how many spaces I have between the words. Like this: AaAaAaA aAaAaAa AaAa

The first code is to change the lowercase to upercase when I start typing:
   
  #lc=lowercase  UC=uppercase

  lookup x01 {
    sub @lc' by @UC; }
  x01;
 
  lookup x02 {
    sub @UC @UC' by @lc; }
  x02;

And after I couldn't figure it out how avoid the space and punctutations. 
Any idea how to tackle this question?

Comments

  • Erwin Denissen
    Erwin Denissen Posts: 302
    edited December 2017
    This should do the trick:

    script latn {<br>&nbsp; feature StandardLigatures1;<br>}<br><br>class @UC [A-Z];<br>class @lc [a-z];<br>class @SP [space comma period exclam question];<br><br>feature StandardLigatures1 liga {<br>&nbsp; lookup ChainingContext1;<br>}<br><br>lookup ChainingContext1 {<br>&nbsp; context (@lc @SP @SP) @lc;<br>&nbsp; sub 0 SingleSubstitution1;<br>&nbsp; context (@lc @SP) @lc;<br>&nbsp; sub 0 SingleSubstitution1;<br>&nbsp; context (@lc) @lc;<br>&nbsp; sub 0 SingleSubstitution1;<br>}<br><br>lookup SingleSubstitution1 {<br>&nbsp; sub @lc -> @UC;<br>}<br>

    It is in OpenType Layout Feature code as used by FontCreator, but you can easily adapt it to other code.
  • Thank you very much for your reply. 
    I'm new to coding. I tried to translate it to FontLab and Glyphs, but I need to understand some parts. Could you give me a good source where I can find explanation and a way to implement these codes into FontLab or Glyphs?
  • Bahman Eslami
    Bahman Eslami Posts: 73
    edited December 2017
    This is the code in AFDKO syntax as you would use it in Fontlab or Glyphs or Robofont.

    <code>space comma period exclam question];

    lookup ChainingContext1 {
        sub @lc @SP @SP @SP @lc' @lc by @UC;
        sub @lc @SP @SP @lc' @lc by @UC;
        sub @lc @SP @lc' @lc by @UC;
        sub @lc @lc' @lc by @UC;
        sub @lc @lc' by @UC;    
    } ChainingContext1;

    feature liga {
      lookup ChainingContext1;
    } liga;
    languagesystem DFLT dflt;<br>languagesystem latn dflt;<br><br>@UC = [A-Z];<br>@lc = [a-z];<br>@SP = [




  • Thank you so much, it works perfectly!