Repository navigation
Expand file tree
/
Copy pathchar2path.dtx
More file actions
1615 lines (1577 loc) · 56.3 KB
/
Copy pathchar2path.dtx
File metadata and controls
1615 lines (1577 loc) · 56.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
% \iffalse meta-comment
%
% File: char2path.dtx
% -----------------------------------------------------------------------
% Copyright (C) 2025 by Zongping Ding <zongpingding5@outlook.com> and *
% Mingyu Xia <myhsia@outlook.com> *
% *
% This work may be distributed and/or modified under the conditions *
% of the LaTeX Project Public License (LPPL), either version 1.3c of *
% this license or (at your option) any later version. *
% The latest version of this license is in *
% *
% http://www.latex-project.org/lppl.txt *
% *
% and version 1.3c or later is part of all distributions of LaTeX *
% version 2008 or later. *
% *
% This work has the LPPL maintenance status `maintained'. *
% *
% The Current Maintainer of this work is Zongping Ding and Mingyu Xia.*
% *
% This work consists of the files char2path.dtx, *
% ctp-data.dtx, *
% char2path.ins, *
% the derived files char2path.sty, *
% ctp-lmr-arabic.data.tex, *
% ctp-lmr-alpha-small.data.tex, *
% ctp-lmr-alpha-caps.data.tex, *
% ctp-lmr-others.data.tex, *
% ctp-lms-arabic.data.tex, *
% ctp-lms-alpha-small.data.tex, *
% ctp-lms-alpha-caps.data.tex, *
% ctp-lms-others.data.tex, *
% ctp-lmm-arabic.data.tex, *
% ctp-lmm-alpha-small.data.tex, *
% ctp-lmm-alpha-caps.data.tex, *
% ctp-lmm-others.data.tex, *
% ctp-adventor-arabic.data.tex, *
% ctp-adventor-alpha-small.data.tex, *
% ctp-adventor-alpha-caps.data.tex, *
% ctp-adventor-others.data.tex, *
% ctp-bonum-arabic.data.tex, *
% ctp-bonum-alpha-small.data.tex, *
% ctp-bonum-alpha-caps.data.tex, *
% ctp-bonum-others.data.tex, *
% ctp-chorus-arabic.data.tex, *
% ctp-chorus-alpha-small.data.tex, *
% ctp-chorus-alpha-caps.data.tex, *
% ctp-chorus-others.data.tex, *
% ctp-cursor-arabic.data.tex, *
% ctp-cursor-alpha-small.data.tex, *
% ctp-cursor-alpha-caps.data.tex, *
% ctp-cursor-others.data.tex, *
% ctp-heros-arabic.data.tex, *
% ctp-heros-alpha-small.data.tex, *
% ctp-heros-alpha-caps.data.tex, *
% ctp-heros-others.data.tex, *
% ctp-pagella-arabic.data.tex, *
% ctp-pagella-alpha-small.data.tex, *
% ctp-pagella-alpha-caps.data.tex, *
% ctp-pagella-others.data.tex, *
% ctp-schola-arabic.data.tex, *
% ctp-schola-alpha-small.data.tex, *
% ctp-schola-alpha-caps.data.tex, *
% ctp-schola-others.data.tex, *
% ctp-termes-arabic.data.tex, *
% ctp-termes-alpha-small.data.tex, *
% ctp-termes-alpha-caps.data.tex, *
% ctp-termes-others.data.tex, *
% the documentation files char2path.pdf, *
% and README.md. *
% -----------------------------------------------------------------------
%
% Any modification of this file should ensure that the copyright and
% license information is placed in the derived files.
%
% -----------------------------------------------------------------------
%
%<*internal>
\iffalse
%</internal>
%
%<*readme>
[](https://ctan.org/pkg/char2path)
[](https://github.com/zongpingding/char2path/releases/latest)
[](https://github.com/zongpingding/char2path/commits)
[](https://github.com/zongpingding/char2path/actions)
[](https://github.com/zongpingding/char2path)
The `char2path` Package
=======================
The `char2path` package provides a LaTeX package for converting characters into Ti*k*Z paths.
Overview
--------
The package provides the `\chartopath` and `\chartoclip` macro
\chartopath [<keys>] {<font>} {<string>}
\chartoclip [<keys>] {<font>} {<character>}
to print Ti*k*Z paths for characters in a string.
See `char2path.pdf` for more. Happy TeXing!
Generate Ti*k*Z paths from font
-------------------------------
First, install the dependencies. For Windows users:
```shell
cd resources/scripts
pip install -r requirements.txt
```
for Linux users:
```python
cd resources/scripts
pip3 install -r requirements.txt
```
on macOS, run the following command:
```shell
cd resources/scripts
brew install cairo pkg-config
python3 -m pip install -r requirements.txt --break-system-packages
```
Next, custom your own `config.toml`, An example configuration is:
```toml
[flow]
method = "font2svg"
gensvg = true
extsvg = true
gentkz = true
[font_spec]
folder = "../Fonts/"
name = "texgyreadventor-regular.otf"
alias = 'texgyre'
[svg_dir]
folder = "SVGs"
sub_1 = "."
sub_2 = "_moreSVGs_"
caps = "caps"
small = "small"
nums = "nums"
others = "others"
[tkz_data]
folder = "../data"
caps = "ctp-%ALIAS%-alpha-caps.data.tex"
small = "ctp-%ALIAS%-alpha-small.data.tex"
nums = "ctp-%ALIAS%-arabic.data.tex"
others = "ctp-%ALIAS%-others.data.tex"
digits = 3
# coor_x = "+\\ctpXshift"
# coor_y = "+\\ctpYshift"
```
Command-line arguments take precedence over the TOML file.
``` txt
usage: font2path [options]
font2path: a tool that converts font into TikZ paths.
options:
-h, --help show this help message and exit
-m, --method tikz path generating method.
-s, --string the string for conversion('fonttools' only).
-p, --folder font folder.
-d, --data tikz path data folder.
-a, --alias font name alias.
-g, --gensvg (Bool) 'True' to generate SVGs from font.
-e, --extsvg (Bool) 'True' to extract SVGs from previous run.
-c, --gentkz (Bool) 'True' to generate tikz path from previous run.
-q, --quiet (Bool) 'True' to suppress message.
-f, --font font name('*.ttf' or '*.otf').
```
Finally, run the command below:
``` shell
python font2path.py
```
Issues
------
The issue tracker for `char2path` is currently located
[on GitHub](https://github.com/zongpingding/char2path/issues).
Build status
------------
This project uses [GitHub Actions](https://github.com/features/actions)
as a hosted continuous integration service. For each commit, the build status
is tested using the current release of TeX Live.
_Current build status:_ 
References
----------
\[1\] https://www.gust.org.pl/projects/e-foundry/latin-modern/download
\[2\] https://www.unicode.org/standard/standard.html
Copyright and License
---------------------
Copyright (C) 2025 by Zongping Ding <[zongpingding5@outlook.com](mailto:zongpingding5@outlook.com)> and
Mingyu Xia <[myhsia@outlook.com](mailto:myhsia@outlook.com)>
---
This package's `lm' data is converted from the
[Latin Modern family](https://www.gust.org.pl/projects/e-foundry/latin-modern),
based on the Computer Modern fonts, which are released into public
domain by AMS (1997). It's licensed under
**[The GUS Font License (GFL)](https://ctan.org/license/gfl)**.
This package's `tg' data is converted from the
[TeX Gyre fonts](https://ctan.org/pkg/tex-gyre),
which are being released under
**[The GUS Font License (GFL)](https://ctan.org/license/gfl)**.
---
This work may be distributed and/or modified under the conditions
of the LaTeX Project Public License (LPPL), either version 1.3c of
this license or (at your option) any later version.
The latest version of this license is in
http://www.latex-project.org/lppl.txt
and version 1.3c or later is part of all distributions of LaTeX
version 2008 or later.
This work has the LPPL maintenance status `maintained'.
The Current Maintainer of this work is **Zongping Ding** and **Mingyu Xia**.
%</readme>
%
%<*eg-preamble>
%% \iffalse
\documentclass{article}
\def\MakePercentIgnore{\catcode`\%9\relax}
\def\MakePercentComment{\catcode`\%14\relax}
\def\DocInput#1{\MakePercentIgnore\input{#1}\MakePercentComment}
\catcode`\^^A 14\relax
\usepackage[scale = 10pt]{char2path}
\usepackage[T1]{fontenc}
\setCTPfamilyfont {sans} {adventor}
\setCTPfamilyfont {serif} {bonum}
\setCTPfamilyfont {serif} {chorus}
\setCTPfamilyfont {mono} {cursor}
\setCTPfamilyfont {sans} {heros}
\setCTPfamilyfont {serif} {pagella}
\setCTPfamilyfont {serif} {schola}
\setCTPfamilyfont {serif} {termes}
\usepackage{geometry, verbatim, listings}
\geometry{margin = .5in}
\lstset{basicstyle = \footnotesize\ttfamily, numbers = left}
\newenvironment{example}{\vskip1ex\hrule\vskip1ex}{\vskip1ex\hrule\vskip1ex\par}
\begin{document}
\pagestyle{empty}
\DocInput{\jobname.tex}
\end{document}
%% \fi
%</eg-preamble>
%
%<*internal>
\fi
%</internal>
%
%<*driver>
\documentclass[show-notes]{l3doc}
\usepackage[scale = 10pt]{char2path}
\setCTPfamilyfont {sans} {adventor}
\setCTPfamilyfont {serif} {bonum}
\setCTPfamilyfont {serif} {chorus}
\setCTPfamilyfont {mono} {cursor}
\setCTPfamilyfont {sans} {heros}
\setCTPfamilyfont {serif} {pagella}
\setCTPfamilyfont {serif} {schola}
\setCTPfamilyfont {serif} {termes}
\usepackage{listings, pdfpages, microtype}
\DisableLigatures[-]{encoding = T1, family = tt*}
\lstset{basicstyle = \footnotesize\ttfamily, numbers = left}
\AddToHook{env/function/before}{\vspace*{-.5\baselineskip}}
\ExplSyntaxOn \makeatletter
\DeclareDocumentCommand \key { s m }
{
\IfBooleanTF {#1} { \textcolor{red}{\ttfamily \bfseries #2} }
{
\ttfamily
\seq_set_from_clist:Nn \l_tmpa_seq {#2}
\seq_set_map:NNn \l_tmpb_seq \l_tmpa_seq
{ \exp_not:n { \textcolor{red}{\bfseries ##1} } }
\seq_use:Nn \l_tmpb_seq { ,~ } \:=\:
}
}
\DeclareCommandCopy \val \meta
\def \TFF {true\textup{\textbar\underline{\textbf{false}}}}
\def \TTF {\textup{\underline{\textbf{true}}\textbar}false}
\newcounter{example}[subsection]
\renewcommand\theexample{\thesubsection.\arabic{example}}
\newwrite\example@out
\def\example@name{\jobname.example.aux}
\long\def\example@start{\begingroup\@bsphack
\immediate\openout\example@out=\example@name
\let\do\@makeother\dospecials\catcode`\^^M\active
\def\verbatim@processline{\immediate\write\example@out{\the\verbatim@line}}^^A
\verbatim@start}
\long\def\example@end{\immediate\closeout\example@out\@esphack\endgroup
\trivlist\item\relax
\leavevmode\hbox to \z@{^^A
\hbox to \z@{\hss{\footnotesize[\theexample]}\hskip4pt}
\begin{minipage}[c]{.75\textwidth}^^A
\small\verbatiminput \example@name
\end{minipage}^^A
\fbox{^^A
\begin{minipage}[c]{.21\textwidth}^^A
\normalsize\input \example@name
\end{minipage}^^A
}^^A
\hss}^^A
\endtrivlist}
\long\def\s@example@end{\immediate\closeout\example@out\@esphack\endgroup
\trivlist\item\relax
\leavevmode\hbox to \z@{^^A
\hbox to \z@{\hss{\footnotesize[\theexample]}\hskip4pt}\vbox{\noindent
\hskip-4pt
\begin{minipage}{\textwidth}^^A
\small\VerbatimInput[gobble=2]{\example@name}^^A
\end{minipage}\par\smallskip\noindent
\fbox{^^A
\begin{minipage}{\textwidth}^^A
\normalsize\input \example@name^^A
\end{minipage}^^A
}}^^A
\hss}^^A
\endtrivlist}
\newenvironment{example}
{\stepcounter{example}\example@start}{\example@end}
\newenvironment{example*}
{\stepcounter{example}\example@start}{\s@example@end}
\makeatother \ExplSyntaxOff
\newlist{keyval}{itemize}{10}
\setlist[keyval]{leftmargin = 0pt, labelsep = 0pt}
\makeindex
\begin{document}
\DocInput{\jobname.dtx}
\end{document}
%</driver>
% \fi
% \title{^^A
% The \texorpdfstring{^^A
% \chartopath[hfading = {teal, purple}]{lms}{char2path}^^A
% }{char2path} Package\thanks{^^A
% \url{https://ctan.org/pkg/char2path},
% \url{https://github.com/zongpingding/char2path}^^A
% }^^A
% }
% \author{^^A
% Zongping Ding\thanks{^^A
% \href{mailto:zongpingding5@outlook.com}{\texttt{zongpingding5@outlook.com}}},~
% Mingyu Xia\thanks{^^A
% \href{mailto:xiamingyu@westlake.edu.cn}{\texttt{xiamingyu@westlake.edu.cn}}^^A
% }^^A
% }
% \date{Released 2025-08-09\quad \texttt{v1.0.1}}
% \def\Copyright{^^A
% \begin{center}
% \fbox{\fbox{\begin{tabular}{@{}>{\small}{l}@{}}^^A
% This package's `lm' data is converted from the
% \href{https://www.gust.org.pl/projects/e-foundry/latin-modern}{Latin Modern family}, based\\^^A
% on the Computer Modern fonts, which are released into public domain by\\^^A
% AMS (1997). It's licensed under
% \href{https://ctan.org/license/gfl}{The GUS Font License (GFL)}.\\^^A
% This package's `tg' data is converted from the
% \href{https://ctan.org/pkg/tex-gyre}{TeX Gyre fonts}, which are\\^^A
% being released under
% \href{https://ctan.org/license/gfl}{The GUS Font License (GFL)}.
% \end{tabular}}}\end{center}}
% \makeatletter \def\@thanks{\Copyright} \makeatother
%
% \maketitle
%
% \begin{documentation}
%
% \section{Introduction}\label{sec:introduction}
%
% The \pkg{char2path} package provides a \LaTeX\ package for converting
% characters into Ti\textit k\/Z paths.
% It supports compilation methods including \hologo{pdfLaTeX},
% \hologo{XeLaTeX}, and \hologo{LuaLaTeX}.
% \DeleteShortVerb\| \DeleteShortVerb\"
% \iffalse
%<*example>
\begin{center}
\raggedright\vbox{^^A
\begin{minipage}{.96\linewidth}
\chartopath[mono = .032\linewidth, draw]{lmr}{!\#$"\%&'()*+,-./0123456789:;<=>?@}
\chartopath[mono = .032\linewidth, draw]{lmr}{ABCDEFGHIJKLMNOPQRSTUVWXYZ[\ctpbackslash]^_`}
\chartopath[mono = .032\linewidth, draw]{lmr}{abcdefghijklmnopqrstuvwxyz\{|\}~}
\end{minipage}
\hspace*\fill
\begin{minipage}{.02\linewidth}
\centering
\rotatebox{90}{\textrm{LMR}}
\end{minipage}
\vskip1ex\hrule \vskip1ex
\begin{minipage}{.96\linewidth}
\chartopath[mono = .032\linewidth, draw]{lms}{!\#$"\%&'()*+,-./0123456789:;<=>?@}
\chartopath[mono = .032\linewidth, draw]{lms}{ABCDEFGHIJKLMNOPQRSTUVWXYZ[\ctpbackslash]^_`}
\chartopath[mono = .032\linewidth, draw]{lms}{abcdefghijklmnopqrstuvwxyz\{|\}~}
\end{minipage}
\hspace*\fill
\begin{minipage}{.02\linewidth}
\centering
\rotatebox{90}{\textsf{LMS}}
\end{minipage}
\vskip1ex\hrule \vskip1ex
\begin{minipage}{.96\linewidth}
\chartopath[mono = .032\linewidth, draw]{lmm}{!\#$"\%&'()*+,-./0123456789:;<=>?@}
\chartopath[mono = .032\linewidth, draw]{lmm}{ABCDEFGHIJKLMNOPQRSTUVWXYZ[\ctpbackslash]^_`}
\chartopath[mono = .032\linewidth, draw]{lmm}{abcdefghijklmnopqrstuvwxyz\{|\}~}
\end{minipage}
\hspace*\fill
\begin{minipage}{.02\linewidth}
\centering
\rotatebox{90}{\texttt{LMM}}
\end{minipage}
\vskip1ex\hrule \vskip1ex
\begin{minipage}{.96\linewidth}
\chartopath[mono = .032\linewidth, draw]{adventor}{!\#$"\%&'()*+,-./0123456789:;<=>?@}
\chartopath[mono = .032\linewidth, draw]{adventor}{ABCDEFGHIJKLMNOPQRSTUVWXYZ[\ctpbackslash]^_`}
\chartopath[mono = .032\linewidth, draw]{adventor}{abcdefghijklmnopqrstuvwxyz\{|\}~}
\end{minipage}
\hspace*\fill
\begin{minipage}{.02\linewidth}
\centering
\rotatebox{90}{\footnotesize\fontfamily{qag}\selectfont Adventor}
\end{minipage}
\vskip1ex\hrule \vskip1ex
\begin{minipage}{.96\linewidth}
\chartopath[mono = .032\linewidth, draw]{bonum}{!\#$"\%&'()*+,-./0123456789:;<=>?@}
\chartopath[mono = .032\linewidth, draw]{bonum}{ABCDEFGHIJKLMNOPQRSTUVWXYZ[\ctpbackslash]^_`}
\chartopath[mono = .032\linewidth, draw]{bonum}{abcdefghijklmnopqrstuvwxyz\{|\}~}
\end{minipage}
\hspace*\fill
\begin{minipage}{.02\linewidth}
\centering
\rotatebox{90}{\footnotesize\fontfamily{qbk}\selectfont Bonum}
\end{minipage}
\vskip1ex\hrule \vskip1ex
\begin{minipage}{.96\linewidth}
\chartopath[mono = .032\linewidth, draw]{chorus}{!\#$"\%&'()*+,-./0123456789:;<=>?@}
\chartopath[mono = .032\linewidth, draw]{chorus}{ABCDEFGHIJKLMNOPQRSTUVWXYZ[\ctpbackslash]^_`}
\chartopath[mono = .032\linewidth, draw]{chorus}{abcdefghijklmnopqrstuvwxyz\{|\}~}
\end{minipage}
\hspace*\fill
\begin{minipage}{.02\linewidth}
\centering
\rotatebox{90}{\footnotesize\fontfamily{qzc}\selectfont Chorus}
\end{minipage}
\vskip1ex\hrule \vskip1ex
\begin{minipage}{.96\linewidth}
\chartopath[mono = .032\linewidth, draw]{cursor}{!\#$"\%&'()*+,-./0123456789:;<=>?@}
\chartopath[mono = .032\linewidth, draw]{cursor}{ABCDEFGHIJKLMNOPQRSTUVWXYZ[\ctpbackslash]^_`}
\chartopath[mono = .032\linewidth, draw]{cursor}{abcdefghijklmnopqrstuvwxyz\{|\}~}
\end{minipage}
\hspace*\fill
\begin{minipage}{.02\linewidth}
\centering
\rotatebox{90}{\footnotesize\fontfamily{qcr}\selectfont Cursor}
\end{minipage}
\vskip1ex\hrule \vskip1ex
\begin{minipage}{.96\linewidth}
\chartopath[mono = .032\linewidth, draw]{heros}{!\#$"\%&'()*+,-./0123456789:;<=>?@}
\chartopath[mono = .032\linewidth, draw]{heros}{ABCDEFGHIJKLMNOPQRSTUVWXYZ[\ctpbackslash]^_`}
\chartopath[mono = .032\linewidth, draw]{heros}{abcdefghijklmnopqrstuvwxyz\{|\}~}
\end{minipage}
\hspace*\fill
\begin{minipage}{.02\linewidth}
\centering
\rotatebox{90}{\footnotesize\fontfamily{qhv}\selectfont Heros}
\end{minipage}
\vskip1ex\hrule \vskip1ex
\begin{minipage}{.96\linewidth}
\chartopath[mono = .032\linewidth, draw]{pagella}{!\#$"\%&'()*+,-./0123456789:;<=>?@}
\chartopath[mono = .032\linewidth, draw]{pagella}{ABCDEFGHIJKLMNOPQRSTUVWXYZ[\ctpbackslash]^_`}
\chartopath[mono = .032\linewidth, draw]{pagella}{abcdefghijklmnopqrstuvwxyz\{|\}~}
\end{minipage}
\hspace*\fill
\begin{minipage}{.02\linewidth}
\centering
\rotatebox{90}{\footnotesize\fontfamily{qpl}\selectfont Pagella}
\end{minipage}
\vskip1ex\hrule \vskip1ex
\begin{minipage}{.96\linewidth}
\chartopath[mono = .032\linewidth, draw]{schola}{!\#$"\%&'()*+,-./0123456789:;<=>?@}
\chartopath[mono = .032\linewidth, draw]{schola}{ABCDEFGHIJKLMNOPQRSTUVWXYZ[\ctpbackslash]^_`}
\chartopath[mono = .032\linewidth, draw]{schola}{abcdefghijklmnopqrstuvwxyz\{|\}~}
\end{minipage}
\hspace*\fill
\begin{minipage}{.02\linewidth}
\centering
\rotatebox{90}{\footnotesize\fontfamily{qcs}\selectfont Schola}
\end{minipage}
\vskip1ex\hrule \vskip1ex
\begin{minipage}{.96\linewidth}
\chartopath[mono = .032\linewidth, draw]{termes}{!\#$"\%&'()*+,-./0123456789:;<=>?@}
\chartopath[mono = .032\linewidth, draw]{termes}{ABCDEFGHIJKLMNOPQRSTUVWXYZ[\ctpbackslash]^_`}
\chartopath[mono = .032\linewidth, draw]{termes}{abcdefghijklmnopqrstuvwxyz\{|\}~}
\end{minipage}
\hspace*\fill
\begin{minipage}{.02\linewidth}
\centering
\rotatebox{90}{\footnotesize\fontfamily{qtm}\selectfont Termes}
\end{minipage}
}
\end{center}
%</example>
% \fi
% \MakeShortVerb\| \MakeShortVerb\"
%
% \section{Getting Started}
%
% \noindent
% \begin{minipage}{.55\linewidth}
% To load this package, write the line
% \begin{Verbatim}[commandchars = \|\{\}]
% \usepackage[scale = |meta{choice}]|{char2path|}
% \end{Verbatim}
% The supported right listed \meta{choice} can
% scale the converted paths with corresponding factors.
% \end{minipage}
% \hspace*\fill
% \begin{minipage}{.43\linewidth}
% \begin{tabular}{*5{>{\small}c}}
% \toprule
% Choice & |10pt| & |11pt| & |12pt| & |13pt|\\
% Factor & |0.82| & |0.90| & |0.98| & |1.07|\\
% \midrule
% Choice & |14pt| & |15pt| & |16pt| & ... \\
% Factor & |1.15| & |1.23| & |1.31| & ... \\
% \bottomrule
% \end{tabular}
% \end{minipage}
% \par \medskip \noindent
% \DescribeMacro{\ctpbackslash}
% The characters listed in Section~\ref{sec:introduction}
% are supported by this package within
% \textrm{Latin Modern Roman},
% \textsf{Latin Modern Sans}, and \texttt{Latin Modern Mono} fonts.
% Inputting some characters needs to be escaped.
% Using the \texttt{Latin Modern Mono} font as an example:
% \begin{Verbatim}[gobble = 4]
% \chartopath{lmm}{!\#$"\%&'()*+,-./0123456789:;<=>?@}
% \chartopath{lmm}{ABCDEFGHIJKLMNOPQRSTUVWXYZ[\ctpbackslash]^_`}
% \chartopath{lmm}{abcdefghijklmnopqrstuvwxyz\{|\}~}
% \end{Verbatim}
%
% \section{Font Setup}
%
% \begin{function}[added = 2025-07-31]{\setCTPfamilyfont}
% \begin{syntax}
% \cs{setCTPfamilyfont} \marg{font style} \marg{font family} \oarg{database}
% \end{syntax}
% This function enables users to load custom font by generating path data
% files^^A
% \NB{Note}{Compiling option |-shell -escape| is required.}
% \file{ctp-}\meta{font family}\file{-}\meta{database}\file{.code.tex}.
% The \meta{font style} will determine if the font needs to be monospace.
% This package has already loaded the following fonts:
% \begin{Verbatim}[gobble = 4]
% \setCTPfamilyfont {serif} {lmr}
% \setCTPfamilyfont {sans} {lms}
% \setCTPfamilyfont {mono} {lmm}
% \end{Verbatim}
% This package also contains the path data files of \TeX~Gyre font family,
% but they have not been loaded.
% \end{function}
%
% \section{Basic Usage}
%
% \begin{function}[updated = 2025-08-01]{\chartopath}
% \begin{syntax}
% \cs{chartopath} \oarg{key-vals} \marg{font family} \marg{string}
% \end{syntax}
% The \oarg{key-vals} accepts the listed keys to set how the \meta{string}
% converts to path.
% \begin{keyval}
% \item [\key{font}] \val{lmr\textup\textbar lms\textup\textbar lmm}
% choose char's font.
% \item [\key{draw, fill}] \val{color} set the color of
% the outline/fill of string (Default: |black|).
% \item [\key{outline}] \val{dim} set the outline of the string
% to achieve the ``Fake Bold'' effect (Default: |0pt|).
% \item [\key{scale}] \val{fp num} set font's scale factor
% (Default: |1|).
% \item [\key{mono}] \val{dim} set font's monospace width
% (Default: |0pt|, monospace width is disabled now).
% \item [\key{hfading, vfading}] \val{color clist} set the two colors
% for horizontally/vertically fading the whole string.
% \item [\key{rescan}] \val{\TTF} rescan tokens |$|, |&|, and |~|
% with catcode 12 (other).
% \end{keyval}
% \end{function}
%
% \begin{function}[updated = 2025-08-01]{\chartoclip}
% \begin{syntax}
% \cs{chartoclip} \oarg{key-vals} \marg{font family} \marg{char}
% \end{syntax}
% The mandatory argument accepts a single character, and the optional
% argument accepts the following keys to set the style how the character clip
% the image.
% \begin{keyval}
% \item [\key{font}] \val{lmr\textup\textbar lms\textup\textbar lmm}
% choose char's font.
% \item [\key{image}] \val{image file} set image for clipping.
% \item [\key{scale}] \val{fp num} set font's scale factor (Default: |1|).
% \item [\key{anchor}] \val{tikz anchor} set image's anchor.
% \item [\key{offset}] \val{(x, y)} set imgae anchor's offset.
% \item [\key{height}] \val{dim} image's height.
% \end{keyval}
% \end{function}
%
% \section{Advanced}
%
% \begin{function}[added = 2025-07-28]{\ctpdata}
% \begin{syntax}
% \cs{ctpdata} \marg{font family} \marg{character}
% \end{syntax}
% This function can output the path data (in \textsc{pgf} coordinates).
% \NB{Note}{This command is expandable.}
% \begin{example*}
% \def\0{\ctpdata{lmr}{-}} \small\ttfamily\detokenize\expandafter{\expanded{\0}}
% \end{example*}
% \end{function}
%
% \section{Examples}
%
% \subsection{Outline, Fill and Scale}
%
% \noindent
% \iffalse
%<*example>
% \fi
\def\0{char2path}
% \iffalse
%</example>
% \fi
% If none of the \oarg{keys} in the optional argument of \cs{chartopath}
% is assigned, then only the outline of the inputted string will be printed.
% \iffalse
%<*example>
% \fi
\begin{example}
\def\0{char2path} \chartopath{lmm}\0
\end{example}
% \iffalse
%</example>
% \fi
% Commands like \cs[no-index]{small} can be directly applied to \cs{chartopath}.
% A comparison of the text and the converted path under 4 different font size
% is shown in the following figure.
% \begin{center}
% \begin{tikzpicture}[every node/.style = {font = \ttfamily}]
% \draw [ -stealth, gray!25, line width = 1em, line cap = round ]
% (0,0) --++ (.93\linewidth,0) node [ left, black ] {\tn{f@size}};
% \node [ above = 1ex ] at (.06\linewidth,0) {\small \0};
% \node [ above = 1ex ] at (.24\linewidth,0) {\normalsize \0};
% \node [ above = 1ex ] at (.45\linewidth,0) {\large \0};
% \node [ above = 1ex ] at (.72\linewidth,0) {\Large \0};
% \node [ below = 1ex ] at (.06\linewidth,0)
% {\small \chartopath[fill = orange]{lmm}\0};
% \node [ below = 1ex] at (.24\linewidth,0)
% {\normalsize\chartopath[fill = green]{lmm}\0};
% \node [ below = 1ex ] at (.45\linewidth,0)
% {\large \chartopath[fill = blue]{lmm}\0};
% \node [ below = 1ex ] at (.72\linewidth,0)
% {\Large \chartopath[fill = purple]{lmm}\0};
% \makeatletter
% \node at (.06\linewidth,0)
% {\small \scalebox{\fpeval{8/\f@size}}
% {\small \f@size pt (\cs[no-index]{small})}};
% \node at (.24\linewidth,0)
% {\normalsize\scalebox{\fpeval{8/\f@size}}
% {\normalsize\f@size pt (\cs[no-index]{normalsize})}};
% \node at (.45\linewidth,0)
% {\large \scalebox{\fpeval{8/\f@size}}
% {\large \f@size pt (\cs[no-index]{large})}};
% \node at (.72\linewidth,0)
% {\Large \scalebox{\fpeval{8/\f@size}}
% {\Large \f@size pt (\cs[no-index]{Large})}};
% \makeatother
% \end{tikzpicture}
% \end{center}
% \noindent
% Users can specific the color of outline and fill,
% specific the fill-in pattern,
% and specific the scale and slant of inputted characters.
% Just like the keys in Ti\textit k\/Z.
% \iffalse
%<*example>
% \fi
\begin{example}
\chartopath[draw = none, fill = blue]{lmm}\0
\end{example}
% \iffalse
%</example>
% \fi
% \iffalse
%<*example>
% \fi
\begin{example}
\chartopath[pattern = north west lines, draw = teal,
pattern color = violet, scale = 1.2]{lmm}\0
\end{example}
% \iffalse
%</example>
% \fi
% \iffalse
%<*example>
% \fi
\begin{example}
\chartopath[fill = green, xslant = .15]{lmm}\0
\end{example}
% \iffalse
%</example>
% \fi
%
% \subsection{Fading the path}
% \iffalse
%<*example>
% \fi
\begin{example}
\chartopath[hfading = {red, green}]{lmm}\0
\end{example}
% \iffalse
%</example>
% \fi
% \iffalse
%<*example>
% \fi
\begin{example}
\chartopath[hfading = {blue, -}]{lmm}\0
\end{example}
% \iffalse
%</example>
% \fi
% \iffalse
%<*example>
% \fi
\begin{example}
\chartopath[hfading = {-, violet}]{lmm}\0
\end{example}
% \iffalse
%</example>
% \fi
% \iffalse
%<*example>
% \fi
\begin{example}
\chartopath[vfading = {teal, purple}]{lmm}\0
\end{example}
% \iffalse
%</example>
% \fi
% \iffalse
%<*example>
% \fi
\begin{example}
\chartopath[vfading = {-, orange}]{lmm}\0
\end{example}
% \iffalse
%</example>
% \fi
% \iffalse
%<*example>
% \fi
\begin{example}
\chartopath[vfading = {violet, -}]{lmm}\0
\end{example}
% \iffalse
%</example>
% \fi
% \begin{texnote}
% Fading will cost too much time!!!
% \end{texnote}
%
% \subsection{Using in \pkg{listings}}
%
% This package can be used within \pkg{listings} or \pkg{minted},
% then users could directly copy the source code from |.pdf| file
% without worry about including unwanted line numbers.
%
% \iffalse
%<*example>
% \fi
\let\orithelstnumber\thelstnumber
\def\thelstnumber{^^A
\chartopath[rescan = false, hfading = {violet, blue}]{lmm}{\orithelstnumber}^^A
}
% \iffalse
%</example>
% \fi
% \begin{verbatim}
% \let\orithelstnumber\thelstnumber
% \def\thelstnumber{%
% \chartopath[rescan = false, hfading = {violet, blue}]{lmm}{\orithelstnumber}%
% }
% \end{verbatim}
% \iffalse
%<*example>
% \fi
\begin{example}
\begin{lstlisting}[language = {[LaTeX]TeX}]
\documentclass{article}
\begin{document}
Hello, \LaTeX!
\end{document}
\end{lstlisting}
\end{example}
% \iffalse
%</example>
% \fi
% If the user loads Ti\textit k\/Z's "external" library,
% it is suggested to add the following before modifying the code line numbers:
% \begin{verbatim}
% \tikzexternaldisable
% \end{verbatim}
% Otherwise, every line number would have to be cached, which is redundant.
% \subsection{Clipping string}
% Define a command, \cs[no-index]{strpathclip},
% to accepts a string instead of a single character:
% \iffalse
%<*example>
% \fi
\begin{example}
\ExplSyntaxOn
\NewDocumentCommand \strpathclip { O{} m }
{ \int_step_inline:nn { \exp_args:Ne \tl_count:n {#2} }
{ \chartoclip [ #1, offset = {(##1*1, 0pt)} ]
{lmr} { \tl_item:nn {#2}{##1}} \kern2pt } }
\ExplSyntaxOff
\strpathclip[scale = 2, image = example-grid-100x100bp]{Hello, c2p}
\end{example}
% \iffalse
%</example>
% \fi
% \subsection{\hologo{(La)TeX} logo}
% The logos \TeX\ and \LaTeX\ can be recreated using \cs{chartoclip}:
% \iffalse
%<*example>
% \fi
\begin{example}
\def\ctp#1{\chartoclip[image = example-grid-100x100bp]{lmr}{#1}}
\protected\def\ctpTeX{\ctp T\kern-.125em \lower.54ex\hbox{\ctp E}\kern-.1em \ctp X}
\protected\def\ctpLaTeX{\ctp L\kern -.36em{\lower-.54ex
\hbox{\scalebox{.72}{\ctp A}}}\kern -.08em\ctpTeX}
\scalebox{1.5}{\ctpTeX} \scalebox{1.5}{\ctpLaTeX}
\end{example}
% \iffalse
%</example>
% \fi
% \footnotesize
% \section{Todo List}
%
% \begin{itemize}
% \item [\textcolor{green}{\textsf{Warn}}] Resolve the font warning:
% Font shape \texttt{OMS/cmtt/m/n} undefined for \texttt{textbackslash}.
% \item [\textcolor{blue}{\textsf{Function}}] Support syntax
% "\chartopath{\usefont{T1}{cmr}{m}{sc} abc}",
% "\chartopath{\sffamily abc}".
% \end{itemize}
%
% \end{documentation}
%
% \includepdf{char2path-demo}
%
% \begin{implementation}
%
% \section{The Source Code}
%
% \begin{macrocode}
%<*package>
% \end{macrocode}
%
% \begin{macrocode}
%<@@=ctp>
% \end{macrocode}
%
% \begin{macrocode}
\ProvidesExplPackage {char2path} {2025-08-09} {v1.0.1}
{A LaTeX package that converts characters into TikZ paths}
% \end{macrocode}
% \begin{variable}{\g_@@_scale_tl}
% Define the |scale| key for this package.
% \begin{macrocode}
\keys_define:nn { char2path }
{
scale .tl_gset:N = \g_@@_scale_tl,
scale .initial:n = { 10pt },
}
\ProcessKeyOptions [ char2path ]
% \end{macrocode}
% \end{variable}
% \begin{macrocode}
\ExplSyntaxOff
\RequirePackage{tikz}
\usetikzlibrary{patterns, fadings, calc}
\ExplSyntaxOn
% \end{macrocode}
% Warning Broadcast
% \begin{macrocode}
\cs_new_protected:Npn \@@_msg_new:nn #1#2
{ \msg_new:nnn { char2path } {#1} {#2} }
\cs_new_protected:Npn \@@_msg_warning:n #1
{ \msg_warning:nn { char2path } {#1} }
\cs_new_protected:Npn \@@_msg_error:nn #1#2
{ \msg_error:nne { char2path } {#1} {#2} }
\@@_msg_new:nn { fading } { Unsupport ~ multiple ~ fading ~ directions }
\@@_msg_new:nn { kernel } { file ~ not ~ found }
\@@_msg_new:nn { shell-escape }
{ '-shell-escape' ~ is ~ required ~ to ~ use ~ \token_to_str:N \ctpgendata }
\@@_msg_new:nn { font2path-method }
{ 'font2path' ~ only ~ supports ~ methods: ~ 'font2svg' ~ and ~ 'fonttools' }
% \end{macrocode}
% \begin{variable}
% {\c_@@_tikz_folder_tl, \c_@@_global_scale_fp, \c_@@_scale_prop}
% Define global variables: \cmd{\c_@@_tikz_folder_tl} for future use,
% \cmd{\c_@@_global_scale_fp} for global scale factor, and
% \cmd{\c_@@_scale_prop} for storing scale choices respectly.
% \begin{macrocode}
\tl_const:Nn \c_@@_tikz_folder_tl { font_glyph }
\fp_const:Nn \c_@@_global_scale_fp { .0135 }
\prop_const_from_keyval:Nn \c_@@_scale_prop
{
10pt = 0.820, 11pt = 0.902, 12pt = 0.984, 13pt = 1.066,
14pt = 1.148, 15pt = 1.230, 16pt = 1.311,
}
% \end{macrocode}
% \end{variable}
% \begin{macro}{\setCTPfamilyfont}
% User's interface for loading custom font.
% \begin{macrocode}
\DeclareDocumentCommand \setCTPfamilyfont
{ m m O{arabic, alpha-small, alpha-caps, others} }
{ \@@_load_font_data:nnn {#1} {#2} {#3} }
% \end{macrocode}
% \end{macro}
% \begin{variable}{\l_@@_tikz_data_merge_tl}
% To merge a font's different parts of data into a \meta{token list}.
% \begin{macrocode}
\tl_new:N \l_@@_tikz_data_merge_tl
% \end{macrocode}
% \end{variable}
% \begin{macro}{\@@_load_font_data:nnn}
% Load fonts' path data from database file (|*.data.tex|).
% Due to the fact that character |~| is stored in the database,
% |\char_set_catcode:nn { 126 } { 12 }| should be applied
% to ensure it's path data could be correctly loaded in |expl3| syntax.
% \vspace*{-9pt}
% \begin{multicols}{3}
% \begin{arguments}
% \item font style
% \item font name
% \item data files
% \end{arguments}
% \end{multicols}
% \vspace*{-12pt}
% \begin{macrocode}
\cs_new_protected_nopar:Npn \@@_load_font_data:nnn #1#2#3
{
\clist_map_inline:nn {#3}
{
\file_get:nnNTF
{ ctp-#2-##1.data.tex } { \char_set_catcode:nn { 126 } { 12 } }
\l_@@_tikz_data_single_tl
{
\tl_gput_right:NV \l_@@_tikz_data_merge_tl
\l_@@_tikz_data_single_tl
} { \@@_msg_error:nn { kernel } { ctp-#2-##1.data.tex } }
}
\exp_args:NnV \prop_const_from_keyval:cn
{ c_@@_tikz_#2_data_prop } { \l_@@_tikz_data_merge_tl }
\tl_set:cn { l_@@_font_#2_type_tl } {#1}
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\@@_protected_char:nn}
% To create a macro so that it couldn't be expanded.
% \begin{macrocode}
\cs_new:Npn \@@_protected_char:nn #1#2
{ \cs_new_protected:cpn {#1} { \exp_not:n {#2} } }
\@@_protected_char:nn { ctpbackslash } { \textbackslash }