のねのBlog

パソコンやソフト開発で起きた問題など書きます。よろしくお願いします。

shape_consumer_t用 main

hb_shape_full()                                                                                              at hb-shape.cc:374 0x7ffff7b413df	
shape_options_t::shape()                                                                              at options.hh:248 0x4049bc	
shape_consumer_t<view_cairo_t>::consume_line()                                    at shape-consumer.hh:61 0x4053b2	
main_font_text_t<shape_consumer_t<view_cairo_t>, 256, 8>::main()       at main-font-text.hh:80 0x4051eb	
main() at hb-view.cc:39 0x404410	
2つ、consume_lineの関数がある。
H A D	shape-consumer.hh	        48 void consume_line (hb_buffer_t *buffer, function in struct:shape_consumer_t 
H A D	hb-ot-shape-closure.cc	62 void consume_line (hb_buffer_t *buffer, function in struct:shape_closure_consumer_t 

①−1:shape_consumer_t用

32 #define DEFAULT_FONT_SIZE 256
33 #define SUBPIXEL_BITS 8
34
35 int
36 main (int argc, char **argv)
37 {
38      main_font_text_t<shape_consumer_t<view_cairo_t>, DEFAULT_FONT_SIZE, SUBPIXEL_BITS> driver;
39      return driver.main (argc, argv);
40 }
②共通
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  }
③−1::shape_consumer_t用
33 template <typename output_t>
34 struct shape_consumer_t
35 {
48  void consume_line (hb_buffer_t  *buffer,
49		     const char   *text,
50		     unsigned int  text_len,
51		     const char   *text_before,
52		     const char   *text_after)
53  {
54       output.new_line ();
55
56       for (unsigned int n = shaper.num_iterations; n; n--)
57       {
58          shaper.populate_buffer (buffer, text, text_len, text_before, text_after);
59          if (n == 1)
60	          output.consume_text (buffer, text, text_len, shaper.utf8_clusters);
61          if (!shaper.shape (font, buffer)) {
62	          failed = true;
63	          hb_buffer_set_length (buffer, 0);
64	          output.shape_failed (buffer, text, text_len, shaper.utf8_clusters);
65	          return;
66          }
67    }
81  void consume_text (hb_buffer_t    *buffer,
82   	                               const char     *text,
83	                               unsigned int  text_len,
84	                               hb_bool_t       utf8_clusters)
85  {
86        g_string_set_size (gs, 0);
87        format.serialize_buffer_of_text (buffer, line_no, text, text_len, font, gs);
88        fprintf (options.fp, "%s", gs->str);
89  }
デバッグ用かな?
774 void
775 format_options_t::serialize_buffer_of_text (hb_buffer_t  *buffer,
776					    unsigned int  line_no,
777					    const char   *text,
778					    unsigned int  text_len,
779					    hb_font_t    *font,
780					    GString      *gs)
781{
782  if (show_text) {
783    serialize_line_no (line_no, gs);
784    g_string_append_c (gs, '(');
785    g_string_append_len (gs, text, text_len);
786    g_string_append_c (gs, ')');
787    g_string_append_c (gs, '\n');
788  }
789
790  if (show_unicode) {
791    serialize_line_no (line_no, gs);
792    serialize_unicode (buffer, gs);
793    g_string_append_c (gs, '\n');
794  }
795}