Skip to content

Commit

Permalink
Use nicer fonts
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Dawson committed Sep 15, 2024
1 parent a42c96a commit 9b9e6c0
Show file tree
Hide file tree
Showing 10 changed files with 8,025 additions and 239 deletions.
Binary file removed build/picorx.uf2
Binary file not shown.
7,991 changes: 7,991 additions & 0 deletions font_16x12.h

Large diffs are not rendered by default.

File renamed without changes.
110 changes: 0 additions & 110 deletions font_Ubuntu_16x12.h

This file was deleted.

110 changes: 0 additions & 110 deletions font_Ubuntu_8x6.h

This file was deleted.

2 changes: 1 addition & 1 deletion ssd1306.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ SOFTWARE.
#include <stdio.h>

#include "ssd1306.h"
#include "font.h"
#include "font_8x5.h"

inline static void swap(int32_t *a, int32_t *b) {
int32_t *t=a;
Expand Down
16 changes: 14 additions & 2 deletions ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,13 @@ void ui::display_print_char(char x, uint32_t scale, uint32_t style)
cursor_y += 9*scale;
}

ssd1306_draw_char(&disp, cursor_x, cursor_y, scale, x, !(style&style_reverse) );
if(scale==1){
ssd1306_draw_char_with_font(&disp, cursor_x, cursor_y, 1, font_8x5, x, !(style&style_reverse));
} else {
ssd1306_draw_char_with_font(&disp, cursor_x, cursor_y, 1, font_16x12, x, !(style&style_reverse));
}

//ssd1306_draw_char(&disp, cursor_x, cursor_y, scale, x, !(style&style_reverse) );
cursor_x += (6*scale);
}

Expand Down Expand Up @@ -170,7 +176,13 @@ void ui::display_print_str(const char str[], uint32_t scale, uint32_t style)
cursor_x = 0;
cursor_y += 9*scale;
}
ssd1306_draw_char(&disp, cursor_x, cursor_y, scale, str[i], colour );

if(scale==1){
ssd1306_draw_char_with_font(&disp, cursor_x, cursor_y, 1, font_8x5, str[i], colour);
} else {
ssd1306_draw_char_with_font(&disp, cursor_x, cursor_y, 1, font_16x12, str[i], colour);
}

if (style&style_bordered) {
if (cursor_x < box_x1) box_x1=cursor_x;
if (cursor_y < box_y1) box_y1=cursor_y;
Expand Down
3 changes: 2 additions & 1 deletion ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
#include "hardware/i2c.h"
#include "quadrature_encoder.pio.h"
#include "ssd1306.h"
#include "font.h"
#include "font_8x5.h"
#include "font_16x12.h"
#include "rx.h"
#include "memory.h"
#include "autosave_memory.h"
Expand Down
12 changes: 7 additions & 5 deletions utils/font.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import imageio
import sys

def draw_character(width, height, x, y, character, of):
def draw_character(width, height, x, y, character, font, of):

#create an image of each glyph using cairo
surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height)
Expand All @@ -20,7 +20,7 @@ def draw_character(width, height, x, y, character, of):
ctx.set_font_size(height)
matrix = cairo.Matrix(xx=width, yy=height)
ctx.set_font_matrix(matrix)
ctx.select_font_face("Ubuntu",
ctx.select_font_face(font,
cairo.FONT_SLANT_NORMAL,
cairo.FONT_WEIGHT_NORMAL)
fo = cairo.FontOptions()
Expand Down Expand Up @@ -72,12 +72,14 @@ def generate_font(height, width, x, y, first_char, last_char, font):
of.write("%u, %u, %u, %u, %u,\n"%(height, width-1, 1, first_char, last_char))
characters = "".join([chr(i) for i in range(first_char, last_char+1)])
for character in characters:
draw_character(width, height, x, y, character, of)
draw_character(width, height, x, y, character, font, of)
of.write(
"""};
#endif
""")

generate_font(16, 12, 1, 13, 32, 127, "Ubuntu")
generate_font(8, 6, 1, 6, 32, 127, "Ubuntu")
#generate_font(16, 12, 1, 13, 32, 127, "Chilanka")
#generate_font(16, 12, 1, 13, 32, 127, "Dhurjati")
generate_font(16, 12, 1, 13, 32, 127, "Liberation-Mono")
#generate_font(8, 6, 1, 6, 32, 127, "Ubuntu")

Loading

0 comments on commit 9b9e6c0

Please sign in to comment.