@@ -84,7 +84,7 @@ class CDrawer
84
84
85
85
/* fonts */
86
86
const char *fonts_paths[NUM_EXAMPLES] = {
87
- " C:/Windows/Fonts/arial .ttf" ,
87
+ " C:/Windows/Fonts/calibri .ttf" ,
88
88
// "C:/Windows/Fonts/arial.ttf",
89
89
" C:/Users/korol/AppData/Local/Microsoft/Windows/Fonts/ArabicTest.ttf" ,
90
90
" C:/Windows/Fonts/simsun.ttc"
@@ -95,7 +95,7 @@ const char *num_glyph_types[NUM_GLYPH_TYPES] = {"UNCLASSIFIED", "BASE_GLYPH", "L
95
95
96
96
/* tranlations courtesy of google */
97
97
const char *texts[NUM_EXAMPLES] = {
98
- " hello " ,
98
+ " fi " ,
99
99
" لا لآ لأ لا" ,
100
100
" 懶惰的姜貓"
101
101
};
@@ -107,7 +107,7 @@ const hb_direction_t text_directions[NUM_EXAMPLES] = {
107
107
};
108
108
109
109
const int text_skip[NUM_EXAMPLES] = {
110
- 1 ,
110
+ 0 ,
111
111
0 ,
112
112
1 ,
113
113
};
@@ -435,6 +435,11 @@ static void print_layout_info_using_private_api(hb_blob_t *blob)
435
435
/* end of private API use */
436
436
#endif
437
437
438
+ struct hb_feature_test {
439
+ hb_tag_t tag;
440
+ uint32_t value;
441
+ };
442
+
438
443
int main (int argc, char *argv[])
439
444
{
440
445
// hb_blob_t* blobFileTest = hb_blob_create_from_file("C:/Windows/Fonts/calibri.ttf");
@@ -499,28 +504,34 @@ int main(int argc, char *argv[])
499
504
hb_buffer_set_language (buf, hb_language_from_string (languages[i], strlen (languages[i])));
500
505
// hb_buffer_set_cluster_level (buf, HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES);
501
506
// 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
+ }
524
535
525
536
/* Layout the text */
526
537
hb_buffer_add_utf8 (buf, texts[i], strlen (texts[i]), 0 , strlen (texts[i]));
@@ -531,7 +542,7 @@ int main(int argc, char *argv[])
531
542
// const char*const pHbShapers[] = { "graphite2", "coretext_aat", "ot", "fallback", nullptr };
532
543
// bool ok = hb_shape_full(hb_ft_font[i], buf, userfeatures, userfeatures_count, pHbShapers);
533
544
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);
535
546
536
547
unsigned int glyph_count;
537
548
hb_glyph_info_t *glyph_info = hb_buffer_get_glyph_infos (buf, &glyph_count);
0 commit comments