)EjM<dZddlmZddlZddlZddlZddlmZmZm Z m Z m Z m Z m Z ddlmZmZmZmZmZmZmZmZmZddlmZmZddlmZmZmZmZm Z m!Z!m"Z"ej#e$Z%eeeege&fZ'd-dZ(dde(fd.dZ)dde(fd/dZ*d0dZ+d1d!Z,d2d%Z-d3d)Z.d4d,Z/dS)5zAllows 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) ConditionSetRangeRegiongetVFUserRegionlocationInRegionregionInRegionuserRegionToDesignRegiondocr instancer statNamesrreturnstrc|jp|jd}|jp|jd}|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)rrrr%r(s PC:\PYTHON\MyICR_Suite\python\Lib\site-packages\fontTools/designspaceLib/split.pydefaultMakeInstanceFilenamer+)sW$G (=(A(A$(G(GJ"Di&:&>&>t&D&DI * *9 * * **T makeNamesboolexpandLocationsmakeInstanceFilenameMakeInstanceFilenameCallable8Iterator[Tuple[SimpleLocationDict, DesignSpaceDocument]]c #Kg}i}|jD]z}t|dr+tt|}||=tt |}t |j|j|j ||j <{tj d|D}|D];}dt||D} t|i|| d|||} | | fVz%splitInterpolable..hs+Q+Q+QDDK+Q+Q+Qr,c$i|] \}}|j|Sr6name)r8 discreteAxisvalues r* z%splitInterpolable..js1   # e  u   r,TkeepVFsr-r/r0N)axeshasattrr rappendr rminimummaximumdefaultr= itertoolsproductzip_extractSubSpace) rr-r/r0 discreteAxesinterpolableUserRegionr9valueCombinationsr4discreteUserLocationsubDocs r*splitInterpolablerR6sCDL%'   4 " " .55D    % % % %--D05   11 "49 - - ")+Q+QL+Q+Q+QR# + +  '*<'@'@   "  >% >)= >+!5    #F***** + +r,F)Iterator[Tuple[str, DesignSpaceDocument]]c #K|D]G}t||}t||d|||}i|j|j|_|j|fVHdS)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 FrAN)getVariableFontsrrLlibr=)rr-r/r0vf vfUserRegionvfDocs r*splitVariableFontsrZys.""$$  &sB//   +!5    ,uy+BF+ gun  r,Dict[str, DesignSpaceDocument]cvi}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)rRrZ formatVersion)rvfs _locationrQvfNamerYs r* convert5to4ras_ C.s33   6/77  MFE"'E CKK  Jr, userRegionrrBcH t}fd}jD]}|jttrt |drt t|}|t|j |j|j |j tj |j jp|jtj|jfd|jDdd gx|_} d|jDjD]} t'fd| jDs6t'fd| jDs't.d| j| jt3} | | j| | jjD]q}|j| vr |jj |j ks'jj|jksj|jkr!t.d |jqr| t9| j| j t;} t=j| |_j |_ j!D]} tE#| j$s+|%tM| j'| j(| j)| jtU|| | j+| j,| j-| j.| j/| j0 |1}1}|| |j2|_2|r}3D]h}ti|}tk|rF|6to|j|j'fd |j8D|j9 ij:D]@}tE|;s'|rcty|;}|j,p|j=>d}|j-p|j?>d}|@td id|j'p |||d|j(d|j)d|jp|d|drin|jBdtU||d|d|d|jCp|jCd|jDp|jE>dd|jFp|jFd|j2p|j=d|jGp|j?d|jHp|jEd|jIpid|j9|@td id|j'd|j(d|j)d|jdrin|jBdtU||d|j,d|j-d|jCd|jDd|jFd|j2d|jGd|jHd|jId|j9Bj9|_9|S)!Nc@r|S|jSN)getFullDesignLocationdesignLocation)objectrr/s r*maybeExpandDesignLocationz3_extractSubSpace..maybeExpandDesignLocations(  )//44 4( (r,rFcRg|]#\}}j|cxkr jknn||f$Sr6)rFrG)r8userdesignranges r*r:z$_extractSubSpace..sQ(D& =DAAAAEMAAAAAvAAAr,) tagr= labelNameshiddenrFrHrGmap axisOrdering axisLabelsch|] }|j Sr6r<r7s r* z#_extractSubSpace..s444$)444r,c3 K|]}|vV dSrer6r8r9 subDocAxess r* z#_extractSubSpace..s(OO$4:%OOOOOOr,c3 K|]}|vV dSrer6rws r*ryz#_extractSubSpace..s(PP$4:%PPPPPPr,zPIn axis mapping from input %s, some output axes are not in the variable-font: %szALimiting axis ranges used in elements not supported: %s) inputLocationoutputLocation) filenamepathfontr=rg layerNamer%r( muteKerningmuteInfomutedGlyphNamescTg|]$}t|jt"|%Sr6) isinstancer=r)r8 axisSubsetrbs r*r:z$_extractSubSpace..:s@%%% *)*Z_*EuMM%&%%%r,)r=r} axisSubsetsrVr#r}r~rr= userLocationrgr%r(postScriptFontNamestyleMapFamilyNamestyleMapStyleNamelocalisedFamilyNamelocalisedStyleNamelocalisedStyleMapFamilyNamelocalisedStyleMapStyleNamerVr6)Jr rCr=rrrDr r addAxisrnrorpmaxrFrHminrGrq axisMappingsallr{keysr|LOGGERerrorsetupdaterEr r_subsetRulesBasedOnConditionsrulesrulesProcessingLastsourcesr map_backwardrg addSourcerr}r~r_filterLocationrr%r(rrr findDefaultrrUrraddVariableFontrrrV instancesgetFullUserLocationrr&r'r) addInstancerrrrstyleMapFamilyNamesrrrr)rrbrBr-r/r0rQrir9mappingsmapping mappingAxes designRegionsource vfDefault oldDefaultrWrXrrr%r(rmrxs`` ` @@r*rLrLsk! " "F)))))) 49% eU # # i(@(@ --D NN#; t|<<!M9T\ t|<<,0H "&##   ,&('F(44 444J#" " OOOO'2G2L2L2N2NOOOOO  PPPP'2H2M2M2O2OPPPPP  LLb%&    ee 705577888716688999H  Dy ++ty)E --M-%-4<2O2O=DL00 WI 1  !%3&5       ,C<> '/&@'3 2#$)1(D)- ,'((0'B(, ++,190T15 4/008/R034! 5    >   "%..!""  (7!QH# >L"<00B46O"' 1=1C1C1E1E 7 7- ~ **nucl;;7%M):::/3++&M):::')-'8'E'En'U'U '3+22,9/;/C/;/C!"!"37//& >%,,_===   % OOG $ $ $ Or,locationDict[str, float]cDfd|DS)NcZi|]'\}}|v t|t$||(Sr6)rr)r8r=r?rbs r*r@z#_filterLocation..sH    D% :  *Z-=u"E"E  e   r,)r)rbrs` r*rrs8    #>>++   r,)rr rrrrr r!) rr r-r.r/r.r0r1r r2) rr r-r.r/r.r0r1r rS)rr r r[)rr rbrrBr.r-r.r/r.r0r1r r )rrr r)rrrrr r)rbrrrr r)0__doc__ __future__rrIloggingrtypingrrrrrr r fontTools.designspaceLibr r r rrrrrr"fontTools.designspaceLib.statNamesrrfontTools.designspaceLib.typesrrrrrrr getLogger__name__rr!r1r+rRrZrarLrrrr6r,r*rs`#""""" CCCCCCCCCCCCCCCCCC                      GFFFFFFF  8 $ $',i8#=  + + + + 9T @+@+@+@+@+J!9T """""J"UUUUp    >>>>Br,