Skip to content

text.BoundString gives a position about a dot to the left #1893

Answered by hajimehoshi
AlbericC asked this question in Q&A
Discussion options

You must be logged in to vote

textDims's origin position is the dot position. And, text.Draw's position is also the dot position. Then, I guess

	text.Draw(screen, g.Msg, fontFace,
		screen.Bounds().Min.X+(screen.Bounds().Dx()-textDims.Dx())/2,
		screen.Bounds().Min.Y+(screen.Bounds().Dy()+textDims.Dy())/2,
		color.White)

should be

	text.Draw(screen, g.Msg, fontFace,
		screen.Bounds().Min.X+(screen.Bounds().Dx()-textDims.Dx())/2-textDims.Min.X,
		screen.Bounds().Min.Y+(screen.Bounds().Dy()-textDims.Dy())/2-textDims.Min.Y,
		color.White)

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@AlbericC
Comment options

Answer selected by AlbericC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1892 on December 06, 2021 03:03.