blob: 1708ce9b99196b88448305ef6f9eedf32d9a0718 [file] [log] [blame]
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build ignore
// +build ignore
package main
import (
func main() {
data, offsets := []byte(nil), []int{0}
for _, name := range names {
data = append(data, name...)
offsets = append(offsets, len(data))
b := new(bytes.Buffer)
fmt.Fprintf(b, "// generated by go run gen.go; DO NOT EDIT\n\n")
fmt.Fprintf(b, "package sfnt\n\n")
fmt.Fprintf(b, "const numBuiltInPostNames = %d\n\n", len(names))
fmt.Fprintf(b, "const builtInPostNamesData = \"\" +\n")
for s := data; ; {
if len(s) <= 64 {
fmt.Fprintf(b, "%q\n", s)
fmt.Fprintf(b, "%q +\n", s[:64])
s = s[64:]
fmt.Fprintf(b, "\n")
fmt.Fprintf(b, "var builtInPostNamesOffsets = [...]uint16{\n")
for i, o := range offsets {
fmt.Fprintf(b, "%#04x,", o)
if i%8 == 7 {
fmt.Fprintf(b, "\n")
fmt.Fprintf(b, "\n}\n")
dstUnformatted := b.Bytes()
dst, err := format.Source(dstUnformatted)
if err != nil {
log.Fatalf("format.Source: %v\n\n----\n%s\n----", err, dstUnformatted)
if err := ioutil.WriteFile("data.go", dst, 0666); err != nil {
log.Fatalf("ioutil.WriteFile: %v", err)
// names is the built-in post table names listed at
var names = [258]string{