shape_closure_consumer_t用 main
①ー2:shape_closure_consumer_t用
110 int 111 main (int argc, char **argv) 112 { 113 main_font_text_t<shape_closure_consumer_t, FONT_SIZE_NONE, 0> driver; 114 return driver.main (argc, argv); 115 }
②共通 50 template <typename consumer_t, int default_font_size, int subpixel_bits> 51 struct main_font_text_t 52 { 59 int 60 main (int argc, char **argv) 61 { 62 options.parse (&argc, &argv); 63 64 argc--, argv++; 65 if (argc && !font_opts.font_file) font_opts.font_file = locale_to_utf8 (argv[0]), argc--, argv++; 66 if (argc && !input.text && !input.text_file) input.text = locale_to_utf8 (argv[0]), argc--, argv++; 67 if (argc) 68 fail (true, "Too many arguments on the command line"); 69 if (!font_opts.font_file) 70 options.usage (); 71 if (!input.text && !input.text_file) 72 input.text_file = g_strdup ("-"); 73 74 consumer.init (&font_opts); 75 76 hb_buffer_t *buffer = hb_buffer_create (); 77 unsigned int text_len; 78 const char *text; 79 while ((text = input.get_line (&text_len))) 80 consumer.consume_line (buffer, text, text_len, input.text_before, input.text_after); <====== 81 hb_buffer_destroy (buffer); 82 83 consumer.finish (&font_opts); 84 85 return consumer.failed ? 1 : 0; 86 }
③−2:shape_closure_consumer_t用 33 struct shape_closure_consumer_t : option_group_t 34 { 62 void consume_line (hb_buffer_t *buffer, 63 const char *text, 64 unsigned int text_len, 65 const char *text_before, 66 const char *text_after) 67 { 68 hb_set_clear (glyphs); 69 shaper.shape_closure (text, text_len, font, buffer, glyphs); <===シェーパの登録 70 71 if (hb_set_is_empty (glyphs)) 72 return; 73 74 /* Print it out! */ 75 bool first = true; 76 for (hb_codepoint_t i = -1; hb_set_next (glyphs, &i);) 77 { 78 if (first) 79 first = false; 80 else 81 printf (" "); 82 if (show_glyph_names) 83 { 84 char glyph_name[64]; 85 hb_font_glyph_to_string (font, i, glyph_name, sizeof (glyph_name)); 86 printf ("%s", glyph_name); 87 } else 88 printf ("%u", i); 89 } 90 }
254 void shape_closure (const char *text, int text_len, 255 hb_font_t *font, hb_buffer_t *buffer, 256 hb_set_t *glyphs) 257 { 258 hb_buffer_reset (buffer); 259 hb_buffer_add_utf8 (buffer, text, text_len, 0, text_len); 260 setup_buffer (buffer); 261 hb_ot_shape_glyphs_closure (font, buffer, features, num_features, glyphs);<===シェーパの登録 262 }
897 void 898 hb_ot_shape_glyphs_closure (hb_font_t *font, 899 hb_buffer_t *buffer, 900 const hb_feature_t *features, 901 unsigned int num_features, 902 hb_set_t *glyphs) 903 { 904 hb_ot_shape_plan_t plan; 905 906 const char *shapers[] = {"ot", NULL}; 907 hb_shape_plan_t *shape_plan = hb_shape_plan_create_cached ( <===シェーパの登録 font->face, &buffer->props, 908 features, num_features, shapers); 909 910 bool mirror = hb_script_get_horizontal_direction (buffer->props.script) == HB_DIRECTION_RTL; 911 912 unsigned int count = buffer->len; 913 hb_glyph_info_t *info = buffer->info; 914 for (unsigned int i = 0; i < count; i++) 915 add_char (font, buffer->unicode, mirror, info[i].codepoint, glyphs); 916 917 hb_set_t lookups; 918 lookups.init (); 919 hb_ot_shape_plan_collect_lookups (shape_plan, HB_OT_TAG_GSUB, &lookups); 920 921 /* And find transitive closure. */ 922 hb_set_t copy; 923 copy.init (); 924 do { 925 copy.set (glyphs); 926 for (hb_codepoint_t lookup_index = -1; hb_set_next (&lookups, &lookup_index);) 927 hb_ot_layout_lookup_substitute_closure (font->face, lookup_index, glyphs); 928 } while (!copy.is_equal (glyphs)); 929 930 hb_shape_plan_destroy (shape_plan); 931 }