[Request] align-text for canvas' api support more alignments

When lv_canvas’ obj draw a text,
at current api support only 3 text-alignments.


But if a developer want to align the text by baseline or other type.
It is not easy to align the text.

I observe from the other library such as TFT_eSPI
in the library TFT_eSPI when draw text to the tft,
it supports many type of text-alignments
as the following link

If lvgl’s lv_canvas or lv_draw_label(..) supports for many text-alignments more than at the current point of any version of lvgl,
it will be convenient for manupulating the text-alignment.

Thank you.

So do you suggest to replace LV_LABEL_ALIGN_LEFT/RIGHT/CENTER with higher-level alignments which and treat x/y as offset?

Could it be used with other drawings too? E.g. to draw a rectangle to the right top corner.

It’s only my personal opinion but I think with:

  • x
  • y
  • max_w
  • align

you can easily position the label. Or is there complicated in some situations?

When a maker want to display a label on a line,
the maker set only

  • x, y

as the following picture,
line is at y = 120
the maker set only x = 120, y = 120 (center of the screen) and datum = C_BASELINE

Or another example
When a maker want to display number on watch-dial,
he just calculate a rotated point around a pivot point.
and set only the rotated point x, y with MC_DATUM for drawing number on the watch-dial.


I see, thanks for the examples.

In the case of labels align has a different meaning. It determines the alignment of the lines, similarly to the Left/Center/Right alignment in Office Word.

Do you have an idea about how to handle C_BASELINE with multi-line text?

Thank you for meaning of alignment.

C_BASELINE for multi-line text like this way?

situation :
set x, y = (120,120)
if a text is a multi-line text,
the next line is alway x = 120 ?


1 Like