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

Multi-line text not working #189

Open
petric3 opened this issue Aug 2, 2023 · 1 comment
Open

Multi-line text not working #189

petric3 opened this issue Aug 2, 2023 · 1 comment

Comments

@petric3
Copy link

petric3 commented Aug 2, 2023

Thank you for the great package. I try to study it and make some multi-line text, but it seems I cannot make it work. This is my code:

func main() {
        text := "Hello, World! \nHello, World! \nHello, World!"
	
	// const S = 1024
	const W, H = 1024, 1024
	dc := gg.NewContext(W, H)
	dc.SetRGB(1, 1, 1)
	dc.Clear()
	dc.SetRGB(0, 0, 0)
	if err := dc.LoadFontFace("/home/oem/Downloads/Verdana.ttf", 39); err != nil {
		panic(err)
	}
	dc.DrawStringAnchored(text, W/2, H/2, 0.5, 0.5)
	dc.SavePNG("out.png")
}

And this is the result:
out

I also tried for example:

text := `Hello, World! 
Hello, World! 
Hello, World! 
`

but the result is the same. Is there any other way that I don't know of? Thank you!

@web-xiaxia
Copy link

you can use dc.DrawStringWrapped

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants