aboutsummaryrefslogtreecommitdiff
path: root/devtools
diff options
context:
space:
mode:
Diffstat (limited to 'devtools')
-rw-r--r--devtools/convbdf.cpp34
1 files changed, 31 insertions, 3 deletions
diff --git a/devtools/convbdf.cpp b/devtools/convbdf.cpp
index 59ea5cc4e5..5fbcd98b25 100644
--- a/devtools/convbdf.cpp
+++ b/devtools/convbdf.cpp
@@ -38,7 +38,10 @@ struct BdfBoundingBox {
};
struct BdfFont {
+ char *familyName;
+ char *slant;
int maxAdvance;
+ int size;
int height;
BdfBoundingBox defaultBox;
int ascent;
@@ -51,7 +54,7 @@ struct BdfFont {
unsigned char *advances;
BdfBoundingBox *boxes;
- BdfFont() : bitmaps(0), advances(0), boxes(0) {
+ BdfFont() : bitmaps(0), advances(0), boxes(0), familyName(0), slant(0) {
}
~BdfFont() {
@@ -62,6 +65,8 @@ struct BdfFont {
delete[] bitmaps;
delete[] advances;
delete[] boxes;
+ delete[] familyName;
+ delete[] slant;
}
};
@@ -138,7 +143,9 @@ int main(int argc, char *argv[]) {
error("Premature end of file");
if (hasPrefix(line, "SIZE ")) {
- // Ignore
+ int hDpi, vDpi;
+ if (sscanf(line.c_str(), "SIZE %d %d %d", &font.size, &hDpi, &vDpi) != 3)
+ error("Invalid SIZE");
} else if (hasPrefix(line, "FONT ")) {
fontName = line.substr(5);
} else if (hasPrefix(line, "COPYRIGHT ")) {
@@ -159,6 +166,24 @@ int main(int argc, char *argv[]) {
memset(font.bitmaps, 0, sizeof(unsigned char *) * font.numCharacters);
font.advances = new unsigned char[font.numCharacters];
font.boxes = new BdfBoundingBox[font.numCharacters];
+ } else if (hasPrefix(line, "FAMILY_NAME \"")) {
+ font.familyName = new char[line.size()]; // We will definitely fit here
+ strncpy(font.familyName, &line.c_str()[13], line.size() - 1);
+ char *p = &font.familyName[strlen(font.familyName)];
+ while (p != font.familyName && *p != '"')
+ p--;
+ if (p == font.familyName)
+ error("Invalid FAMILY_NAME");
+ *p = '\0'; // Remove last quote
+ } else if (hasPrefix(line, "SLANT \"")) {
+ font.familyName = new char[line.size()]; // We will definitely fit here
+ strncpy(font.familyName, &line.c_str()[7], line.size() - 1);
+ char *p = &font.slant[strlen(font.slant)];
+ while (p != font.slant && *p != '"')
+ p--;
+ if (p == font.slant)
+ error("Invalid SLANT");
+ *p = '\0'; // Remove last quote
} else if (hasPrefix(line, "FONT_ASCENT ")) {
if (sscanf(line.c_str(), "FONT_ASCENT %d", &font.ascent) != 1)
error("Invalid FONT_ASCENT");
@@ -481,7 +506,10 @@ int main(int argc, char *argv[]) {
printf("// Font structure\n"
"static const BdfFontData desc = {\n"
+ "\t\"%s\", // Family name\n"
+ "\t\"%s\", // Slant\n"
"\t%d, // Max advance\n"
+ "\t%d, // Size\n"
"\t%d, // Height\n"
"\t{ %d, %d, %d, %d }, // Bounding box\n"
"\t%d, // Ascent\n"
@@ -491,7 +519,7 @@ int main(int argc, char *argv[]) {
"\t%d, // Characters\n"
"\n"
"\tbitmapTable, // Bitmaps\n",
- font.maxAdvance, font.height, font.defaultBox.width,
+ font.familyName, font.slant, font.maxAdvance, font.size, font.height, font.defaultBox.width,
font.defaultBox.height, font.defaultBox.xOffset, font.defaultBox.yOffset,
font.ascent, font.firstCharacter, font.defaultCharacter, font.numCharacters);