static int margin_l = 10;
static int margin_r = 10;
static int line_space = 0;
+static int face_index = 0;
static double font_size = 18;
static const char *fore = "#000000";
static const char *back = "#ffffff";
static cairo_surface_t *surface = NULL;
static cairo_pattern_t *fore_pattern = NULL;
static cairo_pattern_t *back_pattern = NULL;
-static FT_Library ft_library;
-static FT_Face ft_face;
static cairo_font_face_t *cairo_face;
G_GNUC_NORETURN static void
version (void)
{
- printf ("hb-view (harfbuzz) %s\n", PACKAGE_VERSION);
+ printf ("hb-view (harfbuzz) %s\n", HB_VERSION_STRING);
exit (0);
}
while (1)
{
int option_index = 0, c;
- static struct option long_options[] = {
+ static const struct option long_options[] = {
{"annotate", 0, &annotate, TRUE},
{"background", 1, 0, 'B'},
{"debug", 0, &debug, TRUE},
{"direction", 1, 0, 'd'},
{"features", 1, 0, 'f'},
{"font-size", 1, 0, 's'},
+ {"face-index", 1, 0, 'i'},
{"foreground", 1, 0, 'F'},
{"help", 0, 0, 'h'},
{"language", 1, 0, 'L'},
case 'v':
version ();
break;
+ case 'i':
+ face_index = atoi (optarg);
+ break;
case 'l':
line_space = atoi (optarg);
break;
case 'm':
switch (sscanf (optarg, "%d %d %d %d", &margin_t, &margin_r, &margin_b, &margin_l)) {
+ default: break;
case 1: margin_r = margin_t;
case 2: margin_b = margin_t;
case 3: margin_l = margin_r;
static cairo_glyph_t *
_hb_cr_text_glyphs (cairo_t *cr,
- const char *text, int len,
+ const char *utf8, int len,
unsigned int *pnum_glyphs)
{
cairo_scaled_font_t *scaled_font = cairo_get_scaled_font (cr);
hb_buffer_set_language (hb_buffer, hb_language_from_string (language));
if (len < 0)
- len = strlen (text);
- hb_buffer_add_utf8 (hb_buffer, text, len, 0, len);
+ len = strlen (utf8);
+ hb_buffer_add_utf8 (hb_buffer, utf8, len, 0, len);
hb_shape (hb_font, hb_buffer, features, num_features);
int
main (int argc, char **argv)
{
+ static FT_Library ft_library;
+ static FT_Face ft_face;
cairo_status_t status;
setlocale (LC_ALL, "");
parse_opts (argc, argv);
FT_Init_FreeType (&ft_library);
- if (FT_New_Face (ft_library, font_file, 0, &ft_face)) {
+ if (FT_New_Face (ft_library, font_file, face_index, &ft_face)) {
fprintf (stderr, "Failed to open font file `%s'\n", font_file);
exit (1);
}