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

[bug] GetStringBounds does not account for italics style #92

Open
kodawah opened this issue Nov 4, 2015 · 1 comment
Open

[bug] GetStringBounds does not account for italics style #92

kodawah opened this issue Nov 4, 2015 · 1 comment
Assignees
Labels

Comments

@kodawah
Copy link

kodawah commented Nov 4, 2015

Hi, I'm drawing some text on an image and color its background with ClearRect()

I noticed that when italics is set, the background and the image are incorrectly offset

sample img

see the picture, the string has some space before the text starts, and a section of the 't' is drawn outside the background

for both italics and normal style, GetStringBounds reports l:3.703125, t:-29.546875, r:204.656250, b:0.468750

here is the relevant portions of my code

    l, t, r, b := gc.GetStringBounds(str)
    strWidth  := int(math.Ceil(r)) - int(math.Ceil(l))
    strHeight := int(math.Ceil(t)) - int(math.Ceil(b))

    pointX := (input.Bounds().Dx() - strWidth) / 2
    pointY := (input.Bounds().Dy() - strHeight) / 2

    gc.SetFillColor(color.RGBA{255,255,255,255})
    gc.ClearRect(pointX, pointY, pointX + strWidth, pointY + strHeight)

    gc.SetFillColor(color.RGBA{0,0,0,255})
    gc.FillStringAt(str, float64(pointX), float64(pointY))
@llgcode llgcode self-assigned this Nov 5, 2015
@llgcode
Copy link
Owner

llgcode commented Nov 5, 2015

We need to use the new freetype API to draw and compute string length. It may correct this issue.

@llgcode llgcode added the bug label Nov 5, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants