This repository has been archived on 2025-10-02. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
inter-font/src/features/calt.fea

394 lines
13 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# -------------------------------------------------------------------------------------
# BEGIN glyph class definitions
@DASH = [
hyphen
endash
emdash
];
@DASH_CASE = [
hyphen.case
endash.case
emdash.case
];
@DASH_ANY = [ @DASH @DASH_CASE ];
# cap-height tall glyphs
@UC = [
@Uppercase
@Numeral
# punctuation
ampersand exclam exclamdbl exclamdown uni2049 question uni2047 uni2048
questiondown interrobang invertedinterrobang bar paragraph
# currency
dollar cent yen sterling florin uni20BA uni20BD euro uni20B9 tenge peseta
peso kip won lira austral hryvnia naira guarani coloncurrency cedi cruzeiro
tugrik uni20AF mill afii57636 manat rupee lari franc
# cap-tall symbols
numero triagrt triagdn triagup warningSign blackleftpointingtriangle
circleblack circlewhite
diamondblack diamondblack_x diamondwhite diamondwhite_x
sunWithRays blackSunWithRays
heartWhiteSuit heartBlackSuit heavyBlackHeart
upBlackArrow upWhiteArrow
capslock placeofinterestsign control projective option alternativekeysymbol
brokenCircleNorthWestArrow anticlockwiseOpenCircleArrow
clockwiseOpenCircleArrow
deleteleft deleteright clear ejectsymbol
# percent and fractions
onehalf onethird onequarter threequarters fivesixths onefraction seveneighths
oneeighth fiveeighths threeeighths percent perthousand pertenthousand uni214D
cadauna careof accountof addresssubject
];
# x-height tall glyphs
@LC = [
@Lowercase
];
@CASE_DELIM_L = [
braceleft braceright
bracketleft bracketright
parenleft parenright
];
@CASE_NONDELIM_L = [
at
multiply
minus
plus
plusminus
divide
equal
notequal
endash
figuredash
emdash
hyphen
bullet
openbullet
hyphenbullet
trianglebullet
blackleftbullet
blackrightbullet
blackSmallSquare
leftArrow
leftLongArrow
leftLongArrow2
leftDoubleArrow
leftLongDoubleArrow
rightArrow
rightLongArrow
rightLongArrow2
rightDoubleArrow
rightLongDoubleArrow
leftRightArrow
leftRightLongArrow
leftRightDoubleArrow
leftRightLongDoubleArrow
northEastArrow
southEastArrow
southWestArrow
northWestArrow
colon
approxequal
asciitilde
less
greater
lessequal
greaterequal
];
@CASE_L = [
@CASE_DELIM_L
@CASE_NONDELIM_L
];
@CASE_DELIM_R = [
braceleft.case braceright.case
bracketleft.case bracketright.case
parenleft.case parenright.case
];
@CASE_NONDELIM_R = [
at.case
multiply.case
minus.case
plus.case
plusminus.case
divide.case
equal.case
notequal.case
endash.case
figuredash.case
emdash.case
hyphen.case
bullet.case
openbullet.case
hyphenbullet.case
trianglebullet.case
blackleftbullet.case
blackrightbullet.case
blackSmallSquare.case
leftArrow.case
leftLongArrow.case
leftLongArrow2.case
leftDoubleArrow.case
leftLongDoubleArrow.case
rightArrow.case
rightLongArrow.case
rightLongArrow2.case
rightDoubleArrow.case
rightLongDoubleArrow.case
leftRightArrow.case
leftRightLongArrow.case
leftRightDoubleArrow.case
leftRightLongDoubleArrow.case
northEastArrow.case
southEastArrow.case
southWestArrow.case
northWestArrow.case
colon.case
approxequal.case
asciitilde.case
less.case
greater.case
lessequal.case
greaterequal.case
];
@CASE_R = [
@CASE_DELIM_R
@CASE_NONDELIM_R
];
@Punctuation = [
slash bar quoteleft quoteright quotesingle quotedbl
quotedblleft quotedblright quotedblbase quotesinglbase prime doubleprime
tripleprime quadrupleprime primerev doubleprimerev tripleprimerev primemod
doubleprimemod comma period ellipsis twodotleader semicolon underscore
asciicircum circumflex
asterisk
];
# END glyph class definitions
# -------------------------------------------------------------------------------------
# BEGIN arrow replacements
# --->
sub @DASH @DASH @DASH greater by rightLongArrow2;
sub @DASH_ANY @DASH_ANY @DASH_ANY greater.case by rightLongArrow2.case;
# -->
sub @DASH @DASH greater by rightLongArrow;
sub @DASH_ANY @DASH_ANY greater.case by rightLongArrow.case;
# [endash emdash]-> (legacy)
sub [endash emdash] greater by rightLongArrow;
sub [endash emdash endash.case emdash.case] greater.case by rightLongArrow.case;
# ->
sub hyphen greater by rightArrow;
sub [hyphen hyphen.case] greater.case by rightArrow.case;
# <---
sub less @DASH @DASH @DASH by leftLongArrow2;
sub less.case @DASH_ANY @DASH_ANY @DASH_ANY by leftLongArrow2.case;
# <--
sub less @DASH @DASH by leftLongArrow;
sub less.case @DASH_ANY @DASH_ANY by leftLongArrow.case;
# <-[endash emdash] (legacy)
sub less [endash emdash] by leftLongArrow;
sub less.case [endash emdash endash.case emdash.case] by leftLongArrow.case;
# ignore e.g. "<-3" ("less than negative")
ignore sub less' hyphen' @Numeral;
ignore sub less.case' [hyphen hyphen.case]' @Numeral;
# <-
sub less' hyphen' by leftArrow;
sub less.case' [hyphen hyphen.case]' by leftArrow.case;
# <->
sub less rightArrow by leftRightArrow; # <,->
sub [less less.case] rightArrow.case by leftRightArrow.case;
sub leftArrow greater by leftRightArrow; # <-,-
sub leftArrow.case [greater greater.case] by leftRightArrow.case;
# <-->
sub less rightLongArrow by leftRightLongArrow; # <,-->
sub [less less.case] rightLongArrow.case by leftRightLongArrow.case;
sub leftLongArrow greater by leftRightLongArrow; # <--,>
sub leftLongArrow.case [greater greater.case] by leftRightLongArrow.case;
# <=>
sub less equal greater by leftRightDoubleArrow;
sub less.case [equal equal.case] [greater greater.case] by leftRightDoubleArrow.case;
sub less equal equal greater by leftRightLongDoubleArrow;
sub less.case [equal equal.case] [equal equal.case] [greater greater.case] by leftRightLongDoubleArrow.case;
# =>
sub equal equal greater by rightLongDoubleArrow;
sub [equal equal.case] [equal equal.case] greater.case by rightLongDoubleArrow.case;
sub equal greater by rightDoubleArrow;
sub [equal equal.case] greater.case by rightDoubleArrow.case;
# <==
sub less equal equal by leftLongDoubleArrow;
sub less.case [equal equal.case] [equal equal.case] by leftLongDoubleArrow.case;
# Note: We do NOT (sub less equal by leftDoubleArrow) as that would
# interfere with "<=" (less than or equal to)
# END arrow replacements
# -------------------------------------------------------------------------------------
# BEGIN smiley
# :-)
sub colon' [ @DASH_ANY minus minus.case ] [parenright parenright.case] by colon.case;
sub [colon colon.case] hyphen' [parenright parenright.case] by hyphen.case;
sub [colon colon.case] endash' [parenright parenright.case] by endash.case;
sub [colon colon.case] emdash' [parenright parenright.case] by emdash.case;
sub [colon colon.case] [ @DASH_ANY minus minus.case ] parenright' by parenright.case;
# END smiley
# -------------------------------------------------------------------------------------
# BEGIN case
# A foo' -> A foo.case
#
# ignore subs adjacent to lower case
#
# h[1,3]
ignore sub @LC @CASE_DELIM_L @All @CASE_DELIM_L'; # h[X]
ignore sub @LC @CASE_DELIM_L @All @All @CASE_DELIM_L'; # h[XX]
ignore sub @LC @CASE_DELIM_L @All @All @All @CASE_DELIM_L'; # h[XXX]
ignore sub @LC @CASE_DELIM_L @All @All @All @All @CASE_DELIM_L'; # h[XXXX]
# x[]X
ignore sub @LC @CASE_DELIM_L @CASE_DELIM_L' @UC; # x[]X
ignore sub @LC @CASE_DELIM_L' @Whitespace @UC; # x[ X
ignore sub @LC @CASE_DELIM_L' @Whitespace @Whitespace @UC; # x[ X
ignore sub @LC @CASE_DELIM_L @CASE_DELIM_L' @Whitespace @UC; # x[] X
ignore sub @LC @CASE_DELIM_L @CASE_DELIM_L' @Whitespace @Whitespace @UC; # x[] X
ignore sub @LC @CASE_DELIM_L' @UC; # x[X
# short runs of uc-lc, e.g "(Xx)", "[xxX]"
ignore sub @CASE_DELIM_L' @UC @LC @CASE_DELIM_L; # (Xx)
ignore sub @CASE_DELIM_L' @UC @All @LC @CASE_DELIM_L; # (X.x)
ignore sub @CASE_DELIM_L @LC @UC @CASE_DELIM_L'; # (xX)
ignore sub @CASE_DELIM_L @LC @All @UC @CASE_DELIM_L'; # (x.X)
#
# e.g. "x-M"
ignore sub @LC @CASE_L'; # x-
ignore sub @LC @CASE_L @CASE_L'; # x--
ignore sub @LC @CASE_L @CASE_L @CASE_L'; # x---
# ignore sub @LC [@CASE_L @Whitespace] @CASE_L'; # x--, x -
# ignore sub @LC [@CASE_L @Whitespace] [@CASE_L @Whitespace] @CASE_L'; # x---, x --, x -, x- -
# ignore sub @LC
# [@CASE_L @Whitespace]
# [@CASE_L @Whitespace]
# [@CASE_L @Whitespace]
# @CASE_L'; # x----, x ---, x --, x -, x- --, x- -, x-- -
# ignore sub @LC
# [@CASE_L @Whitespace]
# [@CASE_L @Whitespace]
# [@CASE_L @Whitespace]
# [@CASE_L @Whitespace]
# @CASE_L'; # x----- ...
#
# e.g. "x- "
# ignore sub @LC @CASE_L' @Whitespace; # "x- "
# ignore sub @LC @CASE_L' @Whitespace @Whitespace; # "x- "
#
# e.g. "-x"
ignore sub @CASE_L' @LC; # -x
ignore sub @CASE_L' @CASE_L @LC; # --x
ignore sub @CASE_L' @CASE_L @CASE_L @LC; # ---x
# ignore sub @CASE_L @CASE_L @CASE_L @CASE_L @LC; # ----x
# ignore sub @CASE_L @CASE_L @CASE_L @CASE_L @CASE_L @LC; # -----x
#
# pairs with space, e.g. "( ) M" since we don't support subbing
# all on the left side.
ignore sub @CASE_DELIM_L @Whitespace @CASE_DELIM_L' @Whitespace [ @UC @CASE_R ];
#
# e.g. "A-", "A -", "A -"
sub [ @UC @CASE_R ] @CASE_L' by @CASE_R;
sub [ @UC @CASE_R ] @Whitespace @CASE_L' by @CASE_R;
sub [ @UC @CASE_R ] @Whitespace @Whitespace @CASE_L' by @CASE_R;
# foo' foo foo foo foo A -> foo.case foo foo foo foo A
# foo' foo foo foo A -> foo.case foo foo foo A
# foo' foo foo A -> foo.case foo foo A
# foo' foo A -> foo.case foo A
# foo' A -> foo.case A
# Note: since we look quite far back, sequences like x{}[]M will case both
# the square brackets next to M _and_ the curly braces to become .case
#
# e.g. "-A", "--A", "---A", "----A", "-----A"
sub @CASE_L' [ @UC @CASE_R ] by @CASE_R;
sub @CASE_L' @CASE_L [ @CASE_R @UC ] by @CASE_R;
sub @CASE_L' @CASE_L @CASE_L [ @CASE_R @UC ] by @CASE_R;
sub @CASE_L' @CASE_L @CASE_L @CASE_L [ @CASE_R @UC ] by @CASE_R;
sub @CASE_L' @CASE_L @CASE_L @CASE_L @CASE_L [ @CASE_R @UC ] by @CASE_R;
#
# e.g. "- A", "-- A", "--- A", "---- A", "----- A"
sub @CASE_L' @Whitespace [ @UC @CASE_R ] by @CASE_R;
sub @CASE_L' @CASE_L @Whitespace [ @CASE_R @UC ] by @CASE_R;
sub @CASE_L' @CASE_L @CASE_L @Whitespace [ @CASE_R @UC ] by @CASE_R;
sub @CASE_L' @CASE_L @CASE_L @CASE_L @Whitespace [ @CASE_R @UC ] by @CASE_R;
sub @CASE_L' @CASE_L @CASE_L @CASE_L @CASE_L @Whitespace [ @CASE_R @UC ] by @CASE_R;
#
# e.g. "- A", "-- A", "--- A", "---- A", "----- A"
sub @CASE_L' @Whitespace @Whitespace [ @UC @CASE_R ] by @CASE_R;
sub @CASE_L' @CASE_L @Whitespace @Whitespace [ @CASE_R @UC ] by @CASE_R;
sub @CASE_L' @CASE_L @CASE_L @Whitespace @Whitespace [ @CASE_R @UC ] by @CASE_R;
sub @CASE_L' @CASE_L @CASE_L @CASE_L @Whitespace @Whitespace [ @CASE_R @UC ] by @CASE_R;
sub @CASE_L' @CASE_L @CASE_L @CASE_L @CASE_L @Whitespace @Whitespace [ @CASE_R @UC ] by @CASE_R;
# X(_)
sub @CASE_DELIM_R @Punctuation @CASE_DELIM_L' by @CASE_DELIM_R;
# in between number position adjustment, e.g. 3 /multiply 4 -> 3 multiply.case 4
@between_num_L = [
multiply
asterisk
];
@between_num_R = [
multiply.case
asterisk.case
];
sub @Numeral @between_num_L' @Numeral by @between_num_R; # 3*9
sub @Numeral @Whitespace @between_num_L' @Numeral by @between_num_R; # 3 *9
sub @Numeral @Whitespace @Whitespace @between_num_L' @Numeral by @between_num_R; # 3 *9
sub @Numeral @between_num_L' @Whitespace @Numeral by @between_num_R; # 3* 9
sub @Numeral @Whitespace @between_num_L' @Whitespace @Numeral by @between_num_R; # 3 * 9
sub @Numeral @Whitespace @Whitespace @between_num_L' @Whitespace @Numeral by @between_num_R; # 3 * 9
sub @Numeral @between_num_L' @Whitespace @Whitespace @Numeral by @between_num_R; # 3* 9
sub @Numeral @Whitespace @between_num_L' @Whitespace @Whitespace @Numeral by @between_num_R; # 3 * 9
sub @Numeral @Whitespace @Whitespace @between_num_L' @Whitespace @Whitespace @Numeral by @between_num_R; # 3 * 9
# END case
# -------------------------------------------------------------------------------------
# BEGIN NxN
# x surrounded by numbers, e.g:
# 3x4 -> 3×4
# 10x20 -> 10×20
# 0x10 -> 0x10 No substitution
#
@NumNoZero = [
#
# NOTE! Keep this up to date with @Whitespace
#
# 1. in glyphs, copy list from font into > features > Whitespace class
# 2. paste & replace this list here
# 3. remove all "zero" glyphs
#
one two twostroke three four five Tonefive six seven eight nine
one.ss01 three.1 four.ss01 six.ss01 nine.ss01
one.tf two.tf three.tf four.tf five.tf six.tf seven.tf eight.tf
nine.tf one.tf.ss01 three.1.tf four.tf.ss01 six.tf.ss01
nine.tf.ss01
];
sub @NumNoZero x' @Numeral by multiply.case; # "3x9" "1x0"
sub @Numeral @Numeral x' @Numeral by multiply.case; # "10x0"
sub @NumNoZero @Whitespace x' @Numeral by multiply.case; # "3 x9" "1 x0"
sub @NumNoZero @Whitespace x' @Whitespace @Numeral by multiply.case; # "3 x 9" "1 x 0"
sub @NumNoZero x' @Whitespace @Numeral by multiply.case; # "3x 9" "1x 0"
sub @Numeral @Numeral @Whitespace x' @Numeral by multiply.case; # "10 x0"
sub @Numeral @Numeral @Whitespace x' @Whitespace @Numeral by multiply.case; # "10 x 0"
sub @Numeral @Numeral x' @Whitespace @Numeral by multiply.case; # "10x 0"
# END NxN
# -------------------------------------------------------------------------------------