@@ -40,6 +40,9 @@ private slots:
4040 void test_cursor_position_iii ();
4141 void test_performance ();
4242 void test_math_performance ();
43+ void test_in_unicode_range_cyrillic ();
44+ void test_roman_cyrillic_fallback ();
45+ void test_sys_chinese_cyrillic ();
4346};
4447
4548void
@@ -188,5 +191,47 @@ TestSmartFont::test_math_performance () {
188191 fn->get_extents (math_text, ex);
189192}
190193
194+ void
195+ TestSmartFont::test_in_unicode_range_cyrillic () {
196+ // Cyrillic 字符不应该被当作 CJK
197+ QVERIFY (!in_unicode_range (" <#400>" , " cjk" ));
198+ QVERIFY (!in_unicode_range (" <#4FF>" , " cjk" ));
199+ // Cyrillic 字符应该属于 cyrillic range
200+ QVERIFY (in_unicode_range (" <#400>" , " cyrillic" ));
201+ QVERIFY (in_unicode_range (" <#4FF>" , " cyrillic" ));
202+ // Latin 字符不应该属于 cyrillic range
203+ QVERIFY (!in_unicode_range (" a" , " cyrillic" ));
204+ }
205+
206+ void
207+ TestSmartFont::test_roman_cyrillic_fallback () {
208+ // roman 文档中的 Cyrillic 字符应该 fallback 到 default_chinese_font_name
209+ font fn= smart_font (" roman" , " rm" , " medium" , " right" , 10 , 600 );
210+ smart_font_rep* fn_rep= (smart_font_rep*) fn.rep ;
211+ string c = utf8_to_cork (" А" );
212+ int nr = fn_rep->resolve (c);
213+ QVERIFY (nr >= 0 );
214+ string chinese_name= default_chinese_font_name ();
215+ if (chinese_name != " roman" ) {
216+ // 确认没有 fallback 到 roman 的 ecrm 字体
217+ QVERIFY (!occurs (" ecrm" , fn_rep->fn [nr]->res_name ));
218+ }
219+ }
220+
221+ void
222+ TestSmartFont::test_sys_chinese_cyrillic () {
223+ // sys-chinese 文档中的 Cyrillic 字符应该正确路由
224+ font fn= smart_font (" sys-chinese" , " rm" , " medium" , " right" , 10 , 600 );
225+ smart_font_rep* fn_rep= (smart_font_rep*) fn.rep ;
226+ string c = utf8_to_cork (" А" );
227+ int nr = fn_rep->resolve (c);
228+ QVERIFY (nr >= 0 );
229+ string chinese_name= default_chinese_font_name ();
230+ if (chinese_name != " roman" ) {
231+ // 确认没有 fallback 到 roman 的 ecrm 字体
232+ QVERIFY (!occurs (" ecrm" , fn_rep->fn [nr]->res_name ));
233+ }
234+ }
235+
191236QTEST_MAIN (TestSmartFont)
192237#include " smart_font_test.moc"
0 commit comments