Browse Source

Add -H flag to psfed to increase height

June 2 months ago
parent
commit
2287c43eef
Signed by: Curtis McEnroe <june@causal.agency> GPG Key ID: CEA2F97ADCFCD77C
2 changed files with 26 additions and 1 deletions
  1. 5
    0
      bin/man/psfed.1
  2. 21
    1
      bin/psfed.c

+ 5
- 0
bin/man/psfed.1 View File

@@ -8,6 +8,7 @@
8 8
 .
9 9
 .Sh SYNOPSIS
10 10
 .Nm
11
+.Op Fl H Ar height
11 12
 .Op Fl g Ar glyphs
12 13
 .Op Fl h Ar height
13 14
 .Op Fl w Ar width
@@ -22,6 +23,10 @@ for the Linux framebuffer.
22 23
 The arguments are as follows:
23 24
 .
24 25
 .Bl -tag -width Ds
26
+.It Fl H Ar height
27
+Modify the height of an existing font.
28
+Only increasing the height is allowed.
29
+.
25 30
 .It Fl g Ar glyphs
26 31
 Set the number of glyphs in a new font.
27 32
 The default number of glyphs is 256.

+ 21
- 1
bin/psfed.c View File

@@ -504,10 +504,12 @@ int main(int argc, char *argv[]) {
504 504
 	uint32_t newLen = 256;
505 505
 	uint32_t newWidth = 8;
506 506
 	uint32_t newHeight = 16;
507
+	uint32_t setHeight = 0;
507 508
 
508 509
 	int opt;
509
-	while (0 < (opt = getopt(argc, argv, "g:h:w:"))) {
510
+	while (0 < (opt = getopt(argc, argv, "H:g:h:w:"))) {
510 511
 		switch (opt) {
512
+			break; case 'H': setHeight = strtoul(optarg, NULL, 0);
511 513
 			break; case 'g': newLen = strtoul(optarg, NULL, 0);
512 514
 			break; case 'h': newHeight = strtoul(optarg, NULL, 0);
513 515
 			break; case 'w': newWidth = strtoul(optarg, NULL, 0);
@@ -520,6 +522,24 @@ int main(int argc, char *argv[]) {
520 522
 	path = strdup(argv[optind]);
521 523
 	fileRead(newLen, newWidth, newHeight);
522 524
 
525
+	if (setHeight) {
526
+		if (setHeight < header.glyph.height) {
527
+			errx(EX_CONFIG, "cannot decrease height");
528
+		}
529
+
530
+		uint32_t setSize = bytes(header.glyph.width) * setHeight;
531
+		uint8_t *setGlyphs = calloc(header.glyph.len, setSize);
532
+		for (uint32_t i = 0; i < header.glyph.len; ++i) {
533
+			memcpy(&setGlyphs[setSize * i], glyph(i), header.glyph.size);
534
+		}
535
+		free(glyphs);
536
+		glyphs = setGlyphs;
537
+
538
+		header.glyph.height = setHeight;
539
+		header.glyph.size = setSize;
540
+		normal.modified = true;
541
+	}
542
+
523 543
 	frameOpen();
524 544
 	frameClear();
525 545
 

Loading…
Cancel
Save