You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

507 lines
20 KiB

//! The ProFont programming font. Image data taken from the
//! [ProFont homepage](https://web.archive.org/web/20180412214402/http://tobiasjung.name/profont/)
extern crate embedded_graphics;
use embedded_graphics::fonts::font_builder::{FontBuilder, FontBuilderConf};
const CHARS_PER_ROW: u32 = 32;
#[cfg(test)]
pub(crate) mod mock_display;
#[derive(Debug, Copy, Clone)]
pub enum ProFont7PointConf {}
impl FontBuilderConf for ProFont7PointConf {
const FONT_IMAGE: &'static [u8] = include_bytes!("../data/ProFont7Point.raw");
const CHAR_HEIGHT: u32 = 9;
const CHAR_WIDTH: u32 = 5;
const FONT_IMAGE_WIDTH: u32 = Self::CHAR_WIDTH * CHARS_PER_ROW;
fn char_offset(c: char) -> u32 {
let fallback = '?' as u32 - ' ' as u32;
if c < ' ' {
return fallback;
}
if c <= '~' {
return c as u32 - ' ' as u32;
}
if c < '¡' || c > 'ÿ' {
return fallback;
}
c as u32 - ' ' as u32 - 34
}
}
/// The 7 point size.
pub type ProFont7Point<'a, C> = FontBuilder<'a, C, ProFont7PointConf>;
#[derive(Debug, Copy, Clone)]
pub enum ProFont9PointConf {}
impl FontBuilderConf for ProFont9PointConf {
const FONT_IMAGE: &'static [u8] = include_bytes!("../data/ProFont9Point.raw");
const CHAR_HEIGHT: u32 = 11;
const CHAR_WIDTH: u32 = 6;
const FONT_IMAGE_WIDTH: u32 = Self::CHAR_WIDTH * CHARS_PER_ROW;
fn char_offset(c: char) -> u32 {
let fallback = '?' as u32 - ' ' as u32;
if c < ' ' {
return fallback;
}
if c <= '~' {
return c as u32 - ' ' as u32;
}
if c < '¡' || c > 'ÿ' {
return fallback;
}
c as u32 - ' ' as u32 - 34
}
}
/// The 9 point size.
pub type ProFont9Point<'a, C> = FontBuilder<'a, C, ProFont9PointConf>;
#[derive(Debug, Copy, Clone)]
pub enum ProFont10PointConf {}
impl FontBuilderConf for ProFont10PointConf {
const FONT_IMAGE: &'static [u8] = include_bytes!("../data/ProFont10Point.raw");
const CHAR_HEIGHT: u32 = 13;
const CHAR_WIDTH: u32 = 7;
const FONT_IMAGE_WIDTH: u32 = Self::CHAR_WIDTH * CHARS_PER_ROW;
fn char_offset(c: char) -> u32 {
let fallback = '?' as u32 - ' ' as u32;
if c < ' ' {
return fallback;
}
if c <= '~' {
return c as u32 - ' ' as u32;
}
if c < '¡' || c > 'ÿ' {
return fallback;
}
c as u32 - ' ' as u32 - 34
}
}
/// The 10 point size.
pub type ProFont10Point<'a, C> = FontBuilder<'a, C, ProFont10PointConf>;
#[derive(Debug, Copy, Clone)]
pub enum ProFont12PointConf {}
impl FontBuilderConf for ProFont12PointConf {
const FONT_IMAGE: &'static [u8] = include_bytes!("../data/ProFont12Point.raw");
const CHAR_HEIGHT: u32 = 15;
const CHAR_WIDTH: u32 = 8;
const FONT_IMAGE_WIDTH: u32 = Self::CHAR_WIDTH * CHARS_PER_ROW;
fn char_offset(c: char) -> u32 {
let fallback = '?' as u32 - ' ' as u32;
if c < ' ' {
return fallback;
}
if c <= '~' {
return c as u32 - ' ' as u32;
}
if c < '¡' || c > 'ÿ' {
return fallback;
}
c as u32 - ' ' as u32 - 34
}
}
/// The 12 point size.
pub type ProFont12Point<'a, C> = FontBuilder<'a, C, ProFont12PointConf>;
#[derive(Debug, Copy, Clone)]
pub enum ProFont14PointConf {}
impl FontBuilderConf for ProFont14PointConf {
const FONT_IMAGE: &'static [u8] = include_bytes!("../data/ProFont14Point.raw");
const CHAR_HEIGHT: u32 = 18;
const CHAR_WIDTH: u32 = 10;
const FONT_IMAGE_WIDTH: u32 = Self::CHAR_WIDTH * CHARS_PER_ROW;
fn char_offset(c: char) -> u32 {
let fallback = '?' as u32 - ' ' as u32;
if c < ' ' {
return fallback;
}
if c <= '~' {
return c as u32 - ' ' as u32;
}
if c < '¡' || c > 'ÿ' {
return fallback;
}
c as u32 - ' ' as u32 - 34
}
}
/// The 14 point size.
pub type ProFont14Point<'a, C> = FontBuilder<'a, C, ProFont14PointConf>;
#[derive(Debug, Copy, Clone)]
pub enum ProFont18PointConf {}
impl FontBuilderConf for ProFont18PointConf {
const FONT_IMAGE: &'static [u8] = include_bytes!("../data/ProFont18Point.raw");
const CHAR_HEIGHT: u32 = 22;
const CHAR_WIDTH: u32 = 12;
const FONT_IMAGE_WIDTH: u32 = Self::CHAR_WIDTH * CHARS_PER_ROW;
fn char_offset(c: char) -> u32 {
let fallback = '?' as u32 - ' ' as u32;
if c < ' ' {
return fallback;
}
if c <= '~' {
return c as u32 - ' ' as u32;
}
if c < '¡' || c > 'ÿ' {
return fallback;
}
c as u32 - ' ' as u32 - 34
}
}
/// The 18 point size.
pub type ProFont18Point<'a, C> = FontBuilder<'a, C, ProFont18PointConf>;
#[derive(Debug, Copy, Clone)]
pub enum ProFont24PointConf {}
impl FontBuilderConf for ProFont24PointConf {
const FONT_IMAGE: &'static [u8] = include_bytes!("../data/ProFont24Point.raw");
const CHAR_HEIGHT: u32 = 30;
const CHAR_WIDTH: u32 = 16;
const FONT_IMAGE_WIDTH: u32 = Self::CHAR_WIDTH * CHARS_PER_ROW;
fn char_offset(c: char) -> u32 {
let fallback = '?' as u32 - ' ' as u32;
if c < ' ' {
return fallback;
}
if c <= '~' {
return c as u32 - ' ' as u32;
}
if c < '¡' || c > 'ÿ' {
return fallback;
}
c as u32 - ' ' as u32 - 34
}
}
/// The 24 point size.
pub type ProFont24Point<'a, C> = FontBuilder<'a, C, ProFont24PointConf>;
#[cfg(test)]
mod tests {
use super::*;
use embedded_graphics::coord::Coord;
use embedded_graphics::dev::TestPixelColor;
use embedded_graphics::fonts::Font;
use mock_display::Display;
use embedded_graphics::style::Style;
use embedded_graphics::style::WithStyle;
use embedded_graphics::transform::Transform;
use embedded_graphics::unsignedcoord::UnsignedCoord;
use embedded_graphics::Drawing;
#[test]
fn off_screen_text_does_not_infinite_loop() {
let text: ProFont9Point<TestPixelColor> = ProFont9Point::render_str("Hello World!")
.with_style(Style::with_stroke(1u8.into()))
.translate(Coord::new(5, -10));
let mut it = text.into_iter();
assert_eq!(it.next(), None);
}
#[test]
fn unstroked_text_does_not_infinite_loop() {
let text: ProFont9Point<TestPixelColor> = ProFont9Point::render_str("Hello World!")
.with_style(Style::with_stroke(1u8.into()))
.translate(Coord::new(5, -10));
let mut it = text.into_iter();
assert_eq!(it.next(), None);
}
#[test]
fn text_dimensions() {
let hello: ProFont9Point<TestPixelColor> = ProFont9Point::render_str("Hello World!");
let empty: ProFont9Point<TestPixelColor> = ProFont9Point::render_str("");
assert_eq!(hello.dimensions(), UnsignedCoord::new(72, 8));
assert_eq!(empty.dimensions(), UnsignedCoord::new(0, 0));
}
#[test]
fn default_style() {
let mut display_default = Display::default();
display_default.draw(ProFont9Point::render_str("Mm").into_iter());
let mut display_full_style = Display::default();
display_full_style.draw(
ProFont9Point::render_str("Mm")
.with_stroke(Some(1u8.into()))
.with_fill(Some(0u8.into()))
.into_iter(),
);
let mut display_stroke = Display::default();
display_stroke.draw(
ProFont9Point::render_str("Mm")
.with_stroke(Some(1u8.into()))
.into_iter(),
);
let mut display_fill = Display::default();
display_fill.draw(
ProFont9Point::render_str("Mm")
.with_fill(Some(0u8.into()))
.into_iter(),
);
assert_eq!(display_default, display_full_style);
assert_eq!(display_default, display_stroke);
assert_eq!(display_default, display_fill);
}
#[test]
fn correct_m() {
let mut display = Display::default();
display.draw(
ProFont9Point::render_str("Mm")
.with_stroke(Some(1u8.into()))
.into_iter(),
);
assert_eq!(
display,
Display([
[1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
//
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
])
);
}
#[test]
fn correct_inverse_coloured_m() {
let mut display = Display::default();
display.draw(
ProFont9Point::render_str("Mm")
.with_stroke(Some(0u8.into()))
.with_fill(Some(1u8.into()))
.into_iter(),
);
assert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 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
])
);
}
// tests if black on white has really the same behaviour as white on black
#[test]
fn compare_inverse_coloured_m() {
let mut display_inverse = Display::default();
display_inverse.draw(
ProFont9Point::render_str("Mm")
.with_stroke(Some(0u8.into()))
.with_fill(Some(1u8.into()))
.into_iter(),
);
let mut display_normal = Display::default();
display_normal.draw(
ProFont9Point::render_str("Mm")
.with_stroke(Some(1u8.into()))
.with_fill(Some(0u8.into()))
.into_iter(),
);
for (x, y) in display_inverse.0[0..8]
.iter()
.zip(display_normal.0[0..8].iter())
{
for (x2, y2) in x[0..12].iter().zip(y[0..12].iter()) {
assert_ne!(x2, y2);
}
}
}
#[test]
fn correct_ascii_borders() {
let mut display = Display::default();
display.draw(
ProFont9Point::render_str(" ~")
.with_stroke(Some(1u8.into()))
.into_iter(),
);
assert_eq!(
display,
Display([
[0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
//
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
])
);
}
#[test]
fn correct_dollar_y() {
let mut display = Display::default();
display.draw(
ProFont9Point::render_str("$y")
.with_stroke(Some(1u8.into()))
.into_iter(),
);
assert_eq!(
display,
Display([
[0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
]
);
let mut display = Display::default();
display.draw(
ProFont9Point::render_str("\0\n")
.with_stroke(Some(1u8.into()))
.into_iter(),
);
assert_eq!(display, two_question_marks);
let mut display = Display::default();
display.draw(
ProFont9Point::render_str("\x7F\u{A0}")
.with_stroke(Some(1u8.into()))
.into_iter(),
);
assert_eq!(display, two_question_marks);
let mut display = Display::default();
display.draw(
ProFont9Point::render_str("Ā💣")
.with_stroke(Some(1u8.into()))
.into_iter(),
);
assert_eq!(display, two_question_marks);
}
}