|
@@ -94,7 +94,7 @@ func text_to_hextext(line string) string {
|
|
}
|
|
}
|
|
|
|
|
|
func ExtractColor(name string, offsets []uint16, data []byte) {
|
|
func ExtractColor(name string, offsets []uint16, data []byte) {
|
|
- fmt.Printf("Extract Color Font: %s\n", name)
|
|
|
|
|
|
+ // fmt.Printf("Extract Color Font: %s\n", name)
|
|
var indexes []int
|
|
var indexes []int
|
|
var blocks [][][]byte
|
|
var blocks [][][]byte
|
|
var current [][]byte
|
|
var current [][]byte
|
|
@@ -155,18 +155,20 @@ func ExtractColor(name string, offsets []uint16, data []byte) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- // Handle Names with spaces
|
|
|
|
- filename := fmt.Sprintf("%s_font.go", strings.Replace(name, " ", "", -1))
|
|
|
|
|
|
+ /*
|
|
|
|
+ // Handle Names with spaces
|
|
|
|
+ filename := fmt.Sprintf("%s_font.go", strings.Replace(name, " ", "", -1))
|
|
|
|
|
|
- fp, err := os.Create(filename)
|
|
|
|
- if err != nil {
|
|
|
|
- panic(err)
|
|
|
|
- }
|
|
|
|
- fmt.Printf("Writing: %s\n", filename)
|
|
|
|
-
|
|
|
|
- defer fp.Close()
|
|
|
|
- writer := bufio.NewWriter(fp)
|
|
|
|
|
|
+ fp, err := os.Create(filename)
|
|
|
|
+ if err != nil {
|
|
|
|
+ panic(err)
|
|
|
|
+ }
|
|
|
|
+ fmt.Printf("Writing: %s\n", filename)
|
|
|
|
|
|
|
|
+ defer fp.Close()
|
|
|
|
+ writer := bufio.NewWriter(fp)
|
|
|
|
+ */
|
|
|
|
+ writer := bufio.NewWriter(os.Stdout)
|
|
// writer.WriteString("package main\n")
|
|
// writer.WriteString("package main\n")
|
|
writer.WriteString("// " + name + "\n\n")
|
|
writer.WriteString("// " + name + "\n\n")
|
|
|
|
|
|
@@ -206,7 +208,7 @@ func ExtractColor(name string, offsets []uint16, data []byte) {
|
|
}
|
|
}
|
|
|
|
|
|
func ExtractBlock(name string, offsets []uint16, data []byte) {
|
|
func ExtractBlock(name string, offsets []uint16, data []byte) {
|
|
- fmt.Printf("Extract Block Font: %s\n", name)
|
|
|
|
|
|
+ // fmt.Printf("Extract Block Font: %s\n", name)
|
|
var indexes []int
|
|
var indexes []int
|
|
var blocks [][][]byte
|
|
var blocks [][][]byte
|
|
var current [][]byte
|
|
var current [][]byte
|
|
@@ -264,17 +266,20 @@ func ExtractBlock(name string, offsets []uint16, data []byte) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- // Handle Names with spaces
|
|
|
|
- filename := fmt.Sprintf("%s_font.go", strings.Replace(name, " ", "", -1))
|
|
|
|
|
|
+ /*
|
|
|
|
+ // Handle Names with spaces
|
|
|
|
+ filename := fmt.Sprintf("%s_font.go", strings.Replace(name, " ", "", -1))
|
|
|
|
|
|
- fp, err := os.Create(filename)
|
|
|
|
- if err != nil {
|
|
|
|
- panic(err)
|
|
|
|
- }
|
|
|
|
- fmt.Printf("Writing: %s\n", filename)
|
|
|
|
|
|
+ fp, err := os.Create(filename)
|
|
|
|
+ if err != nil {
|
|
|
|
+ panic(err)
|
|
|
|
+ }
|
|
|
|
+ fmt.Printf("Writing: %s\n", filename)
|
|
|
|
|
|
- defer fp.Close()
|
|
|
|
- writer := bufio.NewWriter(fp)
|
|
|
|
|
|
+ defer fp.Close()
|
|
|
|
+ writer := bufio.NewWriter(fp)
|
|
|
|
+ */
|
|
|
|
+ writer := bufio.NewWriter(os.Stdout)
|
|
|
|
|
|
// Should this output routine be part of the BlockFont?
|
|
// Should this output routine be part of the BlockFont?
|
|
// I think so!
|
|
// I think so!
|
|
@@ -374,7 +379,7 @@ func ExtractFonts(filename string, fonts []string) {
|
|
case 2:
|
|
case 2:
|
|
ExtractColor(Name, letterOffsets, data)
|
|
ExtractColor(Name, letterOffsets, data)
|
|
default:
|
|
default:
|
|
- fmt.Printf("Sorry, I can't handle Font: %s Type %d!\n", Name, FontType)
|
|
|
|
|
|
+ fmt.Printf("// Sorry, I can't handle Font: %s Type %d!\n", Name, FontType)
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
for _, f := range fonts {
|
|
for _, f := range fonts {
|
|
@@ -385,7 +390,7 @@ func ExtractFonts(filename string, fonts []string) {
|
|
case 2:
|
|
case 2:
|
|
ExtractColor(Name, letterOffsets, data)
|
|
ExtractColor(Name, letterOffsets, data)
|
|
default:
|
|
default:
|
|
- fmt.Printf("Sorry, I can't handle Font: %s Type %d!\n", Name, FontType)
|
|
|
|
|
|
+ fmt.Printf("// Sorry, I can't handle Font: %s Type %d!\n", Name, FontType)
|
|
}
|
|
}
|
|
break
|
|
break
|
|
}
|
|
}
|
|
@@ -395,7 +400,7 @@ func ExtractFonts(filename string, fonts []string) {
|
|
}
|
|
}
|
|
|
|
|
|
func main() {
|
|
func main() {
|
|
- fmt.Println("Font-Out - A TDF (TheDraw Font) file processor.")
|
|
|
|
|
|
+
|
|
var fonts string
|
|
var fonts string
|
|
var defaultPackage string = "main"
|
|
var defaultPackage string = "main"
|
|
var listFonts bool
|
|
var listFonts bool
|
|
@@ -408,11 +413,22 @@ func main() {
|
|
flag.Parse()
|
|
flag.Parse()
|
|
|
|
|
|
if flag.NArg() == 0 {
|
|
if flag.NArg() == 0 {
|
|
|
|
+ fmt.Println("Font-Out - A TDF (TheDraw Font) file processor.")
|
|
fmt.Println("No TDF filenames given.")
|
|
fmt.Println("No TDF filenames given.")
|
|
flag.PrintDefaults()
|
|
flag.PrintDefaults()
|
|
os.Exit(2)
|
|
os.Exit(2)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if !listFonts {
|
|
|
|
+ fmt.Printf("package %s\n\n", defaultPackage)
|
|
|
|
+ fmt.Println("import (")
|
|
|
|
+ fmt.Println(" \"red-green/door\"")
|
|
|
|
+ fmt.Println(")")
|
|
|
|
+ fmt.Println("")
|
|
|
|
+ } else {
|
|
|
|
+ fmt.Println("Font-Out - A TDF (TheDraw Font) file processor.")
|
|
|
|
+ }
|
|
|
|
+
|
|
var fontList []string
|
|
var fontList []string
|
|
if len(fonts) > 0 {
|
|
if len(fonts) > 0 {
|
|
fontList = strings.Split(fonts, ",")
|
|
fontList = strings.Split(fonts, ",")
|
|
@@ -431,10 +447,10 @@ func main() {
|
|
for _, fontfile := range flag.Args() {
|
|
for _, fontfile := range flag.Args() {
|
|
if listFonts {
|
|
if listFonts {
|
|
ListFonts(fontfile)
|
|
ListFonts(fontfile)
|
|
- }
|
|
|
|
-
|
|
|
|
- if len(fontList) > 0 {
|
|
|
|
- ExtractFonts(fontfile, fontList)
|
|
|
|
|
|
+ } else {
|
|
|
|
+ if len(fontList) > 0 {
|
|
|
|
+ ExtractFonts(fontfile, fontList)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|