Last active
August 29, 2015 14:22
-
-
Save ajstarks/f2002d8e16f58fc3a443 to your computer and use it in GitHub Desktop.
Make unicode tables
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// uni: make glyph tables | |
package main | |
import ( | |
"flag" | |
"fmt" | |
"os" | |
"github.com/ajstarks/svgo" | |
) | |
func main() { | |
begin := flag.String("begin", "20", "begin (hex)") | |
font := flag.String("font", "Calibri,sans-serif", "font") | |
fsize := flag.Int("fs", 18, "font size (px)") | |
rows := flag.Int("rows", 20, "rows") | |
cols := flag.Int("cols", 16, "columns") | |
flag.Parse() | |
offset := *fsize* 2 | |
top := offset * 2 | |
left := offset * 3 | |
spacing := 5 | |
b := 32 | |
nb, err := fmt.Sscanf(*begin, "%x", &b) | |
if b < 32 || nb != 1 || err != nil { | |
b = 32 | |
} | |
x := left | |
y := top | |
canvas := svg.New(os.Stdout) | |
canvas.Start(1600, 900) | |
canvas.Gstyle(fmt.Sprintf("font-family:%s;font-size:%dpx;text-anchor:middle", *font, *fsize)) | |
for r := 0; r < *rows; r++ { | |
canvas.Text(x-offset, y, fmt.Sprintf("%X", b), "text-anchor:end;fill:lightgray") | |
for c := 0; c < *cols; c++ { | |
if r == 0 { | |
canvas.Text(x, y-offset, fmt.Sprintf("%02X", c), "fill:lightgray") | |
} | |
canvas.Text(x, y, string(b)) | |
b++ | |
x += (offset + spacing) | |
} | |
x = left | |
y += offset | |
} | |
canvas.Gend() | |
canvas.End() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment