fogleman / gg

Go Graphics - 2D rendering in Go with a simple API.
https://godoc.org/github.com/fogleman/gg
MIT License
4.39k stars 355 forks source link

Error in MeasureString for multiline strings #49

Closed rekby closed 5 years ago

rekby commented 5 years ago

When I split line with newline symbol: It doesn't add in height, but increase width.

func test() {
    font := LoadFont()
    fontFace := truetype.NewFace(font, &truetype.Options{
        Size: 20,
    })

    ggContext := gg.NewContext(1000, 1000)

    ggContext.SetFontFace(fontFace)
    text1 := "asd asd"
    text2 := "asd\nasd"
    w1, h1 := ggContext.MeasureString(text1)
    w2, h2 := ggContext.MeasureString(text2)
    fmt.Printf("W1: %v, H1: %v\n", w1, h1)
    fmt.Printf("W2: %v, H2: %v\n", w2, h2)
}

I have output:

W1: 50, H1: 20
W2: 58, H2: 20
fogleman commented 5 years ago

Fixed in #52