Open bauer00 opened 2 years ago
Same issue for me and this is not the same font
I'm also having the same issue with a handful of Google fonts. Here is Quicksand:
Same with Inter font (google fonts), any solutions?
The solution is to download font from other sources. I used https://rsms.me/inter/ and it works fine. The font file size is twice, so i guess google optimizing font for web quite heavily.
Is there a concrete solution for this, facing this issue and can not get higher quality fonts as this is a custom font.
I found a solution here: https://www.reddit.com/r/golang/comments/14ldjiu/problems_with_drawing_fonts_onto_an_image/
Use https://github.com/goki/freetype to load font instead of using https://github.com/golang/freetype.
import (
"github.com/goki/freetype"
"github.com/goki/freetype/truetype"
...
)
// Load font with goki freetype
func loadFontFace(path string) font.Face {
var fontBytes []byte
fontBytes, err := os.ReadFile(FontPath)
if err != nil {
panic(err)
}
font, err := freetype.ParseFont(fontBytes)
if err != nil {
panic(err)
}
face := truetype.NewFace(font, &truetype.Options{
Size: 72,
})
return face
}
Before
dc. LoadFontFace("NotoSansTC-Black.ttf", 72)
After
face := loadFontFace("NotoSansTC-Black.ttf")
dc.SetFontFace(face)
I'm currently using the Google Font "Inter" (https://fonts.google.com/specimen/Inter) and when I draw a text onto an image with that font, some letters with cross sections, like "f" or "t" are rendered transparent in this cross section. I also use the latest version of "gg", 1.3.0.
It looks like this:![grafik](https://user-images.githubusercontent.com/3669176/143210129-a9b187e9-b41b-41fd-962a-093d48736ce2.png)
This is the code I've executed to generate the image above (I've used examples/text.go and changed it a little bit):
Do I need to load the font differently? Or use different settings to draw the text? Or is it an actual render bug withing the gg package?
Thanks for your help.