update(add) packaging directory and spec file from OBSTF:Private, OBS
[framework/uifw/harfbuzz.git] / src / hb-view.cc
index 5dceaf9..31b2a24 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";
@@ -71,8 +72,6 @@ static int height = 0;
 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;
 
 
@@ -86,7 +85,7 @@ usage (FILE *f, int status)
 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);
 }
 
@@ -99,13 +98,14 @@ parse_opts (int argc, char **argv)
   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'},
@@ -131,11 +131,15 @@ parse_opts (int argc, char **argv)
        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;
@@ -341,7 +345,7 @@ static void parse_features (char *s)
 
 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);
@@ -364,8 +368,8 @@ _hb_cr_text_glyphs (cairo_t *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);
 
@@ -521,6 +525,8 @@ draw (void)
 int
 main (int argc, char **argv)
 {
+  static FT_Library ft_library;
+  static FT_Face ft_face;
   cairo_status_t status;
 
   setlocale (LC_ALL, "");
@@ -528,7 +534,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);
   }