[OT] Any way to select line breaks?

Eimantas PaškonisEimantas Paškonis Posts: 91
edited July 2017 in Font Technology
I have a script font with three sets of contextual alternates. Everything's working fine except when two consecutive paragraphs start with the same capital letter – they're always from the default set. I tried adding /CR, /lineseparator and /paragraphseparator to the code but it didn't do anything.
Tagged:

Comments

  • André G. IsaakAndré G. Isaak Posts: 626
    edited July 2017
    It's not clear from your question, but I'm assuming that when you say you have three sets of alternates that your code tries to rotate through these? Correct?

    There's no way to reference a carriage return since that's going to define a new text run. If you want to avoid having the same character at the beginning of successive characters about the only way I can think of doing that is to divide the characters in your font into three sets and then do something like the following:

    sub A' @AllCharacters @AllCharacters&nbsp;@AllCharacters&nbsp;@Set1 by A.1;<br>sub A' @AllCharacters&nbsp;@AllCharacters&nbsp;@AllCharacters&nbsp;@Set2 by A.2;<br>sub A' @AllCharacters&nbsp;@AllCharacters&nbsp;@AllCharacters&nbsp;@Set3 by A.3;
    
    ... additional 'calt' code

    That will select an alternate based on the fifth character in the paragraph (I chose the 5th character over the 2-4th since a substantial number of paragraphs begin with 'The ').

    André
  • André G. IsaakAndré G. Isaak Posts: 626
    edited July 2017
    P.S. You can easily refer to the beginning of a paragraph, just not to the character itself or anything from the previous paragraph.

    ignore sub @AllCharacters A;<br>sub A' by A.init;

    can be used for a paragraph-initial alternate, but it won't help with the problem you're trying to solve.

    (I bring this up only because I just spent some time fixing a font that used sub space X' by X.init for all of its word initial alternates which, of course, prevented them from being used at the beginning of a paragraph).

    André
  • Eimantas PaškonisEimantas Paškonis Posts: 91
    edited July 2017
    It's not clear from your question, but I'm assuming that when you say you have three sets of alternates that your code tries to rotate through these? Correct?
    Yes: Default + ss01 + ss02. Sets are broken into consonants and vowels.

    Is it possible to go backwards? Because both paragraphs start with the same two words. I tried but couldn't make it work. I guess one workaround would be to add a ton of @AllChars in the code so it samples not the 5th, but 15th letter or so...

    This matters because I'm doing a digitization of a lettering from a document. Its text will be inevitably typed in the font for comparison.
  • It's not possible to go backwards at the beginning of a paragraph.

    In the situation which you describe, I'd probably not worry about it in the code. My suggestion would prevent the same alternate from being used in many successive paragraphs, but not all, and the same would hold for any workable solution. You can always use the glyph palette to make your own selection in cases where your code produces undesired results

    André
  • Eimantas PaškonisEimantas Paškonis Posts: 91
    edited July 2017
    I made it work, in a messy way.

    <p><b>lookup</b> LT {<br></p><p>
    </p><p><b>sub</b> L' i e t u v o s space T a r y b a @All @All @con0 @vow0 <b>by</b> L.ss01;</p><p>
    </p><p><b>sub</b> L' i e t u v o s space T a r y b a @All @All @con0 @con0 <b>by</b> L.ss02;</p><p><br></p><p>
    </p><p><i># L_i</i></p><p>
    </p><p><b>ignore</b> <b>sub</b> @All @Uppercase i';</p><p>
    </p><p><b>sub</b> @Uppercase i' @All (x16) @con0 <b>by</b> i.ss01;</p><p>
    </p><p><b>sub</b> @Uppercase i' @All (x16) @vow0 <b>by</b> i.ss02;</p><p>
    </p><p>} LT;</p>


    My alternates are split into consonants (con0, con1, con2) and vowels. The first part checks the combination of letters following the "Lietuvos Taryba", which is reoccurring phrase throughout the document, and changes /L accordingly. Since main #calt lookup comes later, this slightly cascades the substitutions and /T changes too.

    Since I don't /L to be always followed by the default /i, I added substitution for it too, which changes sets based on a letter away from the phrase.

    Finally, I added your substitution for capitals too.

  • André G. IsaakAndré G. Isaak Posts: 626
    edited July 2017
    It seems like you're tailoring your feature to a specific text -- your code is going to become massively convoluted if you try to accommodate every desired exception in your code rather than simply touching them up in the glyph palette. OpenType code really should be used for general solutions even if they are imperfect.

    André
  • OpenType lookups cannot be sensitive to line or paragraph boundaries since there are no glyphs that correspond to these. At best, lookups can recognize the ends of runs (by the absence of any glyph), though note that runs can be affected by several things, including line breaks, bidi, styling, and script itemization. If you want an effect at the beginning or end of a paragraph, then the only way to do that would be to have a feature applied to the first or last glyph/character/cluster of the paragraph.
  • It seems like you're tailoring your feature to a specific text -- your code is going to become massively convoluted if you try to accommodate every desired exception in your code rather than simply touching them up in the glyph palette. OpenType code really should be used for general solutions even if they are imperfect.
    Can't disagree. I need it mostly for testing and knowing *how* to force it work. Probably will disable it in the final version.
Sign In or Register to comment.