1 /*
2 * Copyright (c) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "ui_text_language.h"
17 #include "font/ui_font_builder.h"
18 #include "font/ui_font_header.h"
19
20 namespace OHOS {
21 static const UITextLanguageFontParam g_uiTextLangFontsTable[LANGUAGE_FONT_ID_MAX] = {
22 {14, 4, 0, 0, "RobotoCondensed-Regular"},
23 {18, 4, 0, 0, "RobotoCondensed-Regular"},
24 {20, 4, 0, 0, "RobotoCondensed-Regular"},
25 {23, 4, 0, 0, "RobotoCondensed-Regular"},
26 {23, 4, 0, 0, "RobotoCondensed-Regular"},
27 {26, 4, 0, 0, "RobotoCondensed-Regular"},
28 {28, 4, 0, 0, "RobotoCondensed-Regular"},
29 {30, 4, 0, 0, "RobotoCondensed-Regular"},
30 {38, 4, 0, 0, "RobotoCondensed-Regular"},
31 {48, 4, 0, 0, "RobotoCondensed-Regular"},
32 {14, 4, 0, 1, "HYQiHei-65S"},
33 {18, 4, 0, 1, "HYQiHei-65S"},
34 {16, 4, 0, 1, "HYQiHei-65S"},
35 {22, 4, 0, 1, "HYQiHei-65S"},
36 {24, 4, 0, 1, "HYQiHei-65S"},
37 {26, 4, 0, 1, "HYQiHei-65S"},
38 {30, 4, 0, 1, "HYQiHei-65S"},
39 {34, 4, 0, 1, "HYQiHei-65S"},
40 {38, 4, 0, 1, "HYQiHei-65S"},
41 {48, 4, 0, 1, "HYQiHei-65S"},
42 {14, 4, 1, 2, "NotoNaskhArabic-Regular"},
43 {18, 4, 1, 2, "NotoNaskhArabic-Regular"},
44 {24, 4, 1, 2, "NotoNaskhArabic-Regular"},
45 {30, 4, 1, 2, "NotoNaskhArabic-Regular"},
46 {38, 4, 1, 2, "NotoNaskhArabic-Regular"},
47 {20, 4, 1, 2, "NotoNaskhArabic-Regular"},
48 {23, 4, 1, 2, "NotoNaskhArabic-Regular"},
49 {26, 4, 1, 2, "NotoNaskhArabic-Regular"},
50 {28, 4, 1, 2, "NotoNaskhArabic-Regular"},
51 {48, 4, 1, 2, "NotoNaskhArabic-Regular"},
52 {14, 4, 0, 3, "NotoSansCJKjp-Regular"},
53 {18, 4, 0, 3, "NotoSansCJKjp-Regular"},
54 {24, 4, 0, 3, "NotoSansCJKjp-Regular"},
55 {20, 4, 0, 3, "NotoSansCJKjp-Regular"},
56 {23, 4, 0, 3, "NotoSansCJKjp-Regular"},
57 {26, 4, 0, 3, "NotoSansCJKjp-Regular"},
58 {28, 4, 0, 3, "NotoSansCJKjp-Regular"},
59 {30, 4, 0, 3, "NotoSansCJKjp-Regular"},
60 {38, 4, 0, 3, "NotoSansCJKjp-Regular"},
61 {48, 4, 0, 3, "NotoSansCJKjp-Regular"},
62 {14, 4, 0, 4, "NotoSansCJKkr-Regular"},
63 {18, 4, 0, 4, "NotoSansCJKkr-Regular"},
64 {24, 4, 0, 4, "NotoSansCJKkr-Regular"},
65 {20, 4, 0, 4, "NotoSansCJKkr-Regular"},
66 {23, 4, 0, 4, "NotoSansCJKkr-Regular"},
67 {26, 4, 0, 4, "NotoSansCJKkr-Regular"},
68 {28, 4, 0, 4, "NotoSansCJKkr-Regular"},
69 {30, 4, 0, 4, "NotoSansCJKkr-Regular"},
70 {38, 4, 0, 4, "NotoSansCJKkr-Regular"},
71 {48, 4, 0, 4, "NotoSansCJKkr-Regular"},
72 {14, 4, 1, 5, "NotoSansThai-Regular"},
73 {18, 4, 1, 5, "NotoSansThai-Regular"},
74 {24, 4, 1, 5, "NotoSansThai-Regular"},
75 {30, 4, 1, 5, "NotoSansThai-Regular"},
76 {38, 4, 1, 5, "NotoSansThai-Regular"},
77 {14, 4, 1, 6, "NotoSansHebrew-Regular"},
78 {18, 4, 1, 6, "NotoSansHebrew-Regular"},
79 {24, 4, 1, 6, "NotoSansHebrew-Regular"},
80 {30, 4, 1, 6, "NotoSansHebrew-Regular"},
81 {38, 4, 1, 6, "NotoSansHebrew-Regular"},
82 {20, 4, 1, 6, "NotoSansHebrew-Regular"},
83 {23, 4, 1, 6, "NotoSansHebrew-Regular"},
84 {26, 4, 1, 6, "NotoSansHebrew-Regular"},
85 {28, 4, 1, 6, "NotoSansHebrew-Regular"},
86 {48, 4, 1, 6, "NotoSansHebrew-Regular"},
87 {20, 4, 1, 5, "NotoSansThai-Regular"},
88 {23, 4, 1, 5, "NotoSansThai-Regular"},
89 {26, 4, 1, 5, "NotoSansThai-Regular"},
90 {28, 4, 1, 5, "NotoSansThai-Regular"},
91 {48, 4, 1, 5, "NotoSansThai-Regular"},
92 {14, 4, 1, 7, "NotoSansDevanagari-Regular"},
93 {18, 4, 1, 7, "NotoSansDevanagari-Regular"},
94 {24, 4, 1, 7, "NotoSansDevanagari-Regular"},
95 {20, 4, 1, 7, "NotoSansDevanagari-Regular"},
96 {23, 4, 1, 7, "NotoSansDevanagari-Regular"},
97 {26, 4, 1, 7, "NotoSansDevanagari-Regular"},
98 {28, 4, 1, 7, "NotoSansDevanagari-Regular"},
99 {30, 4, 1, 7, "NotoSansDevanagari-Regular"},
100 {38, 4, 1, 7, "NotoSansDevanagari-Regular"},
101 {48, 4, 1, 7, "NotoSansDevanagari-Regular"},
102 {14, 4, 1, 8, "NotoSansMyanmar-Condensed"},
103 {18, 4, 1, 8, "NotoSansMyanmar-Condensed"},
104 {20, 4, 1, 8, "NotoSansMyanmar-Condensed"},
105 {23, 4, 1, 8, "NotoSansMyanmar-Condensed"},
106 {24, 4, 1, 8, "NotoSansMyanmar-Condensed"},
107 {26, 4, 1, 8, "NotoSansMyanmar-Condensed"},
108 {28, 4, 1, 8, "NotoSansMyanmar-Condensed"},
109 {30, 4, 1, 8, "NotoSansMyanmar-Condensed"},
110 {38, 4, 1, 8, "NotoSansMyanmar-Condensed"},
111 {48, 4, 1, 8, "NotoSansMyanmar-Condensed"},
112 {22, 4, 1, 9, "NotoSansBengali-Regular"},
113 {26, 4, 1, 9, "NotoSansBengali-Regular"},
114 {30, 4, 1, 9, "NotoSansBengali-Regular"},
115 {34, 4, 1, 9, "NotoSansBengali-Regular"},
116 {38, 4, 1, 9, "NotoSansBengali-Regular"},
117 {48, 4, 1, 9, "NotoSansBengali-Regular"},
118 {20, 4, 1, 9, "NotoSansBengali-Regular"},
119 {23, 4, 1, 9, "NotoSansBengali-Regular"},
120 {28, 4, 1, 9, "NotoSansBengali-Regular"},
121 }; // g_uiTextLangFontsTable
122
123 static const LangTextParam g_langTextDefaultParamTable[LANGUAGE_MAX] = {
124 {0, 30, "HYQiHei-65S", "zh"},
125 {0, 30, "RobotoCondensed-Regular", "en"},
126 {0, 30, "RobotoCondensed-Regular", "fr"},
127 {0, 30, "RobotoCondensed-Regular", "de"},
128 {0, 30, "RobotoCondensed-Regular", "pt"},
129 {0, 30, "RobotoCondensed-Regular", "ru"},
130 {0, 30, "RobotoCondensed-Regular", "es"},
131 {0, 30, "RobotoCondensed-Regular", "it"},
132 {0, 30, "RobotoCondensed-Regular", "pl"},
133 {0, 30, "RobotoCondensed-Regular", "en"},
134 {0, 30, "RobotoCondensed-Regular", "tr"},
135 {0, 30, "RobotoCondensed-Regular", "da"},
136 {0, 30, "RobotoCondensed-Regular", "sv"},
137 {0, 30, "RobotoCondensed-Regular", "no"},
138 {0, 30, "RobotoCondensed-Regular", "fi"},
139 {0, 30, "HYQiHei-65S", "zh"},
140 {0, 30, "HYQiHei-65S", "zh"},
141 {0, 30, "NotoSansCJKjp-Regular", "jv"},
142 {0, 30, "NotoSansCJKkr-Regular", "ko"},
143 {1, 30, "NotoNaskhArabic-Regular", "ar"},
144 {0, 30, "RobotoCondensed-Regular", "pt"},
145 {0, 30, "RobotoCondensed-Regular", "es"},
146 {0, 30, "NotoSansThai-Regular", "th"},
147 {0, 30, "RobotoCondensed-Regular", "vi"},
148 {1, 30, "NotoSansHebrew-Regular", "he"},
149 {0, 30, "RobotoCondensed-Regular", "cs"},
150 {0, 30, "RobotoCondensed-Regular", "sk"},
151 {0, 30, "RobotoCondensed-Regular", "nl"},
152 {0, 30, "RobotoCondensed-Regular", "el"},
153 {0, 30, "RobotoCondensed-Regular", "hu"},
154 {0, 30, "RobotoCondensed-Regular", "ms"},
155 {0, 30, "RobotoCondensed-Regular", "ro"},
156 {0, 30, "RobotoCondensed-Regular", "sr"},
157 {0, 30, "NotoSansDevanagari-Regular", "hi"},
158 {0, 30, "RobotoCondensed-Regular", "uk"},
159 {0, 30, "NotoSansMyanmar-Condensed", "my"},
160 {0, 30, "RobotoCondensed-Regular", "id"},
161 {0, 30, "RobotoCondensed-Regular", "bg"},
162 {0, 30, "RobotoCondensed-Regular", "hr"},
163 {0, 30, "RobotoCondensed-Regular", "sl"},
164 {0, 30, "RobotoCondensed-Regular", "lt"},
165 {0, 30, "RobotoCondensed-Regular", "lv"},
166 {0, 30, "RobotoCondensed-Regular", "et"},
167 }; // g_langTextDefaultParamTable
168
BitmapFontInit()169 void BitmapFontInit()
170 {
171 UIFontBuilder* uiFontBuilder = UIFontBuilder::GetInstance();
172 if (uiFontBuilder == nullptr) {
173 return;
174 }
175 uiFontBuilder->SetTextLangFontsTable(g_uiTextLangFontsTable, LANGUAGE_FONT_ID_MAX);
176 uiFontBuilder->SetLangTextDefaultParamTable(g_langTextDefaultParamTable, LANGUAGE_MAX);
177 uiFontBuilder->SetMaxTextId(LANGUAGE_TEXT_ID_MAX);
178 }
179 } // namespace OHOS