{
option_group_t *option_group = (option_group_t *) data;
option_group->pre_parse (error);
- return *error == nullptr;
+ return !*error;
}
static gboolean
{
option_group_t *option_group = static_cast<option_group_t *>(data);
option_group->post_parse (error);
- return *error == nullptr;
+ return !*error;
}
void
GError *parse_error = nullptr;
if (!g_option_context_parse (context, argc, argv, &parse_error))
{
- if (parse_error != nullptr) {
+ if (parse_error)
+ {
fail (true, "%s", parse_error->message);
//g_error_free (parse_error);
- } else
+ }
+ else
fail (true, "Option parse error");
}
}
static gboolean
+parse_font_extents (const char *name G_GNUC_UNUSED,
+ const char *arg,
+ gpointer data,
+ GError **error G_GNUC_UNUSED)
+{
+ view_options_t *view_opts = (view_options_t *) data;
+ view_options_t::font_extents_t &e = view_opts->font_extents;
+ switch (sscanf (arg, "%lf%*[ ,]%lf%*[ ,]%lf", &e.ascent, &e.descent, &e.line_gap)) {
+ case 1: HB_FALLTHROUGH;
+ case 2: HB_FALLTHROUGH;
+ case 3:
+ view_opts->have_font_extents = true;
+ return true;
+ default:
+ g_set_error (error, G_OPTION_ERROR, G_OPTION_ERROR_BAD_VALUE,
+ "%s argument should be one to three space-separated numbers",
+ name);
+ return false;
+ }
+}
+
+static gboolean
parse_margin (const char *name G_GNUC_UNUSED,
const char *arg,
gpointer data,
{
g_string_free (gs, TRUE);
g_set_error (error, G_OPTION_ERROR, G_OPTION_ERROR_BAD_VALUE,
- "Failed parsing Unicode values at: '%s'", s);
+ "Failed parsing Unicode values at: '%s'", s);
return false;
}
{"background", 0, 0, G_OPTION_ARG_STRING, &this->back, "Set background color (default: " DEFAULT_BACK ")", "rrggbb/rrggbbaa"},
{"foreground", 0, 0, G_OPTION_ARG_STRING, &this->fore, "Set foreground color (default: " DEFAULT_FORE ")", "rrggbb/rrggbbaa"},
{"line-space", 0, 0, G_OPTION_ARG_DOUBLE, &this->line_space, "Set space between lines (default: 0)", "units"},
+ {"font-extents", 0, 0, G_OPTION_ARG_CALLBACK, (gpointer) &parse_font_extents, "Set font ascent/descent/line-gap (default: auto)","one to three numbers"},
{"margin", 0, 0, G_OPTION_ARG_CALLBACK, (gpointer) &parse_margin, "Margin around output (default: " G_STRINGIFY(DEFAULT_MARGIN) ")","one to four numbers"},
{nullptr}
};
{
const char *text;
- if (nullptr == supported_formats)
+ if (!supported_formats)
text = "Set output serialization format";
else
{
line = text;
line_len = text_len;
}
- if (line_len == (unsigned int) -1)
+ if (line_len == UINT_MAX)
line_len = strlen (line);
if (!line_len) {
while (start < num_glyphs)
{
- char buf[1024];
+ char buf[32768];
unsigned int consumed;
start += hb_buffer_serialize_glyphs (buffer, start, num_glyphs,
buf, sizeof (buf), &consumed,