
    TAi                        S SK Jr  S SKrS SKrS SKrS SKJr  S SKJ	r	J
r
Jr  S SKJr  \R                  " \5      r " S S\5      r " S S	\5      r " S
 S\5      rg)    )annotationsN)files)
DictionaryNamePdf)Fontc                      \ rS rSrSS jrSrg)EncodableFont   c                    [        5       eN)NotImplementedErrorselftexts     X/var/www/html/land-ocr/venv/lib/python3.13/site-packages/ocrmypdf/hocrtransform/_font.pytext_encodeEncodableFont.text_encode   s    !##     Nr   strreturnbytes)__name__
__module____qualname____firstlineno__r   __static_attributes__r   r   r   r
   r
      s    $r   r
   c                      \ rS rSr\R
                  " SS-  5      rSr\" S5      \-  R                  5       r
SrS rSS jrSS	 jrSS
 jrSrg)GlyphlessFont   s    i   zpdf.ttfzocrmypdf.data   c                    g r   r   )r   s    r   __init__GlyphlessFont.__init__    s    r   c                `    [        [        R                  " SU5      5      X R                  -  -  $ )FEstimate the width of a text string when rendered with the given font.NFKC)lenunicodedata	normalizeCHAR_ASPECTr   r   fontsizes      r   
text_widthGlyphlessFont.text_width#   s*     ;((678FVFV;VWWr   c                $    UR                  S5      $ )Nzutf-16beencoder   s     r   r   GlyphlessFont.text_encode(   s    {{:&&r   c                   [         R                  nUR                  [        [         R                  U/[        S5      [         R
                  U[         R                  S95      nUR                  [        [         R                  U[        SSSS9U[         R                  [         R                  SU R                  -  S95      nU/Ul	        UR                  U R                  [         R                  S	9Ul        UR                  S
5      Ul        UR                  [        SSSSSSSU R                  -  S/U[         R                  SS[         R                  S9
5      nUR                  U R                   5      Ul        XTl        U$ )a
  Register the glyphless font.

Create several data structures in the Pdf to describe the font. While it create
the data, a reference should be set in at least one page's /Resources dictionary
to retain the font in the output PDF and ensure it is usable on that page.
z/Identity-H)BaseFontDescendantFontsEncodingSubtype	ToUnicodeTypeIdentityAdober   )OrderingRegistry
Supplementi  )r7   CIDToGIDMapCIDSystemInfoFontDescriptorr:   r<   DW)Filtersa  /CIDInit /ProcSet findresource begin
12 dict begin
begincmap
/CIDSystemInfo
<<
  /Registry (Adobe)
  /Ordering (UCS)
  /Supplement 0
>> def
/CMapName /Adobe-Identify-UCS def
/CMapType 2 def
1 begincodespacerange
<0000> <FFFF>
endcodespacerange
1 beginbfrange
<0000> <FFFF> <0000>
endbfrange
endcmap
CMapName currentdict /CMap defineresource pop
end
end
   P   )
Ascent	CapHeightDescentFlagsFontBBox	FontFile2FontNameItalicAngleStemVr<   )r   Placeholdermake_indirectr   GlyphLessFontType0r   CIDFontType2r-   r8   make_streamCID_TO_GID_DATAFlateDecoderB   r;   rD   GLYPHLESS_FONTrO   )r   pdfPLACEHOLDERbasefontcid_font_type2font_descriptors         r   registerGlyphlessFont.register+   sp    &&$$++!,m,

%YY	
 **++'('$ 
  +))YY4+++
 %3#3 %(__  )9)9 &5 &
" !__
. ++Q(8(8 8$?%++((
 %(OOD4G4G$H!(7%r   r   Nr   r   r/   floatr   rd   r   )r\   r   )r   r   r   r   zlibcompressrY   GLYPHLESS_FONT_NAMEpackage_files
read_bytesr[   r-   r%   r0   r   ra   r   r   r   r   r!   r!      sO    mmK%$78O##O47JJVVXNKX
'Mr   r!   c                  6    \ rS rSrSrSS jrS	S jrS
S jrSrg)Courier{   zCourier font.c                    [        U5      U-  $ )r(   )r*   r.   s      r   r0   Courier.text_width~   s    4y8##r   c                "    UR                  SSS9$ )Npdfdocignore)errorsr3   r   s     r   r   Courier.text_encode   s    {{8H{55r   c                    UR                  [        [        R                  [        R                  [        R
                  S95      $ )zRegister the font.)r7   r<   r:   )rT   r   r   rk   r   Type1)r   r\   s     r   ra   Courier.register   s2      YY


 	
r   r   Nrc   r   )r\   r   r   r   )	r   r   r   r   __doc__r0   r   ra   r   r   r   r   rk   rk   {   s    $6
r   rk   )
__future__r   loggingr+   re   importlib.resourcesr   rh   pikepdfr   r   r   pikepdf.canvasr   	getLoggerr   logr
   r!   rk   r   r   r   <module>r      s\    #    6 
  !$D $
^M ^B
m 
r   