Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

images.Text: Add support for vertical alignment of text #13414

Open
pranshugaba opened this issue Feb 17, 2025 · 0 comments · May be fixed by #13415
Open

images.Text: Add support for vertical alignment of text #13414

pranshugaba opened this issue Feb 17, 2025 · 0 comments · May be fixed by #13415

Comments

@pranshugaba
Copy link

It would be useful to be able to choose a vertical alignment (relative to the y offset) for text added using images.Text. This becomes useful in the following scenarios when the number of lines of text is not fixed.

  • Centering text vertically.
  • Creating an Open Graph image with a subtitle at a fixed distance below the title. This can be achieved by making the title "bottom" aligned and the subtitle "top" aligned and having the same y offset for both texts.

It is not currently possible to implement these using only the y option which sets a vertical offset for the top of the text relative to the top of the image.

Vertical alignment would complement the horizontal alignment feature (alignx) mentioned in #10849 and added in #13223.

pranshugaba added a commit to pranshugaba/hugo that referenced this issue Feb 18, 2025
Add option ``aligny`` to specify the vertical alignment of the text
with respect to the ``y`` offset from the top of the image. Possible
values of ``aligny`` are ``top`` (default), ``center``, and ``bottom``.

The height of the block of text is measured from the top of the first
line to the baseline of the last line.

- ``top``: (Current behaviour) The top of the first line of the block of
  text is at an offset of ``y`` from the top of the image.

- ``center``: The vertical center of the block of text is at an offset of
  ``y`` from the top of the image.

- ``bottom``: The baseline of the last line of the text is at an offset
  of ``y`` from the top of the image.

Resolves gohugoio#13414
@pranshugaba pranshugaba linked a pull request Feb 18, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant