Load an actual font
This commit is contained in:
parent
23a04a9cdb
commit
1afbcdb6bc
@ -1,8 +1,8 @@
|
|||||||
package x
|
package x
|
||||||
|
|
||||||
import "image"
|
import "image"
|
||||||
// import "golang.org/x/image/font"
|
import "golang.org/x/image/font"
|
||||||
// import "golang.org/x/image/font/basicfont"
|
import "golang.org/x/image/font/basicfont"
|
||||||
|
|
||||||
import "github.com/jezek/xgb"
|
import "github.com/jezek/xgb"
|
||||||
import "github.com/jezek/xgbutil"
|
import "github.com/jezek/xgbutil"
|
||||||
@ -12,6 +12,7 @@ import "github.com/jezek/xgbutil/xevent"
|
|||||||
import "github.com/jezek/xgbutil/xwindow"
|
import "github.com/jezek/xgbutil/xwindow"
|
||||||
import "github.com/jezek/xgbutil/xgraphics"
|
import "github.com/jezek/xgbutil/xgraphics"
|
||||||
|
|
||||||
|
|
||||||
import "git.tebibyte.media/sashakoshka/stone"
|
import "git.tebibyte.media/sashakoshka/stone"
|
||||||
|
|
||||||
type Backend struct {
|
type Backend struct {
|
||||||
@ -28,6 +29,10 @@ type Backend struct {
|
|||||||
quit chan(struct { })
|
quit chan(struct { })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
font struct {
|
||||||
|
face font.Face
|
||||||
|
}
|
||||||
|
|
||||||
metrics struct {
|
metrics struct {
|
||||||
windowWidth int
|
windowWidth int
|
||||||
windowHeight int
|
windowHeight int
|
||||||
@ -141,6 +146,7 @@ func (backend *Backend) handleXEvent (event xgb.Event) {
|
|||||||
// backend.canvas.Scale (
|
// backend.canvas.Scale (
|
||||||
// backend.metrics.windowWidth,
|
// backend.metrics.windowWidth,
|
||||||
// backend.metrics.windowHeight)
|
// backend.metrics.windowHeight)
|
||||||
|
backend.drawRune(8, 16, 'X')
|
||||||
backend.bindCanvas()
|
backend.bindCanvas()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -193,6 +199,10 @@ func (backend *Backend) bindCanvas () {
|
|||||||
backend.canvas.XPaint(backend.window.Id)
|
backend.canvas.XPaint(backend.window.Id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (backend *Backend) drawRune (x, y int, character rune) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// factory instantiates an X backend.
|
// factory instantiates an X backend.
|
||||||
func factory (application *stone.Application) (output stone.Backend, err error) {
|
func factory (application *stone.Application) (output stone.Backend, err error) {
|
||||||
backend := &Backend {
|
backend := &Backend {
|
||||||
@ -200,10 +210,16 @@ func factory (application *stone.Application) (output stone.Backend, err error)
|
|||||||
config: application.Config(),
|
config: application.Config(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// load font
|
||||||
|
// TODO: load this from a file
|
||||||
|
backend.font.face = basicfont.Face7x13
|
||||||
|
|
||||||
// calculate metrics
|
// calculate metrics
|
||||||
// TODO: base these off of font metrics
|
metrics := backend.font.face.Metrics()
|
||||||
backend.metrics.cellWidth = 8
|
glyphAdvance, _ := backend.font.face.GlyphAdvance('M')
|
||||||
backend.metrics.cellHeight = 16
|
backend.metrics.cellWidth = glyphAdvance.Round()
|
||||||
|
backend.metrics.cellHeight = metrics.Height.Round()
|
||||||
|
backend.metrics.descent = metrics.Descent.Round()
|
||||||
backend.metrics.padding =
|
backend.metrics.padding =
|
||||||
backend.config.Padding() *
|
backend.config.Padding() *
|
||||||
backend.metrics.cellHeight
|
backend.metrics.cellHeight
|
||||||
|
Loading…
Reference in New Issue
Block a user