-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxeCJK.cpp
168 lines (168 loc) · 5.12 KB
/
xeCJK.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
// This is xeCJK.cpp of https://github.com/Willie169/LaTeX-ToolKit, licensed under either GPL-3.0-or-later or CC BY-SA 4.0-or-later.
#include<iostream>
#include<string>
#include <algorithm>
#include <cctype>
using namespace std;
class Latex {
public:
Latex() {}
const string cmain = "\\setCJKmainfont";
const string csans = "\\setCJKsansfont";
const string cmono = "\\setCJKmonofont";
const string nff = "\n\\newfontfamily\\";
const string path = "Path=/usr/share/fonts/noto-cjk/,";
const string sansf = "NotoSans";
const string seriff = "NotoSerif";
const string monof = "NotoSansMonoCJK";
const string otf = ".otf";
const string cf = "\\ifnum\\value{CJKFonts}=";
const string cl ="\\ifnum\\value{CJKLanguage}=";
const string cn = "\\ifnum\\value{NotoCJKFamily}=";
const string el = "\\else";
const string cp = "}[";
const string end = "Ligatures=TeX]\n";
const string endd = "Ligatures=TeX]";
const string pre = "\\ifnum\\value{CJKFonts}=0\\else\n";
string ulang[5]={"TC","SC","HK","JP","KR"};
string llang[5]={"tc","sc","hk","jp","kr"};
string fw[5]={"UprightFont","ItalicFont","BoldFont","BoldItalicFont","SmallCapsFont"};
string sansw[5]={"Regular","Medium","Bold","Black","DemiLight"};
string serifw[5]={"Regular","Medium","Bold","Black","Light"};
string monofwn[2]={"UprightFont","BoldFont"};
string monow[2]={"Regular","Bold"};
string sans(string lang){
string ret="{"+sansf+lang+cp+path;
for (int i=0; i<5; i++) ret+=fw[i]+"="+sansf+lang+"-"+sansw[i]+otf+",";
ret+=end;
return ret;
}
string serif(string lang){
string ret="{"+seriff+lang+cp+path;
for (int i=0; i<5; i++) ret+=fw[i]+"="+seriff+lang+"-"+serifw[i]+otf+",";
ret+=end;
return ret;
}
string mono(string lang){
string ret="{"+monof+lang+cp+path;
for (int i=0; i<2; i++) ret+=monofwn[i]+"="+monof+lang+"-"+monow[i]+otf+",";
ret+=end;
return ret;
}
string ssans(string lang){
string ret="Sans"+lang+"{"+sansf+lang+cp+path;
for (int i=0; i<5; i++) ret+=fw[i]+"="+sansf+lang+"-"+sansw[i]+otf+",";
ret+=endd;
return ret;
}
string sserif(string lang){
string ret="Serif"+lang+"{"+seriff+lang+cp+path;
for (int i=0; i<5; i++) ret+=fw[i]+"="+seriff+lang+"-"+serifw[i]+otf+",";
ret+=endd;
return ret;
}
string lsans(string lang){
string ret=lang+"{"+sansf+lang+cp+path;
for (int i=0; i<5; i++) ret+=fw[i]+"="+sansf+lang+"-"+sansw[i]+otf+",";
ret+=endd;
return ret;
}
string lserif(string lang){
string ret=lang+"{"+seriff+lang+cp+path;
for (int i=0; i<5; i++) ret+=fw[i]+"="+seriff+lang+"-"+serifw[i]+otf+",";
ret+=endd;
return ret;
}
string smono(string ulang){
string lang = ulang;
transform(lang.begin(), lang.end(), lang.begin(), [](unsigned char c) { return tolower(c); });
string ret="Mono"+ulang+"{"+monof+lang+cp+path;
for (int i=0; i<2; i++) ret+=monofwn[i]+"="+monof+lang+"-"+monow[i]+otf+",";
ret+=endd;
return ret;
}
void yes() {
cout << pre;
for (int i=0; i<5; i++) {
cout << cl+to_string(i)+"\n";
cout << cf+"1"+"\n";
cout << cmain << sans(ulang[i]);
cout << csans << serif(ulang[i]);
cout << cmono << mono(llang[i]);
cout << "\\else";
cout << cf+"2"+"\n";
cout << cmain << serif(ulang[i]);
cout << csans << sans(ulang[i]);
cout << cmono << mono(llang[i]);
cout << "\\else";
cout << cf+"3"+"\n";
cout << cmain << sans(ulang[i]);
cout << cmono << mono(llang[i]);
cout << "\\else";
cout << cf+"4"+"\n";
cout << cmain << serif(ulang[i]);
cout << cmono << mono(llang[i]);
cout << "\\else";
cout << cf+"5"+"\n";
cout << cmain << sans(ulang[i]);
cout << csans << serif(ulang[i]);
cout << "\\else";
cout << cf+"6"+"\n";
cout << cmain << serif(ulang[i]);
cout << csans << sans(ulang[i]);
cout << "\\else";
cout << cf+"7"+"\n";
cout << cmain << sans(ulang[i]);
cout << "\\else";
cout << cf+"8"+"\n";
cout << cmain << serif(ulang[i]);
cout << "\\fi\\fi\\fi\\fi\\fi\\fi\\fi\\fi";
if (i!=4) cout << "\\else\n";
}
cout << "\\fi\\fi\\fi\\fi\\fi\\fi\n";
cout << cn << "0\n";
cout << "\\else" << cn << "1";
for (int i=0; i<5; i++) {
cout << nff << ssans(ulang[i]);
cout << nff << lsans(ulang[i]);
cout << nff << sserif(ulang[i]);
cout << nff << smono(ulang[i]);
}
cout << "\\else" << cn << "2";
for (int i=0; i<5; i++) {
cout << nff << ssans(ulang[i]);
cout << nff << sserif(ulang[i]);
cout << nff << lserif(ulang[i]);
cout << nff << smono(ulang[i]);
}
cout << "\\else" << cn << "3";
for (int i=0; i<5; i++) {
cout << nff << ssans(ulang[i]);
cout << nff << sserif(ulang[i]);
cout << nff << smono(ulang[i]);
}
cout << "\\else" << cn << "4";
for (int i=0; i<5; i++) {
cout << nff << ssans(ulang[i]);
cout << nff << lsans(ulang[i]);
cout << nff << sserif(ulang[i]);
}
cout << "\\else" << cn << "5";
for (int i=0; i<5; i++) {
cout << nff << ssans(ulang[i]);
cout << nff << sserif(ulang[i]);
cout << nff << lserif(ulang[i]);
}
cout << "\\else" << cn << "6";
for (int i=0; i<5; i++) {
cout << nff << ssans(ulang[i]);
cout << nff << sserif(ulang[i]);
}
cout << "\n\\fi\\fi\\fi\\fi\\fi\\fi\\fi\n";
}
};
int main() {
Latex latex=Latex();
latex.yes();
return 0;
}