diff --git a/glyphs/font_atlas.go b/glyphs/font_atlas.go index a59bfb7..8c67df9 100755 --- a/glyphs/font_atlas.go +++ b/glyphs/font_atlas.go @@ -148,8 +148,8 @@ func NewFontAtlasFromFont(f *truetype.Font, face font.Face, pointSize uint) (*Fo Img: image.NewRGBA(image.Rect(0, 0, atlasSizeX, atlasSizeY)), Glyphs: make(map[rune]FontAtlasGlyph, len(glyphs)), - SpaceAdvance: I26_6ToF32(spaceAdv), - LineHeight: I26_6ToF32(lineHeight), + SpaceAdvance: float32(spaceAdv.Ceil()), + LineHeight: float32(lineHeight.Ceil()), } //Clear background to black @@ -167,7 +167,7 @@ func NewFontAtlasFromFont(f *truetype.Font, face font.Face, pointSize uint) (*Fo const drawBoundingBoxes bool = false atlasSizeXFixed := fixed.I(atlasSizeX) - // atlasSizeYFixed := fixed.I(atlasSizeY) + atlasSizeYFixed := fixed.I(atlasSizeY) for _, g := range glyphs { //Glyph metrics @@ -188,17 +188,17 @@ func NewFontAtlasFromFont(f *truetype.Font, face font.Face, pointSize uint) (*Fo nextDotPosDeltaX := bearingXFixed + gWidthFixed + charPaddingXFixed if drawer.Dot.X+nextDotPosDeltaX >= atlasSizeXFixed { + assert.T(drawer.Dot.Y+lineHeight < atlasSizeYFixed, "Failed to create atlas because it did not fit") + drawer.Dot.X = charPaddingXFixed if bearingXFixed < 0 { drawer.Dot.X += absI26_6(bearingXFixed) } drawer.Dot.Y += lineHeight + charPaddingYFixed - - // assert.T(drawer.Dot.Y+largestLineDescent+lineHeight < atlasSizeYFixed, "Failed to create atlas because it did not fit") } - drawer.Dot = fixed.P(drawer.Dot.X.Floor(), drawer.Dot.Y.Floor()) + drawer.Dot = fixed.P(drawer.Dot.X.Round(), drawer.Dot.Y.Round()) //Build and insert glyph struct gTopLeft := image.Point{ diff --git a/main.go b/main.go index 9d48576..5931158 100755 --- a/main.go +++ b/main.go @@ -94,7 +94,7 @@ func (p *program) Init() { fmt.Printf("DPI: %f, font size: %d\n", dpi, p.FontSize) w, h := p.win.SDLWin.GetSize() - p.GlyphRend, err = glyphs.NewGlyphRend("./res/fonts/alm-fixed.ttf", &truetype.Options{Size: float64(p.FontSize), DPI: p.Dpi, SubPixelsX: subPixelX, SubPixelsY: subPixelY, Hinting: hinting}, w, h) + p.GlyphRend, err = glyphs.NewGlyphRend("./res/fonts/arabtype-variable.ttf", &truetype.Options{Size: float64(p.FontSize), DPI: p.Dpi, SubPixelsX: subPixelX, SubPixelsY: subPixelY, Hinting: hinting}, w, h) if err != nil { panic("Failed to create atlas from font file. Err: " + err.Error()) } @@ -190,7 +190,7 @@ func (p *program) Update() { var isDrawingBounds = false var drawManyLines = false -var textToShow = " Hello there يا friend. اسمي عمر wow!" +var textToShow = "Hello there يا friend. اسمي عمر wow!" var xOff float32 = 0 var yOff float32 = 0