;ņ
½0sDc           @   sP  d  Z  d Z d k Z d k Z d k l Z d k l Z d k l	 Z	 l
 Z
 d k l Z l Z l Z l Z l Z d k l Z d k l Z h  d	 d
 <d d <d d <d d <Z d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d   Z d e f d     YZ d   Z e d j o e   n d S(   s    $Id s:  Routines to print code page (character set) drawings.

To be sure we can accurately represent characters in various encodings
and fonts, we need some routines to display all those characters.
These are defined herein.  The idea is to include flowable, drawable
and graphic objects for single and multi-byte fonts. N(   s   Canvas(   s   Flowable(   s
   pdfmetricss   cidfonts(   s   Drawings   Groups   Strings   Circles   Rect(   s   Widget(   s   colorss   WinAnsiEncodings   winansis   MacRomanEncodings   macromans	   MacExperts	   macexperts   PDFDocs   pdfdocs   CodeChartBasec           B   s5   t  Z d  Z d   Z d   Z d   Z d d  Z RS(   sr   Basic bits of drawing furniture used by
    single and multi-byte versions: ability to put letters
    into boxes.c         C   sū   |  i d |  i } | t |  j o t |  |  _ n t |  d |  _ |  i d |  i |  _ |  i d |  i |  _ g  |  _ x2 t	 |  i d  D] } |  i i | |  i  q Wg  |  _ x2 t	 |  i d  D] } |  i i | |  i  qÖ Wd S(   s&   Work out x and y positions for drawingf1.0i   i   N(   s   selfs
   codePointss   charsPerRows   rowss   ints   boxSizes   widths   heights   ylists   ranges   rows   appends   xlists   col(   s   selfs   rowss   cols   row(    (    sB   /home/packages/reportlab/reportlab_2_0/reportlab/lib/codecharts.pys
   calcLayout#   s     	 	 c         C   s"   |  i o d | Sn	 d | Sd  S(   Ns   %02Xs   %d(   s   selfs   hexs   byt(   s   selfs   byt(    (    sB   /home/packages/reportlab/reportlab_2_0/reportlab/lib/codecharts.pys
   formatByte8   s    
c      
   C   s’  |  i |  i t |  } x! t |  D] } | i t	  q' Wd } d } |  i i |  i |  i d  x| D]} | t	 j ol |  i i d  |  i i d | |  i |  i | d |  i |  i |  i d d d d |  i i d  nŻ y7 |  i i | d |  i |  i | d	 |  i |  Wn¢ |  i i d  |  i i d | |  i |  i | d |  i |  i |  i d d d d |  i i | d |  i |  i | d	 |  i d
  |  i i d  n X| d } | |  i j o | d } d } qn qn Wd S(   s]   Fills boxes in order.  None means skip a box.
        Empty boxes at end get filled with grayi    f0.75f0.90000000000000002i   s   strokes   fillf0.0f1.5f0.875s   ?N(   s   selfs   rowss   charsPerRows   lens   charLists   extraNeededs   ranges   is   appends   Nones   rows   cols   canvs   setFonts   fontNames   boxSizes   chs   setFillGrays   rects   drawCentredString(   s   selfs   charLists   chs   is   extraNeededs   cols   row(    (    sB   /home/packages/reportlab/reportlab_2_0/reportlab/lib/codecharts.pys	   drawChars>   s>       ,,

s    c      	   C   sĮ  |  i i d  |  i i d |  i d |  i |  i d d d d |  i i d d |  i |  i d d d d d |  i i d  |  i i d d	 |  i  d } xw t	 |  i
  D]f } |  i o |  i | } n |  i | |  i  } |  i i d
 |  i |  i
 | d |  i |  q± WxO t	 |  i  D]> } |  i i | d |  i |  i
 d |  i |  i |   q+W| oI |  i i d d
 |  i  |  i i d
 |  i |  i
 d |  i |  n d S(   s4   Writes little labels in the top row and first columnf0.80000000000000004i    iž’’’s   filli   s   strokef0.0s   Helvetica-Obliquef0.375f0.5f0.75f1.5f0.25s   Helvetica-BoldObliqueN(   s   selfs   canvs   setFillGrays   rects   ylists   widths   boxSizes   setFonts   byts   ranges   rowss   rows	   rowLabelss   labels
   formatBytes   charsPerRows   drawCentredStrings   cols   topLeft(   s   selfs   topLefts   labels   cols   byts   row(    (    sB   /home/packages/reportlab/reportlab_2_0/reportlab/lib/codecharts.pys
   drawLabelsd   s2     2/ 
 (   s   __name__s
   __module__s   __doc__s
   calcLayouts
   formatBytes	   drawCharss
   drawLabels(    (    (    sB   /home/packages/reportlab/reportlab_2_0/reportlab/lib/codecharts.pys   CodeChartBase   s
    			&s   SingleByteEncodingChartc           B   s)   t  Z d d d d d d  Z d   Z RS(   Ns	   Helveticas   WinAnsiEncodingi   i   i   c         C   s   d |  _ | |  _ | |  _ |  i d |  i |  _ | |  _ | |  _ | |  _ t |  _	 t
 i t
 i |  i |  i |  i   |  i   d  S(   Ni   s   -(   s   selfs
   codePointss   faceNames   encodingNames   fontNames   charsPerRows   boxSizes   hexs   Nones	   rowLabelss
   pdfmetricss   registerFonts   Fonts
   calcLayout(   s   selfs   faceNames   encodingNames   charsPerRows   boxSizes   hex(    (    sB   /home/packages/reportlab/reportlab_2_0/reportlab/lib/codecharts.pys   __init__   s    							c            s¾   |  i   t g d t t t d d   } |  i } t	 i
 | |  } t i |  d     d   } g  i } | D] } | | |   qu ~ } |  i |  |  i i |  i |  i  d  S(   Ni    i   i   c            s-   |  t j o t Sn   |  d d d Sd  S(   Ns   errorss   replacei    (   s   txts   Nones   decoder(   s   txt(   s   decoder(    sB   /home/packages/reportlab/reportlab_2_0/reportlab/lib/codecharts.pys
   decodeFunc¢   s    (   s   selfs
   drawLabelss   Nones   maps   chrs   ranges   charLists   encodingNames   encNames   adobe2codecs   gets   codecss   lookups   decoders
   decodeFuncs   appends   _[1]s   chs	   drawCharss   canvs   grids   xlists   ylist(   s   selfs   chs
   decodeFuncs   encNames   _[1]s   charLists   decoder(    (   s   decodersB   /home/packages/reportlab/reportlab_2_0/reportlab/lib/codecharts.pys   draw   s    
#	-(   s   __name__s
   __module__s   __init__s   draw(    (    (    sB   /home/packages/reportlab/reportlab_2_0/reportlab/lib/codecharts.pys   SingleByteEncodingChart   s   s   KutenRowCodeChartc           B   s)   t  Z d  Z d   Z d   Z d   Z RS(   sf  Formats one 'row' of the 94x94 space used in many Asian encodings.aliases

    These deliberately resemble the code charts in Ken Lunde's "Understanding
    CJKV Information Processing", to enable manual checking.  Due to the large
    numbers of characters, we don't try to make one graphic with 10,000 characters,
    but rather output a sequence of these.c         C   sŹ   | |  _  d |  _ d |  _ d |  _ d |  _ d d d d d	 g |  _ d
 |  _ | |  _ | |  _	 y) t
 i |  i |  i	  } t i |  Wn d |  _ d |  _	 n X|  i d |  i	 |  _ |  i   d  S(   Ni^   i   i   i   s   00s   20s   40s   60s   80i    s	   Helveticas   WinAnsiEncodings   -(   s   rows   selfs
   codePointss   boxSizes   charsPerRows   rowss	   rowLabelss   hexs   faceNames   encodingNames   cidfontss   CIDFonts   fonts
   pdfmetricss   registerFonts   fontNames
   calcLayout(   s   selfs   rows   faceNames   encodingNames   font(    (    sB   /home/packages/reportlab/reportlab_2_0/reportlab/lib/codecharts.pys   __init__¹   s"    									c         C   s   g  } t i |  i d  d j oI xZ t d d  D]1 } t | d  t | d  } | i
 |  q2 Wn | i
 t g d  | Sd S(   s1   Works out the character values for this kuten rows   EUCi’’’’i   i_   i    i^   N(   s   cellss   strings   finds   selfs   encodingNames   ranges   cols   chrs   rows   chs   appends   None(   s   selfs   rows   chs   cellss   col(    (    sB   /home/packages/reportlab/reportlab_2_0/reportlab/lib/codecharts.pys   makeRowĻ   s      c         C   sZ   |  i d d |  i  t g |  i |  i  } |  i |  |  i i |  i	 |  i
  d  S(   Ns   topLefts   R%d(   s   selfs
   drawLabelss   rows   Nones   makeRows   charLists	   drawCharss   canvs   grids   xlists   ylist(   s   selfs   charList(    (    sB   /home/packages/reportlab/reportlab_2_0/reportlab/lib/codecharts.pys   drawß   s    (   s   __name__s
   __module__s   __doc__s   __init__s   makeRows   draw(    (    (    sB   /home/packages/reportlab/reportlab_2_0/reportlab/lib/codecharts.pys   KutenRowCodeChart°   s    		s   Big5CodeChartc           B   s)   t  Z d  Z d   Z d   Z d   Z RS(   sæ   Formats one 'row' of the 94x160 space used in Big 5

    These deliberately resemble the code charts in Ken Lunde's "Understanding
    CJKV Information Processing", to enable manual checking.c      
   C   sŁ   | |  _  d |  _ d |  _ d |  _ d |  _ d |  _ | |  _ | |  _ d d d d	 d
 d d d d d g
 |  _	 y) t
 i |  i |  i  } t i |  Wn d |  _ d |  _ n X|  i d |  i |  _ |  i   d  S(   Ni    i   i   i
   i   s   4s   5s   6s   7s   As   Bs   Cs   Ds   Es   Fs	   Helveticas   WinAnsiEncodings   -(   s   rows   selfs
   codePointss   boxSizes   charsPerRows   rowss   hexs   faceNames   encodingNames	   rowLabelss   cidfontss   CIDFonts   fonts
   pdfmetricss   registerFonts   fontNames
   calcLayout(   s   selfs   rows   faceNames   encodingNames   font(    (    sB   /home/packages/reportlab/reportlab_2_0/reportlab/lib/codecharts.pys   __init__š   s"    								'	c      
   C   s¹   g  } t i |  i d  d j o{ x d d d d d d d	 d
 d d g
 D]N } xE t d  D]7 } | d | } t	 |  t	 |  } | i |  qZ WqG Wn | i t g d  | Sd S(   sL   Works out the character values for this Big5 row.
        Rows start at 0xA1s   B5i’’’’i   i   i   i   i
   i   i   i   i   i   i   i    N(   s   cellss   strings   finds   selfs   encodingNames   ys   ranges   xs   cols   chrs   rows   chs   appends   None(   s   selfs   rows   chs   cols   ys   xs   cells(    (    sB   /home/packages/reportlab/reportlab_2_0/reportlab/lib/codecharts.pys   makeRow  s     %  c         C   sS   |  i d d |  i  |  i |  i  } |  i |  |  i i |  i |  i	  d  S(   Ns   topLefts   %02X(
   s   selfs
   drawLabelss   rows   makeRows   charLists	   drawCharss   canvs   grids   xlists   ylist(   s   selfs   charList(    (    sB   /home/packages/reportlab/reportlab_2_0/reportlab/lib/codecharts.pys   draw  s    (   s   __name__s
   __module__s   __doc__s   __init__s   makeRows   draw(    (    (    sB   /home/packages/reportlab/reportlab_2_0/reportlab/lib/codecharts.pys   Big5CodeChartė   s    		c      	   C   sĪ   | i   y t i |  } Wn/ t j
 o# t i |  } t i	 |  n X| i
 d  | i | | t i |  | d  d d d d d | i
 d  | i | d d  | i | | |   | i   d S(   s”   Helper for stringwidth tests on Asian fonts.

    Registers font if needed.  Then draws the string,
    and a box around it derived from the stringWidth functionf0.80000000000000004i   s   strokei    s   filli   N(   s   canvass	   saveStates
   pdfmetricss   getFonts   fontNames   fonts   KeyErrors   cidfontss   UnicodeCIDFonts   registerFonts   setFillGrays   rects   xs   ys   stringWidths   msgs   setFonts
   drawStrings   restoreState(   s   msgs   canvass   xs   ys   fontNames   font(    (    sB   /home/packages/reportlab/reportlab_2_0/reportlab/lib/codecharts.pys   hBoxText  s     
1s
   CodeWidgetc           B   s    t  Z d  Z d   Z d   Z RS(   s    Block showing all the charactersc         C   s(   d |  _ d |  _ d |  _ d |  _ d  S(   Ni    i    (   s   selfs   xs   ys   widths   height(   s   self(    (    sB   /home/packages/reportlab/reportlab_2_0/reportlab/lib/codecharts.pys   __init__3  s    			c      
   C   sń   |  i d } |  i d } t   } | i t |  i	 |  i
 |  i |  i d t d t i  x t d  D]~ } xu t d  D]g } | d | } | d j oF t |  i	 | | |  i
 |  i | | t |   } | i |  qz qz Wqg W| Sd  S(   Nf16.0s	   fillColors   strokeColori   i    (   s   selfs   widths   dxs   heights   dys   Groups   gs   adds   Rects   xs   ys   Nones   colorss   blacks   ranges	   charValues   Strings   chrs   s(   s   selfs   gs   ss	   charValues   dxs   dys   ys   x(    (    sB   /home/packages/reportlab/reportlab_2_0/reportlab/lib/codecharts.pys   draw9  s    	!  $(   s   __name__s
   __module__s   __doc__s   __init__s   draw(    (    (    sB   /home/packages/reportlab/reportlab_2_0/reportlab/lib/codecharts.pys
   CodeWidget1  s    	c          C   sØ   t  d  }  |  i d d  |  i d d d  t   } | i |  d d  t d d	  } | i |  d d
  t d d d d  } | i |  d d  |  i	   d GHd  S(   Ns   codecharts.pdfs   Helvetica-Boldi   iH   iī  s   Testing code page chartsiō  s   charsPerRowi    i,  i   s   hexi    id   s   saved codecharts.pdf(
   s   Canvass   cs   setFonts
   drawStrings   SingleByteEncodingCharts   cc1s   drawOns   cc2s   cc3s   save(   s   cs   cc1s   cc3s   cc2(    (    sB   /home/packages/reportlab/reportlab_2_0/reportlab/lib/codecharts.pys   testM  s    	
s   __main__(   s   __version__s   __doc__s   strings   codecss   reportlab.pdfgen.canvass   Canvass   reportlab.platypuss   Flowables   reportlab.pdfbases
   pdfmetricss   cidfontss   reportlab.graphics.shapess   Drawings   Groups   Strings   Circles   Rects   reportlab.graphics.widgetbases   Widgets   reportlab.libs   colorss   adobe2codecs   CodeChartBases   SingleByteEncodingCharts   KutenRowCodeCharts   Big5CodeCharts   hBoxTexts
   CodeWidgets   tests   __name__(   s   KutenRowCodeCharts   Canvass   Groups   Flowables   SingleByteEncodingCharts   hBoxTexts   colorss   Circles   adobe2codecs   Strings   Big5CodeCharts   cidfontss   tests   __version__s   __doc__s   Rects   strings
   CodeWidgets   Widgets   codecss   Drawings
   pdfmetricss   CodeChartBase(    (    sB   /home/packages/reportlab/reportlab_2_0/reportlab/lib/codecharts.pys   ?   s&   		%*f,;2		