Skip to content

Commit

Permalink
Add remaining sizes
Browse files Browse the repository at this point in the history
10, 12, 14 aren't coming out monospaced so they are skipped for now.
  • Loading branch information
wezm committed Nov 21, 2018
1 parent c2c5441 commit 1c2fc46
Show file tree
Hide file tree
Showing 19 changed files with 75 additions and 0 deletions.
Binary file modified data/ProFont10Point.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/ProFont10Point.raw
Binary file not shown.
Binary file modified data/ProFont10Point.xcf
Binary file not shown.
Binary file modified data/ProFont12Point.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/ProFont12Point.raw
Binary file not shown.
Binary file modified data/ProFont12Point.xcf
Binary file not shown.
Binary file modified data/ProFont14Point.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/ProFont14Point.raw
Binary file not shown.
Binary file modified data/ProFont14Point.xcf
Binary file not shown.
Binary file modified data/ProFont18Point.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/ProFont18Point.raw
Binary file not shown.
Binary file modified data/ProFont18Point.xcf
Binary file not shown.
Binary file modified data/ProFont24Point.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/ProFont24Point.raw
Binary file not shown.
Binary file modified data/ProFont24Point.xcf
Binary file not shown.
Binary file modified data/ProFont7Point.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/ProFont7Point.raw
Binary file not shown.
Binary file modified data/ProFont7Point.xcf
Binary file not shown.
75 changes: 75 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,31 @@ use embedded_graphics::fonts::font_builder::{FontBuilder, FontBuilderConf};
#[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 = 200;
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 {
Expand All @@ -33,6 +58,56 @@ impl FontBuilderConf for ProFont9PointConf {
/// The 9 point size.
pub type ProFont9Point<'a, C> = FontBuilder<'a, C, ProFont9PointConf>;

#[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 = 480;
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 = 29;
const CHAR_WIDTH: u32 = 16;
const FONT_IMAGE_WIDTH: u32 = 640;
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::*;
Expand Down

0 comments on commit 1c2fc46

Please sign in to comment.