A different font.

It's easy enough to substitute a different font in the call to
Imagemagick's `convert` tool, but in the case of pixel fonts, it will
scale them, so you're not getting a proper bitmap of the pixels, you're
getting a kind of screenshot of the pixels.

I want to make a different machinery for bitmapped pixel fonts, and I
want to make a simple DEFINE-based way to pick them without having to
edit your source code,  e.g. #define font_data font_PublicPixel_22_data
yeah?

After that, simple affine transforms for fake 3D..
This commit is contained in:
Simon Forman 2023-02-28 06:53:31 -08:00
parent 58f779c430
commit 144e73ebc3
3 changed files with 18259 additions and 5922 deletions

View File

@ -1,5 +1,7 @@
FONT=Inconsolata
#FONT=Inconsolata
FONT=Public-Pixel
FFFONT=PublicPixel
POINTSIZE=22
FILL=white
@ -20,7 +22,7 @@ all: font.h
font.h: $(BMPS) convert.py GNUmakefile
python ./convert.py $(FONT) $(POINTSIZE) > font.h
python ./convert.py $(FFFONT) $(POINTSIZE) > font.h
$(TXTS): make_txt_files.py GNUmakefile
python ./make_txt_files.py

File diff suppressed because it is too large Load Diff

View File

@ -19,19 +19,19 @@ void
draw_char(u8 ch, u64 dest_x, u64 dest_y)
{
// Check the inputs.
if (ch < 0 || ch > font_Inconsolata_22_number_of_characters
|| dest_x < 0 || dest_x >= (FRAME_WIDTH - font_Inconsolata_22_width)
|| dest_y < 0 || dest_y >= (FRAME_HEIGHT - font_Inconsolata_22_height))
if (ch < 0 || ch > font_PublicPixel_22_number_of_characters
|| dest_x < 0 || dest_x >= (FRAME_WIDTH - font_PublicPixel_22_width)
|| dest_y < 0 || dest_y >= (FRAME_HEIGHT - font_PublicPixel_22_height))
// No error message or anything, just decline to draw.
return;
carefree_alpha_blend_blit(
frame_buffer,
font_Inconsolata_22_data[ch],
font_PublicPixel_22_data[ch],
FRAME_WIDTH,
dest_x,
dest_y,
font_Inconsolata_22_width,
font_Inconsolata_22_height
font_PublicPixel_22_width,
font_PublicPixel_22_height
);
}
@ -73,8 +73,8 @@ keydown(u64 window_id, u16 keycode)
void
mousedown(u64 window_id, u8 btn_id)
{
u8 ch = rand() % font_Inconsolata_22_number_of_characters;
draw_char(ch, pos_x - font_Inconsolata_22_width, pos_y - font_Inconsolata_22_height);
u8 ch = rand() % font_PublicPixel_22_number_of_characters;
draw_char(ch, pos_x - font_PublicPixel_22_width, pos_y - font_PublicPixel_22_height);
window_draw_frame(window_id, frame_buffer);
}
@ -94,15 +94,15 @@ main()
init_font_data();
wid = window_create(FRAME_WIDTH, FRAME_HEIGHT, "Xerblin", 0);
draw_background(frame_buffer, FRAME_WIDTH, FRAME_HEIGHT);
for (size_t ch = 0; ch < font_Inconsolata_22_number_of_characters; ++ch) {
for (size_t ch = 0; ch < font_PublicPixel_22_number_of_characters; ++ch) {
draw_char(
ch,
128 + (ch % 26) * font_Inconsolata_22_width,
128 + (ch / 26) * font_Inconsolata_22_height
128 + (ch % 26) * font_PublicPixel_22_width,
128 + (ch / 26) * font_PublicPixel_22_height
);
}
u64 w = 3 + 26 * font_Inconsolata_22_width;
u64 h = 4 + 4 * font_Inconsolata_22_height;
u64 w = 3 + 26 * font_PublicPixel_22_width;
u64 h = 4 + 4 * font_PublicPixel_22_height;
carefree_draw_box(frame_buffer, FRAME_WIDTH, 126, 126, w, h, WHITE);
w = 200;
carefree_wu_line(frame_buffer, FRAME_WIDTH, 0, 0, FRAME_WIDTH, FRAME_HEIGHT-1, WHITE);