|
|
|
@ -1,5 +1,30 @@
|
|
|
|
|
//! The ProFont programming font. Image data taken from the
|
|
|
|
|
//! [ProFont homepage](https://web.archive.org/web/20180412214402/http://tobiasjung.name/profont/)
|
|
|
|
|
//! The [ProFont](https://web.archive.org/web/20180412214402/http://tobiasjung.name/profont/)
|
|
|
|
|
//! monospace programming font for use with
|
|
|
|
|
//! [embedded-graphics](https://github.com/jamwaffles/embedded-graphics). Font data taken from the
|
|
|
|
|
//! [ProFont homepage](https://web.archive.org/web/20180412214402/http://tobiasjung.name/profont/).
|
|
|
|
|
//!
|
|
|
|
|
//! ### Synopsis
|
|
|
|
|
//!
|
|
|
|
|
//! Assuming `display` is something that implements the [Drawing
|
|
|
|
|
//! trait](https://docs.rs/embedded-graphics/0.4.4/embedded_graphics/trait.Drawing.html)
|
|
|
|
|
//!
|
|
|
|
|
//! ```no_run
|
|
|
|
|
//! display.draw(
|
|
|
|
|
//! ProFont24Point::render_str("Hello World")
|
|
|
|
|
//! .with_stroke(Some(Color::Red))
|
|
|
|
|
//! .with_fill(Some(Color::White))
|
|
|
|
|
//! .translate(Coord::new(10, 10))
|
|
|
|
|
//! .into_iter(),
|
|
|
|
|
//! );
|
|
|
|
|
//! ```
|
|
|
|
|
//!
|
|
|
|
|
//! For a more complete example see [the example in the ssd1675
|
|
|
|
|
//! crate](https://github.com/wezm/ssd1675/blob/master/examples/raspberry_pi_inky_phat.rs).
|
|
|
|
|
//!
|
|
|
|
|
//! ### Glyph Coverage
|
|
|
|
|
//!
|
|
|
|
|
//! This crate provides support for [ISO/IEC 8859-1](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
|
|
|
|
|
//! (latin1), although do note that the font is missing a few glyphs in this range.
|
|
|
|
|
|
|
|
|
|
extern crate embedded_graphics; |
|
|
|
|
|
|
|
|
@ -7,9 +32,6 @@ use embedded_graphics::fonts::font_builder::{FontBuilder, FontBuilderConf};
|
|
|
|
|
|
|
|
|
|
const CHARS_PER_ROW: u32 = 32; |
|
|
|
|
|
|
|
|
|
#[cfg(test)] |
|
|
|
|
pub(crate) mod mock_display; |
|
|
|
|
|
|
|
|
|
fn char_offset_impl(c: char) -> u32 { |
|
|
|
|
let fallback = '?' as u32 - ' ' as u32; |
|
|
|
|
if c < ' ' { |
|
|
|
@ -36,7 +58,7 @@ impl FontBuilderConf for ProFont7PointConf {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// The 7 point size.
|
|
|
|
|
/// The 7 point size with a character size of 5x9 pixels.
|
|
|
|
|
pub type ProFont7Point<'a, C> = FontBuilder<'a, C, ProFont7PointConf>; |
|
|
|
|
|
|
|
|
|
#[derive(Debug, Copy, Clone)] |
|
|
|
@ -51,7 +73,7 @@ impl FontBuilderConf for ProFont9PointConf {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// The 9 point size.
|
|
|
|
|
/// The 9 point size with a character size of 6x11 pixels.
|
|
|
|
|
pub type ProFont9Point<'a, C> = FontBuilder<'a, C, ProFont9PointConf>; |
|
|
|
|
|
|
|
|
|
#[derive(Debug, Copy, Clone)] |
|
|
|
@ -66,7 +88,7 @@ impl FontBuilderConf for ProFont10PointConf {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// The 10 point size.
|
|
|
|
|
/// The 10 point size with a character size of 7x13 pixels.
|
|
|
|
|
pub type ProFont10Point<'a, C> = FontBuilder<'a, C, ProFont10PointConf>; |
|
|
|
|
|
|
|
|
|
#[derive(Debug, Copy, Clone)] |
|
|
|
@ -81,7 +103,7 @@ impl FontBuilderConf for ProFont12PointConf {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// The 12 point size.
|
|
|
|
|
/// The 12 point size with a character size of 8x15 pixels.
|
|
|
|
|
pub type ProFont12Point<'a, C> = FontBuilder<'a, C, ProFont12PointConf>; |
|
|
|
|
|
|
|
|
|
#[derive(Debug, Copy, Clone)] |
|
|
|
@ -96,7 +118,7 @@ impl FontBuilderConf for ProFont14PointConf {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// The 14 point size.
|
|
|
|
|
/// The 14 point size with a character size of 10x18 pixels.
|
|
|
|
|
pub type ProFont14Point<'a, C> = FontBuilder<'a, C, ProFont14PointConf>; |
|
|
|
|
|
|
|
|
|
#[derive(Debug, Copy, Clone)] |
|
|
|
@ -111,7 +133,7 @@ impl FontBuilderConf for ProFont18PointConf {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// The 18 point size.
|
|
|
|
|
/// The 18 point size with a character size of 12x22 pixels.
|
|
|
|
|
pub type ProFont18Point<'a, C> = FontBuilder<'a, C, ProFont18PointConf>; |
|
|
|
|
|
|
|
|
|
#[derive(Debug, Copy, Clone)] |
|
|
|
@ -126,325 +148,5 @@ impl FontBuilderConf for ProFont24PointConf {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// The 24 point size.
|
|
|
|
|
/// The 24 point size with a character size of 16x30 pixels.
|
|
|
|
|
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_eq!( |
|
|
|
|
display, |
|
|
|
|
Display([ |
|
|
|
|
[0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 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], |
|
|
|
|
]) |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 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(), |
|
|
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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], |
|
|
|
|
]) |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#[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, 0, 0, 0, 0, 0], |
|
|
|
|
[0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], |
|
|
|
|
[0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], |
|
|
|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
|
|
|
|
); |
|
|
|
|
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); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|