% !TeX root = ./CleverPanda_test.tex
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% This package is part of the Panda package
% A package to estimate the blackness of fonts
% Maintained by samcarter
%
% Project repository and bug tracker:
% https://github.com/samcarter/panda
%
% Released under the LaTeX Project Public License v1.3c or later
% See https://www.latex-project.org/lppl.txt
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\ProvidesPackage{CleverPanda}[2026/02/12 version v0.3 Estimating blackness of fonts]

\ExplSyntaxOn
\keys_define:nn { clever@panda } {
  scale.fp_set:N = \l__panda_clever_scale_fp,
  scale.initial:n = 1.0,
}
\ProcessKeyOptions[clever@panda]

\dim_new:N \l__panda_stroke_dim

\cs_new_nopar:Npn \__panda_factor:N {
  \tl_if_head_eq_charcode:VNT \f@series b {
    \str_case_e:nnT { \f@family } {
      {bodoni}{1.0}
      {Courier New(0)}{1.0}
      {fve}{1.2}
      {GilliusADF-LF}{1.5}
      {JanaSkrivana}{1.0}
      {Lao MN(0)}{0.8}
      {LinuxLibertineMonoT-TLF}{1.0}
      {Lithos Pro(0)}{1}
      {LukasSvatba}{0.9}
      {Myanmar MN(0)}{0.8}
      {pag}{1.2}
      {PTMono-TLF}{1.0}
      {qag}{1.2}
      {qcr}{1.2}
      {STIX Two Text (family)(0)}{0.8}
      {STIX Two Text(0)}{0.8}
      {Thonburi(0)}{1}
      {udidot}{1.2}
      {ul9}{1.0}
      {Verdana(0)}{0.8}
    }{ \use_none_delimit_by_q_stop:w }
  }
  \str_case_e:nnF { \f@family } {
    {Academy Engraved LET Plain:1.0(0)}{0.25}
    {Alegreya-OsF}{0.9}
    {Alegreya-TLF}{0.9}
    {AlegreyaSans-OsF}{0.9}
    {American Typewriter Condensed Light(0)}{0.3}
    {American Typewriter Light(0)}{0.3}
    {antp}{0.8}
    {AnonymousPro}{1.0}
    {artemisia}{1.0}
    {augie}{1.3}
    {auncl}{0.3}
    {bch}{0.8}
    {BlackoakStd(0)}{1}
    {Cabin-TLF}{0.8}
    {ClearSans-TLF}{0.9}
    {Clip(0)}{0.35}
    {clmqs}{1.0}
    {clms}{1.0}
    {cmbr}{0.8}
    {cmin}{0.25}
    {cmss}{1.0}
    {cmvtt}{0.8}
    {Cochin Italic(0)}{.4}
    {comfortaa}{0.9}
    {Comic Sans MS Bold(0)}{1.5}
    {Comic Sans MS(0)}{1}
    {Courier New(0)}{0.3}
    {Cyklop-Regular(0)}{1}
    {Cyklop(0)}{1}
    {cyklop}{1.3}
    {DejaVuSans-TLF}{0.9}
    {DejaVuSerif-TLF}{0.9}
    {droidsans}{0.9}
    {droidserif}{0.9}
    {DulceChico(0)}{1}
    {FiraSans-TLF}{1.0}
    {frc}{0.15}
    {fve}{0.9}
    {Gill Sans UltraBold(0)}{1}
    {GilliusADF-LF}{1.0}
    {GilliusADFNoTwo-LF}{0.9}
    {Gurmukhi MN Bold(0)}{0.8}
    {Hammerhead Black(0)}{1}
    {Hammerhead(0)}{0.8}
    {Heiti SC Light(0)}{0.3}
    {Heiti SC Medium(0)}{0.3}
    {Heiti TC Light(0)}{0.3}
    {Heiti TC Medium(0)}{0.3}
    {Impact(0)}{1.0}
    {iwona}{0.9}
    {JetBrains Mono NL Thin Italic(0)}{0.3}
    {JetBrains Mono NL Thin(0)}{0.3}
    {JetBrains Mono Thin Italic(0)}{0.3}
    {JetBrains Mono Thin(0)}{0.3}
    {Lao MN Bold(0)}{0.8}
    {lato-OsF}{0.9}
    {Lbstr-LF}{0.9}
    {LibreBskvl-LF}{1.0}
    {LibreCsln-TLF}{0.9}
    {Linux Biolinum Keyboard O(0)}{0.1}
    {Linux Libertine Capitals Semibold Italic(0)}{0.8}
    {LinuxBiolinumT-OsF}{1.0}
    {Lithos Pro Black(0)}{1}
    {Lithos Pro-Black(0)}{1}
    {Marion Bold(0)}{0.8}
    {Marker Felt Thin(0)}{0.8}
    {Marker Felt Wide(0)}{1}
    {Menlo Italic(0)}{0.4}
    {Menlo Regular(0)}{0.4}
    {MesloLGS NF Italic(0)}{0.4}
    {MesloLGS NF Regular(0)}{0.4}
    {MintSpirit-LF}{0.9}
    {Myanmar MN Bold(0)}{0.8}
    {nanumgt}{5}
    {nanumgt}{6}
    {nanummj}{2.5}
    {nanummj}{3}
    {neohellenic}{1.1}
    {Noto Mono(0)}{0.5}
    {OCRAStd(0)}{0.3}
    {opensans-TLF}{0.9}
    {pbk}{0.9}
    {pcr}{0.6}
    {Pennstander Math Thin(0)}{0.4}
    {Phosphate Solid(0)}{1}
    {phv}{1.0}
    {PlyfrDisplay-OsF}{0.8}
    {pnc}{0.8}
    {PoplarStd(0)}{1}
    {PTSans-TLF}{1.0}
    {PTSansCaption-TLF}{1.0}
    {PTSansNarrow-TLF}{1.0}
    {qcr}{0.45}
    {qcs}{0.8}
    {qhv}{1.2}
    {qhvc}{0.9}
    {qtm}{0.8}
    {Quattro-LF}{1.1}
    {QuattroSans-LF}{1.1}
    {Roboto-TLF}{1.0}
    {RobotoSlab-TLF}{1.1}
    {Saira Stencil One Regular(0)}{1}
    {Songti SC Light(0)}{0.4}
    {Songti SC Regular(0)}{0.4}
    {Songti TC Light(0)}{0.4}
    {Songti TC Regular(0)}{0.4}
    {sqrc}{0.25}
    {STHeiti(0)}{0.35}
    {STIX Two Text Bold Italic(0)}{0.8}
    {STIX Two Text Bold(0)}{0.8}
    {STSong(0)}{0.3}
    {ua1}{0.9}
    {uaq}{0.8}
    {udidot}{0.8}
    {ugq}{1.0}
    {UniversalisADFStd-LF}{1.0}
    {Verdana Bold(0)}{0.8}
    {XB Yas(0)}{0.4}
    {Yas Italic(0)}{0.4}
    {Yas(0)}{0.4}
    {yrd}{1.0}
    {yvod}{0.5}
    {zi4}{1.0}
  }{0.7}
  \use_none:n \q_stop
}

\NewExpandableDocumentCommand{ \CleverPanda }{ m }{
  \dim_eval:n {
    \fp_eval:n {
      \tl_if_blank:nTF { #1 } { \l__panda_clever_scale_fp } { #1 }
      *
      \__panda_factor:N
    }
    \tex_fontcharht:D \tex_font:D `.
  }
}

\NewExpandableDocumentCommand{ \CleverPandaGet }{ m }{
  \dim_eval:n {
    \fp_eval:n {
      \tl_if_blank:nTF { #1 } { \l__panda_clever_scale_fp } { #1 }
      *
      \__panda_factor:N
    }
    \l__panda_stroke_dim
  }
}

\NewDocumentCommand{ \CleverPandaSet }{ }{
  \dim_set:Nn \l__panda_stroke_dim { \tex_fontcharht:D \tex_font:D `. }
}

\ExplSyntaxOff
