+
    f7i.  c                   s    ^ RI HtHt ^RIHt ^ RIt^ RIHt ^ RIt^ RI	t	 ! R R]P                  4      t
 ! R R]! RR	4      4      tR# )
    )	bytesjoinsafeEval)DefaultTableN)
namedtuplec                   s   a  ] tR t^t o RtRt^ tRR ltR tRR lt	RR lt
R tR	 tR
 tR tR tR tR tR tRtV tR# )table_C_P_A_L_a  Color Palette table

The ``CPAL`` table contains a set of one or more color palettes. The color
records in each palette can be referenced by the ``COLR`` table to specify
the colors used in a color glyph.

See also https://learn.microsoft.com/en-us/typography/opentype/spec/cpal
i  Nc                s|    \         P                   P                  W4       . V n        . V n        . V n        . V n        R # N)r   __init__palettespaletteTypespaletteLabelspaletteEntryLabels)selfZtags   &&F/usr/lib64/python3.14/site-packages/fontTools/ttLib/tables/C_P_A_L_.pyr   Ztable_C_P_A_L_.__init__   s5    !!**45"$    c                s   \         P                  ! R VR,          4      w  V n        V n        ppp. V n        ^p\        V4       F  p\         P                  ! RWV^,            4      ^ ,          pV^,          p. p	WX^,          ,           p
\        V P                  4       FB  pV	P                  \        \         P                  ! RWV
^,            4      !  4       V
^,          p
KD  	  V P                  P                  V	4       K  	  V P                  ^ 8X  d   ^ p^ p^ pM4^V^,          ,           p\         P                  ! RWV^,            4      w  pppV P                  VVVV P                  R7      V n
        V P                  WW0P                  R7      V n        V P                  VVV P                  V P                  R7      V n        R# )>HHHHL:Ni   N>H>BBBB>LLL)defaultN)structZunpackversionnumPaletteEntriesr   rangeappendColor_decompileUInt32ArrayDEFAULT_PALETTE_TYPEr	   _decompileUInt16Array
NO_NAME_IDr
   r   )r   datattFontnumPalettesnumColorRecordsZgoffsetFirstColorRecordposiZ
startIndexpaletteZpposZjoffsetToPaletteTypeArrayoffsetToPaletteLabelArrayoffsetToPaletteEntryLabelArrays   &&&            r   	decompileZtable_C_P_A_L_.decompile!   s    MM(DI.	
L"#
 {#AtTa-@A!DJ1HCG*!^;D4112ufmmGTPQ=R&STU	 3 MM  ) $ <<1'($()%-.*{Q&C
 fdr&:;	(). 66$--	 7 
 "77[// 8 
 #'"<"<*""OO	 #= #
r   c                s    V^ 8X  d   V.V,          # \         P                   ! RWV^V,          ,            4      p\        P                  R8w  d   VP                  4        VP	                  4       # )r    ZHbigarraysysZ	byteorderZbyteswapZtolistr   r   ZoffsetZnumElementsr   result   &&&&& r   r   Z$table_C_P_A_L_._decompileUInt16ArrayS   V    Q;9{**S$[0H"IJ==E!OO}}r   c                s    V^ 8X  d   V.V,          # \         P                   ! RWV^V,          ,            4      p\        P                  R8w  d   VP                  4        VP	                  4       # )r    ZIr)   r*   r-   r/   r   r   Z$table_C_P_A_L_._decompileUInt32Array\   r0   r   c                s   V P                  4       w  r#V P                  4       pV P                  4       pV P                  4       p\	        V4      ^,          p^\	        V4      ,           pV P
                  ^8  d
   V^,          p\        P                  ! RV P
                  V P                  \	        V P                  4      VV4      p	V P
                  ^ 8X  d   WV.p
MV\	        V4      ,           p\	        V4      ^ 8X  d   ^ pMTpV\	        V4      ,          p\	        V4      ^ 8X  d   ^ pMTpV\	        V4      ,          p\	        V4      ^ 8X  d   ^ pMTpV\	        V4      ,          p\        P                  ! RVVV4      pV	VVVVVV.p
\        V
4      # )   r   r   )_compileColorRecords_compilePaletteTypes_compilePaletteLabels_compilePaletteEntryLabelslenr   r   packr   r   r   )r   r   colorRecordIndicescolorRecordsr	   r
   r   r!   ZoffsetToFirstColorRecordZheaderZdataListr"   r%   r&   r'   Zheader1s   &&              r   compileZtable_C_P_A_L_.compilee   s   +/+D+D+F(002224!<<>l+q0#%,>(?#? <<1$*$LL""$
 <<1LAH*S->>C< A%+,(+.(s<((=!Q&,-),/)s=))%&!+12.14.s=))kk().	G ""H ""r   c                sR    R  p\        V Uu. uF
  q2! V4      NK  	  up4      # u upi )c                 s    \         P                  ! R V P                  V P                  V P                  V P
                  4      # )r   )r   r7   bluegreenredalpha)Zc   &r   Z<lambda>Z0table_C_P_A_L_._compilePalette.<locals>.<lambda>   s%    WaffaggquuaggNr   )r   )r   r$   r7   colors   &&  r   _compilePaletteZtable_C_P_A_L_._compilePalette   s(    N7;7%$u+7;<<;s   $c                sJ   . . / r2pV P                    Fy  pV P                  V4      pWS9   d
   W5,          pM \        V4      pVP                  V4       WcV&   VP                  \        P
                  ! R W`P                  ,          4      4       K{  	  \        V4      \        V4      3# )r   )r   rA   r6   r   r   r7   r   r   )r   r9   r8   Zpoolr$   ZpackedPaletteindexs   &      r   r2   Z#table_C_P_A_L_._compileColorRecords   s    13R$}}G 009M$+L)##M2&+]#%%fkk$@V@V8V&WX % +,i.EEEr   c           	     s    V P                   ^ 8X  g   \        V P                  4      '       g   R# \        V P                   Uu. uF  p\        P
                  ! RV4      NK  	  up4      pV# u upi )r    r   z>I)r   Zanyr	   r   r   r7   )r   Zptyper.   s   &  r   r3   Z#table_C_P_A_L_._compilePaletteTypes   sX    <<1C(9(9$:$:$BSBSTBSFKKe4BSTU Us    A+c           	     T  a  S P                   ^ 8X  gU   \        ;QJ d)    V 3R lS P                   4       F  '       d   K   RM	  RM! V 3R lS P                   4       4      '       d   R# \        S P                   Uu. uF  p\        P
                  ! RV4      NK  	  up4      pV# u upi )r    c              3   @   <"   T F  qSP                   8H  x  K  	  R # 5ir   r   Z.0Zlr      & r   	<genexpr>Z7table_C_P_A_L_._compilePaletteLabels.<locals>.<genexpr>   s     #UBTQ$8BT   FTr   r   )r   allr
   r   r   r7   r   labelr.      f  r   r4   Z$table_C_P_A_L_._compilePaletteLabels   su    <<1#U$BTBT#U#U$BTBT#U U U$BTBTUBTFKKe4BTUV V   < B%c           	     rC   )r    c              3   rD   r   rE   rF   rG   r   rH   Z<table_C_P_A_L_._compilePaletteEntryLabels.<locals>.<genexpr>   s      $
*AQ *ArI   FTr   r   )r   rJ   r   r   r   r7   rK   rM   r   r5   Z)table_C_P_A_L_._compilePaletteEntryLabels   s    <<1 $
*.*A*A$
 $
*.*A*A$
 !
 !
 373J3JK3J%V[[u%3JK
  LrN   c                sL  a  \        S P                  4      p\        S P                  4       UUu/ uF  w  rEWEbK	  	  ppp\        S P                  4       UUu/ uF  w  rGWGbK	  	  pppVP                  R S P                  R7       VP                  4        VP                  RS P                  R7       VP                  4        \        S P                  4       EFf  w  rRV	/pVP                  V	S P                  4      pVP                  V	S P                  4      pS P                  ^ 8  d   VS P                  8w  d   WR&   S P                  ^ 8  d   VS P                  8w  d   WR&   VP                  ! R/ VB  VP                  4        S P                  ^ 8  d^   VS P                  8w  dM   V'       dE   RV9   d>   VR,          P                  V4      pVe"   VP                  V4       VP                  4        \        V
4       F  w  ppVP                  WV4       K  	  VP!                  R4       VP                  4        EKi  	  S P                  ^ 8  EdF   \"        ;QJ d)    V 3R	 lS P$                   4       F  '       d   K   R
M	  RM! V 3R	 lS P$                   4       4      '       g   VP                  R4       VP                  4        \        S P$                  4       F  w  p	pVS P                  8w  g   K  VP                  RV	VR7       S P                  ^ 8  dE   V'       d=   V'       d5   RV9   d.   VR,          P                  V4      pVe   VP                  V4       VP                  4        K  	  VP!                  R4       VP                  4        R# R# R# u uppi u uppi )r   )valuer   rB   rL   typer$   nameNc              3   rD   r   rE   rF   rG   r   rH   Z'table_C_P_A_L_.toXML.<locals>.<genexpr>   s      (
*AQ *ArI   FTr   )rB   rO   )r$   )r6   r   Z	enumerater
   r	   	simpletagr   newliner   getr   r   ZbegintagZgetDebugNameZcommenttoXMLZendtagrJ   r   )r   writerr   r    r#   nameIDr
   Ztypr	   rB   r$   attrsZpaletteTypeZpaletteLabelrQ   Zcindexr@   rL   s   f&&               r   rU   Ztable_C_P_A_L_.toXML   s   $--(6?@R@R6ST6S{6ST/89J9J/KL/K8A/KL$,,7,D4J4JK'6NEe$E&**5$2K2KLK(,,UDOODL||aLDOO$C!-g||aK43L3L$L +fOO//NNq  DOO3f$f~22<@#NN4(NN$!*7!3FF3 "4MM)$NN1 72 <<!CC (
*.*A*A(
CCC (
*.*A*A(
 %
 %
 OO01NN )$*A*A BuDOO+$$WE$G||a'Ef6AQ%f~::5A+"NN40NN$ !C MM./NN%
? ULs   NN c                s   VR 8X  d   V P                   P                  \        VP                  RV P                  4      4      4       V P
                  P                  \        VP                  RV P                  4      4      4       . pV FQ  p\        V\        4      '       d   K  V^,          p\        P                  VR,          4      pVP                  V4       KS  	  V P                  P                  V4       R# VR8X  d   / pV FQ  p\        V\        4      '       d   K  Vw  rpV	R8X  g   K)  \        V
R,          4      p\        V
R,          4      pWV&   KS  	  \        V P                  4       Uu. uF  pVP                  WP                  4      NK   	  upV n        R# RV9   dM   \        VR,          4      p\!        WV4       VR8X  d&   V P                  .V P                  ,          V n        R# R# R# u upi )r$   rL   rP   rO   r   rB   r   N)r
   r   intrT   r   r	   r   Z
isinstanceZstrr   fromHexr   r   r   r   r   Zsetattr)r   rQ   rX   Zcontentr   r$   Zelementr@   ZcolorLabelsZelementNameZelementAttrZ_Z
labelIndexrW   r#   rO   s   &&&&&           r   fromXMLZtable_C_P_A_L_.fromXML   s   9%%c%))GT__*M&NO$$S64;T;T)U%VWG"gs++
eGn5u% # MM  )))K"gs++.5+!')!)+g*>!?J%k'&:;F.4
+ # t556'6A ??36'D# U7^,ED&**+/??*;d>T>T*T' + 	's   1$G4)r   r   r
   r	   r   r   r   )r    )__name__
__module____qualname____firstlineno__Z__doc__r   r   r   r(   r   r   r:   rA   r2   r3   r4   r5   rU   r[   __static_attributes____classdictcell__Z__classdict__   @r   r   r      s^      J%0
d3#j=
F
/bU Ur   r   c                   sV   a  ] tR tRt o R tR tR	R lt]R 4       t]R 4       t	Rt
V tR# )
r   i  c                sl    R V P                   V P                  V P                  V P                  3,          # )z#%02X%02X%02X%02Xr=   r<   r;   r>   r   r?   r   hexZ	Color.hex  s&    "dhh

DIItzz%RRRr   c                s"    V P                  4       # r   )rf   re   r?   r   __repr__ZColor.__repr__  s    xxzr   Nc                sj    VP                  R V P                  4       VR7       VP                  4        R# )r@   )rO   rB   N)rR   rf   rS   )r   rV   r   rB   s   &&&&r   rU   ZColor.toXML!  s'    
%@r   c                s    V^ ,          R8X  d
   VR,          p\        VR,          ^4      p\        VR,          ^4      p\        VR,          ^4      p\        V4      ^8  d   \        VR,          ^4      M^pV ! W#WER7      # )r    Z#:i   NN:r       N:rh   r1   N:r1      N:ri   i   Nrd   )rY   r6   )clsrO   r=   r<   r;   r>   s   &&    r   rZ   ZColor.fromHex%  so    8s?"IE%*b!E#J#5:r"'*5zQE#J#Dsd@@r   c                s    V ! WW4R 7      # )rd    )rj   r=   r<   r;   r>   s   &&&&&r   fromRGBAZColor.fromRGBA/  s    sd@@r   rk   r   )r\   r]   r^   r_   rf   rg   rU   ZclassmethodrZ   rl   r`   ra   rb   rc   r   r   r     sA     S A A A Ar   r   zblue green red alpha)ZfontTools.misc.textToolsr   r   Z r   r+   Zcollectionsr   r   r,   r   r   rk   r   r   <module>rm      sF   
 9   "  
JU\.. JUZAJw 67 Ar   