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