L i'KdZddlmZddlZddlZddlZddlmZmZm Z m Z m Z m Z m Z ddlmZmZmZmZmZmZmZmZmZddlmZmZddlmZmZmZmZm Z m!Z!m"Z"ejFe$Z%eeeege&fZ' ddZ(d d e(f dd Z)d d e(f dd Z* dd Z+ ddZ,ddZ- ddZ. ddZ/y)zAllows building all the variable fonts of a DesignSpace version 5 by splitting the document into interpolable sub-space, then into each VF. ) annotationsN)AnyCallableDictIteratorListTuplecast) AxisDescriptorAxisMappingDescriptorDesignSpaceDocumentDiscreteAxisDescriptorInstanceDescriptorRuleDescriptorSimpleLocationDictSourceDescriptorVariableFontDescriptor) StatNames getStatNames) ConditionSetRangeRegiongetVFUserRegionlocationInRegionregionInRegionuserRegionToDesignRegionc|jxs|jjd}|jxs|jjd}|d|dS)zDefault callable to synthesize an instance filename when makeNames=True, for instances that don't specify an instance name in the designspace. This part of the name generation can be overriden because it's not specified by the STAT table. en-z.ttf) familyName familyNamesget styleName styleNames)docinstance statNamesr r#s d/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/fontTools/designspaceLib/split.pydefaultMakeInstanceFilenamer))sY$$G (=(=(A(A$(GJ""Di&:&:&>&>t&DI\9+T **Tc #"Kg}i}|jD]x}t|dr"tt|}|j |1tt |}t |j|j|j||j<ztj|Dcgc]}|jc}}|D]F}t||D cic]\} } | j| } } } t|i|| d|||} | | fHycc}wcc} } ww)aSplit the given DS5 into several interpolable sub-designspaces. There are as many interpolable sub-spaces as there are combinations of discrete axis values. E.g. with axes: - italic (discrete) Upright or Italic - style (discrete) Sans or Serif - weight (continuous) 100 to 900 There are 4 sub-spaces in which the Weight axis should interpolate: (Upright, Sans), (Upright, Serif), (Italic, Sans) and (Italic, Serif). The sub-designspaces still include the full axis definitions and STAT data, but the rules, sources, variable fonts, instances are trimmed down to only keep what falls within the interpolable sub-space. Args: - ``makeNames``: Whether to compute the instance family and style names using the STAT data. - ``expandLocations``: Whether to turn all locations into "full" locations, including implicit default axis values where missing. - ``makeInstanceFilename``: Callable to synthesize an instance filename when makeNames=True, for instances that don't specify an instance name in the designspace. This part of the name generation can be overridden because it's not specified by the STAT table. .. versionadded:: 5.0 valuesTkeepVFs makeNamesexpandLocationsmakeInstanceFilenameN)axeshasattrr rappendr rminimummaximumdefaultname itertoolsproductr,zip_extractSubSpace) r%r/r0r1 discreteAxesinterpolableUserRegionaxisvalueCombinationsr, discreteAxisvaluediscreteUserLocationsubDocs r(splitInterpolablerE6s,DL%'  4 ".5D    %-D05   1 "499 - "))L+QDDKK+QR# +(+<'@ # e   u $  "  >% >)= >+!5  #F** +,R sBD!D4D D #,DFc #K|jD]N}t||}t||d|||}i|j|j|_|j|fPyw)a$Convert each variable font listed in this document into a standalone designspace. This can be used to compile all the variable fonts from a format 5 designspace using tools that can only deal with 1 VF at a time. Args: - ``makeNames``: Whether to compute the instance family and style names using the STAT data. - ``expandLocations``: Whether to turn all locations into "full" locations, including implicit default axis values where missing. - ``makeInstanceFilename``: Callable to synthesize an instance filename when makeNames=True, for instances that don't specify an instance name in the designspace. This part of the name generation can be overridden because it's not specified by the STAT table. .. versionadded:: 5.0 Fr-N)getVariableFontsrr<libr8)r%r/r0r1vf vfUserRegionvfDocs r(splitVariableFontsrLysq.""$ &sB/   +!5  ,uyy+BFF+ ggun sA#A%cni}t|D]$\}}t|D]\}}d|_|||<&|S)zConvert each variable font listed in this document into a standalone format 4 designspace. This can be used to compile all the variable fonts from a format 5 designspace using tools that only know about format 4. .. versionadded:: 5.0 z4.1)rErL formatVersion)r%vfs _locationrDvfNamerKs r( convert5to4rRsR C.s3  6/7 MFE"'E CK   Jr*cVt}fd}jD]!}||j} t| ts$t |ds1t t|}|jt|j|j|j|jt| j|j| jxs |jt| j |j |j"D cgc]+\} } | j| cxkr| j krnn| | f-c} } dd $gx|_} |jDchc]}|jc}j$D]} t'fd| j(j+Ds1t'fd| j,j+Ds,t.j1d| j(| j,t3}|j5| j(j+|j5| j,j+jD]}|j|vr||j} | j|jk7s?| j| j|jk7s| j |j k7syt.j1d|j| j7t9| j(| j,t;|}t=j>||_j@|_ jBD]}tEjG|jH|s)|jKtM|jN|jP|jR|jtU||||jV|jX|jZ|j\|j^|j` |jc}jc}|||jd|_2|rjgD]}ti|}tk||s|jmto|j|jN|jpDcgc]!}t||jtr|#c}|jr jtD]}tE|jw|s |rty|jw}|jXxs|jzj}d }|jZxs|j~j}d }|jtdid |jNxs |||d |jPd|jRd|jxs|d|drin |jdtU|||d|d|d|jxs |jd|jxs|jj}d d|jxs |jd|jdxs |jzd|jxs |j~d|jxs |jd|jxsid|jr|jtdid |jNd |jPd|jRd|jdrin |jdtU|||d|jXd|jZd|jd|jd|jd|jdd|jd|jd|jd|jrjr|_9|Scc} } wcc}wcc}w)NcBr|jS|jSN)getFullDesignLocationdesignLocation)objectr%r0s r(maybeExpandDesignLocationz3_extractSubSpace..maybeExpandDesignLocations# //4 4(( (r*r5) tagr8 labelNameshiddenr5r7r6map axisOrdering axisLabelsc3&K|]}|v ywrU.0r? subDocAxess r( z#_extractSubSpace..sO$4:%Oc3&K|]}|v ywrUrarbs r(rez#_extractSubSpace..sP$4:%PrfzPIn axis mapping from input %s, some output axes are not in the variable-font: %szALimiting axis ranges used in elements not supported: %s) inputLocationoutputLocation) filenamepathfontr8rW layerNamer r# muteKerningmuteInfomutedGlyphNames)r8rj axisSubsetsrHrrjrkrlr8 userLocationrWr r#postScriptFontNamestyleMapFamilyNamestyleMapStyleNamelocalisedFamilyNamelocalisedStyleNamelocalisedStyleMapFamilyNamelocalisedStyleMapStyleNamerHra)Jr r2r8 isinstancerr3r r addAxisrZr[r\maxr5r7minr6r] axisMappingsallrhkeysriLOGGERerrorsetupdater4r r_subsetRulesBasedOnConditionsrulesrulesProcessingLastsourcesr map_backwardrW addSourcerrjrkrl_filterLocationrmr r#rnrorp findDefaultrwrGrraddVariableFontrrqrH instancesgetFullUserLocationrr!r"r$ addInstancerrsrtrustyleMapFamilyNamesrvrxryrz)r% userRegionr.r/r0r1rDrYr?rangeuserdesignmappingsmapping mappingAxes designRegionsource vfDefault oldDefaultrIrJ axisSubsetr&r'r r#rds` ` @r(r<r<s! "F) 499% eU #i(@-D NN#;; t||<!MM9T\\ t||<-1HH(D& ==DAEMMAv "&## :&('F((. 4$))4J##" O'2G2G2L2L2NOO P'2H2H2M2M2OPP LLb%%&&  e 70055787116689HH Dyy +tyy)E -MM-%--4<<2O==DLL0 WII   !%33&55  ;" P,C '/&@&@'3 22#$)1(D(D)- ,,'((0'B'B(, +++,190T0T15 44/008/R/R034! 5 >   "%..!""  (7HL"<0B46O"' 1=1C1C1E 7- ~ *nucl;%M)::/3+&M)::')-'8'E'En'U '3+22,9/;/C/C/;/C/C!"37/; 7<'%%,,_=G# >H  OOG $S)%V Or*c|jDcic]\}}||vrt||tr||!c}}Scc}}wrU)rr{r)rlocationr8rBs r(rrsI $>>+  D% : *Z-=u"E e   s$<)r%r r&rr'rreturnstr) r%r r/boolr0rr1MakeInstanceFilenameCallablerz8Iterator[Tuple[SimpleLocationDict, DesignSpaceDocument]]) r%r r/rr0rr1rrz)Iterator[Tuple[str, DesignSpaceDocument]])r%r rzDict[str, DesignSpaceDocument])r%r rrr.rr/rr0rr1rrr )rzList[Dict[str, Any]]rr)rList[RuleDescriptor]rrrr)rrrDict[str, float]rr)0__doc__ __future__rr9loggingrtypingrrrrrr r fontTools.designspaceLibr r r rrrrrr"fontTools.designspaceLib.statNamesrrfontTools.designspaceLib.typesrrrrrrr getLogger__name__rrrr)rErLrRr<rrrrar*r(rs# CCC   G   8 $',i8#=  +  +(: +GP + + 9T @+ @+@+@+7 @+ > @+J!9T " """7 " / "J #"U UU U  U  U7UUp > >/5>>Br*