)Ej%&dZddlmZddlmZddlmZmZmZm Z m Z ddl Z ddl m Z mZmZmZmZmZe jeZe ededed ed fZdd dd d ZeGd d ZddZddZddZd dZdS)!a-Compute name information for a given location in user-space coordinates using STAT data. This can be used to fill-in automatically the names of an instance: .. code:: python instance = doc.instances[0] names = getStatNames(doc, instance.getFullUserLocation(doc)) print(names.styleNames) ) annotations) dataclass)DictLiteralOptionalTupleUnionN)AxisDescriptorAxisLabelDescriptorDesignSpaceDocumentDiscreteAxisDescriptorSimpleLocationDictSourceDescriptorregularbolditalicz bold italic))FF)FT)TF)TTcFeZdZUdZded<ded<ded<ded<ded <d S) StatNamesz4Name data generated from the STAT table information.zDict[str, str] familyNames styleNamesz Optional[str]postScriptFontNamestyleMapFamilyNameszOptional[RibbiStyleName]styleMapStyleNameN)__name__ __module__ __qualname____doc____annotations__TC:\PYTHON\MyICR_Suite\python\Lib\site-packages\fontTools/designspaceLib/statNames.pyrr,sT>>%%%%''''//////r rdocr userLocationrreturncPi}|}|tdn2|jtdnd|ji|j}i}||}|d|ji|j}nt|j |}|ritd|D}| d|D]8d fd|D}|s|j |j }||<9d|vsd|vrt||didS|dd |ddd } t!||\} } |} | |krt#|| } | j} i}t||D]W||d}| | d}|dz|z|<Xt||| || S) aECompute the family, style, PostScript names of the given ``userLocation`` using the document's STAT information. Also computes localizations. If not enough STAT data is available for a given name, either its dict of localized names will be empty (family and style names), or the name will be None (PostScript name). Note: this method does not consider info attached to the instance, like family name. The user needs to override all names on an instance that STAT information would compute differently than desired. .. versionadded:: 5.0 Nz7Cannot determine default source to look up family name.zTCannot look up family name, assign the 'familyname' attribute to the default source.enc3.K|]}|jD]}|VdSN) labelNames.0labellanguages r! zgetStatNames..csJ"U=M19r  c3fK|]+}|j |j|jV,dSr()elidabler)get defaultNamer*s r!r.zgetStatNames..hsU%% >%$((53DEE%%%%%%r )rrrrr-) findDefaultLOGGERwarning familyNamelocalisedFamilyNamelabelForUserLocationnamer)_getAxisLabelsForUserLocationaxessetaddjoinelidedFallbackNamerreplace_getRibbiStyle getStatNamesrunionkeysr2strip)r"r#r defaultSourcerr,labels languages styleNamerrregularUserLocationstyleNamesForStyleMapregularStatNamesrr9r-s @r!rErE7s$#%K030A0AMPQQQQ  ! ) b    -* / "$J  $ $\ 2 2E EJ;%*:; /sxFF  1&,I MM$   % 1 1HH%%%%!'%%% !7S%;%G # 6I'0 8$$ ;$j"8"8#!# ""     (-BB 40@BBJJ3PRSS-;C-N-N**&l**'-@AA 0 ; $$**:??+<+<==OO __X{4/@AA )--h8Md8STT )3c)9I)E(L(L(N(NH%% -/+    r r>3list[Union[AxisDescriptor, DiscreteAxisDescriptor]]$Dict[str, list[AxisLabelDescriptor]]ctd|Dd}d|D}|D]}|j|j||j<|S)zbReturns axis labels sorted by their ordering, with unordered ones appended as they are listed.c3(K|] }|j |VdSr( axisOrderingr+axiss r!r.z'_getSortedAxisLabels..s*@@$$"3"?"?"?"?"?@@r c|jSr(rT)as r!z&_getSortedAxisLabels..sanr )keyc(i|]}|j|jSr)r< axisLabelsrVs r! z(_getSortedAxisLabels..s+:::'+ 4?:::r )sortedrUr]r<)r> sortedAxes sortedLabelsrWs r!_getSortedAxisLabelsrbs|@@$@@@ $ $J::/9:::L 66   $&*oL # r list[AxisLabelDescriptor]cg}t|}||krEtd|d|d|D]b\}}||t fd|Dd}|"td|ddM||c|S)Nz Mismatch between user location 'z' and available labels for 'z'.c3K|]9}|jks(|j%|j|jcxkr |jk2nn|V:dSr() userValue userMinimum userMaximum)r+lrfs r!r.z0_getAxisLabelsForUserLocation..su  ;)++M- 1 CCCCamCCCCC  DCCC  r z!Document needs a label for axis 'z', user value ')rbrGr7r8itemsnextdebugappend)r>r#rJ allAxisLabelsaxisNamer]r,rfs @r!r=r=sE)+F(..M|002222 4|/@/@/B/B 4 4(--// 4 4 4   !. 3 3 5 5!!* * /3    #     0 0  = LLZHZZYZZZ     MM% Mr self)Tuple[RibbiStyleName, SimpleLocationDict]c i}d|jD}d}d}|d}|C|jD];}|j||jkr#|j|jkr|j||j<d}n<|dp|d}|]|jD]U}|j||jkr=t |jt |jkr|j||j<d}nVt||fi||fS)zCompute the RIBBI style name of the given user location, return the location of the matching Regular in the RIBBI group. .. versionadded:: 5.0 ci|] }|j| Sr)tagrVs r!r^z"_getRibbiStyle..s888d48T888r FwghtNTitalslnt)r>r2r]linkedUserValuer<rfabsBOLD_ITALIC_TO_RIBBI_STYLE) rpr#rM axes_by_tagrrrW regular_label upright_labels r!rDrDsK88di888KDF ??6 " "D !_  M-di1HHH "+m.KKK1>1H#DI. ??6 " " =koof&=&=D !_  M-di1HHH /003}7T3U3UUU1>1H#DI. %dFl 36 6 6 r )r"r r#rr$r)r>rPr$rQ)r>rPr#rr$rc)rpr r#rr$rq)r __future__r dataclassesrtypingrrrrr loggingfontTools.designspaceLibr r r r rr getLoggerrr7RibbiStyleNamerzrrErbr=rDrr r!rs  #"""""!!!!!!88888888888888  8 $ $ I FO H M  0000000 0YYYYx0####L333333r