Warning: session_start(): Session cannot be started after headers have already been sent in /home/tvrreohg/public_html/manga.php on line 13
3 `Â_û%ã@sÒdZdZddlmZddlmZddlmZddlm Z ddd gZ d j e ƒZ d d gZ d j e ƒZd d„Zdd„Zddd„Zdd„Zdd„ZddlZejdejƒZddd„ZedkrÎddlZddlmZejeƒdS) aXHelpers for text wrapping, hyphenation, Asian text splitting and kinsoku shori. How to split a 'big word' depends on the language and the writing system. This module works on a Unicode string. It ought to grow by allowing ore algoriths to be plugged in based on possible knowledge of the language and desirable 'niceness' of the algorithm. z3.3.0é)Úcategory)Ú stringWidth)Ú_FUZZ)Ú isUnicodeu&!',.:;?!")]ã€�。ã€�ã€�】〕]】)uK々―ã��ã�ƒã�…ã�‡ã�‰ã�£ã‚ƒã‚…ょゎァィゥェォッャュョヮーヵヶu/゛゜・ヽヾã‚�ゞ―â€�°′″℃¢%‰Úu&‘“([{(〔[{〈《「『ã€�u$£@#¥$£@〒§cCs t|ƒdkS)zIs this an Asian character?i0)Úord)Úch©r ú8/tmp/tmp4i9tl1d3/lib64/python/reportlab/lib/textsplit.pyÚ is_multi_byte'sr cs‡‡fdd„|DƒS)u‚Returns a list of glyph widths. >>> getCharWidths('Hello', 'Courier', 10) [6.0, 6.0, 6.0, 6.0, 6.0] >>> from reportlab.pdfbase.cidfonts import UnicodeCIDFont >>> from reportlab.pdfbase.pdfmetrics import registerFont >>> registerFont(UnicodeCIDFont('HeiseiMin-W3')) >>> getCharWidths(u'æ�±äº¬', 'HeiseiMin-W3', 10) #most kanji are 100 ems [10.0, 10.0] csg|]}t|ˆˆƒ‘qSr )r)Ú.0ZuChar)ÚfontNameÚfontSizer r ú 8sz!getCharWidths..r )Úwordr rr )r rr Ú getCharWidths+s rÚutf8c Csjt|ƒs|j|ƒ}n|}t|||ƒ}t|||ƒ}t|ƒsfg}x$|D]\} } |j| | j|ƒgƒqBW|}|S)aAttempts to break a word which lacks spaces into two parts, the first of which fits in the remaining space. It is allowed to add hyphens or whatever it wishes. This is intended as a wrapper for some language- and user-choice-specific splitting algorithms. It should only be called after line breaking on spaces, which covers western languages and is highly optimised already. It works on the 'last unsplit word'. Presumably with further study one could write a Unicode splitting algorithm for text fragments whick was much faster. Courier characters should be 6 points wide. >>> wordSplit('HelloWorld', 30, 'Courier', 10) [[0.0, 'Hello'], [0.0, 'World']] >>> wordSplit('HelloWorld', 31, 'Courier', 10) [[1.0, 'Hello'], [1.0, 'World']] )rÚdecoderÚ dumbSplitÚappendÚencode) rÚ maxWidthsr rÚencodingZuwordZ charWidthsÚlinesZlines2Ú extraSpaceÚtextr r r Ú wordSplit:s   rc CsÊd}t|ttfƒs|g}t|ƒs$t‚g}d}}}|d}t|ƒ} �xZ|| k�r ||} ||} || 7}|d7}||tko„|dkrH||} t| ƒdk�r$||d?} xzt|d| dƒD]f}||}t |ƒdksÞt|ƒdkrº|d}||krº|d}| t |||…ƒ7} ||} ||} |}PqºW| t k�rL||dk�rL|d8}| | 7} |j | |||…j ƒgƒy|t|ƒ}Wntk �r”|d}YnX|}d}qHW|dk�rÆ|j ||||d…gƒ|S) a²This function attempts to fit as many characters as possible into the available space, cutting "like a knife" between characters. This would do for Chinese. It returns a list of (text, extraSpace) items where text is a Unicode string, and extraSpace is the points of unused space available on the line. This is a structure which is fairly easy to display, and supports 'backtracking' approaches after the fact. Test cases assume each character is ten points wide... >>> dumbSplit(u'Hello', [10]*5, 60) [[10, u'Hello']] >>> dumbSplit(u'Hello', [10]*5, 50) [[0, u'Hello']] >>> dumbSplit(u'Hello', [10]*5, 40) [[0, u'Hell'], [30, u'o']] uQ #>>> dumbSplit(u'Hello', [10]*5, 4) # less than one character #(u'', u'Hello') # this says 'Nihongo wa muzukashii desu ne!' (Japanese is difficult isn't it?) in 12 characters >>> jtext = u'日本語ã�¯é›£ã�—ã�„ã�§ã�™ã�­ï¼�' >>> dumbSplit(jtext, [10]*11, 30) # (u'日本語', u'ã�¯é›£ã�—ã�„ã�§ã�™ã�­ï¼�') réi0ÚZsNéÿÿÿÿr)Ú isinstanceÚlistÚtuplerÚAssertionErrorÚlenrrÚrangerÚsumÚALL_CANNOT_STARTrÚstripÚ IndexError)rÚwidthsrZ_morerÚiZ widthUsedZ lineStartPosZmaxWidthZnWÚwÚcrZ limitCheckÚjZcjÚkr r r r\sR     rc Csjg}t|ƒt|ƒkst‚d}g}d}x@||}||}|||krV|j|ƒ||7}q&|tdkr&q&WdS)aSplit according to Japanese rules according to CJKV (Lunde). Essentially look for "nice splits" so that we don't end a line with an open bracket, or start one with a full stop, or stuff like that. There is no attempt to try to split compound words into constituent kanji. It currently uses wrap-down: packs as much on a line as possible, then backtracks if needed This returns a number of words each of which should just about fit on a line. If you give it a whole paragraph at once, it will do all the splits. It's possible we might slightly step over the width limit if we do hanging punctuation marks in future (e.g. dangle a Japanese full stop in the right margin rather than using a whole character box. grN)r$r#rÚCANNOT_END_LINE) rr*Z availWidthrZcurWidthZcurLiner+rr,r r r ÚkinsokuShoriSplitºs    r1Nu ([⺀-ï¿¿])cCs4t|fdd„tjdt||ƒƒjdƒƒjddƒj|ƒS)NcSsVd|dddgt|ƒ|jdƒdt|jddƒdƒ|kpL|d d…dkoLd|fS) Nz%s%s%sú Ú rrrúér)r$ÚrfindÚsplit)ÚlinerÚwidthr r r Úås .zcjkwrap..z\1\0 r2r4r)ÚreduceÚrxÚsubÚstrr7Úreplacer)rr9rr r r Úcjkwrapäs r@Ú__main__)Ú textsplit)r)r)Ú__doc__Ú __version__Ú unicodedatarZreportlab.pdfbase.pdfmetricsrZreportlab.rl_configrZreportlab.lib.utilsrZCANNOT_START_LINEÚjoinr'r0ZALL_CANNOT_ENDr rrrr1ÚreÚcompileÚUNICODEr<r@Ú__name__ÚdoctestZ reportlab.librBÚtestmodr r r r Ú s0       "^(