-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a bunch of PSF2 fonts, converted from the old SDLn ones
- Loading branch information
Showing
344 changed files
with
90,335 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
Fonts for PDCurses for SDL | ||
========================== | ||
|
||
Since PDCurses for SDL uses its own font format, you probably don't have | ||
any ready to use. Here are a few to get you started. The ones in the | ||
top-level directory are as follows: | ||
|
||
10x20.bmp - From the 10x20 font that comes with Xorg | ||
6x12.bmp - From Xorg | ||
9x18.bmp - From Xorg | ||
default.bmp - PDCurses' default font, from pc8x16s.bdf in the | ||
vgafonts.tar.gz package | ||
lc12x20.bmp - Lucida Console at 12x20 | ||
18x18.bmp - From Xorg | ||
8x13.bmp - From Xorg | ||
cour11x17.bmp - From Xorg -- Courier | ||
dosemu.bmp - DOSEmu's default font (8x16) | ||
medieval2.bmp - I always liked the "medieval" font (see fntcol16); | ||
this is an enlarged (16x28), smoothed version | ||
4x6.bmp - From Xorg | ||
9x15.bmp - From Xorg | ||
cour20x29.bmp - From Xorg -- Courier | ||
vga11x19.bmp - From vgafonts, which says it's Lucida Sans Typewriter | ||
|
||
In addition, the fntcol16 directory contains most of the fonts from the | ||
fntcol16.zip package. These are all 8 pixels wide, with the height given | ||
in the filename (e.g., modern-16.bmp). | ||
|
||
|
||
Distribution Status | ||
------------------- | ||
|
||
I'll let copyleft.txt in the fntcol16 directory explain the situation, | ||
and just add that I don't claim any copyright on the compilation, | ||
either. | ||
|
||
-- William McBrine | ||
July 11, 2007 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
PSF2 fonts | ||
========== | ||
|
||
At present, these fonts work only with the Linux framebuffer port. It is likely that they'll eventually be used with SDLn and DOSVGA, and possibly others, thereby enabling a lot of redundant code to be consolidated. | ||
|
||
SDLn in non-wide mode uses its own font format, in which the font is a monochrome Microsoft(R) Windows .bmp file, with 32 characters across and eight down. For example, this is the default SDLn font : | ||
|
||
 | ||
|
||
At one time, a [wide selection of SDL fonts](https://sourceforge.net/projects/pdcurses/files/sdlfonts/1.0/sdlfonts.zip/download) was distributed with PDCurses. The `bmp2psf2` program was written to convert SDL-formatted fonts into the [`psf2` format](https://www.win.tue.nl/~aeb/linux/kbd/font-formats-1.html). `psf2` is more widely used and allows for more than 256 glyphs (in fact, up to 2^32-1 glyphs, with Unicode information.) | ||
|
||
This directory contains the SDL fonts after conversion to the `psf2` format. See the [README file](README) for details on which fonts are which, history, and copyright/licence info. | ||
|
||
[Tools are available elsewhere for manipulating/converting `psf2` fonts.](https://www.seasip.info/Unix/PSF/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
#include <stdio.h> | ||
#include <stdint.h> | ||
#include <string.h> | ||
#include <stdlib.h> | ||
#include <assert.h> | ||
|
||
/* Code to convert SDL fonts for PDCurses into the more generally | ||
useful PSF2 format. The SDL fonts are Microsoft(R) .bmp files, | ||
with one bit per pixel. If you load up the bitmap into a viewing | ||
program, you'll see 256 glyphs arranged in 8 rows of 32 columns. | ||
Thus, if the glyphs are xpix pixels wide and ypix high, the .bmp | ||
will be 32*xpix wide and 8*ypix high. | ||
This program will read in one or more .bmp files, reverse the | ||
above math to determine glyph sizes from the .bmp size, and write | ||
out a PSF2-formatted font file. */ | ||
|
||
#define PSF2_MAGIC0 0x72 | ||
#define PSF2_MAGIC1 0xb5 | ||
#define PSF2_MAGIC2 0x4a | ||
#define PSF2_MAGIC3 0x86 | ||
|
||
/* bits used in flags */ | ||
#define PSF2_HAS_UNICODE_TABLE 0x01 | ||
|
||
/* max version recognized so far */ | ||
#define PSF2_MAXVERSION 0 | ||
|
||
/* UTF8 separators */ | ||
#define PSF2_SEPARATOR 0xFF | ||
#define PSF2_STARTSEQ 0xFE | ||
|
||
struct psf2_header { | ||
uint8_t magic[4]; | ||
uint32_t version; | ||
uint32_t headersize; /* offset of bitmaps in file */ | ||
uint32_t flags; | ||
uint32_t length; /* number of glyphs */ | ||
uint32_t charsize; /* number of bytes for each character */ | ||
uint32_t height, width; /* max dimensions of glyphs */ | ||
/* charsize = height * ((width + 7) / 8) */ | ||
}; | ||
|
||
#define BIT_SET( buff, n) ((buff[(n) >> 3] << ((n) & 7)) & 0x80) | ||
|
||
static void set_up_psf2_header( struct psf2_header *hdr, const int height, const int width) | ||
{ | ||
hdr->magic[0] = PSF2_MAGIC0; | ||
hdr->magic[1] = PSF2_MAGIC1; | ||
hdr->magic[2] = PSF2_MAGIC2; | ||
hdr->magic[3] = PSF2_MAGIC3; | ||
hdr->version = 0; | ||
hdr->headersize = sizeof( struct psf2_header); | ||
hdr->flags = 0; | ||
hdr->length = 256; | ||
hdr->charsize = (uint32_t)( height * ((width + 7) / 8)); | ||
hdr->height = (uint32_t)height; | ||
hdr->width = (uint32_t)width; | ||
} | ||
|
||
static int convert_bmp_font_to_psf2( const char *bmp_filename) | ||
{ | ||
FILE *ifile = fopen( bmp_filename, "rb"), *ofile; | ||
int32_t header_size, width, height; | ||
size_t glyph_size; | ||
char buff[62]; | ||
uint8_t *glyphs; | ||
int i, j; | ||
struct psf2_header hdr; | ||
|
||
assert( ifile); | ||
if( fread( buff, sizeof( buff), 1, ifile) != 1) | ||
assert( 0); | ||
assert( buff[0] == 'B'); | ||
assert( buff[1] == 'M'); | ||
memcpy( &header_size, buff + 14, sizeof( int32_t)); | ||
memcpy( &width, buff + 18, sizeof( int32_t)); | ||
memcpy( &height, buff + 22, sizeof( int32_t)); | ||
printf( "Width %d height %d header len %d\n", (int)width, (int)height, (int)header_size); | ||
glyph_size = (size_t)( width * height / 8); | ||
printf( "Image size should be %d\n", 62 + (int)glyph_size); | ||
glyphs = (uint8_t *)malloc( glyph_size); | ||
if( fread( glyphs, glyph_size, 1, ifile) != 1) | ||
assert( 0); | ||
fclose( ifile); | ||
|
||
strcpy( buff, bmp_filename); | ||
strcpy( strstr( buff, ".bmp"), ".psf"); | ||
ofile = fopen( buff, "wb"); | ||
assert( ofile); | ||
width /= 32; /* cvt from BMP size to size, in pixels, of the */ | ||
height /= 8; /* individual glyphs in the BMP */ | ||
set_up_psf2_header( &hdr, height, width); | ||
if( fwrite( &hdr, sizeof( hdr), 1, ofile) != 1) | ||
assert( 0); | ||
for( i = 0; i < 256; i++) | ||
for( j = 0; j < height; j++) | ||
{ | ||
int x, x1 = (i % 32) * width, k; | ||
int line_no = 8 * height - 1 - j - (i / 32) * height; | ||
uint8_t *line_ptr = glyphs + line_no * width * 32 / 8; | ||
|
||
assert( line_ptr < glyphs + glyph_size); | ||
assert( line_ptr >= glyphs); | ||
for( k = 0; k < (width + 7) / 8; k++) | ||
{ | ||
uint8_t output_byte = 0; | ||
int n_bits = width - k * 8; | ||
|
||
if( n_bits > 8) | ||
n_bits = 8; | ||
for( x = 0; x < n_bits; x++, x1++) | ||
if( BIT_SET( line_ptr, x1)) | ||
output_byte ^= (uint8_t)(0x80 >> x); | ||
if( fwrite( &output_byte, 1, 1, ofile) != 1) | ||
assert( 0); | ||
} | ||
} | ||
fclose( ofile); | ||
return( 0); | ||
} | ||
|
||
int main( const int argc, const char **argv) | ||
{ | ||
int i; | ||
|
||
for( i = 1; i < argc; i++) | ||
convert_bmp_font_to_psf2( argv[i]); | ||
return( 0); | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.