aboutsummaryrefslogtreecommitdiff
path: root/main.go
blob: 7b90c4dc41db0b0e3b5c4a8781da64ce1cd099a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package main

import "fmt"

var selector = map[string]string{
	"Roman Plain":            "romanp.hmp",
	"Roman Simplex":          "romans.hmp",
	"Roman Duplex":           "romand.hmp",
	"Roman Complex":          "romanc.hmp",
	"Roman Complex Small":    "romancs.hmp",
	"Roman Triplex":          "romant.hmp",
	"Script Simplex":         "scripts.hmp",
	"Script Complex":         "scriptc.hmp",
	"Italic Complex":         "italicc.hmp",
	"Italic Complex Small":   "italiccs.hmp",
	"Italic Triplex":         "italict.hmp",
	"Greek Plain":            "greekp.hmp",
	"Greek Simplex":          "greeks.hmp",
	"Greek Complex":          "greekc.hmp",
	"Greek Complex Small":    "greekcs.hmp",
	"Cyrillic Complex":       "cyrilc.hmp",
	"Gothic English Triplex": "gothgbt.hmp",
	"Gothic German Triplex":  "gothgrt.hmp",
	"Gothic Italian Triplex": "gothitt.hmp",
}

func printAll(f Font) {
	var x, y Unit

	for i := 32; i < 128; i++ {
		gl := f[rune(i)]
		if y+gl.W >= 4000 {
			y = 0
			x += 100
		}
		fmt.Printf("^%v,%v,%s", x, y, gl)
		y += gl.W
	}
}

func printStruct(f Font) {
	fmt.Println("var height = Unit(72)")
	fmt.Println("var font = Font{")
	for i := 0; i < len(f); i++ {
		r := rune(i+32)
		gl := f[r]
		fmt.Printf("%q: Glyph{\n", r)
		fmt.Println("S: Set{")
		for _, s := range gl.S {
			fmt.Println("Path{")
			for _, p := range s {
				fmt.Printf("Point{%v, %v},\n", p.X, p.Y)
			}
			fmt.Println("},")
		}
		fmt.Println("},")
		fmt.Printf("W: %v,\n", gl.W)
		fmt.Println("},")
	}
	fmt.Println("}")
}

func main() {
	f := loadFont("data/hershey", Unit(2))
	m := getMap("data/" + selector["Roman Simplex"])
	fnt := f.Select(m)
	printStruct(fnt)
}