Skip to content

Commit

Permalink
text: remove Text.aspect_ratio
Browse files Browse the repository at this point in the history
  • Loading branch information
ubitux committed Mar 6, 2024
1 parent 954dfdb commit 7b6b04a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 14 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ Versioning](https://semver.org/spec/v2.0.0.html) for `libnopegl`.
`Text.box` parameter; if 3D positioning is required, traditional transform
nodes can be used

### Removed
- `Text.aspect_ratio`, it now matches the viewport aspect ratio

## [2024.0] [libnopegl 0.11.0] - 2024-02-02
### Added
- `ngl.SceneCfg` now includes the backend capabilities
Expand Down
7 changes: 0 additions & 7 deletions libnopegl/nodes.specs
Original file line number Diff line number Diff line change
Expand Up @@ -3711,13 +3711,6 @@
"choices": "writing_mode",
"flags": [],
"desc": "direction flow per character and line"
},
{
"name": "aspect_ratio",
"type": "rational",
"default": [0,0],
"flags": ["live"],
"desc": "box aspect ratio"
}
]
},
Expand Down
8 changes: 1 addition & 7 deletions libnopegl/src/node_text.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ struct text_opts {
size_t nb_effect_nodes;
int valign, halign;
int writing_mode;
int32_t aspect_ratio[2];
};

struct text_priv {
Expand Down Expand Up @@ -224,10 +223,6 @@ static const struct node_param text_params[] = {
{"writing_mode", NGLI_PARAM_TYPE_SELECT, OFFSET(writing_mode), {.i32=NGLI_TEXT_WRITING_MODE_HORIZONTAL_TB},
.choices=&writing_mode_choices,
.desc=NGLI_DOCSTRING("direction flow per character and line")},
{"aspect_ratio", NGLI_PARAM_TYPE_RATIONAL, OFFSET(aspect_ratio),
.flags=NGLI_PARAM_FLAG_ALLOW_LIVE_CHANGE,
.update_func=set_live_changed,
.desc=NGLI_DOCSTRING("box aspect ratio")},
{NULL}
};

Expand Down Expand Up @@ -269,8 +264,7 @@ static int refresh_geometry(struct ngl_node *node)
/* Text/Box ratio */
const struct ngli_box box = {NGLI_ARG_VEC4(o->box)};
const struct viewport viewport = ngli_gpu_ctx_get_viewport(ctx->gpu_ctx);
const int32_t default_ar[2] = {viewport.width, viewport.height};
const int32_t *ar = o->aspect_ratio[1] ? o->aspect_ratio : default_ar;
const int32_t ar[] = {viewport.width, viewport.height};
const float box_ratio = (float)ar[0] * box.w / ((float)ar[1] * box.h);
const float text_ratio = (float)text->width / (float)text->height;

Expand Down

0 comments on commit 7b6b04a

Please sign in to comment.