Adjusted font_data in graphics lib code to enable different height fonts

pull/70/head
David Tillotson 2021-02-11 23:16:47 +00:00 zatwierdzone przez Phil Howard
rodzic 1fb7dcd358
commit 4cecb920bf
2 zmienionych plików z 9 dodań i 6 usunięć

Wyświetl plik

@ -1,5 +1,7 @@
#include <cstdint>
uint8_t font_height = 6;
uint8_t font_data[96][6] = {
{0x00,0x00,0x00,0x00,0x00,0x00}, //
{0x2e,0x00,0x00,0x00,0x00,0x00}, // !

Wyświetl plik

@ -2,6 +2,7 @@
extern uint8_t font_data[96][6];
extern uint8_t character_widths[96];
extern uint8_t font_height;
namespace pimoroni {
@ -106,13 +107,13 @@ namespace pimoroni {
void PicoGraphics::character(const char c, const Point &p, uint8_t scale) {
uint8_t char_index = c - 32;
Rect char_bounds(p.x, p.y, character_widths[char_index] * scale, 6 * scale);
Rect char_bounds(p.x, p.y, character_widths[char_index] * scale, font_height * scale);
if(!clip.intersects(char_bounds)) return;
const uint8_t *d = &font_data[char_index][0];
for(uint8_t cx = 0; cx < character_widths[char_index]; cx++) {
for(uint8_t cy = 0; cy < 6; cy++) {
for(uint8_t cy = 0; cy < font_height; cy++) {
if((1U << cy) & *d) {
rectangle(Rect(p.x + (cx * scale), p.y + (cy * scale), scale, scale));
}
@ -143,7 +144,7 @@ namespace pimoroni {
// move to the next line
if(co != 0 && co + word_width > (uint32_t)wrap) {
co = 0;
lo += 7 * scale;
lo += (font_height + 1) * scale;
}
// draw word
@ -315,8 +316,8 @@ namespace pimoroni {
}else{
// steep version
int32_t s = std::abs(dy); // number of steps
int32_t sy = dy < 0 ? -1 : 1; // x step value
int32_t sx = (dx << 16) / s; // y step value in fixed 16:16
int32_t sy = dy < 0 ? -1 : 1; // y step value
int32_t sx = (dx << 16) / s; // x step value in fixed 16:16
int32_t y = p1.y;
int32_t x = p1.x << 16;
while(s--) {
@ -326,4 +327,4 @@ namespace pimoroni {
}
}
}
}
}