L i ddlmZddlmZmZddlZddlmZmZddl m Z ddl m Z ddl mZddlmZdd lmZmZmZmZdd lmZdd lmZdd lmZmZdd lmZddl m!Z!ddl"m#Z#ddl$Z$ddl%Z%e$jLe'Z(dZ)dZ*dZ+dZ,dZ-dZ.dvdZ/Gdde0Z1Gdde1Z2GddedgdZ3GddZ4Gd d!e1Z5Gd"d#e5Z6Gd$d%e5Z7Gd&d'e1Z8Gd(d)e1Z9Gd*d+e1Z:Gd,d-e1Z;Gd.d/e1Z<Gd0d1e1Z=Gd2d3e1Z>Gd4d5e1Z?Gd6d7e1Z@Gd8d9e0ZAGd:d;e1ZBGd<d=e1ZCd>ZDd?ZEd@ZFdAZGdwdBZHdCZIdDZJdEZKdFZLdGZMdHZNdIZOdJZPe!dKeQLdMZRdNZSe!dOeQLdPZTdQZUdRZVdSZWdTZXdxdUZYdVZZdxdWZ[dXZ\dYZ]dZZ^d[Z_ed\d]Z`d^Zad_Zbd`ZcdaZddbZedcZfddZgdeZhdfZidgZjGdhdie0Zke djdZle dkdZmeeneoeeoeoffZp dy dzdlZqd{dmZrd{dnZs d| d}doZt d~dpZudqZvdrZwdsZxdtZyduZzy)) annotations) namedtuple OrderedDictN)DictUnion) fixedToFloat)otRound)ttLib)otTables) ValueRecordvalueRecordFormatDictOTLOffsetOverflowError OTTableWriter)TTFont)STATNameStatement)_compression_level_from_envcompact_lookup)OpenTypeLibError)deprecateFunction)reducec|sytj} tt||j|_|S#t $r}td|d|d}~wwxYw)a Builds a coverage table. Coverage tables (as defined in the `OpenType spec `__) are used in all OpenType Layout lookups apart from the Extension type, and define the glyphs involved in a layout subtable. This allows shaping engines to compare the glyph stream with the coverage table and quickly determine whether a subtable should be involved in a shaping operation. This function takes a list of glyphs and a glyphname-to-ID map, and returns a ``Coverage`` object representing the coverage table. Example:: glyphMap = font.getReverseGlyphMap() glyphs = [ "A", "B", "C" ] coverage = buildCoverage(glyphs, glyphMap) Args: glyphs: a sequence of glyph names. glyphMap: a glyph name to ID map, typically returned from ``font.getReverseGlyphMap()``. Returns: An ``otTables.Coverage`` object or ``None`` if there are no glyphs supplied. NkeyzCould not find glyph z in font)otCoveragesortedset __getitem__glyphsKeyError ValueError)rglyphMapselfes ^/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/fontTools/otlLib/builder.py buildCoverager& se8  ;;=DES[h.B.BC  K E08<=1DEs%A A AAcyDcgc]}|| c}sytfdDs+JdtDcgc]}|jc}z|rk|dvsJ|dk(rdnd}tj||}t D]7\} }|| <d| _|| _|j| _9nd j}tj} || _|| _ | _ t| j| _ |9| xjtzc_ t|t sJ||| _| S| jtzd k(s Jd |z| Scc}wcc}w) aTurns a collection of rules into a lookup. A Lookup (as defined in the `OpenType Spec `__) wraps the individual rules in a layout operation (substitution or positioning) in a data structure expressing their overall lookup type - for example, single substitution, mark-to-base attachment, and so on - as well as the lookup flags and any mark filtering sets. You may import the following constants to express lookup flags: - ``LOOKUP_FLAG_RIGHT_TO_LEFT`` - ``LOOKUP_FLAG_IGNORE_BASE_GLYPHS`` - ``LOOKUP_FLAG_IGNORE_LIGATURES`` - ``LOOKUP_FLAG_IGNORE_MARKS`` - ``LOOKUP_FLAG_USE_MARK_FILTERING_SET`` Args: subtables: A list of layout subtable objects (e.g. ``MultipleSubst``, ``PairPos``, etc.) or ``None``. flags (int): This lookup's flags. markFilterSet: Either ``None`` if no mark filtering set is used, or an integer representing the filtering set to be used for this lookup. If a mark filtering set is provided, `LOOKUP_FLAG_USE_MARK_FILTERING_SET` will be set on the lookup's flags. table (str): The name of the table this lookup belongs to, e.g. "GPOS" or "GSUB". extension (bool): ``True`` if this is an extension lookup, ``False`` otherwise. Returns: An ``otTables.Lookup`` object or ``None`` if there are no subtables supplied. Nc3VK|] }|jdjk("ywrN) LookupType).0t subtabless r% zbuildLookup..ss)45 ! ///s&)z3all subtables must have the same LookupType; got %sGPOSGSUBr6 r'rz]if markFilterSet is None, flags must not set LOOKUP_FLAG_USE_MARK_FILTERING_SET; flags=0x%04x)allreprr/r lookupTypes enumerateFormat ExtSubTableExtensionLookupTypeLookup LookupFlagSubTablelen SubTableCount"LOOKUP_FLAG_USE_MARK_FILTERING_SET isinstanceintMarkFilteringSet) r2flags markFilterSettable extensionstr1 lookupTypeextSubTableClassir#s ` r% buildLookuprQNs@':2>:I  9B >%0<y) =EAr+-IaL"#IaL ')IaL $/1}}IaL ,  = q\,, 99;D DODODMT]]+D  ==--<}<- - K "DDJ  ?AF G J KG; *sE6E6E; cheZdZdZddZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZddZy) LookupBuilderSUBTABLE_BREAKc||_|j|_||_||c|_|_d|_d|_d|_||_ |dvsJy)Nrr4) fontgetReverseGlyphMapr"locationrK lookup_type lookupflagrJ lookup_indexrL)r#rVrXrKrYrLs r%__init__zLookupBuilder.__init__s^ //1   ',k$ D$! "((((ct||jxrj|j|jk(xrO|j|jk(xr4|j|jk(xr|j |j k(SN)rF __class__rKrZrJrLr#others r%equalszLookupBuilder.equalsss udnn - 2 ekk) 25#3#33 2""e&9&99 2%//1  r]c|gSr_)r#is_named_lookups r%promote_lookup_typez!LookupBuilder.promote_lookup_types v r]ciS)z?Infers glyph glasses for the GDEF table, such as {"cedilla":3}.rer#s r%inferGlyphClasseszLookupBuilder.inferGlyphClasses r]ciS)z$Helper for building 'aalt' features.reris r%getAlternateGlyphsz LookupBuilder.getAlternateGlyphsrkr]cpt||j|j|j|jSr_)rQrZrJrKrLr#r2s r% buildLookup_zLookupBuilder.buildLookup_s0  OO    JJ NN   r]ci}t|j|jjD]}||\}}||vst |||<|S)a{"cedilla": ("BOTTOM", ast.Anchor), ...} --> {"BOTTOM":0, "TOP":1} Helper for MarkBasePostBuilder, MarkLigPosBuilder, and MarkMarkPosBuilder. Seems to return the same numeric IDs for mark classes as the AFDKO makeotf tool. r)rkeysrV getGlyphIDrC)r#marksidsmark markClassName _markAnchors r%buildMarkClasses_zLookupBuilder.buildMarkClasses_sZ5::.Ws4as1vz4TF)rrrrany)r#rrs r%hasAnyGlyphClassesz)ChainContextualRuleset.hasAnyGlyphClassesQsOJJ D![[$++t{{C 4844  r]cd\}}}g}|||fD]O}g}|jD]}|j|||j|}|sy|j|Q|S)N)rr'r()rr~_classBuilderForContext) r#PREFIXGLYPHSSUFFIXclassDefBuildersixcontextrclassess r%format2ClassDefsz'ChainContextualRuleset.format2ClassDefs[s~!(66* -BGZZ &qu% &227;G  # #G , - r]ctd}|D]9}|D]2}t|}|j|sy|j|4;|S)NF useClass0)ClassDefBuilderrcanAddadd)r#rclassdefbuilderpositionglyphsetrs r%rz.ChainContextualRuleset._classBuilderForContexthsZ)E: ,H$ ,X&--f5##F+  , , r]N) rrrr\rrrrrrrer]r%rrAs>   r]rceZdZdZdZdZdZddZddZddZ dZ d Z dd Z dd Z dd Zdd ZddZ ddZdZy)ChainContextualBuildercdtj||xr|j|jk(Sr_rSrcrras r%rczChainContextualBuilder.equalst'##D%0NTZZ5;;5NNr]c tg}|jD]<}|jr|jt)|dj |>|Dcgc]}t |jdkDs|c}Scc}w)Nrr)rrrr~rrC)r#rulesetrrs r%rulesetszChainContextualBuilder.rulesetswsu*+,JJ &D%%578 BK   %  & #7ac!''lQ&6777s B9Bc|sy|jtj|}t}|j ||j t |j}|SNr)rpcopydeepcopyrcompilerVrC getAllData)r#r2rKwsizes r%getCompiledSize_z'ChainContextualBuilder.getCompiledSize_sQ!!$-- ":; O a#1<<>" r]c fg}|j}td|D}|jjj d}|s|j dk(rd}|D]}dddgg}|j D]&}|dj|j||(|j}|r|j|||g|d<|js|j||g|d<g} d D]3} || s |j|| } | j| || f5| st'd |j$t)| d \} }|j+||j-|S#t$r8} tj!d | t#|j$| fzYd} ~ d} ~ wwxYw)zBuild the lookup. Returns: An ``otTables.Lookup`` object representing the chained contextual positioning lookup. c34K|]}|jywr_)r)r0rs r%r3z/ChainContextualBuilder.build..sIWw00Isz$fontTools.otlLib.builder:WRITE_GPOS7PosTNrr(r')r'r(rz*Contextual format %i at %s overflowed (%s)zAll candidates overflowedc |dSrre)rs r%z.ChainContextualBuilder.build..s adr]r)rrrVcfgget subtable_typerr~buildFormat3SubtablerbuildFormat2SubtablerbuildFormat1SubtablerrrrstrrXrminextendrp)r#r2rchaining write_gpos7r candidatesr classdefscandidates_by_sizerPrr$ _min_sizewinners r%rzChainContextualBuilder.builds ==?IIIiimm''(NO t11U:H' %GdB/J  P1 $$T%>%>tX%NO P 002I--gy(K! 1 --!%!:!:7H!M N 1 !#  Ia=I#44Z]C+114A2GH I&&'BDMMRR #$6N K Iv   V $O' %V  ++!2 H #dmm"4a89s6E// F08.F++F0c F|j|}d|_|jt}i}|j d|}|j D]i}|j d|}|rt|j|_ t|j|_ t|jD cgc]} t| dc} |_|jD cgc]} t| dc} |_t|j |_nt|j |_|j ddD cgc]} t| dc} |_|j)||t|j dd} | |vr|j+| g|| <|| j-|lt/||j0|_g} |j2j D]R} |j5d|} t7| ||| t7| |dt|| | j-| Tt7||j9d|| t7||j9d|dzt| |Scc} wcc} wcc} w)Nrr'formatrrCount) newSubtable_r=populateDefaultsr ruleAttr_rnewRule_rCrr{rrr}list Backtrack LookAheadrrrInputbuildLookupListrr~r&r"r newRuleSet_setattr ruleSetAttr_)r#rrrMrrulesetsByFirstGlyphruleAttrrruleAsSubtabler firstGlyphruleSetsrruleSets r%rz+ChainContextualBuilder.buildFormat1SubtablesV     1  5!>>X>>MM DD!]]!h]GN585E2585E2@H@U+V1DGAJ+V(@D +L1DGAJ+L(14T[[1A.,/ ,<)8< AB#H1DGAJ#HN  ~ 6dkk!n-a0J!55 Z(35$Z0  , 3 3N C+ D.$Hdmm< ## %A&&a(&CG GX';A'> ? Gz/5I!5L1M N OOG $  % D%%Q%BHM !!X!>H#h-  =,W+L $Is9J$JJc |j|}d|_|j|r2|Dcgc]}|jc}\|_|_|_n|dj|_|dj}g}|D]&}|jd|} |j| (t} |jd|} |jD]k} |jd|} |rVt| j | _t| j$| _t)| j Dcgc]'}|jj*t-|d)c}| _| j$Dcgc]'}|j j*t-|d)c}| _t| j2| _| j2ddDcgc]'}|j j*t-|d)c}| _||j j*t-| j2dd}nt| j2| _| j2ddDcgc]'}|jj*t-|d)c}| _||jj*t-| j2dd}|j=| | | t| j2dz} t?|| j| tA|| dt?|| ddzntC|D]\}} t?| | rd||<tA||jEd||tA||jEd|dzt|tG| |jH|_%|Scc}wcc}wcc}wcc}wcc}w)Nr r(r'r rr )&r r=rrBacktrackClassDef InputClassDefLookAheadClassDefClassDefrrr~rrrrrCrr{rrr} classDefsrrrrrrrClassrgetattrrr<rr&r"r)r#rrrrMc inClasses classSets_classSetr classRuleAttrrrrsetForThisRulerPs r%rz+ChainContextualBuilder.buildFormat2Subtables     1    %..q.  $ $$A,,,.BKaL((*   'A''q8'DH   X & '5a(C MM( D!]]!h]GN585E2585E2 &dkk2,((22471:>,( IM ,CDB((22471:>,(25T[[1A.DHKKPQPRO(?@B$$..tAwqz:($"+$$..tDKKN/CA/FG"-0 ,<)?C{{12(:;BKK))$q'!*5($"+KK))$t{{1~*>q*AB"  ~ 6 DKKN+ +H NM 2 9 9. I  /'=/(?@1D I( R%Y/ $KAx8]3# !  $ D%%Q%BIN !!X!>H#i. $Hdmm<  A/,,, ((sO,O,O"%,O':,O,cB|j|}d|_|rU|j|j||j |j ||j |j|n|j|j||j|||S)Nr r) r r=rrrrrrrr)r#rrrMs r%rz+ChainContextualBuilder.buildFormat3SubtableOs     1   & &t{{B 7  & &t{{B 7  " "4;; 3   dkk2 . T2& r]c@t|jD]\}}| t|ts|g}|D]f}|j/t|t rd}nd}t d|d|j|j|}||_ |j|_ hy)N substitution positioningz2Missing index of the specified lookup, might be a z lookup) r<rrFrr[ChainContextPosBuilderrrXnewLookupRecord_ SequenceIndexLookupListIndex)r#rrM sequenceIndex lookupListlrbrecs r%rz&ChainContextualBuilder.buildLookupList[s)24<<)@ 9 %M:%!*d3",J# 9A~~-%d,BC$2E$1E.227A MM //3C(5C%*+..C' 9  9r]c|jjt|j|j|j|jgyr_)rr~rrrs r%rz)ChainContextualBuilder.add_subtable_breakpsC  $$$$$$%%&   r]cd|j}|rd|z}tt|}t||jddt||jdg|S)NContextChainr r LookupRecord)rr&rr)r#r subtablenamerMs r%r z#ChainContextualBuilder.newSubtable_zsl !3!3 45 "\1L &WR & (t))*%0!4t))*,7< r]cr|dk(rd}n|dk(rd}n t|jdd|d}|rd|z}|S) Nr'Ruler(r%rrSetr=AssertionErrorrr#r r formatTyper?s r%rz#ChainContextualBuilder.ruleSetAttr_sV Q;J q[ J , ,,,Qq12:,cB "\1Lr]cr|dk(rd}n|dk(rd}n t|jdd|d}|rd|z}|S) Nr'r(r%rrrAr=rCrEs r%rz ChainContextualBuilder.ruleAttr_sV Q;J q[ J , ,,,Qq12:,dC "\1Lr]cptt|j||}|j|Sr_)r&rrrr#r rrMs r%rz"ChainContextualBuilder.newRuleSet_s: W !!&(3    r]cptt|j||}|j|Sr_)r&rrrrJs r%rzChainContextualBuilder.newRule_s8 W vx0    r]NcH|r d|z}d|z}t||st||dt||g|r|}ntt|}t||t||dz|rt||j |||St||j ||S)Nr=rr')hasattrrr&rinsertr~)r#rM subtable_name count_nameexistingindexr new_subtables r%attachSubtableWithCount_z/ChainContextualBuilder.attachSubtableWithCount_s #m3M :-Jr:& B A & B r * #L672}57LJJ 7! ;<  B & - -e\ B B & - -l ;r]c`|j||jd|jddS)Nr>r Fr )rTrr#rMs r%r3z'ChainContextualBuilder.newLookupRecord_sB,, !!", /!!"% ( -  r])T)r'T)NNF)rrrrcrrrrrrrrr rrrrrTr3rer]r%rrss_O 8 E,N,\JX 9* &  RW4 r]rceZdZdZdZdZy)r2a>Builds a Chained Contextual Positioning (GPOS8) lookup. Users are expected to manually add rules to the ``rules`` attribute after the object has been initialized, e.g.:: # pos [A B] [C D] x' lookup lu1 y' z' lookup lu2 E; prefix = [ ["A", "B"], ["C", "D"] ] suffix = [ ["E"] ] glyphs = [ ["x"], ["y"], ["z"] ] lookups = [ [lu1], None, [lu2] ] builder.rules.append( (prefix, glyphs, suffix, lookups) ) Attributes: font (``fontTools.TTLib.TTFont``): A font object. location: A string or tuple representing the location in the original source which produced this lookup. rules: A list of tuples representing the rules in this lookup. lookupflag (int): The lookup's flag markFilterSet: Either ``None`` if no mark filtering set is used, or an integer representing the filtering set to be used for this lookup. If a mark filtering set is provided, `LOOKUP_FLAG_USE_MARK_FILTERING_SET` will be set on the lookup's flags. cRtj|||ddg|_d|_y)Nr5r*rrSr\rrrs r%r\zChainContextPosBuilder.__init__s'tT8VQ? "r]cd}|dddD]>|jk(r|cStts'tfd|Ds=}@|S)z$Helper for add_single_pos_chained_()Nrc3BK|]}j|ywr_)can_add)r0glyphlookupvalues r%r3zCChainContextPosBuilder.find_chainable_single_pos..s!<16ue,<s)rrFSinglePosBuilderr9)r#rrr_resr^s ` @r%find_chainable_single_posz0ChainContextPosBuilder.find_chainable_single_poss_ddm F--- &"23<:@<9   r]N)rrrrr\rbrer]r%r2r2s4# r]r2c(eZdZdZdZdZdZdZy)ChainContextSubstBuildera?Builds a Chained Contextual Substitution (GSUB6) lookup. Users are expected to manually add rules to the ``rules`` attribute after the object has been initialized, e.g.:: # sub [A B] [C D] x' lookup lu1 y' z' lookup lu2 E; prefix = [ ["A", "B"], ["C", "D"] ] suffix = [ ["E"] ] glyphs = [ ["x"], ["y"], ["z"] ] lookups = [ [lu1], None, [lu2] ] builder.rules.append( (prefix, glyphs, suffix, lookups) ) Attributes: font (``fontTools.TTLib.TTFont``): A font object. location: A string or tuple representing the location in the original source which produced this lookup. rules: A list of tuples representing the rules in this lookup. lookupflag (int): The lookup's flag markFilterSet: Either ``None`` if no mark filtering set is used, or an integer representing the filtering set to be used for this lookup. If a mark filtering set is provided, `LOOKUP_FLAG_USE_MARK_FILTERING_SET` will be set on the lookup's flags. cRtj|||ddg|_d|_y)Nr6SubstrYrs r%r\z!ChainContextSubstBuilder.__init__s'tT8VQ? $r]cLi}|jD]}|jr|jD]s}t|ts|g}|D]Y}||j }|j D]1\}}|j|gjfd|D3[u|S)Nc3,K|] }|vs| ywr_re)r0ralts_for_glyphs r%r3z>ChainContextSubstBuilder.getAlternateGlyphs..0s2&'1N;R2s ) rrrrFrrmitems setdefaultr) r#resultrrr^altsr] replacementsrjs @r%rmz+ChainContextSubstBuilder.getAlternateGlyphs#sJJ D%%<< !'40&iG%F)%88:37::</E<-3->->ub-IN*112+72   r]cd}|jdddD]R}|jr|cS|jD]1t|st fdj Dr0}3T|S)z.Helper for add_{single,multi}_subst_chained_()Nrc3TK|]}|vxr|j|k7!ywr_)r)r0rrsubs r%r3z@ChainContextSubstBuilder.find_chainable_subst..<s3>FGALAWQZ3;;q>%AA>s%()rrrrFrr)r#r builder_classrarrrs ` @r%find_chainable_substz-ChainContextSubstBuilder.find_chainable_subst5suJJtt$ D%% || c=1#>KN;;>;C    r]cd}|jdddD]\}|jr|cS|jD];ttst fdt j|Ds:}=^|S)z(Helper for add_ligature_subst_chained_()Nrc3\K|]#}jj|k(%ywr_) ligaturesr)r0seq replacementrrs r%r3zIChainContextSubstBuilder.find_chainable_ligature_subst..Ks/MM%%c;7;Fs),)rrrrFLigatureSubstBuilderr9 itertoolsproduct)r#rryrarrrs ` @r%find_chainable_ligature_substz6ChainContextSubstBuilder.find_chainable_ligature_substBsJJtt$ D%% || !#';<(00&9C   r]N)rrrrr\rmrtr}rer]r%rdrds4% $ r]rdc.eZdZdZdZdZdZdZdZy)rzaBuilds a Ligature Substitution (GSUB4) lookup. Users are expected to manually add ligatures to the ``ligatures`` attribute after the object has been initialized, e.g.:: # sub f i by f_i; builder.ligatures[("f","f","i")] = "f_f_i" Attributes: font (``fontTools.TTLib.TTFont``): A font object. location: A string or tuple representing the location in the original source which produced this lookup. ligatures: An ordered dictionary mapping a tuple of glyph names to the ligature glyphname. lookupflag (int): The lookup's flag markFilterSet: Either ``None`` if no mark filtering set is used, or an integer representing the filtering set to be used for this lookup. If a mark filtering set is provided, `LOOKUP_FLAG_USE_MARK_FILTERING_SET` will be set on the lookup's flags. cTtj|||ddt|_y)Nr6r))rSr\rrwrs r%r\zLigatureSubstBuilder.__init__js!tT8VQ?$r]cdtj||xr|j|jk(Sr_)rSrcrwras r%rczLigatureSubstBuilder.equalsns'##D%0VT^^u5VVr]cd|j|jt}|j|S)zBuild the lookup. Returns: An ``otTables.Lookup`` object representing the ligature substitution lookup. )rrwbuildLigatureSubstSubtablerpros r%rzLigatureSubstBuilder.buildqs1.. NN6   ++r]c|jjDcic]\}}t|dk(r|d|gc}}Scc}}wNr'r)rwrkrC)r# componentsligatures r%rmz'LigatureSubstBuilder.getAlternateGlyphs}sL)-(<(<(> $ H:!# qMH: %   sAcN|j|j|j|f<yr_)rrwrs r%rz'LigatureSubstBuilder.add_subtable_breaks!;?;O;O,,h78r]Nrrer]r%rzrzSs",'W , Pr]rzc.eZdZdZdZdZdZdZdZy)MultipleSubstBuilderaBuilds a Multiple Substitution (GSUB2) lookup. Users are expected to manually add substitutions to the ``mapping`` attribute after the object has been initialized, e.g.:: # sub uni06C0 by uni06D5.fina hamza.above; builder.mapping["uni06C0"] = [ "uni06D5.fina", "hamza.above"] Attributes: font (``fontTools.TTLib.TTFont``): A font object. location: A string or tuple representing the location in the original source which produced this lookup. mapping: An ordered dictionary mapping a glyph name to a list of substituted glyph names. lookupflag (int): The lookup's flag markFilterSet: Either ``None`` if no mark filtering set is used, or an integer representing the filtering set to be used for this lookup. If a mark filtering set is provided, `LOOKUP_FLAG_USE_MARK_FILTERING_SET` will be set on the lookup's flags. cTtj|||ddt|_y)Nr6r(rSr\rrrs r%r\zMultipleSubstBuilder.__init__!tT8VQ?"} r]cdtj||xr|j|jk(Sr_rSrcrras r%rczMultipleSubstBuilder.equals'##D%0RT\\U]]5RRr]cd|j|jt}|j|Sr_)rrbuildMultipleSubstSubtablerpros r%rzMultipleSubstBuilder.builds*..t||=WX   ++r]c|jjDcic]\}}t|dk(r||c}}Scc}}w)Nr'rrkrC)r#r]ros r%rmz'MultipleSubstBuilder.getAlternateGlyphssG(,||'9'9'; #|< A% <    s=cN|j|j|j|f<yr_rrrs r%rz'MultipleSubstBuilder.add_subtable_break!9=9M9M d**H56r]Nrrer]r%rrs",%S, Nr]rc.eZdZdZdZdZdZdZdZy)CursivePosBuilderaBuilds a Cursive Positioning (GPOS3) lookup. Attributes: font (``fontTools.TTLib.TTFont``): A font object. location: A string or tuple representing the location in the original source which produced this lookup. attachments: An ordered dictionary mapping a glyph name to a two-element tuple of ``otTables.Anchor`` objects. lookupflag (int): The lookup's flag markFilterSet: Either ``None`` if no mark filtering set is used, or an integer representing the filtering set to be used for this lookup. If a mark filtering set is provided, `LOOKUP_FLAG_USE_MARK_FILTERING_SET` will be set on the lookup's flags. cDtj|||ddi|_y)Nr5r)rSr\ attachmentsrs r%r\zCursivePosBuilder.__init__s tT8VQ?r]cdtj||xr|j|jk(Sr_)rSrcrras r%rczCursivePosBuilder.equalss-  u - W$2B2BeFWFW2W r]c4|D]}||f|j|<y)akAdds attachment information to the cursive positioning lookup. Args: location: A string or tuple representing the location in the original source which produced this lookup. (Unused.) glyphs: A list of glyph names sharing these entry and exit anchor locations. entryAnchor: A ``otTables.Anchor`` object representing the entry anchor, or ``None`` if no entry anchor is present. exitAnchor: A ``otTables.Anchor`` object representing the exit anchor, or ``None`` if no exit anchor is present. N)r)r#rXr entryAnchor exitAnchorr]s r%add_attachmentz CursivePosBuilder.add_attachments* @E'2J&?D  U # @r]cig}|jD];}|d|jk(r|ji'|j||d|<=|Dcgc]}t||j}}|j |Scc}w)zBuild the lookup. Returns: An ``otTables.Lookup`` object representing the cursive positioning lookup. rr)rrr~buildCursivePosSubtabler"rp)r#rrrr2s r%rzCursivePosBuilder.buildsd ## =C1v---""2&'+'7'7'< B$  = ITT1,Q >T T  ++UsBcf|j|jf|j|j|f<yr_)rrrs r%rz$CursivePosBuilder.add_subtable_breaks1   > $..9:r]N) rrrrr\rcrrrrer]r%rrs!  @ ,  r]rc4eZdZdZdZdZdZdZdZdZ y) MarkBasePosBuilderaBuilds a Mark-To-Base Positioning (GPOS4) lookup. Users are expected to manually add marks and bases to the ``marks`` and ``bases`` attributes after the object has been initialized, e.g.:: builder.marks["acute"] = (0, a1) builder.marks["grave"] = (0, a1) builder.marks["cedilla"] = (1, a2) builder.bases["a"] = {0: a3, 1: a5} builder.bases["b"] = {0: a4, 1: a5} Attributes: font (``fontTools.TTLib.TTFont``): A font object. location: A string or tuple representing the location in the original source which produced this lookup. marks: An dictionary mapping a glyph name to a two-element tuple containing a mark class ID and ``otTables.Anchor`` object. bases: An dictionary mapping a glyph name to a dictionary of mark class IDs and ``otTables.Anchor`` object. lookupflag (int): The lookup's flag markFilterSet: Either ``None`` if no mark filtering set is used, or an integer representing the filtering set to be used for this lookup. If a mark filtering set is provided, `LOOKUP_FLAG_USE_MARK_FILTERING_SET` will be set on the lookup's flags. c`tj|||ddi|_i|_g|_y)Nr5r))rSr\rtbases subtables_rs r%r\zMarkBasePosBuilder.__init__s-tT8VQ?  r]c|j}|js |jr'|j|j|jf|Sr_)rrrtr~r#rs r%get_subtables_z!MarkBasePosBuilder.get_subtables_s9__ ::   tzz4::6 7r]cttj||xr!|j|jk(Sr_rSrcrras r%rczMarkBasePosBuilder.equals 7  u - @##%)=)=)?? r]ci}|jD]E\}}|j|Dcic]}|dc}|j|Dcic]}|dc}G|Scc}wcc}w)Nr'rrupdate)r#rmrtrr]s r%rjz$MarkBasePosBuilder.inferGlyphClasses&sh //1 9LE5 MM75!87 8 MM75!87 8 9 87 A  A" c g}|jD]}|j|d}i}|djD]'\}\}}||vrtd|d||||f||<)i}|djD]B\} } i|| <| jD]%\}}||vrtd|d| ||| ||<'D|j t |||j |j|S)zBuild the lookup. Returns: An ``otTables.Lookup`` object representing the mark-to-base positioning lookup. rz Mark class z not found for mark glyph r'z not found for base glyph )rryrkr!r~buildMarkBasePosSubtabler"rp) r#r2r markClassesrtrvmcanchorrr]anchorss r%rzMarkBasePosBuilder.build-s= ++- TH00!=KE&.qk&7&7&9 8"lr6[($GI4P +27d  8 E"*1+"3"3"5 ;w!e ")--/;JB,(KMuU5;E%LR1 ; ;   5eUDMMR S% T&  ++r]c|jj|j|jfi|_i|_yr_)rr~rtrrs r%rz%MarkBasePosBuilder.add_subtable_breakJs/  DJJ78  r]N rrrrr\rrcrjrrrer]r%rrs%6   ,:r]rc4eZdZdZdZdZdZdZdZdZ y) MarkLigPosBuilderacBuilds a Mark-To-Ligature Positioning (GPOS5) lookup. Users are expected to manually add marks and bases to the ``marks`` and ``ligatures`` attributes after the object has been initialized, e.g.:: builder.marks["acute"] = (0, a1) builder.marks["grave"] = (0, a1) builder.marks["cedilla"] = (1, a2) builder.ligatures["f_i"] = [ { 0: a3, 1: a5 }, # f { 0: a4, 1: a5 } # i ] Attributes: font (``fontTools.TTLib.TTFont``): A font object. location: A string or tuple representing the location in the original source which produced this lookup. marks: An dictionary mapping a glyph name to a two-element tuple containing a mark class ID and ``otTables.Anchor`` object. ligatures: An dictionary mapping a glyph name to an array with one element for each ligature component. Each array element should be a dictionary mapping mark class IDs to ``otTables.Anchor`` objects. lookupflag (int): The lookup's flag markFilterSet: Either ``None`` if no mark filtering set is used, or an integer representing the filtering set to be used for this lookup. If a mark filtering set is provided, `LOOKUP_FLAG_USE_MARK_FILTERING_SET` will be set on the lookup's flags. c`tj|||ddi|_i|_g|_y)Nr5)rSr\rtrwrrs r%r\zMarkLigPosBuilder.__init__o-tT8VQ? r]c|j}|js |jr'|j|j|jf|Sr_)rrwrtr~rs r%rz MarkLigPosBuilder.get_subtables_u9__ >>TZZ   tzz4>>: ;r]cttj||xr!|j|jk(Sr_rras r%rczMarkLigPosBuilder.equals{rr]ci}|jD]E\}}|j|Dcic]}|dc}|j|Dcic]}|dc}G|Scc}wcc}w)Nr(rr)r#rmrtrwr]s r%rjz#MarkLigPosBuilder.inferGlyphClassesi $ 3 3 5 9 E9 MM;5!8; < MM75!87 8 9 <7rc g}|jD]}|j|d}|djDcic]\}\}}||||f}}}}i}|djD]J\} } g|| <| D];} || j| jD cic] \}} |||  c} }=L|jt |||j |j |Scc}}}wcc} }w)zBuild the lookup. Returns: An ``otTables.Lookup`` object representing the mark-to-ligature positioning lookup. rr')rryrkr~buildMarkLigPosSubtabler"rp) r#r2rrrvrrrtligsligrr'as r%rzMarkLigPosBuilder.builds- ++- RH00!=K+31+*;*;*=&D,2v{2//ED#+A;#4#4#6 RZS #RAI$$aggi%PURk"oq&8%PQR R   4UD$--P Q R  ++&Qs C5 C<c|jj|j|jfi|_i|_yr_)rr~rtrwrs r%rz$MarkLigPosBuilder.add_subtable_break/  DNN;< r]Nrrer]r%rrPs%<   ,,r]rc4eZdZdZdZdZdZdZdZdZ y) MarkMarkPosBuilderaBuilds a Mark-To-Mark Positioning (GPOS6) lookup. Users are expected to manually add marks and bases to the ``marks`` and ``baseMarks`` attributes after the object has been initialized, e.g.:: builder.marks["acute"] = (0, a1) builder.marks["grave"] = (0, a1) builder.marks["cedilla"] = (1, a2) builder.baseMarks["acute"] = {0: a3} Attributes: font (``fontTools.TTLib.TTFont``): A font object. location: A string or tuple representing the location in the original source which produced this lookup. marks: An dictionary mapping a glyph name to a two-element tuple containing a mark class ID and ``otTables.Anchor`` object. baseMarks: An dictionary mapping a glyph name to a dictionary containing one item: a mark class ID and a ``otTables.Anchor`` object. lookupflag (int): The lookup's flag markFilterSet: Either ``None`` if no mark filtering set is used, or an integer representing the filtering set to be used for this lookup. If a mark filtering set is provided, `LOOKUP_FLAG_USE_MARK_FILTERING_SET` will be set on the lookup's flags. c`tj|||ddi|_i|_g|_y)Nr5rf)rSr\rt baseMarksrrs r%r\zMarkMarkPosBuilder.__init__rr]c|j}|js |jr'|j|j|jf|Sr_)rrrtr~rs r%rz!MarkMarkPosBuilder.get_subtables_rr]cttj||xr!|j|jk(Sr_rras r%rczMarkMarkPosBuilder.equalsrr]ci}|jD]E\}}|j|Dcic]}|dc}|j|Dcic]}|dc}G|Scc}wcc}w)Nrr)r#rmrtrr]s r%rjz$MarkMarkPosBuilder.inferGlyphClassesrrc g}|jD]}|j|d}t|j|j}|dj Dcic]\}\}}||||f}}}}t j} d| _t|| _ t||j| _ t|d|j| _t||j| _t j"| _t| jj$| j"_g| j"_| jj$D]T} |Dcgc]}|d| j |} }| j"j(j+t-| V|j+| |j/|Scc}}}wcc}w)zBuild the lookup. Returns: An ``otTables.Lookup`` object representing the mark-to-mark positioning lookup. rrr')rryrrrrrkr MarkMarkPosr=rC ClassCountr&r" Mark1Coverage Mark2CoveragebuildMarkArray Mark1Array Mark2Arrayr Mark2Count Mark2Recordr~buildMark2Recordrp) r#r2rr markClassListrvrrrtrMbasers r%rzMarkMarkPosBuilder.builds ++- !H00!=K";#3#3#5;??KM+31+*;*;*=&D,2v{2//E !BBI ,BM,UDMMBB ,Xa[$--HB *5$--@BMMMOBM'*2+;+;+B+B'CBMM $(*BMM %((// L?LM8A;t,004MM ))001A'1JK L   R ) !*  ++%Ns 'G) 4G0c|jj|j|jfi|_i|_yr_)rr~rtrrs r%rz%MarkMarkPosBuilder.add_subtable_breakrr]Nrrer]r%rrs%4   ,>r]rc(eZdZdZdZdZdZdZy)ReverseChainSingleSubstBuildera[Builds a Reverse Chaining Contextual Single Substitution (GSUB8) lookup. Users are expected to manually add substitutions to the ``substitutions`` attribute after the object has been initialized, e.g.:: # reversesub [a e n] d' by d.alt; prefix = [ ["a", "e", "n"] ] suffix = [] mapping = { "d": "d.alt" } builder.substitutions.append( (prefix, suffix, mapping) ) Attributes: font (``fontTools.TTLib.TTFont``): A font object. location: A string or tuple representing the location in the original source which produced this lookup. substitutions: A three-element tuple consisting of a prefix sequence, a suffix sequence, and a dictionary of single substitutions. lookupflag (int): The lookup's flag markFilterSet: Either ``None`` if no mark filtering set is used, or an integer representing the filtering set to be used for this lookup. If a mark filtering set is provided, `LOOKUP_FLAG_USE_MARK_FILTERING_SET` will be set on the lookup's flags. cDtj|||ddg|_y)Nr6r*)rSr\rrs r%r\z'ReverseChainSingleSubstBuilder.__init__stT8VQ? r]cdtj||xr|j|jk(Sr_rras r%rcz%ReverseChainSingleSubstBuilder.equalsrr]cg}|jD]\}}}tj}d|_|j |||j ||t |j|j|_ t||_ |jjDcgc]}|| c}|_ |j||j|Scc}w)zBuild the lookup. Returns: An ``otTables.Lookup`` object representing the chained contextual substitution lookup. r')rrReverseChainSingleSubstr=rrr&rrr"rrCrr Substituter~rp)r#r2rrrrMrs r%rz$ReverseChainSingleSubstBuilder.builds '+zz ! #FFG++-BBI  & &vr 2  & &vr 2'  FBKLBM131C1CDAWQZDBM   R  !  ++Es& Ccyr_rers r%rz1ReverseChainSingleSubstBuilder.add_subtable_break1s r]N)rrrrr\rcrrrer]r%rrs2O,& r]rcNeZdZdZdZdZdZdZd dZdZ dZ d Z d Z d Z y )AnySubstBuilderaFA temporary builder for Single, Multiple, or Ligature substitution lookup. Users are expected to manually add substitutions to the ``mapping`` attribute after the object has been initialized, e.g.:: # sub x by y; builder.mapping[("x",)] = ("y",) # sub a by b c; builder.mapping[("a",)] = ("b", "c") # sub f i by f_i; builder.mapping[("f", "i")] = ("f_i",) Then call `promote_lookup_type()` to convert this builder into the appropriate type of substitution lookup builder. This would promote single substitutions to either multiple or ligature substitutions, depending on the rest of the rules in the mapping. Attributes: font (``fontTools.TTLib.TTFont``): A font object. location: A string or tuple representing the location in the original source which produced this lookup. mapping: An ordered dictionary mapping a tuple of glyph names to another tuple of glyph names. lookupflag (int): The lookup's flag markFilterSet: Either ``None`` if no mark filtering set is used, or an integer representing the filtering set to be used for this lookup. If a mark filtering set is provided, `LOOKUP_FLAG_USE_MARK_FILTERING_SET` will be set on the lookup's flags. cTtj|||ddt|_y)Nr6rrrs r%r\zAnySubstBuilder.__init__Vrr]cV|d|jk7r|d}|d|j|<yrrr#builderrr_s r%_add_to_single_substz$AnySubstBuilder._add_to_single_substZs/ q6T)) )a&C$Qxr]cP|d|jk7r|d}||j|<yrrrs r%_add_to_multiple_substz&AnySubstBuilder._add_to_multiple_subst_s+ q6T)) )a&C$r]c(|d|j|<yr)rwrs r%_add_to_ligature_substz&AnySubstBuilder._add_to_ligature_substds!&q#r]c`|ytd|jD}td|jD}d}d}|jj D]9\}}|d|j k(rt |dkDrd}t |dkDs8d};|xr| xr|xr| }|S)NTc38K|]}t|dkDywrr)r0vs r%r3z2AnySubstBuilder.can_add_mapping..ns.os9Qc!fqj9rFrr')rvaluesrrrrkrrC) r#ris_multiis_ligahas_existing_multihas_existing_ligarr can_reuses r%rzAnySubstBuilder.can_add_mappinggs ? <7>>+;<<9',,.99"!LL&&( *DAqtt+++1vz$(!1vz%)"  *,78  *(> r]cvg}|jjD]\}}|d|jk(r|jd*t |dk(r$t |dk(r|jt \t |dk(r$t |dk7r|jt t |dkDr$t |dk(r|jtJdtd|D}td|D}|xr| }|xr| }| xr| } g} | rZt |j|j} |jjD]\}}|j| ||| g} n|rZt |j|j} |jjD]\}}|j| ||| g} n&|rYt|j|j} |jjD]\}}|j| ||| g} n|ryd} t||jjD]\} \}}| t| | ur.| |j|j} | j| | t ur|j| ||b| t ur|j| ||~| tur|j| ||Jd| D]5} |j | _|j"| _|j$| _7| S)Nrr'zShould not happenc3,K|] }|tuywr_)rr0bs r%r3z6AnySubstBuilder.promote_lookup_type..N1 44Nc3,K|] }|tuywr_)rzrs r%r3z6AnySubstBuilder.promote_lookup_type..rr)rrkrr~rCSingleSubstBuilderrrzrrVrXrrrziptyperLrZrJ)r#rfbuilder_classesrr_ has_multiple has_ligature to_multiple to_ligature to_singleretr curr_builderrss r%rgz#AnySubstBuilder.promote_lookup_types,,,,. 2JC1v---&&t,SQ3u:?&&'9:SQ3u:?&&';<SA#e*/&&';<111u 2NoNN NoNN #7<'7 #7<'7 %$9\)9  (DMMBG"ll002 ? U))'3> ?)C *499dmmDG"ll002 A U++GS%@ A)C *499dmmDG"ll002 A U++GS%@ A)C L/2!3!3!50 6+ |U '4 +=]+R#0DMM#JLJJ|, $66--lCG"&::// c5I"&::// c5I5"555 6 7G $G !%G $($6$6G ! 7 r]cdtj||xr|j|jk(Sr_rras r%rczAnySubstBuilder.equalsrr]cJr_reris r%rzAnySubstBuilder.buildsur]c|jjDcic]'\}}t|dk(rt|dk(r|d|)c}}Scc}}wrr)r#rr_s r%rmz"AnySubstBuilder.getAlternateGlyphssR#ll002 U3x1}Uq FEM   s,AcN|j|j|j|f<yr_rrs r%rz"AnySubstBuilder.add_subtable_breakrr]Nr)rrrrr\rrrrrgrcrrmrrer]r%rr6s=>%( % *4M^S Nr]rc.eZdZdZdZdZdZdZdZy)radBuilds a Single Substitution (GSUB1) lookup. Users are expected to manually add substitutions to the ``mapping`` attribute after the object has been initialized, e.g.:: # sub x by y; builder.mapping["x"] = "y" Attributes: font (``fontTools.TTLib.TTFont``): A font object. location: A string or tuple representing the location in the original source which produced this lookup. mapping: A dictionary mapping a single glyph name to another glyph name. lookupflag (int): The lookup's flag markFilterSet: Either ``None`` if no mark filtering set is used, or an integer representing the filtering set to be used for this lookup. If a mark filtering set is provided, `LOOKUP_FLAG_USE_MARK_FILTERING_SET` will be set on the lookup's flags. cTtj|||ddt|_y)Nr6r'rrs r%r\zSingleSubstBuilder.__init__rr]cdtj||xr|j|jk(Sr_rras r%rczSingleSubstBuilder.equalsrr]cd|j|jt}|j|S)zBuild the lookup. Returns: An ``otTables.Lookup`` object representing the multiple substitution lookup. )rrbuildSingleSubstSubtablerpros r%rzSingleSubstBuilder.builds,..t||=UV   ++r]cl|jjDcic] \}}||g c}}Scc}}wr_)rrk)r#r]repls r%rmz%SingleSubstBuilder.getAlternateGlyphss-151C1C1EF+%v FFFs0cN|j|j|j|f<yr_rrs r%rz%SingleSubstBuilder.add_subtable_break rr]Nrrer]r%rrs#*%S,GNr]rc.eZdZdZdZdZdZdZdZy)ClassPairPosSubtableBuilderaSBuilds class-based Pair Positioning (GPOS2 format 2) subtables. Note that this does *not* build a GPOS2 ``otTables.Lookup`` directly, but builds a list of ``otTables.PairPos`` subtables. It is used by the :class:`PairPosBuilder` below. Attributes: builder (PairPosBuilder): A pair positioning lookup builder. cZ||_d\|_|_i|_d|_g|_y)NNNF)builder_ classDef1_ classDef2_values_forceSubtableBreak_r)r#rs r%r\z$ClassPairPosSubtableBuilder.__init__s- +5( #( r]c|j xrX|jduxrH|jj|xr+|jduxr|jj|}|s9|j t d|_t d|_i|_|jj||jj|||f|j ||f<y)a~Add a pair positioning rule. Args: gc1: A set of glyph names for the "left" glyph value1: An ``otTables.ValueRecord`` object for the left glyph's positioning. gc2: A set of glyph names for the "right" glyph value2: An ``otTables.ValueRecord`` object for the right glyph's positioning. NTrF)r$r!rr"flush_rr#r)r#gc1value1gc2value2 mergeables r%addPairz#ClassPairPosSubtableBuilder.addPair!s(( ( ,t+ ,&&s+ ,t+ ,&&s+  KKM-=DO->DODL C  C $*F#3 c3Z r]cd|_y)z-Add an explicit subtable break at this point.TN)r$ris r%addSubtableBreakz,ClassPairPosSubtableBuilder.addSubtableBreak<s #' r]c:|j|jS)z>Return the list of ``otTables.PairPos`` subtables constructed.)r&rris r%r2z%ClassPairPosSubtableBuilder.subtables@s r]c|j |jyt|j|jj }|j y|jj|d|_ y)NF) r!r"buildPairPosClassesSubtabler#r r"rrr~r$rVs r%r&z"ClassPairPosSubtableBuilder.flush_EsY ?? "doo&=  (t}}7M7M N ;;   r"#( r]N) rrrrr\r,r.r2r&rer]r%rrs 46( )r]rc4eZdZdZdZdZdZdZdZdZ y) PairPosBuilderaBuilds a Pair Positioning (GPOS2) lookup. Attributes: font (``fontTools.TTLib.TTFont``): A font object. location: A string or tuple representing the location in the original source which produced this lookup. pairs: An array of class-based pair positioning tuples. Usually manipulated with the :meth:`addClassPair` method below. glyphPairs: A dictionary mapping a tuple of glyph names to a tuple of ``otTables.ValueRecord`` objects. Usually manipulated with the :meth:`addGlyphPair` method below. lookupflag (int): The lookup's flag markFilterSet: Either ``None`` if no mark filtering set is used, or an integer representing the filtering set to be used for this lookup. If a mark filtering set is provided, `LOOKUP_FLAG_USE_MARK_FILTERING_SET` will be set on the lookup's flags. c`tj|||ddg|_i|_i|_y)Nr5r()rSr\pairs glyphPairs locationsrs r%r\zPairPosBuilder.__init__cs-tT8VQ? r]cB|jj||||fy)aAdd a class pair positioning rule to the current lookup. Args: location: A string or tuple representing the location in the original source which produced this rule. Unused. glyphclass1: A set of glyph names for the "left" glyph in the pair. value1: A ``otTables.ValueRecord`` for positioning the left glyph. glyphclass2: A set of glyph names for the "right" glyph in the pair. value2: A ``otTables.ValueRecord`` for positioning the right glyph. N)r5r~)r#rX glyphclass1r( glyphclass2r*s r% addClassPairzPairPosBuilder.addClassPairis ; VDEr]c||f}|jj|d}|(|j|}tj d|||y||f|j|<||j|<y)aAdd a glyph pair positioning rule to the current lookup. Args: location: A string or tuple representing the location in the original source which produced this rule. glyph1: A glyph name for the "left" glyph in the pair. value1: A ``otTables.ValueRecord`` for positioning the left glyph. glyph2: A glyph name for the "right" glyph in the pair. value2: A ``otTables.ValueRecord`` for positioning the right glyph. NzGAlready defined position for pair %s %s at %s; choosing the first value)r6rr7rdebug) r#rXglyph1r(glyph2r*roldValueotherLocs r% addGlyphPairzPairPosBuilder.addGlyphPairvswv??&&sD1  ~~c*H II+  %+F#3DOOC "*DNN3 r]c|jj|j|j|j|jfyr_)r5r~rrs r%rz!PairPosBuilder.add_subtable_breaks= $$$$$$$$   r]ctj||xr4|j|jk(xr|j|jk(Sr_)rSrcr6r5ras r%rczPairPosBuilder.equalssC  u - *5#3#33 * ekk) r]cLi}t|}|jD]:\}}}}||jur|j'|j ||||<g}|j r/|j t|j |j|j |j|j|}|jjjdt} | dk7r,tj!dt#|j| ||S)zBuild the lookup. Returns: An ``otTables.Lookup`` object representing the pair positioning lookup. z0fontTools.otlLib.optimize.gpos:COMPRESSION_LEVEL)defaultrzCompacting GPOS...)rr5rr.r,r6rbuildPairPosGlyphsr"r2rprVrrrrinfor) r#buildersrr9r(r:r*r2r^levels r%rzPairPosBuilder.builds-d38<  F 4Kfd222((* OOKf E  F  ??   /O P**,-""9-  !! >/1"  A: HH) * 499eV 4 r]N) rrrrr\r;rBrrcrrer]r%r3r3Os&& F+8   r]r3c.eZdZdZdZdZdZdZdZy)r`aBuilds a Single Positioning (GPOS1) lookup. Attributes: font (``fontTools.TTLib.TTFont``): A font object. location: A string or tuple representing the location in the original source which produced this lookup. mapping: A dictionary mapping a glyph name to a ``otTables.ValueRecord`` objects. Usually manipulated with the :meth:`add_pos` method below. lookupflag (int): The lookup's flag markFilterSet: Either ``None`` if no mark filtering set is used, or an integer representing the filtering set to be used for this lookup. If a mark filtering set is provided, `LOOKUP_FLAG_USE_MARK_FILTERING_SET` will be set on the lookup's flags. cRtj|||ddi|_i|_y)Nr5r')rSr\r7rrs r%r\zSinglePosBuilder.__init__s&tT8VQ? r]c| t}|j||s!|j|}td|d|||r||j|<||j|<y)a?Add a single positioning rule. Args: location: A string or tuple representing the location in the original source which produced this lookup. glyph: A glyph name. otValueRection: A ``otTables.ValueRecord`` used to position the glyph. Nz.Already defined different position for glyph "z" at )r r\r7rr)r#rXr] otValueRecordrAs r%add_poszSinglePosBuilder.add_possh  'MM||E=1~~e,H"($  "/DLL  (ur]crt|tsJ|jj|}|duxs||k(Sr_)rFr rr)r#r]r_curValues r%r\zSinglePosBuilder.can_adds;%---<<##E*448u#44r]cdtj||xr|j|jk(Sr_rras r%rczSinglePosBuilder.equalsrr]cdt|j|j}|j|S)zBuild the lookup. Returns: An ``otTables.Lookup`` object representing the single positioning lookup. )buildSinglePosrr"rpros r%rzSinglePosBuilder.builds)#4<<?   ++r]N) rrrrr\rOr\rcrrer]r%r`r`s!  ).5 S,r]r`cT|sytj}t||_|S)aBuilds a single substitution (GSUB1) subtable. Note that if you are implementing a layout compiler, you may find it more flexible to use :py:class:`fontTools.otlLib.lookupBuilders.SingleSubstBuilder` instead. Args: mapping: A dictionary mapping input glyph names to output glyph names. Returns: An ``otTables.SingleSubst`` object, or ``None`` if the mapping dictionary is empty. N)r SingleSubstdictrrr#s r%rr s&  >> D=DL Kr]cT|sytj}t||_|S)aBuilds a multiple substitution (GSUB2) subtable. Note that if you are implementing a layout compiler, you may find it more flexible to use :py:class:`fontTools.otlLib.lookupBuilders.MultipleSubstBuilder` instead. Example:: # sub uni06C0 by uni06D5.fina hamza.above # sub uni06C2 by uni06C1.fina hamza.above; subtable = buildMultipleSubstSubtable({ "uni06C0": [ "uni06D5.fina", "hamza.above"], "uni06C2": [ "uni06D1.fina", "hamza.above"] }) Args: mapping: A dictionary mapping input glyph names to a list of output glyph names. Returns: An ``otTables.MultipleSubst`` object or ``None`` if the mapping dictionary is empty. N)r MultipleSubstrWrrXs r%rrs(2    D=DL Kr]cT|sytj}t||_|S)aBuilds an alternate substitution (GSUB3) subtable. Note that if you are implementing a layout compiler, you may find it more flexible to use :py:class:`fontTools.otlLib.lookupBuilders.AlternateSubstBuilder` instead. Args: mapping: A dictionary mapping input glyph names to a list of output glyph names. Returns: An ``otTables.AlternateSubst`` object or ``None`` if the mapping dictionary is empty. N)rAlternateSubstrWrrXs r%rr>s(    D7mDO Kr]c|sytj}i|_t|j |j D]w}tj }|dd|_t|jdz|_ |||_ |d}|jj|gj|y|S)aBuilds a ligature substitution (GSUB4) subtable. Note that if you are implementing a layout compiler, you may find it more flexible to use :py:class:`fontTools.otlLib.lookupBuilders.LigatureSubstBuilder` instead. Example:: # sub f f i by f_f_i; # sub f i by f_i; subtable = buildLigatureSubstSubtable({ ("f", "f", "i"): "f_f_i", ("f", "i"): "f_i", }) Args: mapping: A dictionary mapping tuples of glyph names to output glyph names. Returns: An ``otTables.LigatureSubst`` object or ``None`` if the mapping dictionary is empty. Nrr'r) r LigatureSubstrwrrr_getLigatureSortKeyLigature ComponentrC CompCountLigGlyphrlr~)rr#rrrs r%rrTs4    DDNW\\^1I1IJC ;;='^ !3!34q8#J/]  !!*b188B C Kr]ctj}||c|_|_d|_|||_d|_||+|jdk(sJd||_||_d|_|S)aBuilds an Anchor table. This determines the appropriate anchor format based on the passed parameters. Args: x (int): X coordinate. y (int): Y coordinate. point (int): Index of glyph contour point, if provided. deviceX (``otTables.Device``): X coordinate device table, if provided. deviceY (``otTables.Device``): Y coordinate device table, if provided. Returns: An ``otTables.Anchor`` object. r'r(z7Either point, or both of deviceX/deviceY, must be None.r)rAnchor XCoordinate YCoordinater= AnchorPoint XDeviceTable YDeviceTable)rypointdeviceXdeviceYr#s r% buildAnchorros 99;D)*A&Dd&DK   g1 KK1  E D E ## Kr]cRtj}g|_t||jD]R}||}t |Dcgc]}|j |}}|jjt|Tt|j|_ |Scc}w)aBuilds a base array record. As part of building mark-to-base positioning rules, you will need to define a ``BaseArray`` record, which "defines for each base glyph an array of anchors, one for each mark class." This function builds the base array subtable. Example:: bases = {"a": {0: a3, 1: a5}, "b": {0: a4, 1: a5}} basearray = buildBaseArray(bases, 2, font.getReverseGlyphMap()) Args: bases (dict): A dictionary mapping anchors to glyphs; the keys being glyph names, and the values being dictionaries mapping mark class ID to the appropriate ``otTables.Anchor`` object used for attaching marks of that class. numMarkClasses (int): The total number of mark classes for which anchors are defined. glyphMap: a glyph name to ID map, typically returned from ``font.getReverseGlyphMap()``. Returns: An ``otTables.BaseArray`` object. r) r BaseArray BaseRecordrrrangerr~buildBaseRecordrC BaseCount)rnumMarkClassesr"r#rr markClassrs r%buildBaseArrayrxs4 <<>DDOu("6"679 $K5:>5JK 155#KK w789)DN KLsB$c<tj}||_|Sr_)rrr BaseAnchorrr#s r%rtrts ==?DDO Kr]cB|sytj}||_|S)a Builds a component record. As part of building mark-to-ligature positioning rules, you will need to define ``ComponentRecord`` objects, which contain "an array of offsets... to the Anchor tables that define all the attachment points used to attach marks to the component." This function builds the component record. Args: anchors: A list of ``otTables.Anchor`` objects or ``None``. Returns: A ``otTables.ComponentRecord`` object or ``None`` if no anchors are supplied. N)rComponentRecordLigatureAnchorr{s r%buildComponentRecordrs%    D!D Kr]c|sytj}d|_t|j ||_g|_|j jD]G}||\}}tj }||_||_ |j j|It|j |_ |S)ayBuilds a cursive positioning (GPOS3) subtable. Cursive positioning lookups are made up of a coverage table of glyphs, and a set of ``EntryExitRecord`` records containing the anchors for each glyph. This function builds the cursive positioning subtable. Example:: subtable = buildCursivePosSubtable({ "AlifIni": (None, buildAnchor(0, 50)), "BehMed": (buildAnchor(500,250), buildAnchor(0,50)), # ... }, font.getReverseGlyphMap()) Args: attach (dict): A mapping between glyph names and a tuple of two ``otTables.Anchor`` objects representing entry and exit anchors. glyphMap: a glyph name to ID map, typically returned from ``font.getReverseGlyphMap()``. Returns: An ``otTables.CursivePos`` object, or ``None`` if the attachment dictionary was empty. Nr') r CursivePosr=r&rrrEntryExitRecordr EntryAnchor ExitAnchorr~rCEntryExitCount)attachr"r#r]rrr9s r%rrs2  ==?DDK!&++-:DMD%%)"(- Z  "%# ##C( ) d223D Kr]c|sytj}|j}t|x|_}t |x|_}d|cxkr|ksJJt||dzDcgc]}|j|dc}x|_ }t |}t|}|dkDr|dksJ|dkDr|dkr d|_ |S|dkDr|d kr d|_ |Sd |_ |Scc}w) aBuilds a Device record as part of a ValueRecord or Anchor. Device tables specify size-specific adjustments to value records and anchors to reflect changes based on the resolution of the output. For example, one could specify that an anchor's Y position should be increased by 1 pixel when displayed at 8 pixels per em. This routine builds device records. Args: deltas: A dictionary mapping pixels-per-em sizes to the delta adjustment in pixels when the font is displayed at that size. Returns: An ``otTables.Device`` object if any deltas were supplied, or ``None`` otherwise. Nrr'ir(ir*r) rDevicerrr StartSizemaxEndSizersr DeltaValue DeltaFormat) deltasr#rr startSizeendSizer deltaValuesmaxDeltaminDeltas r% buildDevicer s"  99;D ;;=D!$T*DNY Y&DL7 $W $$ $$ $(-i1(E% $ 4%DOk;H;H d?x#~- -"}A K B8a< K K%s-C!c tj}g|_t||jD]i}g}||D]9}|j t |Dcgc]}|j|c};|jj t|kt|j|_ |Scc}w)a6Builds a LigatureArray subtable. As part of building a mark-to-ligature lookup, you will need to define the set of anchors (for each mark class) on each component of the ligature where marks can be attached. For example, for an Arabic divine name ligature (lam lam heh), you may want to specify mark attachment positioning for superior marks (fatha, etc.) and inferior marks (kasra, etc.) on each glyph of the ligature. This routine builds the ligature array record. Example:: buildLigatureArray({ "lam-lam-heh": [ { 0: superiorAnchor1, 1: inferiorAnchor1 }, # attach points for lam1 { 0: superiorAnchor2, 1: inferiorAnchor2 }, # attach points for lam2 { 0: superiorAnchor3, 1: inferiorAnchor3 }, # attach points for heh ] }, 2, font.getReverseGlyphMap()) Args: ligs (dict): A mapping of ligature names to an array of dictionaries: for each component glyph in the ligature, an dictionary mapping mark class IDs to anchors. numMarkClasses (int): The number of mark classes. glyphMap: a glyph name to ID map, typically returned from ``font.getReverseGlyphMap()``. Returns: An ``otTables.LigatureArray`` object if deltas were supplied. r) r LigatureArrayLigatureAttachrrr~rsrbuildLigatureAttachrC LigatureCount)rrvr"r#rr componentrs r%buildLigatureArrayr2s>    DDd 4 45Ac PI NNn8MN"IMM"-N O P ""#6w#?@ A T001D KOsB; ctj}|Dcgc] }t|c}|_t |j|_|Scc}wr_)rrrr}rCComponentCount)rr#r's r%rr\sG   D=GH03HDd223D KIsAc"tj}g|_t|j |j D]1}||\}}t ||}|jj|3t|j|_ |S)a[Builds a mark array subtable. As part of building mark-to-* positioning rules, you will need to define a MarkArray subtable, which "defines the class and the anchor point for a mark glyph." This function builds the mark array subtable. Example:: mark = { "acute": (0, buildAnchor(300,712)), # ... } markarray = buildMarkArray(marks, font.getReverseGlyphMap()) Args: marks (dict): A dictionary mapping anchors to glyphs; the keys being glyph names, and the values being a tuple of mark class number and an ``otTables.Anchor`` object representing the mark's attachment point. glyphMap: a glyph name to ID map, typically returned from ``font.getReverseGlyphMap()``. Returns: An ``otTables.MarkArray`` object. r) r MarkArray MarkRecordrrrrbuildMarkRecordr~rC MarkCount)rtr"r#rvrwrmarkrecs r%rrds{4 <<>DDOuzz|)=)=>(!$K 6!)V4 w'()DN Kr]z&use buildMarkBasePosSubtable() instead)categoryct|||gS)zBuild a list of MarkBasePos (GPOS4) subtables. .. deprecated:: 4.58.0 Use :func:`buildMarkBasePosSubtable` instead. )r)rtrr"s r%buildMarkBasePosrs %UE8 < ==r]cNtj}d|_t|||_t |||_t|jDcgc]\}}| c}}dz|_ t|||_ t||j||_ |Scc}}w)aBuild a single MarkBasePos (GPOS4) subtable. This builds a mark-to-base lookup subtable containing all of the referenced marks and bases. Example:: # a1, a2, a3, a4, a5 = buildAnchor(500, 100), ... marks = {"acute": (0, a1), "grave": (0, a1), "cedilla": (1, a2)} bases = {"a": {0: a3, 1: a5}, "b": {0: a4, 1: a5}} markbaseposes = [buildMarkBasePosSubtable(marks, bases, font.getReverseGlyphMap())] Args: marks (dict): A dictionary mapping anchors to glyphs; the keys being glyph names, and the values being a tuple of mark class number and an ``otTables.Anchor`` object representing the mark's attachment point. (See :func:`buildMarkArray`.) bases (dict): A dictionary mapping anchors to glyphs; the keys being glyph names, and the values being dictionaries mapping mark class ID to the appropriate ``otTables.Anchor`` object used for attaching marks of that class. (See :func:`buildBaseArray`.) glyphMap: a glyph name to ID map, typically returned from ``font.getReverseGlyphMap()``. Returns: A ``otTables.MarkBasePos`` object. r') r MarkBasePosr=r& MarkCoveragerrrrr BaseCoveragerxrq)rtrr"r#rr*s r%rrs: >> DDK%eX6D#E84DN5<<>:%"a2:;a?DO%eX6D#E4??HEDN K; B! z%use buildMarkLigPosSubtable() insteadct|||gS)zBuild a list of MarkLigPos (GPOS5) subtables. .. deprecated:: 4.58.0 Use :func:`buildMarkLigPosSubtable` instead. )r)rtrr"s r%buildMarkLigPosrs $E4 : ;;r]cNtj}d|_t|||_t |||_t|jDcgc]\}}| c}}dz|_ t|||_ t||j||_ |Scc}}w)aBuild a single MarkLigPos (GPOS5) subtable. This builds a mark-to-base lookup subtable containing all of the referenced marks and bases. Note that if you are implementing a layout compiler, you may find it more flexible to use :py:class:`fontTools.otlLib.lookupBuilders.MarkLigPosBuilder` instead. Example:: # a1, a2, a3, a4, a5 = buildAnchor(500, 100), ... marks = { "acute": (0, a1), "grave": (0, a1), "cedilla": (1, a2) } ligs = { "f_i": [ { 0: a3, 1: a5 }, # f { 0: a4, 1: a5 } # i ], # "c_t": [{...}, {...}] } markligpose = buildMarkLigPosSubtable(marks, ligs, font.getReverseGlyphMap()) Args: marks (dict): A dictionary mapping anchors to glyphs; the keys being glyph names, and the values being a tuple of mark class number and an ``otTables.Anchor`` object representing the mark's attachment point. (See :func:`buildMarkArray`.) ligs (dict): A mapping of ligature names to an array of dictionaries: for each component glyph in the ligature, an dictionary mapping mark class IDs to anchors. (See :func:`buildLigatureArray`.) glyphMap: a glyph name to ID map, typically returned from ``font.getReverseGlyphMap()``. Returns: A ``otTables.MarkLigPos`` object. r') r MarkLigPosr=r&rrrrrrLigatureCoveragerr)rtrr"r#rr*s r%rrsT ==?DDK%eX6D#E84DN5<<>:%"a2:;a?DO)$9D+D$//8LD K;rct|tsJt|tjsJtj}||_||_|Sr_)rFrGrrerr% MarkAnchor)classIDrr#s r%rrsD gs ## # fbii (( ( ==?DDJDO Kr]c<tj}||_|Sr_)rr Mark2Anchorr{s r%rr s >> DD Kr]c^||Sd}|D]!}||| |||jz}#|Sr) getFormat)frrPmaskr_s r%_getValueFormatr sM} D)  q!5 E!H&&( (D) Kr]ct}td}td}t|D]8\}}|j||j ||j |:t j } d| _t||jdx}| _ t||jdx}| _ t||| _ |j| _|j| _|j#} |j#} g| _| D]} t j$} g| _| j$j)| | D]t}t j&}|j+| |fd\}}|r t-||nd |_|r t-||nd |_| j&j)|vt3| j$| _t3| | _| S) aBuilds a class pair adjustment (GPOS2 format 2) subtable. Kerning tables are generally expressed as pair positioning tables using class-based pair adjustments. This routine builds format 2 PairPos subtables. Note that if you are implementing a layout compiler, you may find it more flexible to use :py:class:`fontTools.otlLib.lookupBuilders.ClassPairPosSubtableBuilder` instead, as this takes care of ensuring that the supplied pairs can be formed into non-overlapping classes and emitting individual subtables whenever the non-overlapping requirement means that a new subtable is required. Example:: pairs = {} pairs[( [ "K", "X" ], [ "W", "V" ] )] = ( buildValue(xAdvance=+5), buildValue() ) # pairs[(... , ...)] = (..., ...) pairpos = buildPairPosClassesSubtable(pairs, font.getReverseGlyphMap()) Args: pairs (dict): Pair positioning data; the keys being a two-element tuple of lists of glyphnames, and the values being a two-element tuple of ``otTables.ValueRecord`` objects. glyphMap: a glyph name to ID map, typically returned from ``font.getReverseGlyphMap()``. valueFormat1: Force the "left" value records to the given format. valueFormat2: Force the "right" value records to the given format. Returns: A ``otTables.PairPos`` object. TrFr(rr'rsrc valueFormatN)rrrrrrPairPosr=rr ValueFormat1 ValueFormat2r&rr ClassDef1 ClassDef2r Class1Record Class2Recordr~rr Value1Value2rC Class1Count Class2Count)r5r" valueFormat1 valueFormat2r classDef1 classDef2r'r)r#classes1classes2c1rec1c2rec2val1val2s r%r1r1 sNuH$/I%0I5MS c c ::. s!A$r]rrN)rrr=rrrrrkrlr~r&rrrPairSetrPairValueRecordr SecondGlyphr rrrCPairValueCount PairSetCount)r5r"rrr#rrrrrrr*r]psr?rrpvrs ` r%rr s@ ::&,4 VR ''t(<=>!">A1">IDMDL%%4 ZZ\ B"(57O"P + FD$$$&C$CO ,? J ,? J    % %c * +  2 23%4&DLL)D K-#?s= G# cgt}}iiic}}|jD]Z\}}t|}|j|gj ||j|dgj |||<\|jD]_\}} t | t |zdkDs!| D cic]} | | } } |j t| |j|a|jD]{\} } | Dcgc] }||vs| }}t |dkDs)i}|D] |jfd|D"|j t||j|}|jD]3\}} ||vs | D]} t| |i}|j 5|jfd|Scc} wcc}w)aBuilds a list of single adjustment (GPOS1) subtables. This builds a list of SinglePos subtables from a dictionary of glyph names and their positioning adjustments. The format of the subtables are determined to optimize the size of the resulting subtables. See also :func:`buildSinglePosSubtable`. Note that if you are implementing a layout compiler, you may find it more flexible to use :py:class:`fontTools.otlLib.lookupBuilders.SinglePosBuilder` instead. Example:: mapping = { "V": buildValue({ "xAdvance" : +5 }), # ... } subtables = buildSinglePos(pairs, font.getReverseGlyphMap()) Args: mapping (dict): A mapping between glyphnames and ``otTables.ValueRecord`` objects. glyphMap: a glyph name to ID map, typically returned from ``font.getReverseGlyphMap()``. Returns: A list of ``otTables.SinglePos`` objects. rrr'c3,K|] }|f ywr_re)r0rrrs r%r3z!buildSinglePos.. s%Kq&)n%Ksct|Sr_)_getSinglePosTableKey)r1r"s r%rz buildSinglePos.. s3Ax@r]r) rrk_getSinglePosValueKeyrlr~rC_getSinglePosValueSizebuildSinglePosSubtablerrsort)rr"rmhandled coveragesmasksr]r_rrrformat1Mappingrrrrf2format2MappingrMrs ` ` @r%rTrT s<#%GF "2rIuf  u#E*S"%,,U3 Q$++C0s !( V v;/4 4q 86<=an=N= MM0J K KK  #[[] T 2A'!1a 2 2 r7Q;N L%%%Kil%KK L MM0J K NN2 !( V g  H+Qs ,3s9 G! G&G&cLtj}t|j||_t t j|jDcgc]}|jc}dx}|_ |jjDcgc]}t|||c}tfdDr+d|_|jdk7r d|_|Sd|_|Sd|_|_t!|j|_|Scc}wcc}w)aBuilds a single adjustment (GPOS1) subtable. This builds a list of SinglePos subtables from a dictionary of glyph names and their positioning adjustments. The format of the subtable is determined to optimize the size of the output. See also :func:`buildSinglePos`. Note that if you are implementing a layout compiler, you may find it more flexible to use :py:class:`fontTools.otlLib.lookupBuilders.SinglePosBuilder` instead. Example:: mapping = { "V": buildValue({ "xAdvance" : +5 }), # ... } subtable = buildSinglePos(pairs, font.getReverseGlyphMap()) Args: mapping (dict): A mapping between glyphnames and ``otTables.ValueRecord`` objects. glyphMap: a glyph name to ID map, typically returned from ``font.getReverseGlyphMap()``. Returns: A ``otTables.SinglePos`` object. rrc3.K|] }|dk(ywr.re)r0r valueRecordss r%r3z)buildSinglePosSubtable..H s 6A1 Q  6sr'Nr()r SinglePosr&rrrrrG__or__rr ValueFormatrr r9r=ValuerC ValueCount)rr"r#rrrrs @r%rr! s< <<>D!&++-:DM%+ FMMO> DS[)DO$//*DO Kr]ctj}t|trd|_|\|_|_|Sd|_||_|S)Nrr')r CaretValuerFrr= Coordinate DeviceTable)coordr#s r%buildCaretValueForCoordr sK ==?D% ,1)) K  Kr]cJtj}d|_||_|S)Nr()rrr=CaretValuePoint)rlr#s r%buildCaretValueForPointr! s! ==?DDK D Kr]c f|rt|jn t}|r|j|j|Dcic]-}|t|j ||j |/}}|j Dcic] \}}| || }}}|syt j}t|j||_ |jjDcgc]}|| c}|_ t|j|_ |Scc}wcc}}wcc}w)aBuilds a ligature caret list table. Ligatures appear as a single glyph representing multiple characters; however when, for example, editing text containing a ``f_i`` ligature, the user may want to place the cursor between the ``f`` and the ``i``. The ligature caret list in the GDEF table specifies the position to display the "caret" (the character insertion indicator, typically a flashing vertical bar) "inside" the ligature to represent an insertion point. The insertion positions may be specified either by coordinate or by contour point. Example:: coords = { "f_f_i": [300, 600] # f|fi cursor at 300 units, ff|i cursor at 600. } points = { "c_t": [28] # c|t cursor appears at coordinate of contour point 28. } ligcaretlist = buildLigCaretList(coords, points, font.getReverseGlyphMap()) Args: coords: A mapping between glyph names and a list of coordinates for the insertion point of each ligature component after the first one. points: A mapping between glyph names and a list of contour points for the insertion point of each ligature component after the first one. glyphMap: a glyph name to ID map, typically returned from ``font.getReverseGlyphMap()``. Returns: A ``otTables.LigCaretList`` object if any carets are present, or ``None`` otherwise.N)rrrr buildLigGlyphrrkr LigCaretListr&rrrcrC LigGlyphCount)coordsrr"rrcaretsr'r#s r%buildLigCaretListr( s@$*S suF  fkkm$FL Mavzz!}fjjm<< MF M%||~ ?tq!ad ?F ?  ?? D!&++-:DM(, (<(<=1VAY=DMT]]+D KN ? >s 2D# D(D(3 D.cdg}|r6t|d}|j|Dcgc] }t|c}|r1|jt|Dcgc] }t|c}|syt j }||_t|j |_|Scc}wcc}w)Nc0t|tr|dS|Sr)rFr)r's r%rzbuildLigGlyph.. sjE6JadPQr]r) rrrr!rrcrrC CaretCount)r&rr'r'rr#s r%r#r# s F $QR 6Ba.q1BC  6&>Ja.q1JK  ;;=DDO$//*DO KCJs B(B-c|sytj}d|_|Dcgc]}t||c}|_t |j|_|Scc}w)aBuilds a mark glyph sets definition table. OpenType Layout lookups may choose to use mark filtering sets to consider or ignore particular combinations of marks. These sets are specified by setting a flag on the lookup, but the mark filtering sets are defined in the ``GDEF`` table. This routine builds the subtable containing the mark glyph set definitions. Example:: set0 = set("acute", "grave") set1 = set("caron", "grave") markglyphsets = buildMarkGlyphSetsDef([set0, set1], font.getReverseGlyphMap()) Args: markSets: A list of sets of glyphnames. glyphMap: a glyph name to ID map, typically returned from ``font.getReverseGlyphMap()``. Returns An ``otTables.MarkGlyphSetsDef`` object. Nr')rMarkGlyphSetsDefMarkSetTableFormatr&rrC MarkSetCount)markSetsr"r#ms r%buildMarkGlyphSetsDefr2 sU2    DD9ABA]1h/BDMDMM*D KCsAc.eZdZdZdZdZdZdZdZy)rz$Helper for building ClassDef tables.c>t|_i|_||_yr_)rclasses_glyphs_ useClass0_)r#rs r%r\zClassDefBuilder.__init__< s  #r]ct|ttfr t|}t |}||j vry|D]}||j vsyy)NTF)rFr frozensetrrr5r6r#rr]s r%rzClassDefBuilder.canAddA sU fsI. /F^Fv T]] " E $ r]ct|ttfr t|}t |}||j vry|j j ||D]/}||jvrtd|dd||j|<1y)NzGlyph z is already present in class.) rFrr9rrr5rr6rr:s r%rzClassDefBuilder.addL s fsI. /F^Fv T]] "  &! )E $&UG#@A4#)DLL   )r]ct|jd}|js|jdt |S)Nct| |fSr_r)rs r%rz)ClassDefBuilder.classes..g ss1vgq\r]rr)rr5r7rNr9)r#rms r%rzClassDefBuilder.classesZ s1 +AB MM!Y[ ) r]ci}t|jD]\}}|dk(r |D]}|||< tj}||_|Sr)r<rrr#r$)r# glyphClassesrrr]classDefs r%rzClassDefBuilder.buildl sb (8 .OGV!| .&- U# . . ;;=)r]N) rrrrr\rrrrrer]r%rr9 s.$  )$ r]riic:tjd|d<tjx}|d_t |||||_t||||\}}|sd|_nd|_t|||||} | |z}|djjtj} || _ d|_| |_t!||_d|_d |_|r3tj&} || _| |_t!||_y y ) a Add a 'STAT' table to 'ttFont'. 'axes' is a list of dictionaries describing axes and their values. Example:: axes = [ dict( tag="wght", name="Weight", ordering=0, # optional values=[ dict(value=100, name='Thin'), dict(value=300, name='Light'), dict(value=400, name='Regular', flags=0x2), dict(value=900, name='Black'), ], ) ] Each axis dict must have 'tag' and 'name' items. 'tag' maps to the 'AxisTag' field. 'name' can be a name ID (int), a string, or a dictionary containing multilingual names (see the addMultilingualName() name table method), and will translate to the AxisNameID field. An axis dict may contain an 'ordering' item that maps to the AxisOrdering field. If omitted, the order of the axes list is used to calculate AxisOrdering fields. The axis dict may contain a 'values' item, which is a list of dictionaries describing AxisValue records belonging to this axis. Each value dict must have a 'name' item, which can be a name ID (int), a string, or a dictionary containing multilingual names, like the axis name. It translates to the ValueNameID field. Optionally the value dict can contain a 'flags' item. It maps to the AxisValue Flags field, and will be 0 when omitted. The format of the AxisValue is determined by the remaining contents of the value dictionary: If the value dict contains a 'value' item, an AxisValue record Format 1 is created. If in addition to the 'value' item it contains a 'linkedValue' item, an AxisValue record Format 3 is built. If the value dict contains a 'nominalValue' item, an AxisValue record Format 2 is built. Optionally it may contain 'rangeMinValue' and 'rangeMaxValue' items. These map to -Infinity and +Infinity respectively if omitted. You cannot specify Format 4 AxisValue tables this way, as they are not tied to a single axis, and specify a name for a location that is defined by multiple axes values. Instead, you need to supply the 'locations' argument. The optional 'locations' argument specifies AxisValue Format 4 tables. It should be a list of dicts, where each dict has a 'name' item, which works just like the value dicts above, an optional 'flags' item (defaulting to 0x0), and a 'location' dict. A location dict key is an axis tag, and the associated value is the location on the specified axis. They map to the AxisIndex and Value fields of the AxisValueRecord. Example:: locations = [ dict(name='Regular ABCD', location=dict(wght=300, ABCD=100)), dict(name='Bold ABCD XYZ', location=dict(wght=600, ABCD=200)), ] The optional 'elidedFallbackName' argument can be a name ID (int), a string, a dictionary containing multilingual names, or a list of STATNameStatements. It translates to the ElidedFallbackNameID field. The 'ttFont' argument must be a TTFont instance that already has a 'name' table. If a 'STAT' table already exists, it will be overwritten by the newly created one. STATwindowsmac) windowsNamesmacNamesiirr*rN)r newTablerrBrK_addNameElidedFallbackNameID_buildAxisRecordsVersion_buildAxisValuesFormat4namesrAxisRecordArrayAxisDesignAxisRecordSizeDesignAxisRecordrCDesignAxisCountAxisValueCountAxisValueArray AxisValue) ttFontaxesr7elidedFallbackNamerFrG statTable axisRecords axisValuesmultiAxisValuesaxisRecordArrayaxisValueArrays r%buildStatTabler` s$r^^F+F6N')wwy0Iv$%-"Lh&I" 0 f<(K & ' 1 tV, %z1  6N((*O&O%&I"!0I #K 0I I#I**,#- #1  #&z?  r]cg}g}t|D]X\}}tj}|d|_t ||dd|||_|j d||_|j||j ddD]} tj} || _ | j dd | _ t || d||| _ d | vr(| d | _ d | vrd | _| d | _n_d | _nWd| vrHd| _| d| _| j dt"| _| j dt&| _n t+d|j| [||fS)NtagrrCorderingrrerIrr_ linkedValuerr' nominalValuer( rangeMinValue rangeMaxValuez$Can't determine format for AxisValue)r<r AxisRecordAxisTagrI AxisNameIDr AxisOrderingr~rV AxisIndexFlags ValueNameIDrr= LinkedValue NominalValueAXIS_VALUE_NEGATIVE_INFINITY RangeMinValueAXIS_VALUE_POSITIVE_INFINITY RangeMaxValuer!) rXrWrFrGr[r\axisRecordIndexaxisDictaxisaxisVal axisValRecs r%rKrK sKJ%.t_$*!}} " HV$c.> s cmmr]r)r<rrVr=rIrorrnrkAxisValueRecordrmrr~rrC AxisCount)r7rXrWrFrGaxisTagToIndexrvrwr\axisLocationDictrzaxisValueRecordsrbr_r}s r%rMrM+ s N%.t_:!*9x':J%&\\^  !) $V,l" ,//; *:6<<> )JC$$&C*3/CMCI  # #C (  ) ";<"#34 %5 "*%!&" r]c|d}t|tr|St|tr t|}nt|tr|}nt|trq|j }|D]Z}t|t r>|j|j||j|j|jQtd|Std|j|||||S)Nr)enz*value must be a list of STATNameStatementsz$value must be int, str, dict or list)rWrDrE minNameID)rFrGrrWr_findUnusedNameIDrsetNamestring platformID platEncIDlangID TypeErroraddMultilingualName) rWr_rrDrE nameTablerNnameID nameRecords r%rIrIE svI% % E4  E4 ,,. NJ*&78!!%%))((%%  LMM N >??  ( ( fg3) ) r]c .|j} tjdx|d<} tjx| _} d| _| jt|| _ t| ||||| _ t| |||| | | _ y)a, Add a 'MATH' table to 'ttFont'. 'constants' is a dictionary of math constants. The keys are the constant names from the MATH table specification (with capital first letter), and the values are the constant values as numbers. 'italicsCorrections' is a dictionary of italic corrections. The keys are the glyph names, and the values are the italic corrections as numbers. 'topAccentAttachments' is a dictionary of top accent attachments. The keys are the glyph names, and the values are the top accent horizontal positions as numbers. 'extendedShapes' is a set of extended shape glyphs. 'mathKerns' is a dictionary of math kerns. The keys are the glyph names, and the values are dictionaries. The keys of these dictionaries are the side names ('TopRight', 'TopLeft', 'BottomRight', 'BottomLeft'), and the values are tuples of two lists. The first list contains the correction heights as numbers, and the second list contains the kern values as numbers. 'minConnectorOverlap' is the minimum connector overlap as a number. 'vertGlyphVariants' is a dictionary of vertical glyph variants. The keys are the glyph names, and the values are tuples of glyph name and full advance height. 'horizGlyphVariants' is a dictionary of horizontal glyph variants. The keys are the glyph names, and the values are tuples of glyph name and full advance width. 'vertGlyphAssembly' is a dictionary of vertical glyph assemblies. The keys are the glyph names, and the values are tuples of assembly parts and italics correction. The assembly parts are tuples of glyph name, flags, start connector length, end connector length, and full advance height. 'horizGlyphAssembly' is a dictionary of horizontal glyph assemblies. The keys are the glyph names, and the values are tuples of assembly parts and italics correction. The assembly parts are tuples of glyph name, flags, start connector length, end connector length, and full advance width. Where a number is expected, an integer or a float can be used. The floats will be rounded. Example:: constants = { "ScriptPercentScaleDown": 70, "ScriptScriptPercentScaleDown": 50, "DelimitedSubFormulaMinHeight": 24, "DisplayOperatorMinHeight": 60, ... } italicsCorrections = { "fitalic-math": 100, "fbolditalic-math": 120, ... } topAccentAttachments = { "circumflexcomb": 500, "acutecomb": 400, "A": 300, "B": 340, ... } extendedShapes = {"parenleft", "parenright", ...} mathKerns = { "A": { "TopRight": ([-50, -100], [10, 20, 30]), "TopLeft": ([50, 100], [10, 20, 30]), ... }, ... } vertGlyphVariants = { "parenleft": [("parenleft", 700), ("parenleft.size1", 1000), ...], "parenright": [("parenright", 700), ("parenright.size1", 1000), ...], ... } vertGlyphAssembly = { "braceleft": [ ( ("braceleft.bottom", 0, 0, 200, 500), ("braceleft.extender", 1, 200, 200, 200)), ("braceleft.middle", 0, 100, 100, 700), ("braceleft.extender", 1, 200, 200, 200), ("braceleft.top", 0, 200, 0, 500), ), 100, ], ... } MATHiN)rWr rHrrrKrLr_buildMathConstants MathConstants_buildMathGlyphInfo MathGlyphInfo_buildMathVariants MathVariants)rW constantsitalicsCorrectionstopAccentAttachmentsextendedShapes mathKernsminConnectorOverlapvertGlyphVariantshorizGlyphVariantsvertGlyphAssemblyhorizGlyphAssemblyr"mathrKs r%buildMathTableri sT((*H!NN622F6NT"DJEM -i8E- E, Er]cP|sytj}|jD]{}t|j |j d}|j r1t|j tjsJt|}t||j |}|Sr) rr getConvertersr rr tableClass issubclassMathValueRecord_mathValueRecordr)r mathConstantsconvr_s r%rr s $$&M++-1 dii34 ??door/A/AB BB$U+E tyy%0 1 r]ct||||gsytj}|j|rt |j |}tj |_||j _t|j|j _ |jDcgc]}t||c}|j _ |rt |j |}tj|_ ||j_t|j|j_|jDcgc]}t||c}|j_|rt |||_|rit |j |}tj$|_||j$_t|j|j$_g|j$_|jD]}tj,} dD]} | ||vs ||| \} } t| t| dz k(sJtj.} t| | _| Dcgc] }t|c}| _| Dcgc] }t|c}| _t7| | d| |j$j*j9| |Scc}wcc}wcc}wcc}w)N>TopLeftTopRight BottomLeft BottomRightr'MathKern)rrrrr&rrMathItalicsCorrectionInforrCrItalicsCorrectionCountrItalicsCorrectionMathTopAccentAttachmentTopAccentCoverageTopAccentAttachmentCountTopAccentAttachmentExtendedShapeCoverage MathKernInfoMathKernCoverage MathKernCountMathKernInfoRecordsMathKernInfoRecordr HeightCountCorrectionHeight KernValuerr~)r"rrrrrHrnr]recordsidecorrectionHeights kernValueskernhrs r%rr s  24H)T U   D !3!8!8!:HE)+)E)E)G&2:&&/@CHOO@T&&==E__< 89 /2 3< &&8 !5!:!:!8%L" !18<OO--5**-hoo*>'02-__ AE**,FL =9U++4=e4DT4J1%z01S_q5HHHH;;=D'*+<'=D$5F-01(+-D)DN%Na&6q&9%NDNFtfH$5t< =    1 1 8 8 @ A KK< < *-&Os-K4 K9K>Lct||||gsytj}|j||_|s|rt |||\|_|_|s|rt |||\|_|_ |Sr_) rrrrMinConnectorOverlap_buildMathGlyphConstructionVertGlyphCoverageVertGlyphConstructionHorizGlyphCoverageHorizGlyphConstruction)r"rrrrrvariantss r%rr4 s  .0ACUV  H #6H - '!!  C"H$B/ '""  E#X%D Or]c*t}|r|j|j|r|j|jt||}g}|jD]}t j }|j|rq||vrmt|||_ g|_ ||D]K\}} t j} || _ t| | _ |jj| M|r||vr||\} } t j|_t!| |j_t| |j_g|j_| D]} | \}}}}} t j(} || _t-|| _t|| _t|| _t| | _|jj&j| |j|||fSr_)rrrrr&rrMathGlyphConstructionrrC VariantCountMathGlyphVariantRecord VariantGlyphr AdvanceMeasurementr~ GlyphAssemblyrr PartCount PartRecordsGlyphPartRecordr]rG PartFlagsStartConnectorLengthEndConnectorLength FullAdvance)r"r assembliesrr constructions glyphName construction variantNameadvancerpartsicpart part_namerIstartends r%rr[ s UF hmmo& joo'(VX.HM__+ //1 %%'  X-(+HY,?(@L %24L /(0(; C$ W224&1#,3G,<)33::6B  C )z1"9-IE2)+)9)9);L &;KB;OL & & 836u:L & & 057L & & 2 F8<5 5%g++-( #&u: .5en+,3CL)%,W%5"**66==fE F \*;+> ] ""r]cNtj}t||_|Sr_)rrr r)r_ value_records r%rr s"%%'L L r])rNNF)NNNr)Nr(TT) rWrrY"Union[STATName, STATNameStatement]rFrrGrrNone)TT)rTT) rWrr_rrrGrDrrErrrG) NNNNNrNNNN){ __future__r collectionsrrr{typingrrfontTools.misc.fixedToolsrfontTools.misc.roundToolsr fontToolsr fontTools.ttLib.tablesr rfontTools.ttLib.tables.otBaser r rrfontTools.ttLib.ttFontrfontTools.feaLib.astrfontTools.otlLib.optimize.gposrrfontTools.otlLib.errorrfontTools.misc.loggingToolsr functoolsrloggingr getLoggerrrr&LOOKUP_FLAG_RIGHT_TO_LEFTLOOKUP_FLAG_IGNORE_BASE_GLYPHSLOOKUP_FLAG_IGNORE_LIGATURESLOOKUP_FLAG_IGNORE_MARKSrErQobjectrSrrrrr2rdrzrrrrrrrrrr3r`rrrrrorxrtrrrrrrDeprecationWarningrrrrrrrr1rGrrTrrrrrrrrrrr!r(r#r2rrrrtrGrSTATNamer`rKrMrIrrrrrrrer]r%rs"/2-1 *249 g!$N#!'%!%+"EPoFod.QM.Qb<$&OP<//d` ]` F *3*ZM5M`3P=3Pl+N=+N\> > BUUpQ QhVVr6 ]6 rhNmhNV+N+N\=)&=)@t]tn=,}=,F*@,(\>!H,&R$N'T!H,7I>>$N:EWX<Y<1hL^)X=@Od1h/ .*TU >0 +\  D<f<~ ,K<+J; c4S>) *8 => ~3 ~3; ~3  ~3  ~3 ~3B(#V: ! ! -!! !  !  !L@F 7t$N(#Vr]