[util] Remove main_font_text_t class, use bare function
This commit is contained in:
parent
58c223357b
commit
5545eea7e5
|
@ -113,6 +113,5 @@ struct shape_closure_consumer_t
|
|||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
main_font_text_t<shape_closure_consumer_t, font_options_t, text_options_t> driver;
|
||||
return driver.main (argc, argv);
|
||||
return main_font_text<shape_closure_consumer_t, font_options_t, text_options_t> (argc, argv);
|
||||
}
|
||||
|
|
|
@ -159,7 +159,7 @@ struct output_buffer_t
|
|||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
using driver_t = main_font_text_t<shape_consumer_t<output_buffer_t>, font_options_t, text_options_t>;
|
||||
auto main_func = main_font_text<shape_consumer_t<output_buffer_t>, font_options_t, text_options_t>;
|
||||
|
||||
if (argc == 2 && !strcmp (argv[1], "--batch"))
|
||||
{
|
||||
|
@ -185,13 +185,11 @@ main (int argc, char **argv)
|
|||
start_offset = argc == 2 && p[0] != '\0' && p[0] != ':' && p[1] == ':' && (p[2] == '\\' || p[2] == '/') ? 2 : 0;
|
||||
}
|
||||
|
||||
driver_t driver;
|
||||
ret |= driver.main (argc, args, EOF);
|
||||
ret |= main_func (argc, args, EOF);
|
||||
fflush (stdout);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
driver_t driver;
|
||||
return driver.main (argc, argv);
|
||||
return main_func (argc, argv, '\n');
|
||||
}
|
||||
|
|
|
@ -132,7 +132,7 @@ struct subset_consumer_t : subset_options_t
|
|||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
using driver_t = main_font_text_t<subset_consumer_t, face_options_t, text_options_t>;
|
||||
auto main_func = main_font_text<subset_consumer_t, face_options_t, text_options_t>;
|
||||
|
||||
if (argc == 2 && !strcmp (argv[1], "--batch"))
|
||||
{
|
||||
|
@ -156,8 +156,7 @@ main (int argc, char **argv)
|
|||
args[argc++] = p = e;
|
||||
}
|
||||
|
||||
driver_t driver;
|
||||
int result = driver.main (argc, args, EOF);
|
||||
int result = main_func (argc, args, EOF);
|
||||
fprintf (stdout, result == 0 ? "success\n" : "failure\n");
|
||||
fflush (stdout);
|
||||
ret |= result;
|
||||
|
@ -165,6 +164,5 @@ main (int argc, char **argv)
|
|||
return ret;
|
||||
}
|
||||
|
||||
driver_t driver;
|
||||
return driver.main (argc, argv);
|
||||
return main_func (argc, argv, '\n');
|
||||
}
|
||||
|
|
|
@ -35,6 +35,5 @@ const unsigned SUBPIXEL_BITS = 6;
|
|||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
main_font_text_t<shape_consumer_t<view_cairo_t>, font_options_t, text_options_t> driver;
|
||||
return driver.main (argc, argv);
|
||||
return main_font_text<shape_consumer_t<view_cairo_t>, font_options_t, text_options_t> (argc, argv);
|
||||
}
|
||||
|
|
|
@ -31,27 +31,10 @@
|
|||
|
||||
/* main() body for utilities taking font and processing text.*/
|
||||
|
||||
static char *
|
||||
locale_to_utf8 (char *s)
|
||||
{
|
||||
char *t;
|
||||
GError *error = nullptr;
|
||||
|
||||
t = g_locale_to_utf8 (s, -1, nullptr, nullptr, &error);
|
||||
if (!t)
|
||||
{
|
||||
fail (true, "Failed converting text to UTF-8");
|
||||
}
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
template <typename consumer_t, typename font_options_t, typename text_options_t>
|
||||
struct main_font_text_t
|
||||
int
|
||||
main_font_text (int argc, char **argv, int eol = '\n')
|
||||
{
|
||||
int
|
||||
main (int argc, char **argv, int eol = '\n')
|
||||
{
|
||||
|
||||
font_options_t font_opts;
|
||||
text_options_t input;
|
||||
|
@ -83,7 +66,6 @@ struct main_font_text_t
|
|||
consumer.finish (&font_opts);
|
||||
|
||||
return consumer.failed ? 1 : 0;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -70,6 +70,21 @@ fail (hb_bool_t suggest_help, const char *format, ...)
|
|||
exit (1);
|
||||
}
|
||||
|
||||
static inline char *
|
||||
locale_to_utf8 (char *s)
|
||||
{
|
||||
char *t;
|
||||
GError *error = nullptr;
|
||||
|
||||
t = g_locale_to_utf8 (s, -1, nullptr, nullptr, &error);
|
||||
if (!t)
|
||||
{
|
||||
fail (true, "Failed converting text to UTF-8");
|
||||
}
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
struct option_parser_t
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue