File: hb-draw-all.c

package info (click to toggle)
harfbuzz 12.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 100,084 kB
  • sloc: ansic: 77,785; cpp: 61,949; python: 4,961; xml: 4,651; sh: 426; makefile: 105
file content (45 lines) | stat: -rw-r--r-- 949 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <hb.h>

#include <stdlib.h>
#include <stdio.h>

int main (int argc, char **argv)
{
  if (argc < 2)
  {
    fprintf (stderr, "Usage: %s font-file [font-funcs] [wght]\n", argv[0]);
    return 1;
  }

  hb_face_t *face = hb_face_create_from_file_or_fail (argv[1], 0);

  if (!face)
  {
    fprintf (stderr, "Failed to create face\n");
    return 1;
  }

  hb_font_t *font = hb_font_create (face);

  if (argc > 2)
    hb_font_set_funcs_using (font, argv[2]);

  if (argc > 3)
  {
    hb_variation_t variations[] = {
      { HB_TAG ('w', 'g', 'h', 't'), atoi (argv[3]) },
    };
    hb_font_set_variations (font, variations, 1);
  }

  hb_draw_funcs_t *funcs = hb_draw_funcs_create ();

  unsigned glyph_count = hb_face_get_glyph_count (face);
  for (unsigned gid = 0; gid < glyph_count; gid++)
    hb_font_draw_glyph (font, gid, funcs, NULL);

  hb_draw_funcs_destroy (funcs);
  hb_font_destroy (font);
  hb_face_destroy (face);
  return 0;
}