How can I get the width of a single char?

If I chose a not a default fontface in a button .
a error wold thow up while running.
so I can only use the default fontface .

and I can't not choose a fontface while use Canvas, there is no a option there to set.
as we know there are many font's , Monospaced font & Proportional fonts
every charactor have same width in Monospaced fonts , but not in Proportional fonts, 'i' and 'a' has different width for eg.

Obviously, only proportional fonts can be used in the Canvas,
So my problem is ,how to get the width of a string , while I use the DrawText method in the cavas,
for aligning the width of each line.

Yes, there is only one default font. AFAIK there is no way to change that.
Regarding the button, try this: Canvas_ButtonFont.aia (40.2 KB)

Pressing the button two (multiple) times.

1 Like

If you are not doing animation on the Canvas, consider instead displaying your data in a WebView, which can handle SVG graphics and HTML.

How can I get the width of a single char?

Use a label, untick HasMargins in the designer, get width of label

(Close enough may be good enough ?)

1 Like

Getting the width of a single character isn't as helpful as getting the width of a string, because different combinations of consecutive characters fit together differently in a process called kerning, which pushes characters together if they can fit.

Example: WAV


thank you

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.