Skip to content

Commit

Permalink
[justify] Rename hb-view --width to hb-view --justify-to
Browse files Browse the repository at this point in the history
  • Loading branch information
behdad committed Mar 1, 2023
1 parent 25c66d6 commit 6de9d2b
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions util/shape-options.hh
Expand Up @@ -161,7 +161,7 @@ struct shape_options_t
}
else
{
if (width <= 0)
if (advance <= 0)
{
if (!hb_shape_full (font, buffer, features, num_features, shapers))
{
Expand All @@ -170,11 +170,11 @@ struct shape_options_t
goto fail;
}

if (width < 0)
if (advance < 0)
{
float unit = (1 << SUBPIXEL_BITS);

/* Calculate buffer width */
/* Calculate buffer advance */
float w = 0;
unsigned count = 0;
hb_glyph_position_t *pos = hb_buffer_get_glyph_positions (buffer, &count);
Expand All @@ -185,20 +185,20 @@ struct shape_options_t
for (unsigned i = 0; i < count; i++)
w += pos[i].y_advance;

printf ("Default width: %u\n", (unsigned) roundf (w / unit));
printf ("Default size: %u\n", (unsigned) roundf (w / unit));
exit (0);
}
}
#ifdef HB_EXPERIMENTAL_API
else
{
float unit = (1 << SUBPIXEL_BITS);
float target_width = width * unit;
float target_advance = advance * unit;
float w = 0;
hb_tag_t var_tag;
float var_value;
if (!hb_shape_justify (font, buffer, features, num_features, shapers,
target_width - unit * 0.5f, target_width + unit * 0.5f,
target_advance - unit * 0.5f, target_advance + unit * 0.5f,
&w, &var_tag, &var_value))
{
if (error)
Expand Down Expand Up @@ -242,7 +242,7 @@ struct shape_options_t
hb_feature_t *features = nullptr;
unsigned int num_features = 0;
char **shapers = nullptr;
signed width = 0;
signed advance = 0;
hb_bool_t utf8_clusters = false;
hb_codepoint_t invisible_glyph = 0;
hb_codepoint_t not_found_glyph = 0;
Expand Down Expand Up @@ -370,8 +370,8 @@ shape_options_t::add_options (option_parser_t *parser)
{"bot", 0, 0, G_OPTION_ARG_NONE, &this->bot, "Treat text as beginning-of-paragraph", nullptr},
{"eot", 0, 0, G_OPTION_ARG_NONE, &this->eot, "Treat text as end-of-paragraph", nullptr},
#ifdef HB_EXPERIMENTAL_API
{"width", 'w',0,
G_OPTION_ARG_INT, &this->width, "Target width to justify to", "WIDTH, or -1"},
{"justify-to", 0, 0,
G_OPTION_ARG_INT, &this->advance, "Target size to justify to", "SIZE, or -1"},
#endif
{"preserve-default-ignorables",0, 0, G_OPTION_ARG_NONE, &this->preserve_default_ignorables, "Preserve Default-Ignorable characters", nullptr},
{"remove-default-ignorables",0, 0, G_OPTION_ARG_NONE, &this->remove_default_ignorables, "Remove Default-Ignorable characters", nullptr},
Expand Down

0 comments on commit 6de9d2b

Please sign in to comment.