[hb-view] Add --face-index to choose a face in a TrueType Collection
authorBehdad Esfahbod <behdad@behdad.org>
Tue, 31 May 2011 16:59:17 +0000 (12:59 -0400)
committerBehdad Esfahbod <behdad@behdad.org>
Tue, 31 May 2011 16:59:17 +0000 (12:59 -0400)
src/hb-view.cc

index 519f6cf..104d95c 100644 (file)
@@ -51,6 +51,7 @@ static int margin_b = 10;
 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";
@@ -106,6 +107,7 @@ parse_opts (int argc, char **argv)
        {"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'},
@@ -131,6 +133,9 @@ parse_opts (int argc, char **argv)
        case 'v':
          version ();
          break;
+       case 'i':
+         face_index = atoi (optarg);
+         break;
        case 'l':
          line_space = atoi (optarg);
          break;
@@ -528,7 +533,7 @@ main (int argc, char **argv)
   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);
   }