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\writestatus{loading}{ConTeXt Font Macros Initialization}
47
48
49
50
51\unprotect
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\fontslantperpoint \nullfont 0\scaledpoint
305\fontinterwordspace \nullfont 256377\scaledpoint
306\fontinterwordstretch\nullfont 128188\scaledpoint
307\fontinterwordshrink \nullfont 85459\scaledpoint
308\fontexheight \nullfont 338952\scaledpoint
309\fontemwidth \nullfont 786432\scaledpoint
310\fontextraspace \nullfont 85459\scaledpoint
311
312\appendtoks
313 \fontslantperpoint \nullfont 0\scaledpoint
314 \fontinterwordspace \nullfont 256377\scaledpoint
315 \fontinterwordstretch\nullfont 128188\scaledpoint
316 \fontinterwordshrink \nullfont 85459\scaledpoint
317 \fontexheight \nullfont 338952\scaledpoint
318 \fontemwidth \nullfont 786432\scaledpoint
319 \fontextraspace \nullfont 85459\scaledpoint
320\to \everyjob
321
322
323
324\newtoks\t_font_tracers_definitions
325
326\permanent\protected\def\tracefontdefinitions
327 {\the\t_font_tracers_definitions}
328
329
330
331\permanent\protected\def\setfontparameters
332 {\setfalse\c_font_synchronize
333 \the\everybodyfont
334 \settrue\c_font_synchronize}
335
336\mutable\let\savedfont\empty
337
338\installmacrostack\savedfont
339
340
341
342
343
344
345
346\permanent\protected\def\savefont
347 {\edef\savedfont{\the\font}
348 \push_macro_savedfont}
349
350\permanent\protected\def\restorefont
351 {\pop_macro_savedfont
352 \savedfont}
353
354\aliased\let\popcurrentfont\relax
355
356\permanent\protected\def\pushcurrentfont
357 {\enforced\permanent\protected\edef\popcurrentfont
358 {\def\noexpand\fontbody {\fontbody}
359 \def\noexpand\fontstyle {\fontstyle}
360 \def\noexpand\fontalternative{\fontalternative}
361 \def\noexpand\fontsize {\fontsize}
362 \font_helpers_check_big_math_synchronization
363 \font_helpers_synchronize_font}}
364
365
366
367\mutable\let\thedefinedfont\relax
368
369\permanent\tolerant\protected\def\definedfont[#specification]
370 {\ifarguments
371 \c_font_feature_inheritance_mode\c_font_feature_inheritance_fontonly
372 \or
373 \c_font_feature_inheritance_mode\c_font_feature_inheritance_fontonly
374 \font_basics_define_font_without_parameters{thedefinedfont}{#specification}
375 \fi
376 \thedefinedfont
377 \the\everydefinedfont}
378
379
380
381\permanent\protected\def\startfont{\begingroup\definedfont}
382\permanent\protected\def\stopfont {\endgroup}
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404\ifdefined\globalbodyfontsize \else \newdimen\globalbodyfontsize \fi \globalbodyfontsize=12pt
405\ifdefined\localbodyfontsize \else \newdimen\localbodyfontsize \fi \localbodyfontsize =\globalbodyfontsize
406\ifdefined\bodyfontsize \else \newdimen\bodyfontsize \fi \bodyfontsize =\globalbodyfontsize
407
408
409
410
411
412
413\installcorenamespace{fontnormalizedbody}
414
415\permanent\protected\def\normalizebodyfontsize#macro#body
416 {\expandafter\let\expandafter#macro\csname\??fontnormalizedbody\number\dimexpr#body\endcsname
417 \ifrelax#macro
418 \normalizebodyfontsize_indeed#macro{#body}
419 \fi}
420
421\def\normalizebodyfontsize_indeed#macro#body
422 {\edef#macro{\clf_nbfs\dimexpr#body\relax}
423 \gletcsname\??fontnormalizedbody\number\dimexpr#body\endcsname#macro}
424
425\permanent\def\thenormalizedbodyfontsize#body
426 {\clf_nbfs\dimexpr#body\relax}
427
428\mutable\edef\normalizedglobalbodyfontsize{\thenormalizedbodyfontsize\bodyfontsize}
429\mutable\edef\normalizedlocalbodyfontsize {\thenormalizedbodyfontsize\bodyfontsize}
430\mutable\edef\normalizedbodyfontsize {\thenormalizedbodyfontsize\bodyfontsize}
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\installcorenamespace{mappedfontsize}
460
461\permanent\tolerant\protected\def\mapfontsize[#from]#spacer[#to]
462 {\ifarguments\or\or\defcsname\??mappedfontsize\the\dimexpr#from\relax\endcsname{#to}\fi}
463
464\def\font_basics_set_mapped_fontsize#from
465 {\ifcsname\??mappedfontsize\the\dimexpr#from\relax\endcsname
466 \lastnamedcs\else#from
467 \fi}
468
469\installcorenamespace{fontbodyknown}
470\installcorenamespace{fontclassyes}
471\installcorenamespace{fontclassnop}
472
473\def\font_helpers_process_relative_size_list#command
474 {#command\v!big
475 #command\v!small}
476
477\let\v_font_size_relative \plusone
478\def\v_font_size_absolute {\fontbody}
479
480\let\v_font_rscale_default\!!plusone
481\let\p_font_rscale \v_font_rscale_default
482
483\def\font_helpers_check_relative_font_id
484 {\let\p_font_rscale\minusone
485 \let\p_font_rscale\v_font_rscale_default}
486
487\def\font_helpers_check_relative_font_size#style
488 {\edef\p_font_rscale
489 {\ifcsname\??fontclass\fontclass#style\s!rscale\endcsname
490 \lastnamedcs
491 \orelse\ifcsname\??fontclass\defaultfontclass#style\s!rscale\endcsname
492 \lastnamedcs
493 \else
494 \v_font_rscale_default
495 \fi}
496
497 \ifx\p_font_rscale\v!auto
498 \let\p_font_rscale\plusone
499 \font_helpers_check_relative_font_id
500 \fi}
501
502\def\font_rscale_xx#style
503 {\ifcsname\??fontclass\fontclass#style\s!rscale\endcsname
504 \lastnamedcs
505 \else
506 \v_font_rscale_default
507 \fi}
508
509\def\font_rscale_mm
510 {\ifcsname\??fontclass\fontclass\s!mm\s!rscale\endcsname
511 \lastnamedcs
512 \else
513 \v_font_rscale_default
514 \fi}
515
516\def\font_helpers_register_fontbody#body
517 {\letcsname\??fontbodyknown#body\endcsname\empty}
518
519
520
521
522
523
524
525
526
527
528
529
530
531\installcorenamespace{fontstyle}
532\installcorenamespace{fontshortstyle}
533
534\installcorenamespace{fontstyleknown}
535\installcorenamespace{fontalternativeknown}
536\installcorenamespace{fontsizeknown}
537
538\newtoks\t_font_style_commands
539\newtoks\t_font_size_commands
540\newtoks\t_font_alternative_commands
541
542\setnewmacro\m_font_style_command \gobbleoneargument
543\setnewmacro\m_font_size_command \gobbleoneargument
544\setnewmacro\m_font_alternative_command\gobbleoneargument
545
546\def\font_helpers_process_style_list #command{\def\m_font_style_command {#command}\the\t_font_style_commands}
547\def\font_helpers_process_size_list #command{\def\m_font_size_command {#command}\the\t_font_size_commands}
548\def\font_helpers_process_alternative_list#command{\def\m_font_alternative_command{#command}\the\t_font_alternative_commands}
549
550\def\font_helpers_register_style #style{\letcsname\??fontstyleknown #style\endcsname\empty}
551\def\font_helpers_register_size #size{\letcsname\??fontsizeknown #size\endcsname\empty}
552\def\font_helpers_register_alternative#alternative{\letcsname\??fontalternativeknown#alternative\endcsname\empty}
553
554\permanent\protected\def\definefontstyle[#commands]#spacer[#style]
555 {\ifcsname\??fontstyleknown#style\endcsname \else
556 \font_helpers_register_style{#style}
557 \toksapp\t_font_style_commands{\m_font_style_command{#style}}
558 \fi
559 \processcommalist[#commands]{\font_basics_define_fontstyle_indeed{#style}}}
560
561\def\font_basics_define_fontstyle_indeed#style#command
562 {\defcsname\??fontshortstyle#command\endcsname{#style}
563 \defcsname\??fontstyle #command\endcsname{\csname#style\endcsname}}
564
565\permanent\protected\def\definefontsize[#size]
566 {\ifcsname\??fontsizeknown#size\endcsname \else
567 \font_helpers_register_size{#size}
568 \toksapp\t_font_size_commands{\m_font_size_command{#size}}
569 \fi
570 \font_helpers_check_fontname_combinations}
571
572\permanent\protected\def\definefontalternative[#alternative]
573 {\ifcsname\??fontalternativeknown#alternative\endcsname \else
574 \font_helpers_register_alternative{#alternative}
575 \toksapp\t_font_alternative_commands{\m_font_alternative_command{#alternative}}
576 \fi
577 \font_helpers_check_fontname_combinations}
578
579\protected\def\font_helpers_check_fontname_combinations
580 {\font_helpers_process_style_list\font_helpers_check_fontname_combinations_s}
581
582\def\font_helpers_check_fontname_combinations_s#style
583 {\font_helpers_process_alternative_list{\font_helpers_check_fontname_combinations_indeed_s_a{#style}}}
584
585\def\font_helpers_check_fontname_combinations_indeed_s_a#style#alternative
586 {\font_helpers_process_size_list{\font_basics_check_fontname_combination{#style}{#alternative}}}
587
588\definefontstyle [\s!mm] [\s!mm]
589\definefontstyle [\s!rm] [\s!rm]
590\definefontstyle [\s!ss] [\s!ss]
591\definefontstyle [\s!tt] [\s!tt]
592
593
594
595
596
597
598
599
600\newmacro\m_font_mm
601
602\def\font_basics_check_fontname_combination#style
603 {\edef\m_font_mm{#style}
604 \ifx\m_font_mm\s!mm
605 \expandafter\font_basics_check_math_bodyfont
606 \else
607 \expandafter\font_basics_check_text_bodyfont
608 \fi{#style}}
609
610\def\font_basics_check_math_bodyfont#style#alternative#size
611 {}
612
613\def\font_basics_check_text_bodyfont_step#whatever#body
614 {\ifcsname#whatever\endcsname\else
615 \permanent\setugvalue{#whatever}{#body}
616 \fi}
617
618\def\font_basics_check_text_bodyfont#style#alternative#size
619 {\font_basics_check_text_bodyfont_step{#style#size}{\font_helpers_set_current_font_style_size{#style}{#size}}
620 \font_basics_check_text_bodyfont_step{#alternative#size}{\font_helpers_set_current_font_alternative_size{#alternative}{#size}}
621 \font_basics_check_text_bodyfont_step{#style#alternative#size}{\font_helpers_set_current_font_style_alternative_size{#style}{#alternative}{#size}}
622 \font_basics_check_text_bodyfont_step{#style}{\font_helpers_set_current_font_style{#style}}
623 \font_basics_check_text_bodyfont_step{#alternative}{\font_helpers_set_current_font_alternative{#alternative}}
624 \font_basics_check_text_bodyfont_step{#style\s!x }{\font_helpers_set_current_font_x_style_alternative{#style}}
625 \font_basics_check_text_bodyfont_step{#style\s!xx}{\font_helpers_set_current_font_xx_style_alternative{#style}}
626 \font_basics_check_text_bodyfont_step{#alternative\s!x }{\font_helpers_set_current_font_x_alternative{#alternative}}
627 \font_basics_check_text_bodyfont_step{#alternative\s!xx}{\font_helpers_set_current_font_xx_alternative{#alternative}}
628 \font_basics_check_text_bodyfont_step{#style#alternative}{\font_helpers_set_current_font_style_alternative{#style}{#alternative}}}
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\permanent\def\safontscale{\number\dimexpr\v_font_size_absolute\relax}
660\permanent\def\mofontscale{\number\dimexpr\font_basics_set_mapped_fontsize\v_font_size_absolute\relax}
661
662\mutable\let\somefontname \s!unknown
663\mutable\let\somefontspec \s!unknown
664\mutable\let\somefontfile \s!unknown
665\mutable\let\somefontsize \zerocount
666\mutable\let\somefontsizex\empty
667\mutable\let\somefontsizey\empty
668
669\newcount\scaledfontmode
670\newcount\scaledfontsize
671\newcount\lastfontid
672\newtoks \everydefinefont
673
674\aliased\let\c_font_feature_inheritance_fontnone \zerocount
675\aliased\let\c_font_feature_inheritance_fontonly \plusone
676\aliased\let\c_font_feature_inheritance_classonly \plustwo
677\aliased\let\c_font_feature_inheritance_fontfirst \plusthree
678\aliased\let\c_font_feature_inheritance_classfirst\plusfour
679
680\aliased\let\c_font_feature_inheritance_default \c_font_feature_inheritance_fontfirst
681
682\setnewconstant\c_font_feature_inheritance_mode \c_font_feature_inheritance_default
683
684\newdimen \d_font_scaled_text_face
685\newdimen \d_font_scaled_font_size
686\newconditional\c_font_body_scale
687\newfraction \f_font_body_scale
688
689\newconditional\c_font_compact
690\newcount \c_font_scaled_glyph_scale
691
692\immutable\dimensiondef\d_font_scaled_default 10pt
693
694\newcount\c_font_future_glyph_scale
695
696
697
698\newcount\c_font_future_glyph_scale
699\newcount\c_font_scaled_font_mode_saved
700\newcount\c_font_scaled_points
701
702\mutable\let\somefontspec \empty
703\mutable\let\lastrawfontcall \relax
704\mutable\let\lastglobalrawfontcall\relax
705
706\protected\def\font_helpers_low_level_define
707 {\ifconditional\c_font_compact
708 \expandafter\font_helpers_low_level_define_compact
709 \else
710 \expandafter\font_helpers_low_level_define_normal
711 \fi}
712
713\protected\def\font_helpers_low_level_define_normal#specification#csname
714 {
715 \glet\somefontname\defaultfontfile
716 \let\somefontsize\empty
717 \let\somefontsizex\empty
718 \let\somefontsizey\empty
719 \clf_definefont_one{\detokenize\expandafter{\normalexpanded{#specification}}}
720
721 \ifcase\fontface\relax
722
723 \or
724 \let\v_font_size_absolute\textface
725 \or
726 \let\v_font_size_absolute\scriptface
727 \or
728 \let\v_font_size_absolute\scriptscriptface
729 \or
730 \let\v_font_size_absolute\xtextface
731 \or
732 \let\v_font_size_absolute\xxtextface
733 \fi
734
735 \ifcase\scaledfontmode\relax
736
737 \d_font_scaled_font_size\plusthousand\scaledpoint
738 \or
739
740 \d_font_scaled_font_size\somefontsize
741 \or
742
743 \d_font_scaled_font_size\v_font_size_absolute\relax
744 \d_font_scaled_font_size\currentfontbodysize\d_font_scaled_font_size
745 \or
746
747 \d_font_scaled_font_size\font_basics_set_mapped_fontsize\v_font_size_absolute
748 \d_font_scaled_font_size\currentfontbodysize\d_font_scaled_font_size
749 \or
750
751 \d_font_scaled_font_size\somefontsize\scaledpoint
752 \else
753
754 \d_font_scaled_font_size\somefontsize
755 \fi
756 \relax
757 \d_font_scaled_font_size\v_font_size_relative\d_font_scaled_font_size
758 \relax
759
760 \ifconditional\c_font_auto_size
761 \font_helpers_check_body_scale\fontsize
762 \ifconditional\c_font_body_scale
763 \d_font_scaled_font_size\f_font_body_scale\d_font_scaled_font_size
764 \d_font_scaled_text_face\f_font_body_scale\dimexpr\textface\relax
765 \else
766 \d_font_scaled_font_size\f_font_body_scale
767 \d_font_scaled_text_face\textface
768 \fi
769 \else
770 \d_font_scaled_text_face\textface
771 \fi
772
773 \edef\somefontspec{at \number\d_font_scaled_font_size sp}
774 \edef\somefontfile{\truefontname\somefontname}
775 \ifx\somefontfile\s!unknown
776 \edef\somefontfile{\defaultfontfile}
777 \fi
778 \font_helpers_update_font_parameters
779 \font_helpers_update_font_class_parameters
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798 \clf_definefont_two
799 \ifempty\fontclass\s!false\else\s!true\fi
800 {#csname}
801 \somefontfile
802 \d_font_scaled_font_size
803 \c_font_feature_inheritance_mode
804 \m_font_class_features
805 \m_font_features
806 \m_font_class_fallbacks
807 \m_font_fallbacks
808 \fontface
809 \d_font_scaled_text_face
810 \m_font_class_goodies
811 \m_font_goodies
812 \m_font_class_designsize
813 \m_font_designsize
814 \scaledfontmode
815 \relax
816 \ifcase\scaledfontsize
817
818 \let\somefontspec\empty
819 \let\lastrawfontcall\relax
820 \mutable\letcsname#csname\endcsname\relax
821 \else
822 \edef\somefontspec{at \number\scaledfontsize sp}
823 \expandafter\let\expandafter\lastrawfontcall\csname#csname\endcsname
824 \the\everydefinefont
825 \fi
826 \c_font_feature_inheritance_mode\c_font_feature_inheritance_default}
827
828\protected\def\font_helpers_low_level_define_compact#specification#csname
829 {
830 \glet\somefontname\defaultfontfile
831 \let\somefontsize\empty
832 \let\somefontsizex\empty
833 \let\somefontsizey\empty
834 \clf_definefont_one{\detokenize\expandafter{\normalexpanded{#specification}}}
835
836 \ifcase\fontface\relax
837
838 \or
839 \let\v_font_size_absolute\textface
840 \or
841 \let\v_font_size_absolute\scriptface
842 \or
843 \let\v_font_size_absolute\scriptscriptface
844 \or
845 \let\v_font_size_absolute\xtextface
846 \or
847 \let\v_font_size_absolute\xxtextface
848 \fi
849
850 \ifcase\scaledfontmode\relax
851
852 \d_font_scaled_font_size\plusthousand\scaledpoint
853 \or
854
855 \d_font_scaled_font_size\somefontsize
856 \or
857
858 \d_font_scaled_font_size\v_font_size_absolute\relax
859 \d_font_scaled_font_size\currentfontbodysize\d_font_scaled_font_size
860 \or
861
862 \d_font_scaled_font_size\font_basics_set_mapped_fontsize\v_font_size_absolute
863 \d_font_scaled_font_size\currentfontbodysize\d_font_scaled_font_size
864 \or
865
866 \d_font_scaled_font_size\somefontsize\scaledpoint
867 \else
868
869 \d_font_scaled_font_size\somefontsize
870 \fi
871 \relax
872 \d_font_scaled_font_size\v_font_size_relative\d_font_scaled_font_size
873 \relax
874
875 \ifconditional\c_font_auto_size
876 \font_helpers_check_body_scale\fontsize
877 \ifconditional\c_font_body_scale
878 \d_font_scaled_font_size\f_font_body_scale\d_font_scaled_font_size
879 \d_font_scaled_text_face\f_font_body_scale\dimexpr\textface\relax
880 \else
881 \d_font_scaled_font_size\f_font_body_scale
882 \d_font_scaled_text_face\textface
883 \fi
884 \else
885 \d_font_scaled_text_face\textface
886 \fi
887
888 \ifnum\c_font_scaled_font_mode_saved>\plusfour
889 \c_font_scaled_font_mode_saved\scaledfontmode
890 \scaledfontmode\zerocount
891 \fi
892 \c_font_future_glyph_scale\numexpr\plushundred*\d_font_scaled_font_size\maxcard\relax
893 \glyphscale\numexpr\plushundred*\d_font_scaled_font_size\maxcard\relax
894
895
896
897 \edef\somefontspec{at \number\d_font_scaled_font_size sp}
898
899 \edef\somefontfile{\truefontname\somefontname}
900 \ifx\somefontfile\s!unknown
901 \edef\somefontfile{\defaultfontfile}
902 \fi
903 \font_helpers_update_font_parameters
904 \font_helpers_update_font_class_parameters
905
906
907 \clf_definefont_two
908 \ifempty\fontclass\s!false\else\s!true\fi
909 {#csname}
910 \somefontfile
911 \d_font_scaled_font_size
912 \c_font_feature_inheritance_mode
913 \m_font_class_features
914 \m_font_features
915 \m_font_class_fallbacks
916 \m_font_fallbacks
917 \fontface
918 \d_font_scaled_default
919 \m_font_class_goodies
920 \m_font_goodies
921 \m_font_class_designsize
922 \m_font_designsize
923 \scaledfontmode
924 \relax
925 \ifcase\scaledfontsize
926
927 \let\somefontspec\empty
928 \let\lastrawfontcall\relax
929 \mutable\letcsname#csname\endcsname\relax
930 \else
931 \edef\somefontspec{at \number\scaledfontsize sp}
932
933 \glyphscale
934 \ifnum\c_font_scaled_font_mode_saved>\plusfour
935 \numexpr\plusthousand*\dimexpr\d_font_scaled_default\relax\c_font_scaled_points\relax
936 \else
937 \c_font_future_glyph_scale
938 \fi
939 \ifempty\somefontsizex\else
940 \edef\somefontsizex{\glyphxscale\somefontsizex\relax}
941 \fi
942 \ifempty\somefontsizey\else
943 \edef\somefontsizey{\glyphyscale\somefontsizey\relax}
944 \fi
945 \ifempty\fontclass\else\global\fi
946 \mutable\protected\edefcsname#csname\endcsname
947 {\setfontid\the\fontid\csname#csname\endcsname\relax
948 \glyphscale\the\glyphscale\relax
949 \somefontsizex
950 \somefontsizey}
951
952 \expandafter\let\expandafter\lastrawfontcall\csname#csname\endcsname
953 \the\everydefinefont
954 \fi
955 \c_font_feature_inheritance_mode\c_font_feature_inheritance_default}
956
957\def\font_helpers_check_body_scale#fontsize
958 {\ifcsname\??fontenvironments\fontclass\fontbody#fontsize\endcsname
959 \expandafter\let\expandafter\f_font_body_scale\lastnamedcs
960 \setfalse\c_font_body_scale
961 \orelse\ifcsname\??fontenvironments\fontclass\s!default#fontsize\endcsname
962 \expandafter\let\expandafter\f_font_body_scale\lastnamedcs
963 \settrue\c_font_body_scale
964 \orelse\ifcsname\??fontenvironments\fontbody#fontsize\endcsname
965 \expandafter\let\expandafter\f_font_body_scale\lastnamedcs
966 \setfalse\c_font_body_scale
967 \orelse\ifcsname\??fontenvironments\s!default#fontsize\endcsname
968 \expandafter\let\expandafter\f_font_body_scale\lastnamedcs
969 \settrue\c_font_body_scale
970 \orelse\ifcsname\??fontenvironments\fontclass\s!default\s!text\endcsname
971 \expandafter\let\expandafter\f_font_body_scale\lastnamedcs
972 \settrue\c_font_body_scale
973 \orelse\ifcsname\??fontenvironments\s!default\s!text\endcsname
974 \expandafter\let\expandafter\f_font_body_scale\lastnamedcs
975 \settrue\c_font_body_scale
976 \else
977 \let\f_font_body_scale\plusone
978 \settrue\c_font_body_scale
979 \fi}
980
981\newif\ifskipfontcharacteristics \skipfontcharacteristicstrue
982
983\tracingfonts\plussix
984
985
986
987
988\mutable\let\fontfile\s!unknown
989
990
991
992\installcorenamespace{fonts}
993\installcorenamespace{fontslanguage}
994
995\installsetuponlycommandhandler \??fonts {fonts}
996
997\newconstant\c_fonts_auto_language
998
999\letcsname\??fontslanguage\v!auto\endcsname\plusone
1000
1001
1002\appendtoks
1003 \c_fonts_auto_language
1004 \ifcsname\??fontslanguage\fontsparameter\c!language\endcsname
1005 \lastnamedcs
1006 \else
1007 \zerocount
1008 \fi
1009\to \everysetupfonts
1010
1011\appendtoks
1012 \ifcase\c_fonts_auto_language
1013
1014 \or
1015 \addfflanguage
1016
1017
1018 \fi
1019\to \everylanguage
1020
1021
1022
1023
1024
1025
1026
1027\ifdefined\everyfont \else \newtoks\everyfont \fi
1028\ifdefined\everyfontswitch \else \newtoks\everyfontswitch \fi
1029
1030\permanent\def\setfontcharacteristics{\the\everyfont}
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058\permanent\tolerant\protected\def\definefont[#1]#*[#2]#*[#3]
1059 {\ifparameter#3\or
1060 \expandafter\font_basics_define_font_a
1061 \else
1062 \expandafter\font_basics_define_font_b
1063 \fi[#1][#2][#3]}
1064
1065\def\font_basics_define_font_a[#name][#specification][#settings]
1066 {\doifelsesetups{#settings}
1067 {\mutable\protected\defcsname#name\endcsname{\font_basics_define_font_with_setups {#name}{#specification}{#settings}}}
1068 {\mutable\protected\defcsname#name\endcsname{\font_basics_define_font_with_parameters{#name}{#specification}{#settings}}}}
1069
1070\def\font_basics_define_font_b[#name][#specification][#dummy]
1071 {\mutable\protected\defcsname#name\endcsname{\font_basics_define_font_without_parameters{#name}{#specification}}}
1072
1073\def\font_basics_define_font_with_parameters#name#specification#settings
1074 {\font_basics_define_font_without_parameters{#name}{#specification}
1075 \setuplocalinterlinespace[#settings]
1076 \setupspacing\relax}
1077
1078\def\font_basics_define_font_with_setups#name#specification#settings
1079 {\font_basics_define_font_without_parameters{#name}{#specification}
1080 \setups[#settings]}
1081
1082
1083
1084
1085\permanent\tolerant\protected\def\definefrozenfont[#name]#spacer[#specification]#spacer[#settings]
1086 {\ifparameter#name\or
1087 \begingroup
1088 \definefont[#name][#specification][#settings]
1089 \csname#name\endcsname
1090 \glet\lastglobalrawfontcall\lastrawfontcall
1091 \endgroup
1092 \aliased\letcsname#name\endcsname\lastglobalrawfontcall
1093 \fi}
1094
1095
1096
1097
1098
1099
1100
1101\ifdefined\??fontinstanceready \else \installcorenamespace{fontinstanceready} \fi
1102\ifdefined\??fontinstancebasic \else \installcorenamespace{fontinstancebasic} \fi
1103\ifdefined\??fontinstanceclass \else \installcorenamespace{fontinstanceclass} \fi
1104
1105\newconditional\c_font_auto_size \settrue\c_font_auto_size
1106
1107\mutable\let\lastfontidentifier\empty
1108
1109\def\v_font_identifier_basic{\??fontinstancebasic \lastfontidentifier\fontsize\fontface}
1110\def\v_font_identifier_class{\??fontinstanceclass\fontclass\lastfontidentifier\fontsize\fontface}
1111
1112\let\v_font_identifier_basic_saved\v_font_identifier_basic
1113\let\v_font_identifier_class_saved\v_font_identifier_class
1114
1115
1116
1117\def\font_basics_define_font_without_parameters#identifier#2
1118 {\c_font_feature_inheritance_mode\c_font_feature_inheritance_fontonly
1119 \edef\lastfontidentifier{#identifier}
1120 \let\v_font_size_relative\v_font_rscale_default
1121 \let\v_font_size_absolute\fontbody
1122 \font_helpers_low_level_define{#2}\v_font_identifier_basic
1123 \csname\v_font_identifier_basic\endcsname
1124 \setfalse\c_font_auto_size
1125 \the\everyfont
1126 \the\everyfontswitch
1127 \let\v_font_identifier_basic\v_font_identifier_basic_saved}
1128
1129\protected\def\font_helpers_trigger#identifier
1130 {\edef\lastfontidentifier{#identifier}
1131 \ifcsname\v_font_identifier_class\endcsname
1132
1133 \expandafter\font_helpers_trigger_reuse
1134 \else
1135
1136 \expandafter\font_helpers_trigger_define
1137 \fi}
1138
1139\def\font_helpers_trigger_define#relative#absolute#specification
1140 {\def\v_font_size_relative{#relative}
1141 \def\v_font_size_absolute{#absolute}
1142 \font_helpers_low_level_define{#specification}\v_font_identifier_class
1143 \csname\v_font_identifier_class\endcsname
1144 \setfalse\c_font_auto_size
1145 \ifskipfontcharacteristics \else
1146 \the\everyfont
1147 \the\everyfontswitch
1148 \fi
1149 \let\v_font_identifier_class\v_font_identifier_class_saved}
1150
1151\def\font_helpers_trigger_reuse#relative#absolute#specification
1152 {\csname\v_font_identifier_class\endcsname
1153 \setfalse\c_font_auto_size
1154 \ifskipfontcharacteristics \else
1155 \the\everyfont
1156 \the\everyfontswitch
1157 \fi
1158 \let\v_font_identifier_class\v_font_identifier_class_saved}
1159
1160
1161
1162
1163
1164
1165
1166
1167\installcorenamespace{fontenvironments}
1168
1169\permanent\def\currentfontbodysize
1170 {\ifcsname\??fontenvironments\fontclass\s!default\somefontsize\endcsname
1171 \lastnamedcs
1172 \orelse\ifcsname\??fontenvironments\s!default\somefontsize\endcsname
1173 \lastnamedcs
1174 \else
1175 \somefontsize
1176 \fi}
1177
1178\permanent\def\currentfontbodyscale
1179 {\csname\??fontenvironments
1180 \ifcsname\??fontenvironments\fontclass\s!default\fontsize\endcsname\fontclass\s!default\fontsize\orelse
1181 \ifcsname\??fontenvironments \s!default\fontsize\endcsname \s!default\fontsize\orelse
1182 \ifcsname\??fontenvironments\fontclass\s!default\s!text \endcsname\fontclass\s!default\s!text \orelse
1183 \ifcsname\??fontenvironments \s!default\s!text \endcsname \s!default\s!text \else
1184 \s!default \fi
1185 \endcsname}
1186
1187\def\font_currentfontbodyscale
1188 {\ifcsname\??fontenvironments\fontclass\s!default\fontsize\endcsname\lastnamedcs\orelse
1189 \ifcsname\??fontenvironments \s!default\fontsize\endcsname\lastnamedcs\orelse
1190 \ifcsname\??fontenvironments\fontclass\s!default\s!text \endcsname\lastnamedcs\orelse
1191 \ifcsname\??fontenvironments \s!default\s!text \endcsname\lastnamedcs\else
1192 \csname\??fontenvironments \s!default \endcsname \fi}
1193
1194\permanent\def\currentfontscale
1195 {\csname\??fontenvironments
1196 \ifcsname\??fontenvironments\fontclass\s!default\xfontsize\endcsname\fontclass\s!default\fontsize\orelse
1197 \ifcsname\??fontenvironments \s!default\xfontsize\endcsname \s!default\fontsize\orelse
1198 \ifcsname\??fontenvironments\fontclass\s!default\s!text \endcsname\fontclass\s!default\s!text \orelse
1199 \ifcsname\??fontenvironments \s!default\s!text \endcsname \s!default\s!text \else
1200 \s!default \fi
1201 \endcsname}
1202
1203\def\font_currentfontscale
1204 {\ifcsname\??fontenvironments\fontclass\s!default\xfontsize\endcsname\lastnamedcs\orelse
1205 \ifcsname\??fontenvironments \s!default\xfontsize\endcsname\lastnamedcs\orelse
1206 \ifcsname\??fontenvironments\fontclass\s!default\s!text \endcsname\lastnamedcs\orelse
1207 \ifcsname\??fontenvironments \s!default\s!text \endcsname\lastnamedcs\else
1208 \csname\??fontenvironments \s!default \endcsname \fi}
1209
1210\setvalue{\??fontenvironments\s!default}{1}
1211
1212
1213
1214
1215
1216\newconstant\currentxfontsize
1217
1218\permanent\def\xfontsize{\ifcase\currentxfontsize\fontsize\or\s!x\else\s!xx\fi}
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305\letvalue\??fontenvironments\empty
1306
1307\permanent\def\bodyfontvariable#parameter
1308 {\csname\??fontenvironments
1309 \ifcsname\??fontenvironments\fontclass\normalizedbodyfontsize#parameter\endcsname\fontclass\normalizedbodyfontsize#parameter\orelse
1310 \ifcsname\??fontenvironments\fontclass #parameter\endcsname\fontclass #parameter\orelse
1311 \ifcsname\??fontenvironments \normalizedbodyfontsize#parameter\endcsname \normalizedbodyfontsize#parameter\orelse
1312 \ifcsname\??fontenvironments\s!default #parameter\endcsname\s!default #parameter\fi
1313 \endcsname}
1314
1315\def\font_bodyfontvariable#parameter
1316 {\ifcsname\??fontenvironments\fontclass\normalizedbodyfontsize#parameter\endcsname\lastnamedcs\orelse
1317 \ifcsname\??fontenvironments\fontclass #parameter\endcsname\lastnamedcs\orelse
1318 \ifcsname\??fontenvironments \normalizedbodyfontsize#parameter\endcsname\lastnamedcs\orelse
1319 \ifcsname\??fontenvironments\s!default #parameter\endcsname\lastnamedcs\fi}
1320
1321\permanent\def\bodyfontsizevariable#size#parameter
1322 {\csname\??fontenvironments
1323 \ifcsname\??fontenvironments\fontclass#size#parameter\endcsname\fontclass#size#parameter\orelse
1324 \ifcsname\??fontenvironments\fontclass #parameter\endcsname\fontclass #parameter\orelse
1325 \ifcsname\??fontenvironments #size#parameter\endcsname #size#parameter\orelse
1326 \ifcsname\??fontenvironments\s!default #parameter\endcsname\s!default #parameter\fi
1327 \endcsname}
1328
1329\def\font_bodyfontsizevariable#size#parameter
1330 {\ifcsname\??fontenvironments\fontclass#size#parameter\endcsname\lastnamedcs\orelse
1331 \ifcsname\??fontenvironments\fontclass #parameter\endcsname\lastnamedcs\orelse
1332 \ifcsname\??fontenvironments #size#parameter\endcsname\lastnamedcs\orelse
1333 \ifcsname\??fontenvironments\s!default #parameter\endcsname\lastnamedcs\fi}
1334
1335\permanent\def\bodyfontinterlinespace{\bodyfontvariable\c!interlinespace}
1336
1337\permanent\def\bodyfontdimension#class#size#parameter#body
1338 {\the\dimexpr
1339 \ifcsname\??fontenvironments #class#size#parameter\endcsname \lastnamedcs \orelse
1340 \ifcsname\??fontenvironments#class\s!default#parameter\endcsname \lastnamedcs\dimexpr#body\relax\orelse
1341 \ifcsname\??fontenvironments #size#parameter\endcsname \lastnamedcs \else
1342 \lastnamedcs\dimexpr#body\relax\fi
1343 \relax}
1344
1345\installcorenamespace{fontenvironmentknown}
1346
1347\def\font_helpers_register_environment#class#body
1348 {\letcsname\??fontenvironmentknown#class#body\endcsname\empty}
1349
1350\newmacro\m_font_body
1351\newmacro\m_font_body_normalized
1352
1353\permanent\tolerant\protected\def\definebodyfontenvironment[#1]#*[#2]#*[#3]
1354 {\ifarguments
1355 \expandafter\font_basics_define_body_font_environment_unset
1356 \or
1357 \expandafter\font_basics_define_body_font_environment_unset
1358 \or
1359 \expandafter\font_basics_define_body_font_environment_empty
1360 \or
1361 \expandafter\font_basics_define_body_font_environment_class
1362 \fi[#1][#2][#3]}
1363
1364\aliased\let\setupbodyfontenvironment\definebodyfontenvironment
1365
1366
1367
1368
1369
1370\permanent\def\processbodyfontenvironmentlist#1
1371 {\clf_processbodyfontsizes{\strippedcsname#1}}
1372
1373\permanent\def\bodyfontenvironmentlist
1374 {\clf_getbodyfontsizes}
1375
1376\def\font_basics_define_body_font_environment_class[#class][#body][#settings]
1377 {\edef\m_font_body{#body}
1378 \ifx\m_font_body\s!default
1379
1380 \getrawparameters[\??fontenvironments#class\s!default][#settings]
1381 \else
1382 \normalizebodyfontsize\m_font_body_normalized\m_font_body
1383 \font_basics_define_body_font_environment_size[#class][\m_font_body_normalized][#settings]
1384 \clf_registerbodyfontsize{\m_font_body_normalized}
1385 \fi}
1386
1387
1388
1389
1390\def\font_basics_define_body_font_environment_empty[#body][#settings][#dummy]
1391 {\push_macro_fontclass
1392 \let\fontclass\empty
1393 \font_basics_define_body_font_environment_class[][#body][#settings]
1394 \pop_macro_fontclass}
1395
1396\def\font_basics_define_body_font_environment_unset[#body][#dummya][#dummyb]
1397 {\push_macro_fontclass
1398 \let\fontclass\empty
1399 \font_basics_define_body_font_environment_class[][#body][]
1400 \pop_macro_fontclass}
1401
1402
1403
1404\newconditional\c_font_defining_environment_state
1405
1406\def\font_basics_define_body_font_environment_size[#class][#normalizedbody][#settings]
1407 {\getrawparameters[\??fontenvironments#class#normalizedbody][#settings]
1408 \ifcsname\??fontenvironmentknown#class#normalizedbody\endcsname
1409
1410 \orelse\ifproductionrun
1411 \push_macro_fontclass
1412 \edef\fontclass{#class}
1413 \font_helpers_register_environment{#class}{#normalizedbody}
1414 \settrue\c_font_defining_environment_state
1415 \font_helpers_define_unknown_font{#normalizedbody}
1416 \setfalse\c_font_defining_environment_state
1417 \pop_macro_fontclass
1418 \fi
1419 \font_helpers_register_fontbody{#normalizedbody}}
1420
1421
1422
1423\def\font_helpers_check_bodyfont_environment#normalizedbody#body
1424 {\ifcsname\??fontenvironmentknown\fontclass#normalizedbody\endcsname
1425
1426 \else
1427 \font_helpers_check_bodyfont_environment_indeed{#normalizedbody}{#body}
1428 \fi}
1429
1430\def\font_helpers_check_bodyfont_environment_indeed#normalizedbody#body
1431 {\font_helpers_register_environment\fontclass{#normalizedbody}
1432 \ifcsname\??fontbodyknown#normalizedbody\endcsname
1433 \else
1434 \font_helpers_define_unknown_font{#normalizedbody}
1435 \fi}
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513\installcorenamespace{fontdefinitions}
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523\permanent\tolerant\protected\def\definebodyfont[#1]#*[#2]#*[#3]#*[#4]
1524 {\ifarguments
1525 \or
1526 \font_basics_define_body_font[#1][\s!rm][]
1527 \or
1528 \font_basics_define_body_font[#1][\s!rm][#2]
1529 \or
1530 \font_basics_define_body_font[#1][#2][#3]
1531 \or
1532 \processcommacommand[#1]{\font_basics_define_body_font_class_given[#2][#3][#4]}
1533 \fi}
1534
1535\protected\def\font_basics_define_body_font[#whatever]
1536 {\doifelsenumber{#whatever}\font_basics_define_body_font_body\font_basics_define_body_font_name[#whatever]}
1537
1538\protected\def\font_basics_define_body_font_class_given[#1][#2][#3]#4
1539 {\push_macro_fontclass
1540 \doifelse{#4}\s!default
1541 {\let\fontclass\empty}
1542 {\def\fontclass{#4}}
1543 \definebodyfont[#1][#2][#3]
1544 \pop_macro_fontclass}
1545
1546\protected\def\font_basics_define_body_font_body[#body][#style][#specification]
1547 {\ifcondition\validassignment{#specification}
1548 \expandafter\font_basics_define_body_font_body_assignment
1549 \else
1550 \expandafter\font_basics_define_body_font_body_identifier
1551 \fi
1552 [#body][#style][#specification]}
1553
1554\protected\def\font_basics_define_body_font_name[#name][#style][#specification]
1555 {\ifcondition\validassignment{#specification}
1556 \expandafter\font_basics_define_body_font_name_assignment
1557 \else
1558 \expandafter\font_basics_define_body_font_name_identifier
1559 \fi
1560 [#name][#style][#specification]}
1561
1562\protected\def\font_basics_define_body_font_body_assignment[#bodylist][#stylelist][#assignments]
1563 {\processcommalist[#bodylist]{\font_basics_define_body_font_body_assignment_a{#stylelist}{#assignments}}}
1564
1565\protected\def\font_basics_define_body_font_body_assignment_a#stylelist#assignments#body
1566 {\normalizebodyfontsize\m_font_asked_body{#body}
1567
1568 \font_helpers_check_bodyfont_environment\m_font_asked_body\m_font_asked_body
1569 \processcommalist[#stylelist]{\font_basics_define_body_font_body_assignment_b{#assignments}}}
1570
1571\protected\def\font_basics_define_body_font_body_assignment_b#assignments#style
1572 {\edef\m_font_asked_style{#style}
1573 \processcommalist[#assignments]\font_basics_define_body_font_defs}
1574
1575\protected\def\font_basics_define_body_font_defs
1576 {\ifempty\fontclass
1577 \expandafter\font_basics_define_body_font_defs_nop
1578 \else
1579 \expandafter\font_basics_define_body_font_defs_yes
1580 \fi}
1581
1582\protected\def\font_basics_define_body_font_defs_yes_normal#assignment
1583 {\ifx\m_font_asked_style\s!mm
1584 \expandafter\font_basics_define_body_font_yes_mm
1585 \else
1586 \expandafter\font_basics_define_body_font_yes_xx
1587 \fi[#assignment]}
1588
1589\protected\def\font_basics_define_body_font_defs_nop_normal#assignment
1590 {\ifx\m_font_asked_style\s!mm
1591 \expandafter\font_basics_define_body_font_nop_mm
1592 \else
1593 \expandafter\font_basics_define_body_font_nop_xx
1594 \fi[#assignment]}
1595
1596\protected\def\font_basics_define_body_font_defs_yes_traced#assignment
1597 {\writestatus\m!fonts{[\fontclass] [\m_font_asked_body] [\m_font_asked_style] [#assignment]}
1598 \ifx\m_font_asked_style\s!mm
1599 \expandafter\font_basics_define_body_font_yes_mm
1600 \else
1601 \expandafter\font_basics_define_body_font_yes_xx
1602 \fi[#assignment]}
1603
1604\protected\def\font_basics_define_body_font_defs_nop_traced#assignment
1605 {\writestatus\m!fonts{[\fontclass] [\m_font_asked_body] [\m_font_asked_style] [#assignment]}
1606 \ifx\m_font_asked_style\s!mm
1607 \expandafter\font_basics_define_body_font_nop_mm
1608 \else
1609 \expandafter\font_basics_define_body_font_nop_xx
1610 \fi[#assignment]}
1611
1612\let\font_basics_define_body_font_defs_yes\font_basics_define_body_font_defs_yes_normal
1613\let\font_basics_define_body_font_defs_nop\font_basics_define_body_font_defs_nop_normal
1614
1615\appendtoks
1616 \let\font_basics_define_body_font_defs_yes\font_basics_define_body_font_defs_yes_traced
1617 \let\font_basics_define_body_font_defs_nop\font_basics_define_body_font_defs_nop_traced
1618\to \t_font_tracers_definitions
1619
1620
1621
1622
1623
1624\protected\def\font_basics_define_body_font_nop_xx[#one#two#rest=#value]
1625 {\ifcsname\m_font_asked_style#one#two#rest\endcsname\else\font_basics_check_fontname_combination\m_font_asked_style{#one#two}{#rest}\fi
1626 \letcsname\??fontinstanceclass\m_font_asked_body\m_font_asked_style#one#two#rest0\endcsname\undefined
1627 \protected\edefcsname\??fontinstanceready\m_font_asked_body\m_font_asked_style#one#two#rest0\endcsname
1628 {\font_helpers_trigger{\m_font_asked_body\m_font_asked_style#one#two#rest}{\noexpand\font_rscale_xx{\m_font_asked_style}}{\m_font_asked_body}{\normalunexpanded{#value}}}
1629 \letcsname\??fontinstanceclass\m_font_asked_body\m_font_asked_style#one#two#rest4\endcsname\undefined
1630 \protected\edefcsname\??fontinstanceready\m_font_asked_body\m_font_asked_style#one#two#rest4\endcsname
1631 {\font_helpers_trigger{\m_font_asked_body\m_font_asked_style#one#two#rest}{\noexpand\font_rscale_xx{\m_font_asked_style}}{\m_font_asked_body}{\normalunexpanded{#value}}}
1632 \letcsname\??fontinstanceclass\m_font_asked_body\m_font_asked_style#one#two#rest5\endcsname\undefined
1633 \protected\edefcsname\??fontinstanceready\m_font_asked_body\m_font_asked_style#one#two#rest5\endcsname
1634 {\font_helpers_trigger{\m_font_asked_body\m_font_asked_style#one#two#rest}{\noexpand\font_rscale_xx{\m_font_asked_style}}{\m_font_asked_body}{\normalunexpanded{#value}}}
1635 }
1636
1637\protected\def\font_basics_define_body_font_yes_xx[#one#two#rest=#value]
1638 {\ifcsname\m_font_asked_style#one#two#rest\endcsname\else\font_basics_check_fontname_combination\m_font_asked_style{#one#two}{#rest}\fi
1639 \gletcsname\??fontinstanceclass\fontclass\m_font_asked_body\m_font_asked_style#one#two#rest1\endcsname\undefined
1640 \protected\xdefcsname\??fontinstanceready\fontclass\m_font_asked_body\m_font_asked_style#one#two#rest0\endcsname
1641 {\font_helpers_trigger{\m_font_asked_body\m_font_asked_style#one#two#rest0}{\number\p_font_rscale}{\m_font_asked_body}{\normalunexpanded{#value}}}
1642 \gletcsname\??fontinstanceclass\fontclass\m_font_asked_body\m_font_asked_style#one#two#rest2\endcsname\undefined
1643 \protected\xdefcsname\??fontinstanceready\fontclass\m_font_asked_body\m_font_asked_style#one#two#rest4\endcsname
1644 {\font_helpers_trigger{\m_font_asked_body\m_font_asked_style#one#two#rest4}{\number\p_font_rscale}{\m_font_asked_body}{\normalunexpanded{#value}}}
1645 \gletcsname\??fontinstanceclass\fontclass\m_font_asked_body\m_font_asked_style#one#two#rest3\endcsname\undefined
1646 \protected\xdefcsname\??fontinstanceready\fontclass\m_font_asked_body\m_font_asked_style#one#two#rest5\endcsname
1647 {\font_helpers_trigger{\m_font_asked_body\m_font_asked_style#one#two#rest5}{\number\p_font_rscale}{\m_font_asked_body}{\normalunexpanded{#value}}}
1648 }
1649
1650
1651
1652
1653
1654
1655\protected\def\font_basics_define_body_font_nop_mm[#one#two#rest=#value]
1656 {
1657 \letcsname\??fontinstanceclass\m_font_asked_body\s!mm#one#two#rest1\endcsname\undefined
1658
1659
1660 \protected\xdefcsname\??fontinstanceready\m_font_asked_body\s!mm#one#two#rest\endcsname
1661 {\font_helpers_trigger{\m_font_asked_body\s!mm#one#two#rest}{\noexpand\font_rscale_mm}{\m_font_asked_body}{\normalunexpanded{#value}}}
1662 }
1663
1664
1665
1666\protected\def\font_basics_define_body_font_yes_mm[#one#two#rest=#value]
1667 {
1668 \gletcsname\??fontinstanceclass\fontclass\m_font_asked_body\s!mm#one#two#rest1\endcsname\undefined
1669
1670
1671 \protected\xdefcsname\??fontinstanceready\fontclass\m_font_asked_body\s!mm#one#two#rest\endcsname
1672 {\font_helpers_trigger{\m_font_asked_body\s!mm#one#two#rest}{\number\p_font_rscale}{\m_font_asked_body}{\normalunexpanded{#value}}}
1673 }
1674
1675
1676
1677\protected\def\font_basics_define_body_font_body_identifier[#bodylist][#stylelist][#name]
1678 {\processcommalist[#bodylist]{\font_basics_define_body_font_body_identifier_a{#stylelist}{#name}}}
1679
1680\protected\def\font_basics_define_body_font_body_identifier_a#stylelist#name#body
1681 {\normalizebodyfontsize\m_font_asked_body{#body}
1682 \font_helpers_check_bodyfont_environment\m_font_asked_body\m_font_asked_body
1683 \processcommalist[#stylelist]{\font_basics_define_body_font_body_identifier_b{#name}}}
1684
1685\protected\def\font_basics_define_body_font_body_identifier_b#name#style
1686 {\edef\m_font_asked_style{#style}
1687
1688 \csname\??fontdefinitions#name:\m_font_asked_style\endcsname}
1689
1690\protected\def\font_basics_define_body_font_name_assignment[#name][#stylelist][#assignments]
1691 {\processcommalist[#stylelist]{\font_basics_define_body_font_name_assignment_a{#name}{#assignments}}}
1692
1693\protected\def\font_basics_define_body_font_name_assignment_a#name#assignments#style
1694 {
1695 \edefcsname\??fontdefinitions#name:#style\endcsname{\font_basics_define_body_font_default{#assignments}}}
1696
1697\protected\def\font_basics_define_body_font_name_identifier[#name][#stylelist][#identifier]
1698 {\processcommalist[#stylelist]{\font_basics_define_body_font_name_identifier_a{#name}{#identifier}}}
1699
1700\protected\def\font_basics_define_body_font_name_identifier_a#name#identifier#style
1701 {
1702 \ifcsname\??fontdefinitions#name:#style\endcsname
1703 \letcsname\??fontdefinitions#name:#style\expandafter\endcsname\csname\??fontdefinitions#identifier:#style\endcsname
1704 \else
1705 \defcsname\??fontdefinitions#name:#style\endcsname{\csname\??fontdefinitions#identifier:#style\endcsname}
1706 \fi}
1707
1708
1709
1710\newconditional\c_font_defining_unknown
1711\newconditional\c_font_defining_state
1712
1713\protected\def\font_helpers_define_unknown_font#body
1714 {\font_helpers_register_fontbody{#body}
1715 \setfalse\c_font_defining_state
1716 \font_helpers_process_relative_size_list{\font_helpers_define_unknown_check_sizes{#body}}
1717 \ifconditional\c_font_defining_state
1718 \setfalse\c_font_defining_state
1719 \font_helpers_process_style_list{\font_helpers_define_unknown_check_definitions{#body}}
1720 \ifconditional\c_font_defining_state
1721 \ifconditional\c_font_defining_environment_state\else
1722
1723 \clf_registerunknownbodysize{#body}
1724 \fi
1725 \setfalse\c_font_defining_state
1726 \font_helpers_register_fontbody{#body}
1727
1728 \ifconditional\c_font_defining_unknown
1729 \else
1730 \settrue\c_font_defining_unknown
1731 \font_helpers_process_relative_size_list{\font_helpers_define_unknown_check_relatives{#body}}
1732 \setfalse\c_font_defining_unknown
1733 \fi
1734 \fi
1735 \fi}
1736
1737\def\font_helpers_define_unknown_check_sizes#body#relativesize
1738 {\ifcsname\??fontenvironments\s!default#relativesize\endcsname
1739 \expandafter\normalizebodyfontsize\csname\??fontenvironments#body#relativesize\endcsname{\csname\??fontenvironments\s!default#relativesize\endcsname\dimexpr#body\relax}
1740 \settrue\c_font_defining_state
1741 \fi}
1742
1743\def\font_helpers_define_unknown_check_definitions#body#style
1744 {\ifcsname\??fontdefinitions\s!default:#style\endcsname
1745 \edef\m_font_asked_body{#body}
1746 \edef\m_font_asked_style{#style}
1747 \lastnamedcs
1748 \settrue\c_font_defining_state
1749 \fi}
1750
1751\def\font_helpers_define_unknown_check_relatives#body#relativesize
1752 {\ifcsname\??fontbodyknown\csname\??fontenvironments#body#relativesize\endcsname\endcsname \else
1753 \expandafter\font_helpers_define_unknown_font\csname\??fontenvironments#body#relativesize\endcsname
1754 \settrue\c_font_defining_state
1755 \fi}
1756
1757\protected\def\font_basics_define_body_font_default#assignments
1758 {\font_helpers_check_relative_font_size\m_font_asked_style
1759 \ifcsname\m_font_asked_style\endcsname\else
1760 \normalexpanded{\definefontstyle[\m_font_asked_style][\m_font_asked_style]}
1761 \fi
1762 \processcommalist[#assignments]\font_basics_define_body_font_defs
1763 \let\p_font_rscale\v_font_rscale_default}
1764
1765
1766
1767
1768\protected\def\font_basics_switch_points#body
1769 {\ifcsname\??fontbodyknown#body\endcsname \else
1770
1771 \font_helpers_define_unknown_font{#body}
1772 \fi
1773 \ifcsname\??fontbodyknown#body\endcsname
1774 \font_basics_complete_switch{#body}
1775 \localbodyfontsize#body\relax
1776 \normalizebodyfontsize\normalizedbodyfontsize\localbodyfontsize
1777 \font_helpers_check_bodyfont_environment\normalizedbodyfontsize\normalizedbodyfontsize
1778 \else
1779 \showmessage\m!fonts4{#body}
1780 \fi
1781 \ifconditional\c_font_compact
1782 \glyphscale\numexpr\plushundred*\dimexpr\normalizedbodyfontsize\relax\maxcard\relax
1783 \fi}
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794\protected\def\font_basics_switch_style#style
1795 {\ifcsname\??fontstyle#style\endcsname
1796 \lastnamedcs
1797 \edef\fontstyle{#style}
1798 \ifmmode\mr\fi
1799
1800 \else
1801 \showmessage\m!fonts5{#style}
1802 \fi}
1803
1804
1805
1806
1807\ifdefined\font_preloads_at_definition \else \let\font_preloads_at_definition\relax \fi
1808
1809\def\font_helpers_set_font#method#specification
1810 {\edef\m_font_specification{#specification}
1811 \ifempty\m_font_specification \else
1812 \ifx\m_font_specification\v!global
1813 \restoreglobalbodyfont
1814 \else
1815 \processcommacommand[\m_font_specification]{\font_helpers_set_font_check_size}
1816 \processcommacommand[\m_font_specification]{\font_helpers_set_font_set_font{#method}}
1817 \ifproductionrun
1818 \font_preloads_at_definition
1819 \font_basics_switch_points\normalizedbodyfontsize
1820 \font_basics_switch_style\fontstyle
1821 \ifempty\defaultfontclass
1822 \let\defaultfontclass\fontclass
1823 \fi
1824 \fi
1825 \fi
1826 \currentxfontsize\zerocount
1827 \fi}
1828
1829\def\font_helpers_set_font_check_size#option
1830 {\doifelsenumber{#option}{\font_helpers_check_bodyfont_environment{#option}{#option}}\donothing}
1831
1832\def\font_helpers_set_font_set_font#method#option
1833 {\doifsomething{#option}{\font_helpers_set_font_set_font_option{#method}{#option}}}
1834
1835\def\font_helpers_set_font_set_font_option#method#option
1836 {\doifelsenumber{#option}
1837 \font_helpers_set_font_set_font_option_body
1838 \font_helpers_set_font_set_font_option_keyword
1839 {#method}{#option}{#option}}
1840
1841\newmacro\m_font_keyword
1842
1843\protected\def\font_helpers_set_font_set_font_option_keyword#method#keyword#message
1844 {\edef\m_font_keyword{#keyword}
1845 \ifcsname\??fontenvironments\normalizedbodyfontsize\m_font_keyword\endcsname
1846 \edef\m_font_step{\font_bodyfontvariable\m_font_keyword}
1847 \normalexpanded{\font_helpers_set_font_set_font_option_body{#method}{\m_font_step}{#message}}
1848 \orelse\ifx\m_font_keyword\v!reset
1849 \let\fontstyle\empty
1850 \let\fontsize \empty
1851 \orelse\ifcsname\??fontstyle\m_font_keyword\endcsname
1852 \let\fontstyle\m_font_keyword
1853 \else
1854 \setcurrentfontclass\m_font_keyword
1855 \ifcase#method\relax
1856 \let\globalfontclass\globalfontclass
1857 \else
1858 \let\globalfontclass\fontclass
1859 \fi
1860 \font_helpers_set_fontstyle_of_fontclass
1861 \fi}
1862
1863\def\font_helpers_set_fontstyle_of_fontclass
1864 {\let\fontstyle\s!rm}
1865
1866\protected\def\font_helpers_set_font_set_font_option_body#method#body#message
1867 {\normalizebodyfontsize\normalizedsetfont{#body}
1868 \ifcsname\??fontbodyknown\normalizedsetfont\endcsname \else
1869 \font_helpers_define_unknown_font\normalizedsetfont
1870 \fi
1871 \ifcsname\??fontbodyknown\normalizedsetfont\endcsname
1872 \localbodyfontsize\normalizedsetfont
1873 \let\normalizedbodyfontsize\normalizedsetfont
1874 \else
1875 \showmessage\m!fonts4{#message}
1876
1877 \fi}
1878
1879
1880
1881\permanent\def\registerfontclass#class
1882 {\letgvalue{\??fontclassyes#class}\v!yes}
1883
1884\permanent\def\setcurrentfontclass#class
1885 {\ifcsname\??fontclassyes#class\endcsname
1886 \edef\fontclass{#class}
1887 \orelse\ifcsname\??fontclassnop#class\endcsname
1888
1889 \else
1890 \fonts_helpers_try_currentfontclass{#class}
1891 \fi}
1892
1893\ifdefined\fonts_helpers_try_currentfontclass \else
1894
1895 \protected\def\fonts_helpers_try_currentfontclass#typeface
1896 {\letcsname\??fontclassnop#typeface\endcsname\empty}
1897
1898\fi
1899
1900
1901
1902
1903
1904
1905
1906
1907\permanent\protected\def\setcurrentfont#body#style#alternative#size
1908 {\edef\fontbody {#body}
1909 \edef\fontstyle {#style}
1910 \edef\fontalternative{#alternative}
1911 \edef\fontsize {#size}
1912 \font_helpers_check_big_math_synchronization
1913 \font_helpers_synchronize_font}
1914
1915\permanent\protected\def\setcurrentfontbody#body
1916 {\edef\fontbody{#body}
1917 \font_helpers_synchronize_font}
1918
1919
1920
1921\ifdefined\font_typescripts_inherit_check \else
1922 \let\font_typescripts_inherit_check\gobbleoneargument
1923\fi
1924
1925\protected\def\font_helpers_set_current_font_style#style
1926 {\edef\fontstyle{#style}
1927 \font_typescripts_inherit_check\fontstyle
1928 \ifmmode\mr\fi
1929 \font_helpers_synchronize_font}
1930
1931\protected\def\font_helpers_set_current_xsize_alternative#xsize#alternative
1932 {\edef\fontface{#xsize}
1933 \edef\fontalternative{#alternative}
1934 \font_helpers_synchronize_font}
1935
1936\protected\def\font_helpers_set_current_font_alternative#alternative
1937 {\edef\fontalternative{#alternative}
1938 \font_helpers_synchronize_font}
1939
1940\protected\def\font_helpers_set_current_font_size#size
1941 {\edef\fontsize{#size}
1942 \font_helpers_check_big_math_synchronization
1943 \font_helpers_synchronize_font}
1944
1945\protected\def\font_helpers_set_current_font_style_alternative#style#alternative
1946 {\edef\fontstyle {#style}
1947 \edef\fontalternative{#alternative}
1948 \font_helpers_synchronize_font}
1949
1950\protected\def\font_helpers_set_current_font_style_size#style#size
1951 {\edef\fontstyle{#style}
1952 \edef\fontsize {#size}
1953 \font_helpers_check_big_math_synchronization
1954 \font_helpers_synchronize_font}
1955
1956\protected\def\font_helpers_set_current_font_alternative_size#alternative#size
1957 {\edef\fontalternative{#alternative}
1958 \edef\fontsize {#size}
1959 \font_helpers_check_big_math_synchronization
1960 \font_helpers_synchronize_font}
1961
1962\protected\def\font_helpers_set_current_font_style_alternative_size#style#alternative#size
1963 {\edef\fontstyle {#style}
1964 \edef\fontalternative{#alternative}
1965 \edef\fontsize {#size}
1966 \font_helpers_check_big_math_synchronization
1967 \font_helpers_synchronize_font}
1968
1969\protected\def\font_helpers_synchronize_font
1970 {\ifempty\fontclass
1971 \applyfontstrategies
1972 \else
1973 \applyfontclassstrategies
1974 \fi
1975 \setfalse\c_font_auto_size
1976 \ifskipfontcharacteristics
1977 \the\everyfont
1978 \the\everyfontswitch
1979 \fi}
1980
1981
1982
1983
1984\def\font_helpers_check_strategy_class_a
1985 {\ifcsname\??fontinstanceready\fontclass\fontbody\fontstyle\fontalternative\fontsize\fontface\endcsname
1986 \setfalse\c_font_auto_size
1987 \lastnamedcs
1988 \else
1989 \expandafter\font_helpers_check_strategy_class_b
1990 \fi}
1991
1992\def\font_helpers_check_strategy_class_b
1993 {\ifcsname\??fontinstanceready\fontclass\fontbody\fontstyle\fontalternative\defaultfontsize\fontface\endcsname
1994 \settrue\c_font_auto_size
1995 \lastnamedcs
1996 \else
1997 \expandafter\font_helpers_check_strategy_class_c
1998 \fi}
1999
2000\def\font_helpers_check_strategy_class_c
2001 {\ifcsname\??fontinstanceready\fontclass\fontbody\fontstyle\defaultfontalternative\fontsize\fontface\endcsname
2002 \settrue\c_font_auto_size
2003 \lastnamedcs
2004 \else
2005 \expandafter\font_helpers_check_strategy_class_d
2006 \fi}
2007
2008\def\font_helpers_check_strategy_class_d
2009 {\ifcsname\??fontinstanceready\fontclass\fontbody\fontstyle\defaultfontalternative\defaultfontsize\fontface\endcsname
2010 \settrue\c_font_auto_size
2011 \lastnamedcs
2012 \else
2013 \expandafter\font_helpers_check_strategy_class_e
2014 \fi}
2015
2016\def\font_helpers_check_strategy_class_e
2017 {\ifcsname\??fontinstanceready\fontclass\fontbody\defaultfontstyle\defaultfontalternative\defaultfontsize\fontface\endcsname
2018 \setfalse\c_font_auto_size
2019 \lastnamedcs
2020 \else
2021 \expandafter\font_helpers_check_strategy_class_f
2022 \fi}
2023
2024\def\font_helpers_check_strategy_class_f
2025 {\ifcsname\??fontinstanceready\fontclass\defaultfontbody\defaultfontstyle\defaultfontalternative\defaultfontsize\fontface\endcsname
2026 \settrue\c_font_auto_size
2027 \lastnamedcs
2028 \else
2029 \expandafter\font_helpers_check_strategy_a
2030 \fi}
2031
2032
2033
2034\def\font_helpers_check_strategy_a
2035 {\ifcsname\??fontinstanceready\fontbody\fontstyle\fontalternative\fontsize\fontface\endcsname
2036 \setfalse\c_font_auto_size
2037 \lastnamedcs
2038 \else
2039 \expandafter\font_helpers_check_strategy_b
2040 \fi}
2041
2042\def\font_helpers_check_strategy_b
2043 {\ifcsname\??fontinstanceready\fontbody\fontstyle\fontalternative\defaultfontsize\fontface\endcsname
2044 \settrue\c_font_auto_size
2045 \lastnamedcs
2046 \else
2047 \expandafter\font_helpers_check_strategy_c
2048 \fi}
2049
2050\def\font_helpers_check_strategy_c
2051 {\ifcsname\??fontinstanceready\fontbody\fontstyle\defaultfontalternative\fontsize\fontface\endcsname
2052 \settrue\c_font_auto_size
2053 \lastnamedcs
2054 \else
2055 \expandafter\font_helpers_check_strategy_d
2056 \fi}
2057
2058\def\font_helpers_check_strategy_d
2059 {\ifcsname\??fontinstanceready\fontbody\fontstyle\defaultfontalternative\defaultfontsize\fontface\endcsname
2060 \settrue\c_font_auto_size
2061 \lastnamedcs
2062 \else
2063 \expandafter\font_helpers_check_strategy_e
2064 \fi}
2065
2066\def\font_helpers_check_strategy_e
2067 {\ifcsname\??fontinstanceready\fontbody\defaultfontstyle\defaultfontalternative\defaultfontsize\fontface\endcsname
2068 \setfalse\c_font_auto_size
2069 \lastnamedcs
2070 \else
2071 \expandafter\font_helpers_check_strategy_f
2072 \fi}
2073
2074\def\font_helpers_check_strategy_f
2075 {\ifcsname\??fontinstanceready\defaultfontbody\defaultfontstyle\defaultfontalternative\defaultfontsize\fontface\endcsname
2076 \settrue\c_font_auto_size
2077 \lastnamedcs
2078 \fi}
2079
2080\permanent\let\applyfontstrategies \font_helpers_check_strategy_a
2081\permanent\let\applyfontclassstrategies\font_helpers_check_strategy_class_a
2082
2083
2084
2085\newconditional\c_font_synchronize \settrue\c_font_synchronize
2086
2087\prependtoks
2088 \ifconditional\c_font_synchronize
2089 \font_helpers_synchronize_math
2090 \font_helpers_synchronize_font
2091 \fi
2092\to \everybodyfont
2093
2094
2095
2096
2097
2098
2099
2100\def\font_helpers_set_current_font_xxx_alternative#alternative#xsize#scriptstyle
2101 {\ifmmode
2102 #scriptstyle
2103 \else
2104 \font_helpers_set_current_xsize_alternative{#xsize}{#alternative}
2105 \fi}
2106
2107\def\font_helpers_reset_x_fontsize
2108 {\ifcase\currentxfontsize\else
2109 \currentxfontsize\zerocount
2110
2111 \enforced\let\tx \normaltx
2112 \enforced\let\txx\normaltxx
2113 \fi}
2114
2115\let\font_helpers_check_nested_x_fontsize\relax
2116
2117\def\font_helpers_set_current_font_x_alternative#alternative
2118 {\font_helpers_check_nested_x_fontsize
2119 \font_helpers_set_current_font_xxx_alternative{#alternative}{4}\scriptstyle
2120 \currentxfontsize\plusone
2121 \enforced\let\tx\txx}
2122
2123\def\font_helpers_set_current_font_xx_alternative#alternative
2124 {\font_helpers_check_nested_x_fontsize
2125 \font_helpers_set_current_font_xxx_alternative{#alternative}{5}\scriptscriptstyle
2126 \currentxfontsize\plustwo
2127 \enforced\let\tx\empty
2128 \enforced\let\txx\empty}
2129
2130
2131
2132
2133\def\font_helpers_set_current_font_x_style_alternative #alternative{\csname#alternative\endcsname\tx}
2134\def\font_helpers_set_current_font_xx_style_alternative#alternative{\csname#alternative\endcsname\txx}
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157\installcorenamespace{fontscalex}
2158\installcorenamespace{fontscalexx}
2159
2160\newconditional\c_font_inherit_scale
2161
2162\def\font_scale_inherit#1
2163 {\begingroup
2164 \scratchcounterone\fontid\font\relax
2165 \currentxfontsize\plusone
2166 \normalexpanded{\definedfont[\clf_specifiedfont\scratchcounterone\font_currentfontscale\relax]}
2167 \scratchcountertwo\fontid\font\relax
2168 \currentxfontsize\plustwo
2169 \normalexpanded{\definedfont[\clf_specifiedfont\scratchcounterone\font_currentfontscale\relax]}
2170 \scratchcounterthree\fontid\font\relax
2171
2172
2173
2174
2175
2176 \global\expandafter\chardef\csname\??fontscalex \number\scratchcounterone\endcsname\scratchcountertwo
2177 \global\expandafter\chardef\csname\??fontscalexx\number\scratchcounterone\endcsname\scratchcounterthree
2178 \global\expandafter\chardef\csname\??fontscalex \number\scratchcountertwo\endcsname\scratchcounterthree
2179 \global\expandafter\chardef\csname\??fontscalexx\number\scratchcountertwo\endcsname\scratchcounterthree
2180 \endgroup
2181 \setfontid\csname#1\number\fontid\font\endcsname}
2182
2183\def\font_scale_inherit_x
2184 {\ifcsname\??fontscalex\number\fontid\font\endcsname
2185 \setfontid\lastnamedcs
2186 \else
2187 \font_scale_inherit\??fontscalex
2188 \fi
2189 \ifskipfontcharacteristics
2190 \the\everyfont
2191 \the\everyfontswitch
2192 \fi}
2193
2194\def\font_scale_inherit_xx
2195 {\ifcsname\??fontscalexx\number\fontid\font\endcsname
2196 \setfontid\lastnamedcs
2197 \else
2198 \font_scale_inherit\??fontscalexx
2199 \fi
2200 \ifskipfontcharacteristics
2201 \the\everyfont
2202 \the\everyfontswitch
2203 \fi}
2204
2205\def\font_scale_defined_x
2206 {\let\fontface\!!plusfour
2207 \let\fontalternative\fontalternative
2208 \font_helpers_synchronize_font}
2209
2210\def\font_scale_defined_xx
2211 {\let\fontface\!!plusfive
2212 \let\fontalternative\fontalternative
2213 \font_helpers_synchronize_font}
2214
2215
2216
2217\permanent\protected\def\tx
2218 {\currentxfontsize\plusone
2219 \ifmmode
2220 \scriptstyle
2221 \orelse\ifconditional\c_font_inherit_scale
2222 \font_scale_inherit_x
2223 \else
2224 \font_scale_defined_x
2225 \fi
2226 \enforced\let\tx\txx}
2227
2228\permanent\protected\def\txx
2229 {\currentxfontsize\plustwo
2230 \ifmmode
2231 \scriptscriptstyle
2232 \orelse\ifconditional\c_font_inherit_scale
2233 \font_scale_inherit_xx
2234 \else
2235 \font_scale_defined_xx
2236 \fi
2237 \enforced\let\tx \empty
2238 \enforced\let\txx\empty}
2239
2240\permanent\protected\def\sx
2241 {\currentxfontsize\plusone
2242 \ifmmode
2243 \scriptstyle
2244 \else
2245 \font_scale_inherit_x
2246 \fi
2247 \enforced\let\tx\txx
2248 \enforced\let\sx\sxx}
2249
2250\permanent\protected\def\sxx
2251 {\currentxfontsize\plustwo
2252 \ifmmode
2253 \scriptscriptstyle
2254 \else
2255 \font_scale_inherit_xx
2256 \fi
2257 \enforced\let\tx \empty
2258 \enforced\let\txx\empty
2259 \enforced\let\sx \empty
2260 \enforced\let\sxx\empty}
2261
2262\permanent\protected\def\useinheritxsizes{\settrue \c_font_inherit_scale}
2263\permanent\protected\def\usedefinedxsizes{\setfalse\c_font_inherit_scale}
2264
2265\aliased\let\normaltx \tx
2266\aliased\let\normaltxx\txx
2267
2268\aliased\let\normalsx \sx
2269\aliased\let\normalsxx\sxx
2270
2271
2272
2273
2274
2275
2276
2277\permanent\protected\def\textface {\currentbodyfontdimension\s!text }
2278\permanent\protected\def\scriptface {\currentbodyfontdimension\s!script }
2279\permanent\protected\def\scriptscriptface{\currentbodyfontdimension\s!scriptscript}
2280\permanent\protected\def\xtextface {\currentbodyfontdimension\s!x }
2281\permanent\protected\def\xxtextface {\currentbodyfontdimension\s!xx }
2282
2283\installcorenamespace{fontbodyfaces}
2284
2285\protected\def\font_basics_complete_switch#size
2286 {\bodyfontsize#size\relax
2287 \normalizebodyfontsize\normalizedbodyfontsize\bodyfontsize
2288 \expandafter\let\expandafter\font_basics_set_faces\csname\??fontbodyfaces\fontbody\endcsname
2289 \ifrelax\font_basics_set_faces
2290 \font_basics_set_faces_preset
2291 \fi
2292 \font_basics_set_faces}
2293
2294\def\font_basics_set_faces_preset
2295 {\edef\font_basics_set_faces{
2296 \enforced\permanent\protected\def\textface {\currentbodyfontdimension\s!text }
2297 \enforced\permanent\protected\def\scriptface {\currentbodyfontdimension\s!script }
2298 \enforced\permanent\protected\def\scriptscriptface{\currentbodyfontdimension\s!scriptscript}
2299 \enforced\permanent\protected\def\xtextface {\currentbodyfontdimension\s!x }
2300 \enforced\permanent\protected\def\xxtextface {\currentbodyfontdimension\s!xx }
2301 }
2302 \gletcsname\??fontbodyfaces\fontbody\endcsname\font_basics_set_faces}
2303
2304\permanent\def\currentbodyfontdimension#parameter
2305 {\the\dimexpr
2306 \ifcsname\??fontenvironments\fontclass\normalizedbodyfontsize#parameter\endcsname
2307 \lastnamedcs
2308 \orelse\ifcsname\??fontenvironments\fontclass\s!default#parameter\endcsname
2309 \lastnamedcs
2310 \dimexpr\normalizedbodyfontsize\relax
2311 \orelse\ifcsname\??fontenvironments\normalizedbodyfontsize#parameter\endcsname
2312 \lastnamedcs
2313 \else
2314 \csname\??fontenvironments\s!default#parameter\endcsname
2315 \dimexpr\normalizedbodyfontsize\relax
2316 \fi
2317 \relax}
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345\ifdefined\saveinterlinespace \else \let\saveinterlinespace \relax \fi
2346\ifdefined\restoreinterlinespace \else \let\restoreinterlinespace\relax \fi
2347
2348
2349
2350
2351\permanent\protected\def\setupbodyfont
2352 {\doifelsenextoptionalcs\font_basics_setupbodyfont_yes\font_basics_setupbodyfont_nop}
2353
2354\def\font_basics_setupbodyfont_nop
2355 {\restoreglobalbodyfont
2356 \saveinterlinespace}
2357
2358\def\font_basics_setupbodyfont_yes[#specification]
2359 {\doifsomething{#specification}
2360 {\font_helpers_set_font\plusone{#specification}
2361 \globalbodyfontsize\localbodyfontsize
2362 \normalizebodyfontsize\normalizedglobalbodyfontsize\globalbodyfontsize
2363 \let\globalfontstyle\fontstyle
2364 \ifproductionrun
2365 \the\everybodyfont
2366 \the\everyglobalbodyfont
2367 \saveinterlinespace
2368 \fi
2369 \the\everysetupbodyfont}}
2370
2371\protected\def\font_basics_switchtobodyfont#specification
2372 {\edef\m_font_step{\font_bodyfontvariable{#specification}}
2373 \ifempty\m_font_step
2374 \font_helpers_set_font\zerocount{#specification}
2375 \else
2376 \font_helpers_switch_bodyfont_step
2377 \fi
2378 \the\everybodyfont
2379 \the\everyswitchtobodyfont}
2380
2381\permanent\protected\def\switchtobodyfont[#specification]
2382 {\doifsomething{#specification}{\font_basics_switchtobodyfont{#specification}}}
2383
2384\permanent\protected\def\usebodyfontparameter#1
2385 {\edef\m_font_bodyfont_asked{#1\c!bodyfont}
2386 \ifempty\m_font_bodyfont_asked\else
2387 \font_basics_switchtobodyfont\m_font_bodyfont_asked
2388 \fi}
2389
2390\def\font_helpers_switch_bodyfont_step
2391 {\font_basics_switch_points\m_font_step
2392 \font_basics_switch_style \fontstyle}
2393
2394
2395
2396
2397\permanent\protected\def\fastswitchtobodyfont#name
2398 {\ifcsname\??fontenvironments\normalizedbodyfontsize#name\endcsname
2399 \edef\p_bodyfont{\lastnamedcs}
2400 \ifcsname\??fontbodyknown\p_bodyfont\endcsname
2401 \font_basics_complete_switch\p_bodyfont
2402 \localbodyfontsize\p_bodyfont\relax
2403 \fi
2404 \fi
2405 \csname\??fontstyle\fontstyle\endcsname
2406 \the\everybodyfont}
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429\permanent\protected\def\usebodyfont[#1]
2430 {\ifempty\fontclass
2431 \setupbodyfont[#1]
2432 \else
2433 \switchtobodyfont[#1]
2434 \fullrestoreglobalbodyfont
2435 \fi}
2436
2437\fetchmodulecommand \showbodyfontstate \f!font_run
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457\permanent\protected\def\fontchar #character{\clf_fontchar{#character}}
2458\permanent\protected\def\fontcharbyindex #index{\clf_fontcharbyindex#index\relax}
2459\permanent \def\tochar #specifications{\clf_tochar{#specifications}}
2460
2461
2462
2463\permanent\def\purefontname#font{\clf_purefontname{\fontname#font}}
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477\permanent\protected\def\switchstyleonly
2478 {\doifelsenextoptionalcs\font_basics_switch_style_only_opt\font_basics_switch_style_only_arg}
2479
2480\def\font_basics_switch_style_only_arg#name
2481 {\font_helpers_set_current_font_style{\csname\??fontshortstyle\checkedstrippedcsname#name\endcsname}
2482 \the\everybodyfont}
2483
2484\def\font_basics_switch_style_only_opt[#name]
2485 {\font_helpers_set_current_font_style{\csname\??fontshortstyle#name\endcsname}
2486 \the\everybodyfont}
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500\permanent\tolerant\protected\def\definebodyfontswitch[#command]#spacer[#specification]
2501 {\frozen\protected\defcsname#command\endcsname{\switchtobodyfont[#specification]}}
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511\newmacro\m_font_step
2512
2513\def\font_helpers_set_bodyfont_step#step
2514 {\edef\m_font_step{\font_bodyfontvariable{#step}}
2515 \font_basics_switch_points\m_font_step
2516 \font_basics_switch_style \fontstyle}
2517
2518\permanent\protected\def\setsmallbodyfont{\font_helpers_set_bodyfont_step\v!small\the\everybodyfont}
2519\permanent\protected\def\setbigbodyfont {\font_helpers_set_bodyfont_step\v!big \the\everybodyfont}
2520
2521\permanent\protected\def\setmainbodyfont
2522 {\font_basics_switch_points\normalizedbodyfontsize
2523 \font_basics_switch_style\fontstyle
2524 \the\everybodyfont
2525 \the\everyglobalbodyfont
2526 \saveinterlinespace}
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541\mutable\let\globalfontstyle\s!rm
2542
2543\permanent\protected\def\fullrestoreglobalbodyfont
2544 {\let\fontsize\defaultfontsize
2545 \let\fontbody\defaultfontbody
2546 \let\fontface\defaultfontface
2547 \currentxfontsize\zerocount
2548 \let\fontclass\globalfontclass
2549 \font_basics_switch_points\normalizedglobalbodyfontsize
2550 \font_basics_switch_style\globalfontstyle
2551 \redoconvertfont
2552 \tf
2553 \the\everybodyfont
2554 \the\everyglobalbodyfont
2555 \saveinterlinespace}
2556
2557\permanent\protected\def\partialrestoreglobalbodyfont
2558 {\let\fontsize\defaultfontsize
2559 \let\fontbody\defaultfontbody
2560 \let\fontface\defaultfontface
2561 \currentxfontsize\zerocount
2562 \redoconvertfont
2563 \tf
2564 \the\everybodyfont
2565 \the\everyglobalbodyfont
2566 \saveinterlinespace}
2567
2568\permanent\protected\def\restoreglobalbodyfont
2569 {\ifx\fontclass\globalfontclass
2570 \ifx\fontstyle\globalfontstyle
2571 \ifx\normalizedbodyfontsize\normalizedglobalbodyfontsize
2572 \partialrestoreglobalbodyfont
2573 \else
2574 \fullrestoreglobalbodyfont
2575 \fi
2576 \else
2577 \fullrestoreglobalbodyfont
2578 \fi
2579 \else
2580 \fullrestoreglobalbodyfont
2581 \fi}
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598\installcorenamespace{predefinedfont}
2599
2600\permanent\protected\def\predefinefont[#1]#*[#2]
2601 {\protected\gdefcsname#1\endcsname{\font_basics_predefine{#1}{#2}}}
2602
2603\permanent\protected\def\predefinedfont[#1]
2604 {\ifcsname\??predefinedfont#1\endcsname
2605 \lastnamedcs
2606 \else
2607 \font_basics_predefined{#1}
2608 \fi}
2609
2610\protected\def\font_basics_predefine#1#2
2611 {\definedfont[#2]
2612 \gletcsname#1\expandafter\endcsname\csname\v_font_identifier_basic\endcsname}
2613
2614\protected\def\font_basics_predefined#1
2615 {\font_basics_predefine{\??predefinedfont#1}{#1}}
2616
2617
2618
2619\permanent\protected\def\savedefinedfont[#1]
2620 {\bgroup
2621 \definedfont[#1]
2622 \xdef\saveddefinedfontid {\number\fontid\font}
2623 \xdef\saveddefinedfontname{\fontname\font}
2624 \egroup}
2625
2626\mutable\def\saveddefinedfontid {\number\fontid\font}
2627\mutable\def\saveddefinedfontname{\fontname\font}
2628
2629
2630
2631\permanent\protected\def\saverunningstyleandcolor
2632 {\enforced\permanent\protected\edef\restorerunningstyleandcolor
2633 {\setfontid \number\fontid\font
2634 \c_attr_colormodel \the\c_attr_colormodel
2635 \c_attr_color \the\c_attr_color
2636 \c_attr_transparency\the\c_attr_transparency
2637 \relax}}
2638
2639\aliased\let\restorerunningstyleandcolor\relax
2640
2641
2642
2643
2644
2645\aliased\let\getprivateglyphslot\clf_getprivateglyphslot
2646
2647\aliased\let\getprivatechar \clf_getprivatechar
2648\aliased\let\getprivatemathchar \clf_getprivatemathchar
2649\aliased\let\getprivateslot \clf_getprivateslot
2650
2651
2652
2653
2654\permanent\protected\def\privatechar
2655 {\ifmmode
2656 \expandafter\getprivatemathchar
2657 \else
2658 \expandafter\getprivatechar
2659 \fi}
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682\permanent\tolerant\protected\def\definefontcolorpalette[#1]#*[#2]
2683 {\clf_definefontcolorpalette{#1}{#2}}
2684
2685
2686
2687
2688
2689
2690\permanent\protected\def\usefontpath[#1]
2691 {\clf_addfontpath{#1}}
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706\appendtoks
2707 \edef\m_list{\fontsparameter\s!serif}
2708 \ifempty\m_list\else
2709 \registerfallbackfont[\s!serif][\m_list]
2710 \fi
2711 \edef\m_list{\fontsparameter\s!sans}
2712 \ifempty\m_list\else
2713 \registerfallbackfont[\s!sans][\m_list]
2714 \fi
2715 \edef\m_list{\fontsparameter\s!mono}
2716 \ifempty\m_list\else
2717 \registerfallbackfont[\s!mono][\m_list]
2718 \fi
2719\to \everysetupfonts
2720
2721\protect \endinput
2722 |