// text: prove the font layer draws glyphs on the raw screen. package main import ( "fmt" "os" "time" "9front/gui/draw" ) const fontpath = "/lib/font/bit/lucidasans/unicode.8.font" func main() { if err := run(); err != nil { fmt.Fprintf(os.Stderr, "text: %v\n", err) os.Exit(1) } } func run() error { d, err := draw.Init("/dev") if err != nil { return err } defer d.Close() scr := d.Screen r := scr.Rect() f, err := d.OpenFont(fontpath) if err != nil { return err } fmt.Fprintf(os.Stderr, "text: font h=%d ascent=%d\n", f.Height, f.Ascent) // acme's palette: a 25% mix over white, per allocimagemix. bg, err := d.Color(0xFFFFEAFF) if err != nil { return err } ink, err := d.Color(0x000000FF) if err != nil { return err } rule, err := d.Color(0x99994CFF) if err != nil { return err } draw.Draw(scr, r, bg, nil, draw.ZP) y := r.Min.Y + 20 for _, s := range []string{ "Go on Plan 9: glyphs from /lib/font/bit, no libdraw.", "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz", "0123456789 !@#$%^&*()-=[]{};'\\:\"|,./<>?", "width(\"hello\") = " + fmt.Sprint(f.Width("hello")) + " px", time.Now().Format("Mon 2 Jan 2006 15:04:05"), } { f.String(scr, draw.Point{X: r.Min.X + 20, Y: y}, ink, s) y += int32(f.Height) + 6 } draw.Draw(scr, draw.Rect(r.Min.X+20, y+8, r.Min.X+520, y+9), rule, nil, draw.ZP) d.Flush() time.Sleep(90 * time.Second) return nil }