summary refs log tree commit diff
path: root/bin/psfed.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2018-10-03 16:34:09 -0400
committerJune McEnroe <june@causal.agency>2018-10-03 16:34:09 -0400
commit9e54ca8080471ba56a9386c04ec3548e30ca6d52 (patch)
tree7105606b777b504e33fbb489825754d9d64ddfc4 /bin/psfed.c
parentFix ≈ glyph of sans6x8 (diff)
downloadsrc-9e54ca8080471ba56a9386c04ec3548e30ca6d52.tar.gz
src-9e54ca8080471ba56a9386c04ec3548e30ca6d52.zip
Add -H flag to psfed to increase height
Diffstat (limited to 'bin/psfed.c')
-rw-r--r--bin/psfed.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/bin/psfed.c b/bin/psfed.c
index 890ae394..bb7997e2 100644
--- a/bin/psfed.c
+++ b/bin/psfed.c
@@ -504,10 +504,12 @@ int main(int argc, char *argv[]) {
 	uint32_t newLen = 256;
 	uint32_t newWidth = 8;
 	uint32_t newHeight = 16;
+	uint32_t setHeight = 0;
 
 	int opt;
-	while (0 < (opt = getopt(argc, argv, "g:h:w:"))) {
+	while (0 < (opt = getopt(argc, argv, "H:g:h:w:"))) {
 		switch (opt) {
+			break; case 'H': setHeight = strtoul(optarg, NULL, 0);
 			break; case 'g': newLen = strtoul(optarg, NULL, 0);
 			break; case 'h': newHeight = strtoul(optarg, NULL, 0);
 			break; case 'w': newWidth = strtoul(optarg, NULL, 0);
@@ -520,6 +522,24 @@ int main(int argc, char *argv[]) {
 	path = strdup(argv[optind]);
 	fileRead(newLen, newWidth, newHeight);
 
+	if (setHeight) {
+		if (setHeight < header.glyph.height) {
+			errx(EX_CONFIG, "cannot decrease height");
+		}
+
+		uint32_t setSize = bytes(header.glyph.width) * setHeight;
+		uint8_t *setGlyphs = calloc(header.glyph.len, setSize);
+		for (uint32_t i = 0; i < header.glyph.len; ++i) {
+			memcpy(&setGlyphs[setSize * i], glyph(i), header.glyph.size);
+		}
+		free(glyphs);
+		glyphs = setGlyphs;
+
+		header.glyph.height = setHeight;
+		header.glyph.size = setSize;
+		normal.modified = true;
+	}
+
 	frameOpen();
 	frameClear();