TODO                 |    2 --
 src/hb-buffer.cc     |    4 ++--
 src/hb-shape.h       |    2 +-
 util/hb-shape.cc     |    6 +++---
 util/helper-cairo.cc |   30 +++++++++++++++++++++++++++++-
 util/helper-cairo.hh |    1 +
 util/options.cc      |    9 ++++++++-
 util/options.hh      |    5 ++++-
 util/view-cairo.hh   |    2 +-
 9 files changed, 49 insertions(+), 12 deletions(-)

New commits:
commit 3cdce6497b2b9aeb2841bf077daa9dd9b196429d
Author: Behdad Esfahbod <beh...@behdad.org>
Date:   Fri Dec 21 16:54:22 2012 -0500

    Remove TODO that I don't intend to fix

diff --git a/TODO b/TODO
index e3abcd1..27ff868 100644
--- a/TODO
+++ b/TODO
@@ -72,7 +72,6 @@ hb-view / hb-shape enhancements:
 ===============================
 
 - Add --width, --height, --auto-size, --align, etc?
-- --features="init=medi=isol=fina=0"
 
 
 Tests to write:
commit 6f69fa283e0a488da811df78bc83c41ed248b688
Author: Behdad Esfahbod <beh...@behdad.org>
Date:   Fri Dec 21 16:51:15 2012 -0500

    Minor

diff --git a/src/hb-shape.h b/src/hb-shape.h
index 90a188d..10a35cb 100644
--- a/src/hb-shape.h
+++ b/src/hb-shape.h
@@ -52,7 +52,7 @@ hb_bool_t
 hb_feature_from_string (const char *str, int len,
                        hb_feature_t *feature);
 
-/* something like 128 bytes is more than enough.
+/* Something like 128 bytes is more than enough.
  * nul-terminates. */
 void
 hb_feature_to_string (hb_feature_t *feature,
commit f4abcbfc628718bb276363746440df06e7658f6e
Author: Behdad Esfahbod <beh...@behdad.org>
Date:   Fri Dec 21 16:48:51 2012 -0500

    Minor

diff --git a/src/hb-buffer.cc b/src/hb-buffer.cc
index 0a5600b..4b644e4 100644
--- a/src/hb-buffer.cc
+++ b/src/hb-buffer.cc
@@ -1071,8 +1071,8 @@ hb_buffer_normalize_glyphs (hb_buffer_t *buffer)
  */
 
 static const char *serialize_formats[] = {
-  "TEXT",
-  "JSON",
+  "text",
+  "json",
   NULL
 };
 
commit 4a765f092d71bb4adeb468c004987a9121d39db5
Author: Behdad Esfahbod <beh...@behdad.org>
Date:   Fri Dec 21 16:48:47 2012 -0500

    Minor

diff --git a/util/hb-shape.cc b/util/hb-shape.cc
index df8524f..852f9cf 100644
--- a/util/hb-shape.cc
+++ b/util/hb-shape.cc
@@ -32,7 +32,7 @@ struct output_buffer_t
 {
   output_buffer_t (option_parser_t *parser)
                  : options (parser,
-                            g_strjoinv (" / ", (gchar**) 
hb_buffer_serialize_list_formats ())),
+                            g_strjoinv ("/", (gchar**) 
hb_buffer_serialize_list_formats ())),
                    format (parser) {}
 
   void init (const font_options_t *font_opts)
commit 9815a88111072aa51e78e258c5f660993b47d4df
Author: Behdad Esfahbod <beh...@behdad.org>
Date:   Fri Dec 21 16:46:53 2012 -0500

    [util] List supported output formats in --help output

diff --git a/util/hb-shape.cc b/util/hb-shape.cc
index adbb034..df8524f 100644
--- a/util/hb-shape.cc
+++ b/util/hb-shape.cc
@@ -31,7 +31,8 @@
 struct output_buffer_t
 {
   output_buffer_t (option_parser_t *parser)
-                 : options (parser),
+                 : options (parser,
+                            g_strjoinv (" / ", (gchar**) 
hb_buffer_serialize_list_formats ())),
                    format (parser) {}
 
   void init (const font_options_t *font_opts)
@@ -49,8 +50,7 @@ struct output_buffer_t
     {
       if (options.explicit_output_format)
        fail (false, "Unknown output format `%s'; supported formats are: %s",
-             options.output_format,
-             g_strjoinv (" / ", (gchar**) hb_buffer_serialize_list_formats 
()));
+             options.output_format, options.supported_formats);
       else
        /* Just default to TEXT if not explicitly requested and the
         * file extension is not recognized. */
diff --git a/util/helper-cairo.cc b/util/helper-cairo.cc
index ee64b00..bc44e8e 100644
--- a/util/helper-cairo.cc
+++ b/util/helper-cairo.cc
@@ -246,7 +246,7 @@ stdio_write_func (void                *closure,
   return CAIRO_STATUS_SUCCESS;
 }
 
-static const char helper_cairo_supported_formats[] =
+const char helper_cairo_supported_formats[] =
   "ansi"
   #ifdef CAIRO_HAS_PNG_FUNCTIONS
   "/png"
diff --git a/util/helper-cairo.hh b/util/helper-cairo.hh
index 2f2c9d4..b2ac9e4 100644
--- a/util/helper-cairo.hh
+++ b/util/helper-cairo.hh
@@ -36,6 +36,7 @@ cairo_scaled_font_t *
 helper_cairo_create_scaled_font (const font_options_t *font_opts,
                                 double font_size);
 
+extern const char helper_cairo_supported_formats[];
 
 cairo_t *
 helper_cairo_create_context (double w, double h,
diff --git a/util/options.cc b/util/options.cc
index 6246654..17ad8e6 100644
--- a/util/options.cc
+++ b/util/options.cc
@@ -367,10 +367,17 @@ text_options_t::add_options (option_parser_t *parser)
 void
 output_options_t::add_options (option_parser_t *parser)
 {
+  const char *text;
+
+  if (NULL == supported_formats)
+    text = "Set output format";
+  else
+    text = g_strdup_printf ("Set output format\n\n    Supported formats are: 
%s", supported_formats);
+
   GOptionEntry entries[] =
   {
     {"output-file",    0, 0, G_OPTION_ARG_STRING,      &this->output_file,     
        "Set output file-name (default: stdout)","filename"},
-    {"output-format",  0, 0, G_OPTION_ARG_STRING,      &this->output_format,   
        "Set output format",                    "format"},
+    {"output-format",  0, 0, G_OPTION_ARG_STRING,      &this->output_format,   
        text,                                   "format"},
     {NULL}
   };
   parser->add_group (entries,
diff --git a/util/options.hh b/util/options.hh
index c664731..02af758 100644
--- a/util/options.hh
+++ b/util/options.hh
@@ -310,9 +310,11 @@ struct text_options_t : option_group_t
 
 struct output_options_t : option_group_t
 {
-  output_options_t (option_parser_t *parser) {
+  output_options_t (option_parser_t *parser,
+                   const char *supported_formats_ = NULL) {
     output_file = NULL;
     output_format = NULL;
+    supported_formats = supported_formats_;
     explicit_output_format = false;
 
     fp = NULL;
@@ -345,6 +347,7 @@ struct output_options_t : option_group_t
 
   const char *output_file;
   const char *output_format;
+  const char *supported_formats;
   bool explicit_output_format;
 
   mutable FILE *fp;
diff --git a/util/view-cairo.hh b/util/view-cairo.hh
index c621984..f273464 100644
--- a/util/view-cairo.hh
+++ b/util/view-cairo.hh
@@ -33,7 +33,7 @@
 
 struct view_cairo_t {
   view_cairo_t (option_parser_t *parser)
-              : output_options (parser),
+              : output_options (parser, helper_cairo_supported_formats),
                 view_options (parser) {}
   ~view_cairo_t (void) {
     if (debug)
commit f95a87b7b813f588c7910ad4785ee68bb452e864
Author: Behdad Esfahbod <beh...@behdad.org>
Date:   Fri Dec 21 16:35:28 2012 -0500

    [util] List supported output formats in hb-view

diff --git a/TODO b/TODO
index 76104fa..e3abcd1 100644
--- a/TODO
+++ b/TODO
@@ -71,7 +71,6 @@ API additions
 hb-view / hb-shape enhancements:
 ===============================
 
-- --output-format should list available formats.
 - Add --width, --height, --auto-size, --align, etc?
 - --features="init=medi=isol=fina=0"
 
diff --git a/util/helper-cairo.cc b/util/helper-cairo.cc
index 35340d1..ee64b00 100644
--- a/util/helper-cairo.cc
+++ b/util/helper-cairo.cc
@@ -246,6 +246,25 @@ stdio_write_func (void                *closure,
   return CAIRO_STATUS_SUCCESS;
 }
 
+static const char helper_cairo_supported_formats[] =
+  "ansi"
+  #ifdef CAIRO_HAS_PNG_FUNCTIONS
+  "/png"
+  #endif
+  #ifdef CAIRO_HAS_SVG_SURFACE
+  "/svg"
+  #endif
+  #ifdef CAIRO_HAS_PDF_SURFACE
+  "/pdf"
+  #endif
+  #ifdef CAIRO_HAS_PS_SURFACE
+  "/ps"
+   #ifdef HAS_EPS
+    "/eps"
+   #endif
+  #endif
+;
+
 cairo_t *
 helper_cairo_create_context (double w, double h,
                             view_options_t *view_opts,
@@ -268,7 +287,13 @@ helper_cairo_create_context (double w, double h,
       extension = "ansi";
     else
 #endif
+    {
+#ifdef CAIRO_HAS_PNG_FUNCTIONS
       extension = "png";
+#else
+      extension = "ansi";
+#endif
+    }
   }
   if (0)
     ;
@@ -317,7 +342,10 @@ helper_cairo_create_context (double w, double h,
   else if (constructor2)
     surface = constructor2 (stdio_write_func, f, w, h, content);
   else
-    fail (false, "Unknown output format `%s'", extension);
+    fail (false, "Unknown output format `%s'; supported formats are: %s%s",
+         extension, helper_cairo_supported_formats,
+         out_opts->explicit_output_format ? "" :
+         "\nTry setting format using --output-format");
 
   cairo_t *cr = cairo_create (surface);
   content = cairo_surface_get_content (surface);
_______________________________________________
HarfBuzz mailing list
HarfBuzz@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/harfbuzz

Reply via email to