From eee7dfd3c97e9e6a8193e4ff54235bc813abb3bc Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Tue, 2 Oct 2018 12:19:48 -0400 Subject: Allow setting colors in psf2png --- bin/man/psf2png.1 | 14 ++++++++++++++ bin/psf2png.c | 15 ++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/man/psf2png.1 b/bin/man/psf2png.1 index bbabd484..288834dc 100644 --- a/bin/man/psf2png.1 +++ b/bin/man/psf2png.1 @@ -8,7 +8,9 @@ . .Sh SYNOPSIS .Nm +.Op Fl b Ar bg .Op Fl c Ar cols +.Op Fl f Ar fg .Op Fl s Ar str .Op Ar file . @@ -23,11 +25,23 @@ on standard output. .Pp The arguments are as follows: .Bl -tag -width Ds +.It Fl b Ar bg +Use +.Ar bg +(hexadecimal RGB) +as background color. +The default background color is black. .It Fl c Ar cols Arrange glyphs in .Ar cols columns. The default number of columns is 32. +.It Fl f Ar fg +Use +.Ar fg +(hexadecimal RGB) +as foreground color. +The default foreground color is white. .It Fl s Ar str Render glyphs for string .Ar str diff --git a/bin/psf2png.c b/bin/psf2png.c index eee4e1a9..0ff3c9ac 100644 --- a/bin/psf2png.c +++ b/bin/psf2png.c @@ -43,11 +43,15 @@ static void pngChunk(const char *type, uint32_t size) { int main(int argc, char *argv[]) { uint32_t cols = 32; const char *str = NULL; + uint32_t fg = 0xFFFFFF; + uint32_t bg = 0x000000; int opt; - while (0 < (opt = getopt(argc, argv, "c:s:"))) { + while (0 < (opt = getopt(argc, argv, "b:c:f:s:"))) { switch (opt) { + break; case 'b': bg = strtoul(optarg, NULL, 16); break; case 'c': cols = strtoul(optarg, NULL, 0); + break; case 'f': fg = strtoul(optarg, NULL, 16); break; case 's': str = optarg; break; default: return EX_USAGE; } @@ -97,7 +101,12 @@ int main(int argc, char *argv[]) { pngChunk("IHDR", 13); pngInt(width); pngInt(height); - pngWrite("\x08\x00\x00\x00\x00", 5); + pngWrite("\x08\x03\x00\x00\x00", 5); + pngInt(crc); + + pngChunk("PLTE", 6); + pngWrite((uint8_t[]) { bg >> 16, bg >> 8, bg }, 3); + pngWrite((uint8_t[]) { fg >> 16, fg >> 8, fg }, 3); pngInt(crc); uint8_t data[height][1 + width]; @@ -110,7 +119,7 @@ int main(int argc, char *argv[]) { for (uint32_t y = 0; y < header.glyph.height; ++y) { for (uint32_t x = 0; x < header.glyph.width; ++x) { uint8_t bit = glyphs[g][y][x / 8] >> (7 - x % 8) & 1; - data[row + y][col + x] = -bit; + data[row + y][col + x] = bit; } } } -- cgit 1.4.1 '>unfollow)
Commit message (Expand)Author
2018-11-28Make use of config.mk and add Darwin.mkJune McEnroe
2018-11-27Rename project catgirlJune McEnroe
2018-11-27Add M-m key to insert a blank lineJune McEnroe
2018-10-28Add notification with notify-sendJune McEnroe
2018-10-28Use const char *argv[] signaturesJune McEnroe
2018-10-23Fix verbose view name in man pageJune McEnroe
2018-10-22Add more URL schemesJune McEnroe
2018-10-22Rework status lineJune McEnroe
2018-10-22Rename status and verbose tagsJune McEnroe
2018-09-16Revert "Race parallel connects"June McEnroe
2018-09-16Race parallel connectsJune McEnroe
2018-09-15Call tls_error when tls_connect_socket failsJune McEnroe
2018-09-15Try successive getaddrinfo resultsJune McEnroe
2018-09-15Render README from chatte.7June McEnroe
2018-09-14Factor out uiPrompt to call on nick changeJune McEnroe
2018-09-14Run test binaries with set -e and semicolonsJune McEnroe
2018-09-14Fail target when any test binary failsJune McEnroe
2018-09-14Run tests in default targetJune McEnroe
2018-09-14Add termEvent testsJune McEnroe
2018-09-14Check width of entire next word including codesJune McEnroe
2018-09-14Remove word handling from formatParseJune McEnroe
2018-09-14Apply consecutive formatting codes at onceJune McEnroe
2018-09-14Add tests for formatParseJune McEnroe
2018-09-13Preview with nick in input windowJune McEnroe
2018-09-13Never send PRIVMSG to TagStatus or TagVerboseJune McEnroe
2018-09-13Move color selection to format.cJune McEnroe
2018-09-13Fix len for format->split at end of stringJune McEnroe
2018-09-13Avoid uninitialized x in uiReadJune McEnroe
2018-09-13Add IRCDefault to colors enumJune McEnroe
2018-09-13Return a format->split even at the end of the stringJune McEnroe
2018-09-13Fix weird tab-complete after commaJune McEnroe
2018-09-13Rewrite UI againJune McEnroe
2018-09-12Add note about C-oJune McEnroe
2018-09-12Use formatParse split to position input cursorJune McEnroe
2018-09-12Factor out IRC formatting parsingJune McEnroe
2018-09-11Add /help equivalent to /manJune McEnroe
2018-09-11Don't render every PM as a pingJune McEnroe
2018-09-11Add urlOpenMatchJune McEnroe
2018-09-10Depend on man.sh for chroot.tar targetJune McEnroe
2018-09-10Set LESSSECURE=1 in man.shJune McEnroe
2018-09-10Add /man commandJune McEnroe
2018-09-10Install man page in chrootJune McEnroe
2018-09-10Install man pageJune McEnroe
2018-09-10Split keys into subsections and document colorsJune McEnroe
2018-09-10Add "blank" lines to chatte.1June McEnroe
2018-09-10Document key bindings in chatte.1June McEnroe
2018-09-08Document slash commands in chatte.1June McEnroe