|
@@ -92,6 +92,26 @@ func text_to_hextext(line string) string {
|
|
|
return output
|
|
|
}
|
|
|
|
|
|
+// Attempt to fix broken fonts.
|
|
|
+// This verifies that the character offsets are proceeded
|
|
|
+// by a null character.
|
|
|
+func FontFixup(offsets []uint16, data *[]byte) bool {
|
|
|
+ fixed := false
|
|
|
+ for _, offset := range offsets {
|
|
|
+ if offset == 65535 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ if offset == 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ if (*data)[offset-1] != 0 {
|
|
|
+ (*data)[offset-1] = 0
|
|
|
+ fixed = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return fixed
|
|
|
+}
|
|
|
+
|
|
|
func ExtractColor(name string, offsets []uint16, data []byte) {
|
|
|
fmt.Printf("Extract Color Font: %s\n", name)
|
|
|
var indexes []int
|
|
@@ -150,12 +170,18 @@ func ExtractColor(name string, offsets []uint16, data []byte) {
|
|
|
single = append(single, -1)
|
|
|
continue
|
|
|
}
|
|
|
+ found := false
|
|
|
for idx, i := range indexes {
|
|
|
if o == uint16(i) {
|
|
|
single = append(single, idx)
|
|
|
+ found = true
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
+ if !found {
|
|
|
+ fmt.Printf("Unable to locate index %d / %x (font corrupted)", o, o)
|
|
|
+ return
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// Handle Names with spaces
|
|
@@ -265,12 +291,18 @@ func ExtractBlock(name string, offsets []uint16, data []byte) {
|
|
|
single = append(single, -1)
|
|
|
continue
|
|
|
}
|
|
|
+ found := false
|
|
|
for idx, i := range indexes {
|
|
|
if o == uint16(i) {
|
|
|
single = append(single, idx)
|
|
|
+ found = true
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
+ if !found {
|
|
|
+ fmt.Printf("Unable to locate index %d / %x (font corrupted)", o, o)
|
|
|
+ return
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// Handle Names with spaces
|
|
@@ -372,6 +404,10 @@ func ExtractFonts(filename string, fonts []string) {
|
|
|
data := make([]byte, BlockSize)
|
|
|
binary.Read(f, binary.LittleEndian, &data)
|
|
|
|
|
|
+ if FontFixup(letterOffsets, &data) {
|
|
|
+ fmt.Printf("Attempting to *FIX* Font %s\n", Name)
|
|
|
+ }
|
|
|
+
|
|
|
// Special case where they are asking for all fonts
|
|
|
if len(fonts) == 1 && fonts[0] == "*" {
|
|
|
switch FontType {
|