fogleman / gg

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

gg doesn't render rtl and bidi text correctly #32

Closed dariubs closed 3 years ago

dariubs commented 6 years ago

There is some problem to render rtl languages text (like arabic, persian, kurdish, hebrew and ...) in gg. The glypes doesnt render currectly.

Example:

package main

import (
    "github.com/fogleman/gg"
    "log"
)

func main() {
    const S = 1024
    im, err := gg.LoadImage("img.jpg")
    if err != nil {
        log.Fatal(err)
    }

    dc := gg.NewContext(S, S)
    dc.SetRGB(1, 1, 1)
    dc.Clear()
    dc.SetRGB(0, 0, 0)
    if err := dc.LoadFontFace("/home/dariush/Newsify/css/iransans/ttf/font.ttf", 96); err != nil {
        panic(err)
    }
    dc.DrawStringAnchored("سلام", S/2, S/2, 0.5, 0.5)

    dc.DrawRoundedRectangle(0, 0, 512, 512, 0)
    dc.DrawImage(im, 0, 0)
    dc.DrawStringAnchored("سلام", S/2, S/2, 0.5, 0.5)
    dc.Clip()
    dc.SavePNG("out.png")
}

output : out

arastu commented 3 years ago

What has happened to this issue? As well, I faced the same problem. cc: @fogleman

arastu commented 3 years ago

It does not seem to be a gg problem, as mentioned in https://github.com/golang/go/issues/27281, the text shaping API is not yet implemented in Golang.