-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunicodefonttable.dtx
2428 lines (2364 loc) · 86 KB
/
unicodefonttable.dtx
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: unicodefonttable.dtx (C) Copyright 2019-2024 Frank Mittelbach
%
% It 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 the file
%
% https://www.latex-project.org/lppl.txt
%
%
% The development version of the bundle can be found below
%
% https://github.com/FrankMittelbach/fmitex/
%
% for those people who are interested or want to report an issue.
%
\def\unicodefonttabledate {2024/06/06}
\def\unicodefonttableversion{1.0i}
%<*driver>
\documentclass{l3doc-TUB2024}
% some fixes local to this documentation
\ExplSyntaxOn
\cs_new:Npn\IfImplementationShownTF
{\bool_if:NTF \g__codedoc_typeset_implementation_bool}
\ExplSyntaxOff
\makeatletter
\def\meta@font@select{\normalfont\itshape}
\IndexPrologue{%
\IfImplementationShownTF{\section*{Index}%
Numbers written in italic refer to the page
where the corresponding entry is described
or mentioned. Numbers underlined refer to the
code line of the
definition; numbers in Roman refer to the
code lines where the entry is used.}%
{\section{Index}%
Numbers written in italic refer to the page
where the corresponding entry is described
or mentioned.}}
\makeatother
\usepackage{graphicx,unicodefonttable}
\EnableCrossrefs
\CodelineIndex
\begin{document}
\DocInput{unicodefonttable.dtx}
\advance\signaturewidth by 40pt
\makesignature
\end{document}
%</driver>
%
% \fi
%
% \tracinglostchars=3
%
% \newcommand\key [1]{\texttt{#1}}
% \newcommand\kval[1]{\texttt{#1}}
%
% \newcommand\keysetup[1]{\noindent\marginpar{\raggedleft Key setup: #1}\ignorespaces}
% \renewcommand\keysetup[1]{\paragraph*{\hspace*{-8pc}Key setup (#1)}}
%
%
% \title{The \texttt{unicodefonttable} package\thanks{This is
% version \unicodefonttableversion\ of the package, dated
% \unicodefonttabledate; the license is LPPL.}}
% \author{Frank Mittelbach}
% \address{Mainz, Germany}
% \netaddress{https://www.latex-project.org}
% \personalURL{https://ctan.org/pkg/unicodefonttable}
% \raggedbottom
%
% \maketitle
%
%
% \begin{abstract}
% A package for typesetting font tables for larger fonts, e.g.,
% TrueType or OpenType Unicode fonts.
% To produce a one-off table, a standalone version is available as well.
% \end{abstract}
%
% \vspace*{\medskipamount}
%
% \tableofcontents
%
% \vspace*{\bigskipamount}
%
% \section{Introduction}
%
% When I started to write a new chapter for the third edition of
% \emph{The \LaTeX{} Companion} on modern fonts available for
% different \LaTeX{} engines, I was a bit surprised that I couldn't
% find a way to easily typeset tables showing the glyphs available in
% TrueType or OpenType fonts. The \pkg{nfssfont} package available
% with \LaTeX{} only supports fonts from the 8-bit world, but
% modern fonts that can be used with \XeTeX{} or \LuaTeX{} can
% contain thousands of glyphs and having a method to display what
% is available in them was important for me.
%
% I therefore set out to write my own little package and what
% started as an afternoon exercise ended up being this package,
% offering plenty of bells and whistles for typesetting such
% font tables.
%
% As there can be many glyphs in such fonts a tabular
% representation of them might run for several pages, so the
% package internally uses the \pkg{longtable} package to handle
% that.
%
% In most cases the glyphs inside the fonts are indexed by their
% Unicode numbers so it is natural to display them sorted by their
% position in the Unicode character set.
%
% Unicode is organized in named blocks such as ``Basic Latin'',
% ``Latin-1~Supplement'', etc., typically consisting of 265
% characters each.\footnote{Some blocks are smaller, while those
% containing the Asian ideographs are much larger.} It is therefore
% helpful to use these block names as subtitles within the table,
% to more easily find the information one is looking for.
%
% A common way to represent the number of a single Unicode
% character is \texttt{U+} followed by four (or more)
% hexadecimal digits. For example, \texttt{U+0041} represents the letter
% ``A'' and \texttt{U+20AC} the Euro currency symbol ``\texteuro''.
% We use this convention by showing a Unicode range of sixteen
% characters at the left of each table row,
% e.g., \texttt{U+0040 -
% 004F}, followed by the sixteen glyphs in the range. Thus that
% \IfImplementationShownTF{}{\pagebreak}\ignorespaces
% particular table row from the ``Basic Latin'' block would show
% something like
%
% \displayfonttable*[noheader,range-start=0040, range-end=004F,
% color=black!50]{Latin Modern Sans}
%
% If a Unicode character has no glyph representation in a given
% font then this is indicated by a special symbol (by default a
% colored hyphen). By default some color is used, but we've grayscaled
% the output for \TUB.
%
% In order to easily locate any Unicode character the table shows by
% default sixteen hex digits as a column heading. For example, to find
% Euro currency symbol (\texttt{U+20AC}) one first finds the
% right row, which is the range \texttt{U+20A0 - 20AF}, and then
% the \texttt{C} column in that row, and the glyph is there (or an
% indication that the font is missing that glyph;
% the line shows that for some of the other slots).
%
% \displayfonttable*[noheader,range-start=20A0, range-end=20AF,
% color=black!50]{Latin Modern Sans}
%
% It can be useful to compare two fonts with each other by
% filling the table with glyphs from a secondary font if the
% primary font is missing them. For example, the next display shows
% two rows of Latin Modern Math (black glyphs) and instead of showing
% a missing glyph symbol in most slots, we use the glyphs from New
% Computer Modern Math, which has a much larger glyph set
% (normally red glyphs with gray background but again, grayscaled for
% \TUB).
%
%
% \displayfonttable[noheader,nostatistics,display-block=none,
% compare-with=NewCMMath-Regular.otf,range-start=2A00,range-end=2A1F,
% color=black!50,compare-color=none]
% {latinmodern-math.otf}
%
%
% \section{The user interface}
%
% The package offers one command to typeset a font table. The
% appearance of the table can be customized by specifying key/value
% pairs.
%
% \begin{function}{\displayfonttable}
% \begin{syntax}
% \cs{displayfonttable} \texttt{*} \oarg{key/value-list} \Arg{font-name} \oarg{font-features}
% \end{syntax}
% The \meta{font-name} is the font to be displayed. This and the
% \meta{font-features} argument are passed to \pkg{fontspec}, thus they
% should follow the conventions of that package for specifying a
% font. The \meta{key/value-list} offers customization
% possibilities discussed below.
%
% The \cs{displayfonttable*} is a variant of the command, intended
% for use with 8-bit legacy fonts. It presets some keys, but
% otherwise behaves identically. The preset values are:
%\begin{verbatim}
% nostatistics, display-block=none, hex-digits=head, range-end=FF
%\end{verbatim}
% For details see the next section.
% \end{function}
%
%
%
% \begin{function}{\fonttablesetup}
% \begin{syntax}
% \cs{fonttablesetup} \Arg{key/value-list}
% \end{syntax}
% Instead of or in addition to specifying key/values to
% \cs{displayfonttable} it is possible to set them up as
% defaults. Inside \cs{displayfonttable} the defaults are applied first,
% so one can still overwrite their values for an individual table.
% \end{function}
%
%
% \begin{function}{\fonttableglyphcount}
% \begin{syntax}
% \cs{fonttableglyphcount}
% \end{syntax}
% While typesetting a font table the package keeps track of the
% number of glyphs it finds in the font. After the table has finished,
% this value is available in \cs{fonttableglyphcount} and it is, for
% example, used when statistics are produced. At the start of the
% next table it is reset to zero.
% \end{function}
%
%
%
%
% \subsection{Keys and their values}
%
% Several of the available keys are booleans accepting \texttt{true}
% or \texttt{false}. They usually exist in pairs so that one can
% specify the desired behavior without needing to provide a value,
% e.g., specifying \key{header} is equivalent to specifying
% \key{header}\texttt{=true} or \key{noheader}\texttt{=false}, etc.
% In the lists below the default settings are indicated by an
% underline.
%
% \begin{variable}{header,noheader,title-format,title-format-cont}
% The first set of keys is concerned with the overall look and
% feel of the generated table.
% \begin{description}
% \item[\underline{\key{header}}, \key{noheader}]
% These keys determine whether a header to the table is
% produced.
%
% \item[\key{title-format}, \key{title-format-cont}]
% These keys define what is provided as a header title or
% continuation title if the table consists of several pages.
% They expect code as their value. This code can contain \verb=#1=
% and \verb=#2= to denote the \meta{font-name} and
% \meta{font-features} arguments, respectively.
%
% By default a title using the \cs{caption} command is produced; on
% continuation titles, the \meta{font-features} are not shown.
% This is typeset as a \env{longtable} header row, so you either need to use
% \cs{multicolumn} or a \cs{caption} command\Dash otherwise everything
% ends up in the first column.
%
% \end{description}
%
% \end{variable}
%
%
% \begin{variable}{display-block,hex-digits, hex-digits-font,hex-digits-row-format,color}
% These keys handle the inner parts of the table.
%
% \begin{description}
% \item[\key{display-block}]
% The Unicode dataset is organized in named blocks that are typically 128 or
% 256 characters, though some are noticeably larger and a few are
% smaller. With the \key{display-block} key it is
% possible to specify if and how such blocks should be made visible.
% The following values are supported:
% \begin{description}
% \item[\underline{\kval{titles}}]
% Above each display block that contains glyphs the Unicode title
% of the block is displayed.
%
% \item[\kval{rules}]
% Display blocks are indicated only by a \cs{midrule}.
%
% \item[\kval{none}]
% Display blocks are not indicated at all.
% \end{description}
%
% \item[\key{hex-digits}]
% To ease reading the table, rows of hex digits are added to
% it. Where or if this happens is controlled by this key. Allowed
% values for it are the following:
% \begin{description}
% \item[\kval{block}]
% A row of hex digits is placed at the beginning of each Unicode
% block containing glyphs in the displayed font.
%
% \item[\kval{foot}]
% A row is added to the foot of each table page.
%
% \item[\underline{\kval{head}}]
% A row is added to the top of each table page.
%
% \item[\kval{head+foot}]
% A row is added to the top and the foot of each table page.
%
% \item[\kval{none}]
% All hex digit rows are suppressed.
% \end{description}%
%
% \item[\key{hex-digits-font}]
% The font to use for the hex digits, by default
% \underline{\cs{ttfamily}\cs{scriptsize}}.{\hfuzz=2.7pt\par}
%
% \item[\key{hex-digits-row-format}]
% This key defines the format for the hex digits shown on the left
% of each row. It accepts one argument hold the hex values for the
% row except for the last digit, e.g, \texttt{0A3} for the values
% from \texttt{0A30} to \texttt{0A3F}. The default formatting is
% \underline{\ttfamily U+\#10\cs{,}-\cs{,}\#1F} and without further
% adjustments it is automaticaly set
% in \cs{ttfamily}\cs{footnotesize} and in the color
% specified by the \key{color} key.
% A suitable value that takes up less space would be \texttt{U+\#1x}.
%
%
%
% \item[\key{color}]
% This key determines the color for parts of the table (hex digits
% and Unicode ranges). It can be either \kval{none} or a color
% specification as understood by the \cs{color} command.
% The default is \underline{\texttt{blue}}.
%
% \end{description}
%
% \end{variable}
%
%
% \begin{variable}{statistics, nostatistics,statistics-font,statistics-format}
% The next set of keys allows altering the statistics that are produced.
% \begin{description}
%
% \item[\underline{\key{statistics}}, \key{nostatistics}]
% These keys determine whether some statistics are listed at
% the end of the table.
%
% \item[\key{statistics-font}]
% The font used to typeset the statistics; the default is\\
% \underline{\cs{normalfont}\cs{small}}.
%
%
% \item[\key{statistics-format}]
% Code (text) to specify what should be typeset in the
% statistics. One can use \verb=#1= for the \meta{font-name} and
% \verb=#2= for the glyph count.
% The material is typeset on a single line at the end of the
% table. If several lines are needed you need to use \cs{parbox}
% or a similar construct.
% \end{description}
% \end{variable}
%
%
%
% \begin{variable}{glyph-width,missing-glyph, missing-glyph-font, missing-glyph-color}
% Another set of keys deals with customization on the glyph level.
% \begin{description}
% \item[\key{glyph-width}]
% All glyphs are typeset in a box with the same width, the default
% value is \underline{\texttt{6pt}} which is suitable for most 10pt
% fonts
% and make the table fit comfortably into the text width of
% a typical document.
%
% \item[\key{missing-glyph}]
% If a slot in a row doesn't have a glyph in the font you may still
% want display something to indicate this state. By giving the key
% a value any arbitrary glyph or material can be typeset. The
% default is to typeset a \kval{-} (hyphen) in a special color.
%
% Rows that contain no glyph whatsoever are not displayed at
% all. Instead a small vertical space is added to indicate the one
% or more rows are omitted.
%
% \item[\key{missing-glyph-font}]
%
% The font used for the missing glyphs (the default value is
% \underline{\cs{ttfamily}\cs{scriptsize}}).
%
% \item[\key{missing-glyph-color}]
% If not specified it uses the value specified with the \key{color}
% key. If you want a different color, e.g., \texttt{red}, you can
% use a color value or you can specify \kval{none} to use no coloring.
%
% \end{description}
%
% \end{variable}
%
%
% \begin{variable}{compare-with,compare-color, compare-bgcolor,statistics-compare-format}
%
% You can make comparisons between two fonts, which is useful, for
% example when dealing with incomplete math fonts and you need to
% see how well the symbols from one font blend with the supplementary
% symbols from another font.
%
% \begin{description}
% \item[\key{compare-with}]
%
% If given, the value is a \meta{comparison-font-name} that is used
% to supply missing glyphs. This means that if the \meta{font-name}
% to be displayed is missing a glyph in a slot, then the
% \meta{comparison-font-name} is checked, and if that font has the
% glyph in question, it will be displayed instead of showing a
% missing glyph indicator.
%
% \item[\key{compare-color}, \key{compare-bgcolor}]
%
% To distinguish real glyphs from missing but substituted glyphs,
% they can be colored specially (default \underline{\texttt{red}})
% and/or you can have their background colored (default is
% \underline{\texttt{black!10}}, i.e., a light gray).
%
% \item[\key{statistics-compare-format}]
%
% Code (text) to specify what should be typeset in the statistics
% when comparing two fonts. One can use \verb=#1= for the
% \meta{font-name} and \verb=#2= for its glyph count, \verb=#3= is
% the name of the comparison font, \verb=#4= its glyph count,
% \verb=#5= for the number of glyphs missing in this font and
% \verb=#6= the number of extra glyphs in it. This code is used
% instead of \key{statistics-format} when comparisons are made.
%
% The material is typeset on a single line at the end of the
% table. If several lines are needed you need to use \cs{parbox}
% or a similar construct.
%
% \end{description}
% \end{variable}
%
%
% \begin{variable}{range-start, range-end}
% Finally there are two keys for restricting the display range.
% \begin{description}
% \item[\key{range-start}, \key{range-end}]
% The full Unicode set of characters is huge and checking every
% slot to see if the current font contains a glyph in the slot
% takes a long time. If you know that font contains only a
% certain subset then you can speed up the table generation
% considerably by limiting the search (and consequently the output
% generation).
% The \key{range-start} specifies where to start with the search
% (default \underline{\texttt{0000}}) and \key{range-end} gives
% the last slot that is tested (default
% \underline{\texttt{FFFF}}).
%
% Thus, by default we restrict the display to slots below
% \texttt{10000}, because text fonts seldom contain glyphs in the
% higher planes. But if you want to see everything of the font (as
% far as supported by this package) and are prepared to wait for
% the higher
% planes to be scanned, you can go up to a value of \texttt{FFFFF}.
%
% However, please note that the \LuaTeX{} fontloader uses the
% \enquote{Supplementary Private Use Area-A}, which starts at
% \texttt{F0000}, as its own playground and places remapping into
% it, so by default you see random data instead of font data there. You
% either have to use the \XeTeX{} engine or load the font with
% \texttt{Renderer=HarfBuzz} in \LuaTeX{}.
%
% These keys are also quite useful in combination with the previous
% \key{compare-with} key, to display only, for example, the Greek
% letters and see how glyphs from two fonts blend with each other.
% \end{description}
% \end{variable}
%
%
%
% \subsection{A standalone interactive version}
%
% If you want to quickly display a single font, you can run
% \texttt{unicodefont.tex} through \LaTeX{} using \LuaTeX{} (or \XeTeX{})
% as the engine. Similar to
% \texttt{nfssfont.tex} (which is for 8-bit fonts with \pdfTeX) it
% asks you a few questions and then generates the font table for
% you. There are fewer configuration options available,
% but this workflow saves you writing a document to get a
% one-off table.
%
% Most font tables need several runs due to the use of
% \pkg{longtable}, which has to find the right width for the columns
% across several pages. The \texttt{unicodefont} file therefore
% remembers your selection from the previous run and asks you if
% you want to reapply it to speed up the process.
%
%
%
% \section{Notes on the table data}
%
% If you look at some parts of a Unicode font table you see a number of slots that
% do not show a \enquote{missing glyph} sign, but nonetheless appear
% to be empty. For example:
%
% \displayfonttable[noheader,nostatistics,display-block=none,
% range-start=0020,range-end=00BF,
% color=black!50]
% {TeX Gyre Pagella}
%
%
% The reason is that Unicode contains a lot of special
% spaces or otherwise invisible characters, e.g., \texttt{U+0020}
% is the normal space, \texttt{U+00A0} is a non-breaking space,
% \texttt{U+00AD} is a soft-hyphen (what \LaTeX{} users would
% indicate with \cs{-}), and so forth. Especially the row
% \texttt{U+2000-200F} in Table~6 looks strange as it appears to be totally
% empty, but in fact most of its slots contain spaces of different
% width.
%
%\displayfonttable[noheader,nostatistics,hex-digits=foot,
% range-start=2000,range-end=202F,
% color=black!50]
% {latinmodern-math.otf}
%
%
% Another somewhat surprising area is the \enquote{Mathematical
% Alphanumeric Symbols} block in math fonts, starting at \texttt{U+1D400}.
% There you see a number of missing characters, the first two being
% \texttt{U+1D455} (math italic small h) and \texttt{U+1D49D} (math
% script B).
%
% \displayfonttable[noheader,nostatistics,hex-digits=foot,
% range-start=1D400,range-end=1D4AF,
% color=black!50]
% {latinmodern-math.otf}
%
% In this case the reason is \emph{not} that the font
% fails to implement the characters, but that these characters have
% already been defined in earlier revisions of the Unicode standard in the
% lower Unicode plane. For example, the \enquote{h} is the
% Planck constant \texttt{U+210E} and \texttt{U+212C} is
% the script capital B, etc. The Unicode Consortium decided not
% to encode the \emph{same} character twice, hence the apparent
% holes.
%
%
% \IfImplementationShownTF{}
% {\appendix
% \def\theHsection{Appendix.\thesection}
% \addtocontents{toc}{\smallskip}
% \setlength\IndexMin{200pt}
% \PrintIndex
% }
%
%
% \section{Examples}
%
% In this section we show the results of a few calls to
% \cs{displayfonttable}.
% The tables are a bit easier to navigate if they use color in some
% places, but for \TUB{} this is not practical, so we
% use black and gray.
%
% Please note that this documentation was produced with
% \LuaTeX{}. If you reuse the examples with \XeTeX{}, you may have
% to specify the font names differently (i.e., following to the
% \pkg{fontspec} documentation for this engine).
%
%
%
% \subsection{Computer Modern Sans --- 7-bit font}
%
% Our first example is the original Computer Modern Sans, with
% character codes $\le 127$.
%
% Command used: \begin{verbatim}
% \displayfonttable*[color=none, range-end=7F]{cmss10}
% \end{verbatim}
%
% \displayfonttable*[color=none, range-end=7F]{cmss10}
%
%
% \iftrue
%
%\subsection{\TeX\ Gyre Heros --- 8-bit font}
%
% This example shows the \TeX\ Gyre Heros 8-bit font,
% in the T1 encoding, with character codes $\le 255$.
% We used \key{hex-digits-row-format} to shorten the row titles on
% the left:
%\begin{verbatim}
% \displayfonttable*[color=none,hex-digits-row-format=U+#1]{ec-qhvr}
%\end{verbatim}
%
%\displayfonttable*[color=none,hex-digits-row-format=U+#1]{ec-qhvr}
%
% \fi
%
%
% \iftrue
%\subsection{Latin Modern Math --- 8-bit fonts}
%
% The traditional Latin Modern Math Italic, Symbol and Extension fonts.
% The symbol font (\texttt{lmsy10}) has two characters added to the
% Computer Modern symbol repertoire, seen in the last row of the table.
% Commands used:
%
%\begin{verbatim}
% \displayfonttable*[color=none]{lmmi10}
% \displayfonttable*[color=none]{lmsy10}
% \displayfonttable*[color=none]{lmex10}
%\end{verbatim}
%
%\displayfonttable*[color=none]{lmmi10}
%\displayfonttable*[color=none]{lmsy10}
%\displayfonttable*[color=none]{lmex10}
%
% \fi
%
%
% \iffalse % 5pp
%
%\subsection{\TeX{} Gyre Pagella (Palatino) oldstyle figures --- OTF font}
%
% This example shows Pagella with oldstyle numerals.
% Command used:
%\begin{verbatim}
%\displayfonttable{TeX Gyre Pagella}[Numbers=OldStyle]
%\end{verbatim}
%
%\displayfonttable{TeX Gyre Pagella}[Numbers=OldStyle]
%
% \fi
%
%
% ^^A \IfImplementationShownTF{}{\newpage}
%
% \subsection{Latin Modern Math compared to New Computer Modern Math}
%
% This example shows the extra symbols available in New Computer
% Modern Math in comparison to Latin Modern Math as the base font.
% We use the following setup (including settings for the
% grayscaled \TUB\ output, as an example of color overrides):
%\begin{verbatim}
% \displayfonttable[hex-digits=head+foot, range-end=1FFFF,
% compare-with=New Computer Modern Math,
% title-format=\caption{Latin Modern Math compared to
% New Computer Modern Math},
% title-format-cont=\caption{LM Math vs.\ NewCM Math,
% \emph{cont.}},
% compare-color=black, compare-bgcolor=black!5,
% missing-glyph-color=black!50, color=black!75]
% {Latin Modern Math}
%\end{verbatim}
% That is, glyphs only in \texttt{NewCM} are shown with a light gray
% background.
%
% We also extended the range to cover \texttt{U+10000} to
% \texttt{U+1FFFF} in order to include the Unicode Math alphabets.
%
% \displayfonttable[hex-digits=head+foot, range-end=1FFFF,
% compare-with=New Computer Modern Math,
% title-format=\caption{Latin Modern Math compared to
% New Computer Modern Math},
% title-format-cont=\caption{LM Math vs.\ NewCM Math,
% \emph{cont.}},
% compare-color=black, compare-bgcolor=black!5,
% missing-glyph-color=black!50, color=black!75]
% {Latin Modern Math}
%
%
%\subsection{Garamond Libre's Byzantine Musical Symbols}
%
% As a final example we exhibit the Byzantine Musical Symbols as provided by
% Garamond Libre.
% Command used:
%\begin{verbatim}
% \displayfonttable[range-start=1D000, range-end=1D0FF,
% hex-digits=block,
% missing-glyph-color=black!50, color=black!75,
% statistics-format=Total number of glyphs in
% this block of #1 is #2]
% {Garamond Libre}
%\end{verbatim}
%
% Note that we have altered the text produced by the statistics,
% because the default is somewhat misleading if only a portion of
% the font is displayed. This produces the following table:
%
% \displayfonttable[range-start=1D000, range-end=1D0FF,
% hex-digits=foot,
% missing-glyph-color=black!50, color=black!75,
% statistics-format=Total number of glyphs in
% this block of #1 is #2]
% {Garamond Libre}
%
%
%
% \IfImplementationShownTF
% {\StopEventually{\setlength\IndexMin{200pt} \PrintIndex }}
% {\StopEventually{}}
%
%
%
% \section{The package implementation}
%
% \hfuzz=10pt ^^A lots of slightly overfull tt lines
%
% \begin{macrocode}
%<*package>
% \end{macrocode}
%
% By default the package uses coloring to improve the table
% appearance and therefore requires a color package.
% \begin{macrocode}
\RequirePackage{xcolor}
% \end{macrocode}
%
% \begin{macrocode}
%<@@=fmuft>
% \end{macrocode}
%
% We need the package \pkg{xparse} for specifying the document-level
% interface commands and \pkg{l3keys2e} to use the \pkg{expl3} key
% value methods within \LaTeXe{}. These packages automatically
% require \pkg{expl3} so there is no need to load that explicitly.
% Actually, \pkg{expl3}, \pkg{l3keys2e} and the \pkg{xparse}
% functionality is now all part of the \LaTeX{} kernel so the next
% line is actually not needed at all with a current \LaTeX{} kernel, but
% in order to support older installations we keep it for now.
%
% \begin{macrocode}
\RequirePackage{xparse,l3keys2e}
% \end{macrocode}
%
% Here we introduce the package and specify its version number:
% \begin{macrocode}
\ProvidesExplPackage{unicodefonttable}
{\unicodefonttabledate}
{\unicodefonttableversion}
{Producing font tables for Unicode and other fonts}
% \end{macrocode}
%
% This is a tmp fix for code in \texttt{lttabbing.dtx} until that
% is corrected there (probably 2024/11).
% \begin{macrocode}
\cs_set:Npn \tbl_crcr:n #1 {
\int_compare:nNnT \g__tbl_col_int > 0
{
\tbl_count_missing_cells:n {#1}
}
\crcr
}
% \end{macrocode}
%
% \newcommand\hex[1]{$\langle\textit{hex}_{#1}\rangle$}
%
%
%
%
%
% \subsection{User interface commands}
%
%
% Throughout the implementation we will define a number of keys (and
% their allowed values). We introduce them at the point where they are
% used, so they are sprinkled throughout the code.\footnote{This fits
% with the way this package was developed. I first implemented a
% single rigid table layout without configuration possibilities and
% then thought about which parts I wanted to have flexible. I then
% replaced the rigid code with code that is affected by setting
% key/value pairs.}
% \begin{macro}{\fonttablesetup}
% To set up user defaults for the keys we provide a standard
% interface. The command \cs{unicodefonttabletablesetup} expects a
% key/value list and can be called as often as necessary.
% \begin{macrocode}
\NewDocumentCommand \fonttablesetup { m }
{ \keys_set:nn {@@} {#1} \ignorespaces }
% \end{macrocode}
% \end{macro}
%
%
%
% \begin{macro}{\displayfonttable}
% The document-level command for generating a font table.
% \begin{macrocode}
\NewDocumentCommand\displayfonttable {s O{} m o}{%
\IfBooleanTF #1
{
% \end{macrocode}
% For the starred form we preset a number of keys with values
% suitable when displaying 8-bit legacy fonts.
% With such fonts Unicode block headers make little
% sense (as the fonts do not conform to the Unicode layout and
% since they have at most 265 glyphs). It is therefore also unnecessary to
% loop over the whole Unicode range of the first plane.
% If necessary all of them can still be overwritten in the optional argument.
% \begin{macrocode}
\@@_display_fonttable:nnn
{nostatistics,display-block=none,hex-digits=head,range-end=FF,#2}
{#3}{#4}
}
{
\@@_display_fonttable:nnn {#2}{#3}{#4}
}
}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\@@_display_fonttable:nnn}
% This command is the main workhorse of the
% package. It produces a \texttt{longtable} containing all font
% glyphs with 16 glyphs per row. The first optional argument is
% used to configure the table through key/value pairs, the
% mandatory argument is the font name to display (in
% \texttt{fontspec} conventions) and the final optional argument is
% the font feature list if any. If the latter is not provided it
% will get a special value (\texttt{--NoValue--}) assigned by
% \texttt{xparse}, which is something that can be tested for.
% \begin{macrocode}
\cs_new:Npn \@@_display_fonttable:nnn #1#2#3 {
\group_begin:
% \end{macrocode}
% First initialize the font that should be displayed (perhaps with a
% feature list) and then update the key/value list using \verb=#1=.
% \begin{macrocode}
\fontspec{#2}[#3]
\keys_set:nn{@@}{#1}
% \end{macrocode}
% If the \LuaTeX{} engine is used without HarfBuzz and the display
% range includes code points above \texttt{U+EFFFF} the output shows
% remappings and not what is in the font, so we issue a warning.
% \changes{v1.0g}{2022/11/12}{Test for luatex without harfbuzz and
% private area A and warn (gh/8)}
% \begin{macrocode}
\bool_lazy_and:nnT
{ \sys_if_engine_luatex_p: }
{ \int_compare_p:nNn { "EFFFF } < { "\l_@@_range_end_tl } }
{
\directlua{token.put_next(token.create(font.getfont(font.current()).hb~
and~ 'use_none:n'~ or~ 'use:n'))}
{ \msg_warning:nn {unicodefonttable}{noharfbuzz} }
}
% \end{macrocode}
% If the user has asked for a comparsion to some other font we need to set this up:
% \begin{macrocode}
\tl_if_empty:NTF \l_@@_compare_with_tl
{ \tl_clear:N \l_@@_compare_font_tl }
{
\setfontface \l_@@_compare_font_tl {\l_@@_compare_with_tl}[]
\cs_set_eq:NN \@@_handle_missing_glyph:n
\@@_handle_missing_glyph_compare:n
}
% \end{macrocode}
% Typesetting the font tables in twocolumn mode makes little sense
% due to their width, and if \env{longtable} is used it will
% complain. However there is one case where it should work: in a
% page-wide float. To make this happen we claim that we are not in
% twocolumn mode if the display is inside a vertical box.
% \changes{v1.0g}{2022/11/12}{Support use in twocolumn mode if inside
% a table* float (gh/7)}
% \begin{macrocode}
\if_mode_vertical: \if_mode_inner: \@twocolumnfalse \fi: \fi:
% \end{macrocode}
% Then we start the table with 17 columns. We use \texttt{longtable}
% if we produce a caption and \texttt{longtable*} if not (so that
% the table number is not increased, which would look odd if you
% have other tables in your document).
% \begin{macrocode}
\begin{longtable\bool_if:NF\l_@@_display_header_bool{*}}
{@{}r@{\quad}*{16}{c}@{}}
% \end{macrocode}
% Special headers and footers are set up first:
% \begin{macrocode}
\@@_setup_header_footer:nn{#2}{#3}
% \end{macrocode}
% Then we produce all table rows with the glyphs.
% \begin{macrocode}
\@@_produce_table_rows:
% \end{macrocode}
% At the very end we may typeset some statistics. This can't be
% done in the table footer, because the data is dynamic (e.g.,
% number of glyphs processed) and the table footers are static and
% do not change based on the table content.
% \begin{macrocode}
\@@_handle_table_ending:n {#2}
\end{longtable\bool_if:NF\l_@@_display_header_bool{*}}
\group_end:
}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macrocode}
\msg_new:nnn {unicodefonttable}{noharfbuzz}
{ You~ asked~ for~ displaying~ glyphs~ with~ code \iow_newline:
points~ above~ U+EFFFF~ \msg_line_context: ,~ i.e.,~ from~ the~
'Supplementary~ Private~ Use~ Area-A'\iow_newline:
without~ specifying~ '[Renderer=Harfbuzz]'~ when~
loading~ the~ font.
\iow_newline:\iow_newline:
With~ LuaLaTeX,~ this~ Unicode~ region~ is~ used~
for~ remappings~ (if~ the~ HarfBuzz~ engine~ is~ not~ used).~
Thus,~ the~ results~ shown~ do~ not~ reflect~ what~
is~ in~ the~ font!
}
% \end{macrocode}
%
%
%
% \begin{macro}{\fonttableglyphcount}
% \begin{macro}{\g_@@_glyph_int,\g_@@_glyph_only_B_int,\g_@@_glyph_also_B_int}
% While generating the font table we count the number of glyphs we
% see (and typeset). The total is available in the command
% \cs{fonttableglyphcount} after the table got finished and will be reset to
% zero when the next table starts.
% \begin{macrocode}
\DeclareDocumentCommand \fonttableglyphcount {}
{ \int_use:N \g_@@_glyph_int }
% \end{macrocode}
%
% \begin{macrocode}
\int_new:N \g_@@_glyph_int
% \end{macrocode}
% When comparing fonts we also record data for the second font: the
% number of glyphs in both and the number of glyphs only in the
% second one.
% \begin{macrocode}
\int_new:N \g_@@_glyph_only_B_int
\int_new:N \g_@@_glyph_also_B_int
% \end{macrocode}
% \end{macro}
% \end{macro}
% \subsection{The overall table layout}
%
%
% \begin{macro}{\@@_setup_header_footer:nn}
% Setting up header and footer lines of the table.
% This macro receives the \textit{font name} and the \textit{font
% features} specified by the user as its arguments.
% \begin{macrocode}
\cs_new:Npn \@@_setup_header_footer:nn #1#2{
% \end{macrocode}
% On the first page of the table the header may show a caption or
% some other sort of title based on the value of
% \cs{l_@@_display_header_bool}. The formatting is handled by
% \cs{@@_format_table_title:nn} which can be customized through the
% key \key{title-format}.
% \begin{macrocode}
\bool_if:NT \l_@@_display_header_bool
{ \@@_format_table_title:nn{#1}{#2} \@@_debug_nl:n{T}\\*[6pt] }
% \end{macrocode}
% We may also want to display a line of hex digits. This is
% controlled through the key \key{hex-digits} that accepts different
% values: \kval{head}, \kval{foot}, \kval{head+foo}, \kval{block}
% (after a block title) or \kval{none}.
% \begin{macrocode}
\bool_if:NT \l_@@_header_hex_digits_bool
{ \@@_display_row_of_hex_digits: \@@_debug_nl:n{H}\\* }
\endfirsthead
% \end{macrocode}
% Headers for later table pages have a continuation title and
% maybe a row of hex digits.
% \begin{macrocode}
\bool_if:NT \l_@@_display_header_bool
{ \@@_format_table_cont:nn{#1}{#2} \@@_debug_nl:n{T}\\*[6pt] }
\bool_if:NT \l_@@_header_hex_digits_bool
{ \@@_display_row_of_hex_digits: \@@_debug_nl:n{H}\\* }
\endhead
% \end{macrocode}
% Footers of the table are either empty or show a row of hex digits.
% \begin{macrocode}
\bool_if:NT \l_@@_footer_hex_digits_bool
{ \@@_display_row_of_hex_digits: \@@_debug_nl:n{H}\\* }
\endfoot
% \end{macrocode}
% The footer of the last page of the table will always be
% empty. Any special row, such as a row of hex digits, will be
% provided in the table body. The reason is that we may want to
% display statistics at the very end of the table and those can't be
% placed into a static footer.
% \begin{macrocode}
\endlastfoot
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\l_@@_header_hex_digits_bool}
% \begin{macro}{\l_@@_footer_hex_digits_bool}
% \begin{macro}{\l_@@_blockwise_hex_digits_bool}
% Here are the booleans we use in the code.
% \begin{macrocode}
\bool_new:N \l_@@_header_hex_digits_bool