Fonts now render properly with a baseline and all that
This commit is contained in:
parent
8ef81ecc7f
commit
85b6e5495e
@ -32,7 +32,7 @@ func (application *Application) Run () (
|
||||
color.RGBA { R: 0x2E, G: 0x34, B: 0x40, A: 0xFF },
|
||||
color.RGBA { R: 0xA8, G: 0x55, B: 0x5D, A: 0xFF },
|
||||
}
|
||||
application.config.fontName = "DMMono"
|
||||
application.config.fontName = ""
|
||||
application.config.fontSize = 11
|
||||
|
||||
application.config.padding = 2
|
||||
|
@ -209,6 +209,14 @@ func (backend *Backend) reallocateCanvas () {
|
||||
backend.drawRune(6, 0, 'i')
|
||||
backend.drawRune(7, 0, 'c')
|
||||
backend.drawRune(8, 0, 'k')
|
||||
backend.drawRune(0, 1, 'b')
|
||||
backend.drawRune(1, 1, 'r')
|
||||
backend.drawRune(2, 1, 'o')
|
||||
backend.drawRune(3, 1, 'w')
|
||||
backend.drawRune(4, 1, 'n')
|
||||
backend.drawRune(6, 1, 'f')
|
||||
backend.drawRune(7, 1, 'o')
|
||||
backend.drawRune(8, 1, 'x')
|
||||
|
||||
backend.canvas.XSurfaceSet(backend.window.Id)
|
||||
backend.canvas.XDraw()
|
||||
@ -219,18 +227,31 @@ func (backend *Backend) drawRune (x, y int, character rune) {
|
||||
// TODO: cache these draws as non-transparent buffers with the
|
||||
// application background color as the background. that way, we won't
|
||||
// need to redraw the characters *or* composite them.
|
||||
_, mask, maskPoint, _, _ := backend.font.face.Glyph (
|
||||
fixed.Point26_6 { },
|
||||
origin := backend.originOfCell(x, y + 1)
|
||||
destinationRectangle, mask, maskPoint, _, _ := backend.font.face.Glyph (
|
||||
fixed.Point26_6 {
|
||||
X: fixed.I(origin.X),
|
||||
Y: fixed.I(origin.Y - backend.metrics.descent),
|
||||
},
|
||||
character)
|
||||
strokeRectangle (
|
||||
|
||||
fillRectangle (
|
||||
&image.Uniform {
|
||||
C: backend.config.Color(stone.ColorForeground),
|
||||
C: backend.config.Color(stone.ColorApplication),
|
||||
},
|
||||
backend.canvas,
|
||||
backend.boundsOfCell(x, y))
|
||||
|
||||
// strokeRectangle (
|
||||
// &image.Uniform {
|
||||
// C: backend.config.Color(stone.ColorForeground),
|
||||
// },
|
||||
// backend.canvas,
|
||||
// backend.boundsOfCell(x, y))
|
||||
|
||||
draw.DrawMask (
|
||||
backend.canvas,
|
||||
backend.boundsOfCell(x, y),
|
||||
destinationRectangle,
|
||||
&image.Uniform {
|
||||
C: backend.config.Color(stone.ColorForeground),
|
||||
},
|
||||
@ -342,6 +363,7 @@ func factory (application *stone.Application) (output stone.Backend, err error)
|
||||
}
|
||||
|
||||
func findAndLoadFont (name string, size float64) (face font.Face) {
|
||||
if name == "" { return }
|
||||
fontPath, err := findfont.Find(name)
|
||||
if err != nil { return }
|
||||
fontFile, err := os.Open(fontPath)
|
||||
|
Loading…
Reference in New Issue
Block a user