makefont.c (libcaca-0.99.beta19) | : | makefont.c (libcaca-0.99.beta20.tar.bz2) | ||
---|---|---|---|---|
/* | /* | |||
* makefont create libcaca font data | * makefont create libcaca font data | |||
* Copyright (c) 2006-2012 Sam Hocevar <sam@hocevar.net> | * Copyright © 2006—2021 Sam Hocevar <sam@hocevar.net> | |||
* All Rights Reserved | * All Rights Reserved | |||
* | * | |||
* This program is free software. It comes without any warranty, to | * This program is free software. It comes without any warranty, to | |||
* the extent permitted by applicable law. You can redistribute it | * the extent permitted by applicable law. You can redistribute it | |||
* and/or modify it under the terms of the Do What the Fuck You Want | * and/or modify it under the terms of the Do What the Fuck You Want | |||
* to Public License, Version 2, as published by Sam Hocevar. See | * to Public License, Version 2, as published by Sam Hocevar. See | |||
* http://www.wtfpl.net/ for more details. | * http://www.wtfpl.net/ for more details. | |||
* | * | |||
* Usage: | * Usage: | |||
* makefont <prefix> <font> <dpi> <bpp> | * makefont <prefix> <font> <dpi> <bpp> | |||
*/ | */ | |||
skipping to change at line 43 | skipping to change at line 43 | |||
/* Split our big strings into chunks of 480 characters, because it is | /* Split our big strings into chunks of 480 characters, because it is | |||
* the multiple of 32 directly below 509, which is the maximum allowed | * the multiple of 32 directly below 509, which is the maximum allowed | |||
* string size in C89. */ | * string size in C89. */ | |||
#define STRING_CHUNKS 480 | #define STRING_CHUNKS 480 | |||
/* This list is built so that it includes all of ASCII, Latin-1, CP-437, | /* This list is built so that it includes all of ASCII, Latin-1, CP-437, | |||
* and the UTF-8 glyphs necessary for canvas rotation and mirroring. */ | * and the UTF-8 glyphs necessary for canvas rotation and mirroring. */ | |||
static unsigned int const blocklist[] = | static unsigned int const blocklist[] = | |||
{ | { | |||
0x0000, 0x0080, /* Basic latin: A, B, C, a, b, c */ | 0x0020, 0x0080, /* Basic latin: A, B, C, a, b, c */ | |||
#if 0 | ||||
0x0080, 0x0100, /* Latin-1 Supplement: Ä, Ç, å, ß */ | 0x0080, 0x0100, /* Latin-1 Supplement: Ä, Ç, å, ß */ | |||
0x0100, 0x0180, /* Latin Extended-A: Ā č Ō œ */ | 0x0100, 0x0180, /* Latin Extended-A: Ā č Ō œ */ | |||
0x0180, 0x0250, /* Latin Extended-B: Ǝ Ƹ */ | 0x0180, 0x0250, /* Latin Extended-B: Ǝ Ƹ */ | |||
0x0250, 0x02b0, /* IPA Extensions: ɐ ɔ ɘ ʌ ʍ */ | 0x0250, 0x02b0, /* IPA Extensions: ɐ ɔ ɘ ʌ ʍ */ | |||
0x0370, 0x0400, /* Greek and Coptic: Λ α β */ | 0x0370, 0x0400, /* Greek and Coptic: Λ α β */ | |||
0x0400, 0x0500, /* Cyrillic: И Я */ | 0x0400, 0x0500, /* Cyrillic: И Я */ | |||
0x0530, 0x0590, /* Armenian: Ո */ | 0x0530, 0x0590, /* Armenian: Ո */ | |||
0x1401, 0x1677, /* Unified Canadian Aboriginal Syllabics: ᒐ ᗡ */ | 0x1401, 0x1677, /* Unified Canadian Aboriginal Syllabics: ᒐ ᗡ */ | |||
0x1d00, 0x1d80, /* Phonetic Extensions: ᴉ ᵷ */ | 0x1d00, 0x1d80, /* Phonetic Extensions: ᴉ ᵷ */ | |||
0x2000, 0x2070, /* General Punctuation: ‘’ “” */ | 0x2000, 0x2070, /* General Punctuation: ‘’ “” */ | |||
skipping to change at line 66 | skipping to change at line 67 | |||
0x2300, 0x2400, /* Miscellaneous Technical: ⌐ ⌂ ⌠ ⌡ */ | 0x2300, 0x2400, /* Miscellaneous Technical: ⌐ ⌂ ⌠ ⌡ */ | |||
0x2500, 0x2580, /* Box Drawing: ═ ║ ╗ ╔ ╩ */ | 0x2500, 0x2580, /* Box Drawing: ═ ║ ╗ ╔ ╩ */ | |||
0x2580, 0x25a0, /* Block Elements: ▛ ▞ ░ ▒ ▓ */ | 0x2580, 0x25a0, /* Block Elements: ▛ ▞ ░ ▒ ▓ */ | |||
0x25a0, 0x2600, /* Geometric Shapes: ◆ ○ ● */ | 0x25a0, 0x2600, /* Geometric Shapes: ◆ ○ ● */ | |||
0x2600, 0x2700, /* Miscellaneous Symbols: ♥ ★ ☭ */ | 0x2600, 0x2700, /* Miscellaneous Symbols: ♥ ★ ☭ */ | |||
0x3000, 0x3040, /* CJK Symbols and Punctuation: 。「」 */ | 0x3000, 0x3040, /* CJK Symbols and Punctuation: 。「」 */ | |||
0x3040, 0x30a0, /* Hiragana: で す */ | 0x3040, 0x30a0, /* Hiragana: で す */ | |||
0x30a0, 0x3100, /* Katakana: ロ ル */ | 0x30a0, 0x3100, /* Katakana: ロ ル */ | |||
0xff00, 0xfff0, /* Halfwidth and Fullwidth Forms: A, B, C, a, b, c */ | 0xff00, 0xfff0, /* Halfwidth and Fullwidth Forms: A, B, C, a, b, c */ | |||
0x10400, 0x10450, /* Deseret: 𐐒 𐐋 */ | 0x10400, 0x10450, /* Deseret: 𐐒 𐐋 */ | |||
#endif | ||||
0, 0 | 0, 0 | |||
}; | }; | |||
struct glyph | struct glyph | |||
{ | { | |||
uint32_t unicode; | uint32_t unicode; | |||
char buf[10]; | char buf[10]; | |||
unsigned int same_as; | unsigned int same_as; | |||
unsigned int data_offset; | unsigned int data_offset; | |||
unsigned int data_width; | unsigned int data_width; | |||
skipping to change at line 320 | skipping to change at line 322 | |||
n = 0; | n = 0; | |||
for(b = 0; blocklist[b + 1]; b += 2) | for(b = 0; blocklist[b + 1]; b += 2) | |||
{ | { | |||
for(i = blocklist[b]; i < blocklist[b + 1]; i++) | for(i = blocklist[b]; i < blocklist[b + 1]; i++) | |||
{ | { | |||
/* Print glyph value in comment */ | /* Print glyph value in comment */ | |||
printf("/* "); | printf("/* "); | |||
printf_unicode(>ab[n]); | printf_unicode(>ab[n]); | |||
if(gtab[n].same_as == n) | if(gtab[n].same_as == n) | |||
printf_hex(" */ %s\n", | { | |||
glyph_data + gtab[n].data_offset, gtab[n].data_size); | char const *lut = " .:nmW@"; | |||
printf("\n"); | ||||
for (int y = 0; y < height; ++y) | ||||
{ | ||||
for (int x = 0; x < gtab[n].data_width; ++x) | ||||
{ | ||||
int val = glyph_data[gtab[n].data_offset + y * gtab[n].d | ||||
ata_width + x]; | ||||
char ch = lut[val * val * 7 / 256 / 256]; | ||||
printf("%c%c", ch, ch); | ||||
} | ||||
printf("\n"); | ||||
} | ||||
//printf_hex(" */ %s\n", | ||||
// glyph_data + gtab[n].data_offset, gtab[n].data_size | ||||
); | ||||
} | ||||
else | else | |||
{ | { | |||
printf(" is "); | printf(" is "); | |||
printf_unicode(>ab[gtab[n].same_as]); | printf_unicode(>ab[gtab[n].same_as]); | |||
printf(" */\n"); | printf(" */\n"); | |||
} | } | |||
n++; | n++; | |||
} | } | |||
} | } | |||
End of changes. 4 change blocks. | ||||
6 lines changed or deleted | 24 lines changed or added |