Quantcast
Channel: Xojo Programming Forum - Latest topics
Viewing all articles
Browse latest Browse all 3666

Problem centering lines in a canvas

$
0
0

meanwhile I read about this issue and tested a lot of suggestions given in the forum. But I could not come to a solution.

Font and fontsize do not change during execution of the code (paint event of a canvas). But assigning different font-name and size, difference in height comes quicky to the eye.

g.DrawingColor = pQRTxtColor
g.FontName = pFontName
g.FontUnit = FontUnits.Point
g.FontSize = pFontSize
g.Bold = isBold
g.Italic = isItalic

dim mTop as Integer = g.TextHeight//double

dim r as String = “I” + endofline + “go” + endofline + “to” + endofline + “London”

dim mSplitter() as String = split(r, EndOfLine)
dim incr as double = mtop// + (g.TextHeight - g.TextAscent)// *2//integer
for j as Integer = 0 to mSplitter.Ubound
dim theLine as string = mSplitter(j)
g.DrawText(theLine, (g.Width - g.TextWidth(theLine)) / 2, incr)
incr = incr + mTop //+ (g.TextHeight - g.TextAscent)// / 3 -2
next

As you can see from the various alternatives after each commented line (//), I tried a lot of solutions, but I have not come to a stable one.
That is, the overall heigh of the text when drawn center.aligned is never of the same height of the text when drawn as left.aligned.

Suggestions welcome. Thanks.

[removed a few lines because they would not show properly here].

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 3666

Trending Articles