Skip to content

Commit d76ddde

Browse files
committed
Fix test
1 parent b177d01 commit d76ddde

File tree

1 file changed

+37
-26
lines changed

1 file changed

+37
-26
lines changed

Common/3dParty/harfbuzz/test/main.cpp

+37-26
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class CDrawer
8484

8585
/* fonts */
8686
const char *fonts_paths[NUM_EXAMPLES] = {
87-
"C:/Windows/Fonts/arial.ttf",
87+
"C:/Windows/Fonts/calibri.ttf",
8888
//"C:/Windows/Fonts/arial.ttf",
8989
"C:/Users/korol/AppData/Local/Microsoft/Windows/Fonts/ArabicTest.ttf",
9090
"C:/Windows/Fonts/simsun.ttc"
@@ -95,7 +95,7 @@ const char *num_glyph_types[NUM_GLYPH_TYPES] = {"UNCLASSIFIED", "BASE_GLYPH", "L
9595

9696
/* tranlations courtesy of google */
9797
const char *texts[NUM_EXAMPLES] = {
98-
"hello",
98+
"fi",
9999
"لا لآ لأ لا",
100100
"懶惰的姜貓"
101101
};
@@ -107,7 +107,7 @@ const hb_direction_t text_directions[NUM_EXAMPLES] = {
107107
};
108108

109109
const int text_skip[NUM_EXAMPLES] = {
110-
1,
110+
0,
111111
0,
112112
1,
113113
};
@@ -435,6 +435,11 @@ static void print_layout_info_using_private_api(hb_blob_t *blob)
435435
/* end of private API use */
436436
#endif
437437

438+
struct hb_feature_test {
439+
hb_tag_t tag;
440+
uint32_t value;
441+
};
442+
438443
int main(int argc, char *argv[])
439444
{
440445
// hb_blob_t* blobFileTest = hb_blob_create_from_file("C:/Windows/Fonts/calibri.ttf");
@@ -499,28 +504,34 @@ int main(int argc, char *argv[])
499504
hb_buffer_set_language(buf, hb_language_from_string(languages[i], strlen(languages[i])));
500505
// hb_buffer_set_cluster_level (buf, HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES);
501506
// hb_buffer_set_cluster_level (buf, HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS);
502-
hb_buffer_set_cluster_level(buf, HB_BUFFER_CLUSTER_LEVEL_CHARACTERS);
503-
504-
#if 0
505-
#define userfeatures_count 4
506-
hb_feature_t userfeatures[userfeatures_count];
507-
hb_tag_t tags[] = {
508-
HB_TAG('l','i','g','a'),
509-
HB_TAG('c','l','i','g'),
510-
HB_TAG('d','l','i','g'),
511-
HB_TAG('h','l','i','g'),
512-
};
513-
for (int f = 0; f < userfeatures_count; f++)
514-
{
515-
userfeatures[f].tag = tags[f];
516-
userfeatures[f].value = 1;
517-
userfeatures[f].start = HB_FEATURE_GLOBAL_START;
518-
userfeatures[f].end = HB_FEATURE_GLOBAL_END;
519-
}
520-
#else
521-
#define userfeatures_count 0
522-
hb_feature_t *userfeatures = NULL;
523-
#endif
507+
hb_buffer_set_cluster_level(buf, HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES);
508+
509+
hb_feature_test features[] {
510+
{HB_TAG('r','l','i','g'), 1},
511+
{HB_TAG('l','i','g','a'), 0},
512+
{HB_TAG('c','l','i','g'), 1},
513+
{HB_TAG('h','l','i','g'), 1},
514+
{HB_TAG('d','l','i','g'), 1},
515+
{HB_TAG('k','e','r','n'), 2},
516+
{0, 0}
517+
};
518+
519+
int userfeatures_count = 0;
520+
hb_feature_t userfeatures[100];
521+
522+
hb_feature_test* current_feature = features;
523+
while (current_feature->tag != 0)
524+
{
525+
if (current_feature->value != 2)
526+
{
527+
userfeatures[userfeatures_count].tag = current_feature->tag;
528+
userfeatures[userfeatures_count].value = current_feature->value;
529+
userfeatures[userfeatures_count].start = HB_FEATURE_GLOBAL_START;
530+
userfeatures[userfeatures_count].end = HB_FEATURE_GLOBAL_END;
531+
userfeatures_count++;
532+
}
533+
current_feature++;
534+
}
524535

525536
/* Layout the text */
526537
hb_buffer_add_utf8(buf, texts[i], strlen(texts[i]), 0, strlen(texts[i]));
@@ -531,7 +542,7 @@ int main(int argc, char *argv[])
531542
// const char*const pHbShapers[] = { "graphite2", "coretext_aat", "ot", "fallback", nullptr };
532543
// bool ok = hb_shape_full(hb_ft_font[i], buf, userfeatures, userfeatures_count, pHbShapers);
533544

534-
hb_shape(hb_ft_font[i], buf, userfeatures, userfeatures_count);
545+
hb_shape(hb_ft_font[i], buf, (userfeatures_count != 0) ? userfeatures : NULL, userfeatures_count);
535546

536547
unsigned int glyph_count;
537548
hb_glyph_info_t *glyph_info = hb_buffer_get_glyph_infos(buf, &glyph_count);

0 commit comments

Comments
 (0)