ó LzńWc@sadZddlZddlZddlZddlmZddlmZddd„ƒYZ dS(sË Provide an encoder for a font specification configuration: the encoder is fed with Unicode characters one by one and determines the needed font switches between the preceding and the current character. i˙˙˙˙N(tUnicodeInterval(tFontSpecConfigtFontSpecEncodercBsMeZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z RS(sÁ Encoder working with font specifications: it is fed with Unicode characters one by one and it inserts the needed font switches between the preceding and the current character. cCs.t|ƒ|_d|_|jjg|_dS(s„ Create a font specification encoder from the specified configuration file (file name or file-like object). N(Rt_conftNonet _cur_fontspectdefault_fontspect _ref_stack(tselft configuration((sC/usr/lib/python2.7/dist-packages/dbtexmf/dblatex/xetex/fsencoder.pyt__init__s cCs%|jj|_|jjg|_dS(N(RRRR(R((sC/usr/lib/python2.7/dist-packages/dbtexmf/dblatex/xetex/fsencoder.pytreset"scCs[d}||jkr|jƒS|jr>||jjƒ7}n||_||jƒ7}|S(s… Insert the transition string, according to the newly selected fontspec and the previously selected fontspec t(Rt interchartexittenter(Rtfontspects((sC/usr/lib/python2.7/dist-packages/dbtexmf/dblatex/xetex/fsencoder.pyt _switch_to's   cCsĽ|jp|jj}tjdI|jIJ|j|ƒ}x5|sq|jjƒ}|jdj|d|ƒ}q=W||jdkr˜|jj |ƒn|j |ƒS(sĄ Select the fontspec matching the specified , and switch to this font as current font. The principle to find out the fontspec is: - to find from the current font level a matching font (the current font leaf or the direct font children) - if no font is found try with the parent font, and so on, up to the default root font (that must exist). sCurrent:i˙˙˙˙texcluded( RRRtsyststderrtidtmatchRtpoptappendR(RtcharRtleaf((sC/usr/lib/python2.7/dist-packages/dbtexmf/dblatex/xetex/fsencoder.pyt_encode:s   cCs<g|D]}tƒj|ƒ^q}|jjj|ƒdS(sACharacters to ignore in font selection (maintain the current one)N(Rt from_charRRt add_ignored(Rtcharsettct intervals((sC/usr/lib/python2.7/dist-packages/dbtexmf/dblatex/xetex/fsencoder.pyt ignorecharsRs%cCs|j|ƒ|fS(sƒ Return a string consisting of the specified character prepended by all necessary font switching commands. (R(RR((sC/usr/lib/python2.7/dist-packages/dbtexmf/dblatex/xetex/fsencoder.pytencodeWscCs)|jr%|jjƒ}d|_|SdS(s8 Cleanly exit from the current fontspec N(RRR(RR((sC/usr/lib/python2.7/dist-packages/dbtexmf/dblatex/xetex/fsencoder.pytstop^s  ( t__name__t __module__t__doc__R R RRR"R#R$(((sC/usr/lib/python2.7/dist-packages/dbtexmf/dblatex/xetex/fsencoder.pyRs     (( R'Rtretxml.dom.minidomtxmlRRtfsconfigRR(((sC/usr/lib/python2.7/dist-packages/dbtexmf/dblatex/xetex/fsencoder.pyt s