Skip to content

Commit

Permalink
fix: fix incorrect vertical alignment in text render
Browse files Browse the repository at this point in the history
The y argument in OIIO::ImageBufAlgo::render_text() should represent the top and bottom edge of the text if vertical alignment is set to TextAlignY::Top and TextAlignY::Bottom. However currently the rendered text is off. The current code adjusts y to point to the top of the text box before rendering the text, but it has to be adjusted to point to the baseline of the text.
There is a current test case, testing vertical alignment, but the reference image seems wrong and has now been updated.

Signed-off-by: peter.horvath <[email protected]>
  • Loading branch information
peterhorvath111 committed Oct 24, 2024
1 parent 4b8accf commit 088332d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/libOpenImageIO/imagebufalgo_draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1104,9 +1104,9 @@ ImageBufAlgo::render_text(ImageBuf& R, int x, int y, string_view text,
if (alignx == TextAlignX::Center)
x -= (textroi.width() / 2 + textroi.xbegin);
if (aligny == TextAlignY::Top)
y += textroi.height();
y -= textroi.ybegin;
if (aligny == TextAlignY::Bottom)
y -= textroi.height();
y -= textroi.yend;
if (aligny == TextAlignY::Center)
y -= (textroi.height() / 2 + textroi.ybegin);

Expand Down
Binary file modified testsuite/oiiotool-text/ref/aligned.tif
Binary file not shown.

0 comments on commit 088332d

Please sign in to comment.