L i$*dZddlmZddlmZddlmZmZmZm Z m Z ddl Z ddl m Z mZmZmZmZmZe j&eZe ededed ed fZdd dd d ZeGd d Z ddZ ddZ ddZ ddZy)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)TTcDeZdZUdZded<ded<ded<ded<ded <y ) StatNamesz4Name data generated from the STAT table information.zDict[str, str] familyNames styleNamesz Optional[str]postScriptFontNamestyleMapFamilyNameszOptional[RibbiStyleName]styleMapStyleNameN)__name__ __module__ __qualname____doc____annotations__h/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/fontTools/designspaceLib/statNames.pyrr,s#>%%''//r rci}|j}|tjdn<|jtjdnd|ji|j}i}|j |}|d|j i|j}n{t|j|}|rctd|D}|jd|D];djfd|D}|s|j |j}||<=d|vsd|vrt||didS|dd |djdd } t!||\} } |} | |k7rt#|| } | j$} i}t|j'|j)D]E|j+|d}| j+| d}|dz|zj-|<Gt||| || 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.enc3BK|]}|jD]}|ywN) labelNames.0labellanguages r! zgetStatNames..cs-"U=M=M19s c3K|]6}|js(|jj|j8ywr%)elidabler&get defaultNamer's r!r+zgetStatNames..hs9% >>$$((53D3DE%s.s@$$"3"3"?@sc|jSr%rQ)as r!z&_getSortedAxisLabels..s annr )key)sortedr9 axisLabelsrR)r; sortedAxesrS sortedLabelss r!_getSortedAxisLabelsr\s~@$@ $J 0::'+ 4??":L: 6    $&*ooL #6 :sA)cg}t|}|j|jk7r8tjd|jd|jd|j D]O\}}||t fd|Dd}|tj d|dd?|j|Q|S)Nz Mismatch between user location 'z' and available labels for 'z'.c3K|]O}|jk(s:|j2|j&|jcxkr|jkrnn|Qywr%) userValue userMinimum userMaximum)r(lr_s r!r+z0_getAxisLabelsForUserLocation..sN ;;)+MM- 1 CammC  sAAz!Document needs a label for axis 'z', user value ')r\rDr4r5itemsnextdebugappend)r;rGrI allAxisLabelsaxisNamerYr)r_s @r!r:r:s)+F(.M|0022.|/@/@/B.CD(--/0 4 !. 3 3 5!* * /3 #   0  = LL3H:_YKWYZ  MM% )!, Mr ci}|jDcic]}|j|}}d}d}|jd}|d|jD]U}|j||j k(s |j |jks:|j ||j <d}n|jdxs|jd}|v|jD]g}|j||j k(s t|j t|jksL|j ||j <d}nt||fi||fScc}w)zCompute the RIBBI style name of the given user location, return the location of the matching Regular in the RIBBI group. .. versionadded:: 5.0 FwghtTitalslnt) r;tagr/rYlinkedUserValuer9r_absBOLD_ITALIC_TO_RIBBI_STYLE) selfrGrLrS axes_by_tagrr regular_label upright_labels r!rArAsb.2ii8d488T>8K8DF ??6 "D !__ M--dii1HH "++m.K.KK1>1H1H#DII.  ??6 " =koof&=D !__ M--dii1HH //03}7T7T3UU1>1H1H#DII.  &dFl 36 6 6 O9sE)rFr rGrreturnr)r;3list[Union[AxisDescriptor, DiscreteAxisDescriptor]]ruz$Dict[str, list[AxisLabelDescriptor]])r;rvrGrruzlist[AxisLabelDescriptor])rqr rGrruz)Tuple[RibbiStyleName, SimpleLocationDict])r __future__r dataclassesrtypingrrrrr loggingfontTools.designspaceLibr r r r rr getLoggerrr4RibbiStyleNamerprrBr\r:rArr r!r~s  #!88   8 $ I FO H M  00 0Y Y,>YYx =)0# =#$##L3 3-?3.3r