Skip to content

Features and lookups aren’t correctly registered under language systems #33

@lianghai

Description

@lianghai

A skeleton of /sources/features/NotoSansBengali.fea is shown below, which includes only languagesystem statements and feature blocks (in which only script/language statements and lookup blocks are shown). The Python script that generates this skeleton is appended for reference.

Note:

  • languagesystem beng dflt ends up being empty, as all lookups are under script bng2.
  • Declaring lookups in feature rlig before Indic features is misleading, as rlig is not normally executed so early.
  • language statements at the end of feature block don’t seem necessary.
languagesystem DFLT dflt;
languagesystem bng2 dflt;
languagesystem bng2 PAL;
languagesystem beng dflt;
feature rlig {
    script bng2;
    lookup BNG_rlig_KLaStep1 { } BNG_rlig_KLaStep1;
    lookup BNG_rlig_KLaStep2 { } BNG_rlig_KLaStep2;
} rlig;
feature locl {
    script bng2;
    language PAL;
    lookup BNG_bng2_PAL_locl_waBlwf { } BNG_bng2_PAL_locl_waBlwf;
} locl;
feature nukt {
    script bng2;
    lookup BNG_nukt_composition { } BNG_nukt_composition;
    lookup BNG_nukt_onTheFlyComp { } BNG_nukt_onTheFlyComp;
    lookup BNG_nukt_onTheFly_swapNukta { } BNG_nukt_onTheFly_swapNukta;
    language PAL;
} nukt;
feature akhn {
    script bng2;
    lookup BNG_akhn_conjuncts { } BNG_akhn_conjuncts;
    lookup BNG_test { } BNG_test;
    language PAL;
} akhn;
feature rphf {
    script bng2;
    lookup BNG_rphf_reph { } BNG_rphf_reph;
    language PAL;
} rphf;
feature blwf {
    script bng2;
    lookup BNG_bng2_blwf { } BNG_bng2_blwf;
    language PAL;
} blwf;
feature half {
    script bng2;
    lookup BNG_half_khandaTa { } BNG_half_khandaTa;
    lookup BNG_half_onTheFly_triconsonant_middleHalf { } BNG_half_onTheFly_triconsonant_middleHalf;
    lookup BNG_half_onTheFly_biconsonant_firstHalf { } BNG_half_onTheFly_biconsonant_firstHalf;
    lookup BNG_half_onTheFly_biconsonant_firstHalf_nukta { } BNG_half_onTheFly_biconsonant_firstHalf_nukta;
    language PAL;
} half;
feature pstf {
    script bng2;
    lookup BNG_bng2_pstf_yaphala { } BNG_bng2_pstf_yaphala;
    language PAL;
} pstf;
feature vatu {
    script bng2;
    lookup BNG_vatu_raphala { } BNG_vatu_raphala;
    lookup BNG_vatu_baConjuncts { } BNG_vatu_baConjuncts;
    language PAL;
} vatu;
feature cjct {
    script bng2;
    lookup BNG_cjct_precomposedConjuncts { } BNG_cjct_precomposedConjuncts;
    language PAL;
} cjct;
feature init {
    script bng2;
    lookup BNG_init_eMatra { } BNG_init_eMatra;
    language PAL;
} init;
feature pres {
    script bng2;
    lookup BNG_abvs_swapCandrabinduMarkIMatra_1 { } BNG_abvs_swapCandrabinduMarkIMatra_1;
    lookup BNG_abvs_swapCandrabinduMarkIMatra_2 { } BNG_abvs_swapCandrabinduMarkIMatra_2;
    lookup BNG_abvs_swapRephMarkIMatra_1 { } BNG_abvs_swapRephMarkIMatra_1;
    lookup BNG_abvs_swapRephMarkIMatra_2 { } BNG_abvs_swapRephMarkIMatra_2;
    lookup BNG_pres_onTheFly_addTop { } BNG_pres_onTheFly_addTop;
    lookup BNG_pres_onTheFly_halfDecomp { } BNG_pres_onTheFly_halfDecomp;
    lookup BNG_pres_onTheFly_middle_triconsonant_single { } BNG_pres_onTheFly_middle_triconsonant_single;
    lookup BNG_pres_onTheFly_triconsonant_double { } BNG_pres_onTheFly_triconsonant_double;
    lookup BNG_pres_onTheFly_last_biconsonant { } BNG_pres_onTheFly_last_biconsonant;
    lookup BNG_pres_onTheFly_swapDhaPartRa { } BNG_pres_onTheFly_swapDhaPartRa;
    lookup BNG_pres_onTheFly_armsAndParts { } BNG_pres_onTheFly_armsAndParts;
    lookup BNG_pres_onTheFly_half_baphalaRaphala { } BNG_pres_onTheFly_half_baphalaRaphala;
    lookup BNG_pres_onTheFly_half_baphalaRaphala2 { } BNG_pres_onTheFly_half_baphalaRaphala2;
    lookup BNG_pres_onTheFly_baphalaAlts { } BNG_pres_onTheFly_baphalaAlts;
    lookup BNG_pres_onTheFly_raphalaAlts { } BNG_pres_onTheFly_raphalaAlts;
    lookup BNG_pres_addHeadlineStem { } BNG_pres_addHeadlineStem;
    lookup BNG_pres_onTheFly_nukta { } BNG_pres_onTheFly_nukta;
    lookup BNG_pres_onTheFly_halfDecomp2 { } BNG_pres_onTheFly_halfDecomp2;
    lookup BNG_pres_tta_ttha_top { } BNG_pres_tta_ttha_top;
    lookup BNG_pres_iMatra_tta_ttha_topSwap { } BNG_pres_iMatra_tta_ttha_topSwap;
    lookup BNG_pres_iMatra_tta { } BNG_pres_iMatra_tta;
    lookup BNG_pres_iMatra_ttha { } BNG_pres_iMatra_ttha;
    lookup BNG_pres_iMatra_other { } BNG_pres_iMatra_other;
    lookup BNG_pres_eMAtra { } BNG_pres_eMAtra;
    language PAL;
    lookup BNG_PAL_pres_swapWa { } BNG_PAL_pres_swapWa;
    lookup BNG_PAL_pres_onTheFly_lastBaRa { } BNG_PAL_pres_onTheFly_lastBaRa;
} pres;
feature abvs {
    script bng2;
    lookup BNG_abvs_SwapTopIMatra { } BNG_abvs_SwapTopIMatra;
    lookup BNG_abvs_SwapReph { } BNG_abvs_SwapReph;
    lookup BNG_abvs_smallCandrabindu { } BNG_abvs_smallCandrabindu;
    lookup BNG_abvs_altReph { } BNG_abvs_altReph;
    lookup BNG_abvs_shorterIMatraReph { } BNG_abvs_shorterIMatraReph;
    language PAL;
} abvs;
feature blws {
    script bng2;
    lookup BNG_blws_ligatures_precomposed { } BNG_blws_ligatures_precomposed;
    lookup BNG_blws_ligatures_onTheFly_1 { } BNG_blws_ligatures_onTheFly_1;
    lookup BNG_blws_ligatures_onTheFly_2 { } BNG_blws_ligatures_onTheFly_2;
    lookup BNG_blws_onTheFly_uMatraLiga { } BNG_blws_onTheFly_uMatraLiga;
    lookup BNG_blws_vowelAlternates_nukta { } BNG_blws_vowelAlternates_nukta;
    lookup BNG_blws_vowelAlternates { } BNG_blws_vowelAlternates;
    language PAL;
    lookup BNG_PAL_blws_vowelAlternates { } BNG_PAL_blws_vowelAlternates;
} blws;
feature psts {
    script bng2;
    lookup BNG_psts_iiMatra_tthaBase { } BNG_psts_iiMatra_tthaBase;
    lookup BNG_psts_iiMatra_flagSwap { } BNG_psts_iiMatra_flagSwap;
    lookup BNG_psts_iiMatra { } BNG_psts_iiMatra;
    lookup BNG_psts_auLengthMatra { } BNG_psts_auLengthMatra;
    lookup BNG_psts_yaPstf { } BNG_psts_yaPstf;
    language PAL;
} psts;
feature rclt {
    script bng2;
    lookup BNG_rclt_swapVedicStacks_context { } BNG_rclt_swapVedicStacks_context;
    lookup BNG_abvs_swapVedicStacks { } BNG_abvs_swapVedicStacks;
    language PAL;
} rclt;
feature ss01 {
    script bng2;
    lookup BNG_ss01_alternateNna { } BNG_ss01_alternateNna;
    language PAL;
} ss01;
from fontTools.feaLib.ast import (
    FeatureBlock,
    LanguageStatement,
    LanguageSystemStatement,
    LookupBlock,
    ScriptStatement,
)
from fontTools.feaLib.parser import Parser
from glyphsLib import GSFont

gsFont = GSFont("sources/NotoSansBengali.glyphspackage")

with open("sources/features/NotoSansBengali.fea") as f:
    featureFile = Parser(
        f,
        glyphNames=[k for k, v in gsFont.glyphs.items() if v.export],
    ).parse()

for child in featureFile.statements.copy():
    if isinstance(child, LanguageSystemStatement):
        continue
    if isinstance(child, FeatureBlock):
        for grandchild in child.statements.copy():
            if isinstance(grandchild, ScriptStatement | LanguageStatement):
                continue
            if isinstance(grandchild, LookupBlock):
                grandchild.statements.clear()
                continue
            child.statements.remove(grandchild)
        continue
    featureFile.statements.remove(child)

print(featureFile)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions