Browse Source

Add remaining sizes

10, 12, 14 aren't coming out monospaced so they are skipped for now.
pr/update_fontkit
Wesley Moore 4 years ago
parent
commit
1c2fc463a5
No known key found for this signature in database
GPG Key ID: BF67766C0BC2D0EE
  1. BIN
      data/ProFont10Point.png
  2. BIN
      data/ProFont10Point.raw
  3. BIN
      data/ProFont10Point.xcf
  4. BIN
      data/ProFont12Point.png
  5. BIN
      data/ProFont12Point.raw
  6. BIN
      data/ProFont12Point.xcf
  7. BIN
      data/ProFont14Point.png
  8. BIN
      data/ProFont14Point.raw
  9. BIN
      data/ProFont14Point.xcf
  10. BIN
      data/ProFont18Point.png
  11. BIN
      data/ProFont18Point.raw
  12. BIN
      data/ProFont18Point.xcf
  13. BIN
      data/ProFont24Point.png
  14. BIN
      data/ProFont24Point.raw
  15. BIN
      data/ProFont24Point.xcf
  16. BIN
      data/ProFont7Point.png
  17. BIN
      data/ProFont7Point.raw
  18. BIN
      data/ProFont7Point.xcf
  19. 75
      src/lib.rs

BIN
data/ProFont10Point.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

BIN
data/ProFont10Point.raw

Binary file not shown.

BIN
data/ProFont10Point.xcf

Binary file not shown.

BIN
data/ProFont12Point.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
data/ProFont12Point.raw

Binary file not shown.

BIN
data/ProFont12Point.xcf

Binary file not shown.

BIN
data/ProFont14Point.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

BIN
data/ProFont14Point.raw

Binary file not shown.

BIN
data/ProFont14Point.xcf

Binary file not shown.

BIN
data/ProFont18Point.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

BIN
data/ProFont18Point.raw

Binary file not shown.

BIN
data/ProFont18Point.xcf

Binary file not shown.

BIN
data/ProFont24Point.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

BIN
data/ProFont24Point.raw

Binary file not shown.

BIN
data/ProFont24Point.xcf

Binary file not shown.

BIN
data/ProFont7Point.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
data/ProFont7Point.raw

Binary file not shown.

BIN
data/ProFont7Point.xcf

Binary file not shown.

75
src/lib.rs

@ -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 {
@ -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::*;

Loading…
Cancel
Save