[justify] Rename hb-view --width to hb-view --justify-to

This commit is contained in:
Behdad Esfahbod 2023-03-01 14:32:06 -07:00
parent 25c66d633d
commit 6de9d2b89f
1 changed files with 9 additions and 9 deletions

View File

@ -161,7 +161,7 @@ struct shape_options_t
} }
else else
{ {
if (width <= 0) if (advance <= 0)
{ {
if (!hb_shape_full (font, buffer, features, num_features, shapers)) if (!hb_shape_full (font, buffer, features, num_features, shapers))
{ {
@ -170,11 +170,11 @@ struct shape_options_t
goto fail; goto fail;
} }
if (width < 0) if (advance < 0)
{ {
float unit = (1 << SUBPIXEL_BITS); float unit = (1 << SUBPIXEL_BITS);
/* Calculate buffer width */ /* Calculate buffer advance */
float w = 0; float w = 0;
unsigned count = 0; unsigned count = 0;
hb_glyph_position_t *pos = hb_buffer_get_glyph_positions (buffer, &count); hb_glyph_position_t *pos = hb_buffer_get_glyph_positions (buffer, &count);
@ -185,7 +185,7 @@ struct shape_options_t
for (unsigned i = 0; i < count; i++) for (unsigned i = 0; i < count; i++)
w += pos[i].y_advance; 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); exit (0);
} }
} }
@ -193,12 +193,12 @@ struct shape_options_t
else else
{ {
float unit = (1 << SUBPIXEL_BITS); float unit = (1 << SUBPIXEL_BITS);
float target_width = width * unit; float target_advance = advance * unit;
float w = 0; float w = 0;
hb_tag_t var_tag; hb_tag_t var_tag;
float var_value; float var_value;
if (!hb_shape_justify (font, buffer, features, num_features, shapers, 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)) &w, &var_tag, &var_value))
{ {
if (error) if (error)
@ -242,7 +242,7 @@ struct shape_options_t
hb_feature_t *features = nullptr; hb_feature_t *features = nullptr;
unsigned int num_features = 0; unsigned int num_features = 0;
char **shapers = nullptr; char **shapers = nullptr;
signed width = 0; signed advance = 0;
hb_bool_t utf8_clusters = false; hb_bool_t utf8_clusters = false;
hb_codepoint_t invisible_glyph = 0; hb_codepoint_t invisible_glyph = 0;
hb_codepoint_t not_found_glyph = 0; hb_codepoint_t not_found_glyph = 0;
@ -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}, {"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}, {"eot", 0, 0, G_OPTION_ARG_NONE, &this->eot, "Treat text as end-of-paragraph", nullptr},
#ifdef HB_EXPERIMENTAL_API #ifdef HB_EXPERIMENTAL_API
{"width", 'w',0, {"justify-to", 0, 0,
G_OPTION_ARG_INT, &this->width, "Target width to justify to", "WIDTH, or -1"}, G_OPTION_ARG_INT, &this->advance, "Target size to justify to", "SIZE, or -1"},
#endif #endif
{"preserve-default-ignorables",0, 0, G_OPTION_ARG_NONE, &this->preserve_default_ignorables, "Preserve Default-Ignorable characters", nullptr}, {"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}, {"remove-default-ignorables",0, 0, G_OPTION_ARG_NONE, &this->remove_default_ignorables, "Remove Default-Ignorable characters", nullptr},