L i@ `ddlmZddlZddlmZmZmZddlmZm Z ddl m Z ddl Zddl mZddlmZddlZddlZej&dZeej&ed zej, ZGd d eZgd ZedddZedk(rej8eyy))ttLibN)computeMegaGlyphOrdercomputeMegaCmaprenameCFFCharStrings)layoutPreMergelayoutPostMerge)Options)Timer)reducezfontTools.mergez.timer)loggerlevelc6eZdZdZd dZdZdZdZdZdZ y) MergeraFont merger. This class merges multiple files into a single OpenType font, taking into account complexities such as OpenType layout (``GSUB``/``GPOS``) tables and cross-font metrics (for example ``hhea.ascent`` is set to the maximum value across all the fonts). If multiple glyphs map to the same Unicode value, and the glyphs are considered sufficiently different (that is, they differ in any of paths, widths, or height), then subsequent glyphs are renamed and a lookup in the ``locl`` feature will be created to disambiguate them. For example, if the arguments are an Arabic font and a Latin font and both contain a set of parentheses, the Latin glyphs will be renamed to ``parenleft.1`` and ``parenright.1``, and a lookup will be inserted into the to ``locl`` feature (creating it if necessary) under the ``latn`` script to substitute ``parenleft`` with ``parenleft.1`` etc. Restrictions: - All fonts must have the same units per em. - If duplicate glyph disambiguation takes place as described above then the fonts must have a ``GSUB`` table. Attributes: options: Currently unused. Nc*|s t}||_yN)r options)selfrs ^/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/fontTools/merge/__init__.py__init__zMerger.__init__5siG c|Dcgc]}tj|}}t||D]%\}}||_|dj d|_'|Scc}w)Nname)rTTFontzip_merger__fontfile getDebugName _merger__name)r fontfilesfontfilefontsfonts r _openFontszMerger._openFonts;sd8ABHh'BB!%3 >ND(%-D "!%f!:!:1!=D  > CsAc |j|}|Dcgc]}t|j}}t|||dj}|j|}t ||D]+\}}|j |d|vst|||d-|Dcgc]}|d }}|Dcgc]}ic}|_t||tj|} | j |j|D]}|j|||_tt j"d|Dt!} | j%dt'| D]} | |j(j*vrt-d| z5|Dcgc]}|j/| t0} }t2j5d| tj6| } | | j9|| }|t0ur |d ur|| | <t2j5d | nt2j5d | d d d |`|`|j;| | Scc}wcc}wcc}wcc}w#1swYxYw) aMerges fonts together. Args: fontfiles: A list of file names to be merged Returns: A :class:`fontTools.ttLib.TTFont` object. Call the ``save`` method on this to write it out to an OTF file. rzCFF cmap) sfntVersionc3NK|]}t|jywr)listkeys).0r"s r zMerger.merge..is$I4T$))+%6$Is#% GlyphOrderz merge '%s'z Merging '%s'.Fz Merged '%s'.z Dropped '%s'.N)r#r( getGlyphOrderrr&r setGlyphOrderrduplicateGlyphsPerFontrrr glyphOrder _preMerger!r setunionremovesortedr drop_tablestimergetNotImplementedloginfo getTableClassmerge _postMerge)rrr!r" glyphOrdersr&r0cmaps_megaallTagstagtablesclazztables rr=z Merger.mergeBsJ *>CDdtD..01D DdK0Ah**  * #E; 7 E D*   z *~$T:tF|D E +00$f0038&9ar&9#e$|| 4 4??+ !D NN4  ! $I5$I35Q|$'? 3Cdll...|c)* 3DIJD$((37JJ#.++C0c ((v6.53E %DIHH^S1HH_c2 3 3  3$  ' J  gE1&9&K 3 3s0 I" I4 I!I+I&3BI+&I++I5 c tjtgd|D}|D]Ntjd |}|tur(|fd|D}|tusBt||P|S#t$r< |d}n2#t$r&t dd|j jwxYwYxwxYw)Nc3`K|]&}|tus t|j(ywr)r9varsr))r*rGs rr+z&Merger.mergeObjects..s$ TU^8Sd5k Ts ..z %s*zDon't know how to merge key z of class c3@K|]}t|tywr)getattrr9)r*rGkeys rr+z&Merger.mergeObjects..sWuwuc>BWs) r2r3r:r;KeyError Exception __class____name__r9setattr)r returnTablelogicrEallKeys mergeLogicvaluerNs @r mergeObjectszMerger.mergeObjectss)) E Tf T  1C HHUC  "3Z ^+WPVWWEN* S%0! 1$ !&sJ# 5 5 > >@ s*A<< CB  C /B;;CCct|yr)rrr"s rr1zMerger._preMerges trcLt|d|vr|dj|yy)NzOS/2)rrecalcAvgCharWidthr[s rr>zMerger._postMerges* T> L + +D 1 rr) rR __module__ __qualname____doc__rr#r=rYr1r>rrrrs'6 AF82rr)r rmainz%make one with everything (TOTAL TIME)cddlm}|tjdd}t }|j |}g}|j rht|j 5}|jDcgc]1}|jjds|j3}}ddd|D]}|j|t|dkrtdtjtdtjtd tjtd tjtd tjtd tjtd tjtdtjtdtjtdtjy||j rt"j$nt"j&|j(r.t*j,j/t"j0ndt*j,_t5|}|j7|}|j8r|j;|j8t+d5|j=|j>dddycc}w#1swY;xYw#1swYyxYw)zMerge multiple fonts into oner) configLoggerN#zzusage: fonttools merge [font1 ... fontN] [--input-file=filelist.txt] [--output-file=merged.ttf] [--import-file=tables.ttx])filezN [--drop-tables=tags] [--verbose] [--timing]z- font1 ... fontN Files to merge.zp --input-file= Read files to merge from a text file, each path new line. # Comment lines allowed.zM --output-file= Specify output file name (default: merged.ttf).za --import-file= TTX file to import after merging. This can be used to set metadata.zY --drop-tables= Comma separated list of table tags to skip, case sensitive.z: --verbose Output progress information.z5 --timing Output progress timing.)r T)rzcompile and save font) fontToolsrdsysargvr parse_opts input_fileopen readlineslstrip startswithstripappendlenprintstderrverboseloggingINFOWARNINGtimingr7r setLevelDEBUGdisabledrr= import_file importXMLsave output_file) argsrdrr inputfilelinegmergerr"s rrbrbsB' |xx|iG   d #DI '$$ % &//1{{}//4 I   9~  I   \  bszz" =CJJO ~   [   o   g   H  ECJJWww||GOOL~~ gmm, $  G $F << "D w**+ & '' '%%&''m  n''s*K-6K#K4K+KK(+K4__main__r)rirfontTools.merge.basefontTools.merge.cmaprrrfontTools.merge.layoutrrfontTools.merge.optionsr fontTools.merge.tablesfontTools.misc.loggingToolsr functoolsr rjrx getLoggerr:rRryr7objectr__all__rbexitrarrrs  C+- g)* &W&&x(':;7<<PQ2VQ2h (./C'0C'L z CHHTVr