Browse Source

Package more fonts, add GNUTypeWriter

master
Marc Poulhiès 1 year ago
parent
commit
30ab7e5de5
  1. 10
      Cargo.toml
  2. 63
      README.md
  3. BIN
      data/GNUTypeWriter.ttf
  4. BIN
      data/GNUTypeWriter10Point.png
  5. BIN
      data/GNUTypeWriter10Point.raw
  6. BIN
      data/GNUTypeWriter12Point.png
  7. BIN
      data/GNUTypeWriter12Point.raw
  8. BIN
      data/GNUTypeWriter14Point.png
  9. BIN
      data/GNUTypeWriter14Point.raw
  10. BIN
      data/GNUTypeWriter18Point.png
  11. BIN
      data/GNUTypeWriter18Point.raw
  12. BIN
      data/GNUTypeWriter24Point.png
  13. BIN
      data/GNUTypeWriter24Point.raw
  14. BIN
      data/GNUTypeWriter60Point.png
  15. BIN
      data/GNUTypeWriter60Point.raw
  16. BIN
      data/GNUTypeWriter70Point.png
  17. BIN
      data/GNUTypeWriter70Point.raw
  18. BIN
      data/GNUTypeWriter7Point.png
  19. BIN
      data/GNUTypeWriter7Point.raw
  20. BIN
      data/GNUTypeWriter9Point.png
  21. BIN
      data/GNUTypeWriter9Point.raw
  22. 0
      data/Junkyard10Point.png
  23. 0
      data/Junkyard10Point.raw
  24. 0
      data/Junkyard12Point.png
  25. 0
      data/Junkyard12Point.raw
  26. 0
      data/Junkyard14Point.png
  27. 0
      data/Junkyard14Point.raw
  28. 0
      data/Junkyard18Point.png
  29. 0
      data/Junkyard18Point.raw
  30. 0
      data/Junkyard24Point.png
  31. 0
      data/Junkyard24Point.raw
  32. BIN
      data/Junkyard60Point.png
  33. BIN
      data/Junkyard60Point.raw
  34. 0
      data/Junkyard70Point.png
  35. 0
      data/Junkyard70Point.raw
  36. 0
      data/Junkyard7Point.png
  37. 0
      data/Junkyard7Point.raw
  38. 0
      data/Junkyard9Point.png
  39. 0
      data/Junkyard9Point.raw
  40. 16
      data/Makefile
  41. BIN
      data/ProFont10Point.raw
  42. BIN
      data/ProFont12Point.raw
  43. BIN
      data/ProFont14Point.raw
  44. BIN
      data/ProFont18Point.raw
  45. BIN
      data/ProFont24Point.raw
  46. BIN
      data/ProFont7Point.raw
  47. BIN
      data/ProFont9Point.raw
  48. BIN
      data/unkyardFont7Point.raw
  49. 158
      src/fonts.rs
  50. 31
      src/lib.rs

10
Cargo.toml

@ -1,14 +1,14 @@
[package]
name = "embedded-junkyardfont"
description = "The JunkYard font for use with the embedded-graphics crate."
name = "embedded-various-fonts"
description = "Various fonts for use with the embedded-graphics crate."
version = "0.4.0"
authors = ["Wesley Moore <wes@wezm.net>", "Marc Poulhiès <dkm@kataplop.net>"]
documentation = "https://docs.rs/embedded-junkyardfont"
repository = "https://github.com/dkm/embedded-junkyardfont"
documentation = "https://docs.rs/embedded-various-fonts"
repository = "https://github.com/dkm/embedded-various-fonts"
readme = "README.md"
license = "GPL"
license = "GPL, SIL, MIT"
keywords = ["bitmap", "monochrome", "font"]
categories = ["rendering", "embedded", "no-std"]

63
README.md

@ -1,46 +1,85 @@
# Junkyard Font
# Various Fonts
[The Junkyard Font][junkyard] for use with the [embedded-graphics] crate.
## [The Junkyard Font][junkyard] for use with the [embedded-graphics] crate.
`junkyard` is licensed under the [GPL license][GPL].
## Specimens
Junkyard font is available in 8 sizes:
### 7 Point
![7 Point Junkyard Font](https://raw.githubusercontent.com/dkm/embedded-junkyardfont/master/data/JunkyardFont7Point.png)
![7 Point Junkyard Font](https://raw.githubusercontent.com/dkm/embedded-junkyardfont/master/data/Junkyard7Point.png)
### 9 Point
![9 Point Junkyard Font](https://raw.githubusercontent.com/dkm/embedded-junkyardfont/master/data/JunkyardFont9Point.png)
![9 Point Junkyard Font](https://raw.githubusercontent.com/dkm/embedded-junkyardfont/master/data/Junkyard9Point.png)
### 10 Point
![10 Point Junkyard Font](https://raw.githubusercontent.com/dkm/embedded-junkyardfont/master/data/JunkyardFont10Point.png)
![10 Point Junkyard Font](https://raw.githubusercontent.com/dkm/embedded-junkyardfont/master/data/Junkyard10Point.png)
### 12 Point
![12 Point Junkyard Font](https://raw.githubusercontent.com/dkm/embedded-junkyardfont/master/data/JunkyardFont12Point.png)
![12 Point Junkyard Font](https://raw.githubusercontent.com/dkm/embedded-junkyardfont/master/data/Junkyard12Point.png)
### 14 Point
![14 Point Junkyard Font](https://raw.githubusercontent.com/dkm/embedded-junkyardfont/master/data/JunkyardFont14Point.png)
![14 Point Junkyard Font](https://raw.githubusercontent.com/dkm/embedded-junkyardfont/master/data/Junkyard14Point.png)
### 18 Point
![18 Point Junkyard Font](https://raw.githubusercontent.com/dkm/embedded-junkyardfont/master/data/JunkyardFont18Point.png)
![18 Point Junkyard Font](https://raw.githubusercontent.com/dkm/embedded-junkyardfont/master/data/Junkyard18Point.png)
### 24 Point
![24 Point Junkyard Font](https://raw.githubusercontent.com/dkm/embedded-junkyardfont/master/data/JunkyardFont24Point.png)
![24 Point Junkyard Font](https://raw.githubusercontent.com/dkm/embedded-junkyardfont/master/data/Junkyard24Point.png)
### 70 Point
![70 Point Junkyard Font](https://raw.githubusercontent.com/dkm/embedded-junkyardfont/master/data/JunkyardFont70Point.png)
![70 Point Junkyard Font](https://raw.githubusercontent.com/dkm/embedded-junkyardfont/master/data/Junkyard70Point.png)
## [The GNUTypeWriter Font][gtw] monospaced for use with the [embedded-graphics] crate.
`GNUTypeWriter` is licensed under the [OFL (SIL Open Font License)][OFL].
GNUTypeWriter font is available in 8 sizes:
### 7 Point
![7 Point GNUTypeWriter Font](https://raw.githubusercontent.com/dkm/embedded-junkyardfont/master/data/GNUTypeWriter7Point.png)
### 9 Point
![9 Point GNUTypeWriter Font](https://raw.githubusercontent.com/dkm/embedded-junkyardfont/master/data/GNUTypeWriter9Point.png)
### 10 Point
![10 Point GNUTypeWriter Font](https://raw.githubusercontent.com/dkm/embedded-junkyardfont/master/data/GNUTypeWriter10Point.png)
### 12 Point
![12 Point GNUTypeWriter Font](https://raw.githubusercontent.com/dkm/embedded-junkyardfont/master/data/GNUTypeWriter12Point.png)
### 14 Point
![14 Point GNUTypeWriter Font](https://raw.githubusercontent.com/dkm/embedded-junkyardfont/master/data/GNUTypeWriter14Point.png)
### 18 Point
![18 Point GNUTypeWriter Font](https://raw.githubusercontent.com/dkm/embedded-junkyardfont/master/data/GNUTypeWriter18Point.png)
### 24 Point
![24 Point GNUTypeWriter Font](https://raw.githubusercontent.com/dkm/embedded-junkyardfont/master/data/GNUTypeWriter24Point.png)
### 70 Point
![70 Point GNUTypeWriter Font](https://raw.githubusercontent.com/dkm/embedded-junkyardfont/master/data/GNUTypeWriter70Point.png)
[embedded-graphics]: https://github.com/jamwaffles/embedded-graphics
[junkyard]: https://blogfonts.com/junkyard.font
[gtw]: https://fontlibrary.org/en/font/gnutypewriter
[GPL]: https://github.com/dkm/embedded-junkyardfont/blob/master/gpl-2.0.txt
[OFL]: https://github.com/dkm/embedded-junkyardfont/blob/master/OFL.txt

BIN
data/GNUTypeWriter.ttf

Binary file not shown.

BIN
data/GNUTypeWriter10Point.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
data/GNUTypeWriter10Point.raw

Binary file not shown.

BIN
data/GNUTypeWriter12Point.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

BIN
data/GNUTypeWriter12Point.raw

Binary file not shown.

BIN
data/GNUTypeWriter14Point.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

BIN
data/GNUTypeWriter14Point.raw

Binary file not shown.

BIN
data/GNUTypeWriter18Point.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

BIN
data/GNUTypeWriter18Point.raw

Binary file not shown.

BIN
data/GNUTypeWriter24Point.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

BIN
data/GNUTypeWriter24Point.raw

Binary file not shown.

BIN
data/GNUTypeWriter60Point.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

BIN
data/GNUTypeWriter60Point.raw

Binary file not shown.

BIN
data/GNUTypeWriter70Point.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

BIN
data/GNUTypeWriter70Point.raw

Binary file not shown.

BIN
data/GNUTypeWriter7Point.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
data/GNUTypeWriter7Point.raw

Binary file not shown.

BIN
data/GNUTypeWriter9Point.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
data/GNUTypeWriter9Point.raw

Binary file not shown.

0
data/JunkyardFont10Point.png → data/Junkyard10Point.png

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

0
data/JunkyardFont10Point.raw → data/Junkyard10Point.raw

0
data/JunkyardFont12Point.png → data/Junkyard12Point.png

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

0
data/JunkyardFont12Point.raw → data/Junkyard12Point.raw

0
data/JunkyardFont14Point.png → data/Junkyard14Point.png

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

0
data/JunkyardFont14Point.raw → data/Junkyard14Point.raw

0
data/JunkyardFont18Point.png → data/Junkyard18Point.png

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

0
data/JunkyardFont18Point.raw → data/Junkyard18Point.raw

0
data/JunkyardFont24Point.png → data/Junkyard24Point.png

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

0
data/JunkyardFont24Point.raw → data/Junkyard24Point.raw

BIN
data/Junkyard60Point.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
data/Junkyard60Point.raw

Binary file not shown.

0
data/JunkyardFont70Point.png → data/Junkyard70Point.png

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

0
data/JunkyardFont70Point.raw → data/Junkyard70Point.raw

0
data/JunkyardFont7Point.png → data/Junkyard7Point.png

Before

Width:  |  Height:  |  Size: 694 B

After

Width:  |  Height:  |  Size: 694 B

0
data/JunkyardFont7Point.raw → data/Junkyard7Point.raw

0
data/JunkyardFont9Point.png → data/Junkyard9Point.png

Before

Width:  |  Height:  |  Size: 980 B

After

Width:  |  Height:  |  Size: 980 B

0
data/JunkyardFont9Point.raw → data/Junkyard9Point.raw

16
data/Makefile

@ -3,23 +3,15 @@ RAW = ${PNG:.png=.raw}
all: ${RAW}
TTFFONT:=Junkyard.ttf
FONTPREFIX:=JunkyardFont
CARGO_ARGS:=run --release --features=exe --
CARGO_ARGS:=run --release --features=exe -- --ttf $(TTFFONT) --pngprefix $(FONTPREFIX) --libfile ../src/fonts.rs
FONTS:=Junkyard.ttf GNUTypeWriter.ttf
SIZES:=7 9 10 12 14 18 24 60 70
pngs:
echo "use embedded_graphics::{fonts::Font, geometry::Size};" > ../src/fonts.rs
echo "use {char_offset_impl, CHARS_PER_ROW};" >> ../src/fonts.rs
cargo $(CARGO_ARGS) --size 7
cargo $(CARGO_ARGS) --size 9
cargo $(CARGO_ARGS) --size 10
cargo $(CARGO_ARGS) --size 12
cargo $(CARGO_ARGS) --size 14
cargo $(CARGO_ARGS) --size 18
cargo $(CARGO_ARGS) --size 24
cargo $(CARGO_ARGS) --size 70
for f in $(FONTS); do for s in $(SIZES); do cargo $(CARGO_ARGS) --size $$s --ttf $$f --pngprefix $$(basename $$f .ttf) --libfile ../src/fonts.rs; done; done
%.raw: %.png
convert $^ -depth 1 gray:$@

BIN
data/ProFont10Point.raw

Binary file not shown.

BIN
data/ProFont12Point.raw

Binary file not shown.

BIN
data/ProFont14Point.raw

Binary file not shown.

BIN
data/ProFont18Point.raw

Binary file not shown.

BIN
data/ProFont24Point.raw

Binary file not shown.

BIN
data/ProFont7Point.raw

Binary file not shown.

BIN
data/ProFont9Point.raw

Binary file not shown.

BIN
data/unkyardFont7Point.raw

Binary file not shown.

158
src/fonts.rs

@ -3,9 +3,9 @@ use {char_offset_impl, CHARS_PER_ROW};
/// The 7 point size with a character size of 6x7 pixels.
#[derive(Debug, Copy, Clone)]
pub struct JunkyardFont7Point{}
impl Font for JunkyardFont7Point {
const FONT_IMAGE: &'static [u8] = include_bytes!("../data/JunkyardFont7Point.raw");
pub struct Junkyard7Point{}
impl Font for Junkyard7Point {
const FONT_IMAGE: &'static [u8] = include_bytes!("../data/Junkyard7Point.raw");
const CHARACTER_SIZE: Size = Size::new(6, 7);
const FONT_IMAGE_WIDTH: u32 = Self::CHARACTER_SIZE.width * CHARS_PER_ROW;
fn char_offset(c: char) -> u32 {
@ -14,9 +14,9 @@ use {char_offset_impl, CHARS_PER_ROW};
}
/// The 9 point size with a character size of 7x9 pixels.
#[derive(Debug, Copy, Clone)]
pub struct JunkyardFont9Point{}
impl Font for JunkyardFont9Point {
const FONT_IMAGE: &'static [u8] = include_bytes!("../data/JunkyardFont9Point.raw");
pub struct Junkyard9Point{}
impl Font for Junkyard9Point {
const FONT_IMAGE: &'static [u8] = include_bytes!("../data/Junkyard9Point.raw");
const CHARACTER_SIZE: Size = Size::new(7, 9);
const FONT_IMAGE_WIDTH: u32 = Self::CHARACTER_SIZE.width * CHARS_PER_ROW;
fn char_offset(c: char) -> u32 {
@ -25,9 +25,9 @@ use {char_offset_impl, CHARS_PER_ROW};
}
/// The 10 point size with a character size of 8x10 pixels.
#[derive(Debug, Copy, Clone)]
pub struct JunkyardFont10Point{}
impl Font for JunkyardFont10Point {
const FONT_IMAGE: &'static [u8] = include_bytes!("../data/JunkyardFont10Point.raw");
pub struct Junkyard10Point{}
impl Font for Junkyard10Point {
const FONT_IMAGE: &'static [u8] = include_bytes!("../data/Junkyard10Point.raw");
const CHARACTER_SIZE: Size = Size::new(8, 10);
const FONT_IMAGE_WIDTH: u32 = Self::CHARACTER_SIZE.width * CHARS_PER_ROW;
fn char_offset(c: char) -> u32 {
@ -36,9 +36,9 @@ use {char_offset_impl, CHARS_PER_ROW};
}
/// The 12 point size with a character size of 9x12 pixels.
#[derive(Debug, Copy, Clone)]
pub struct JunkyardFont12Point{}
impl Font for JunkyardFont12Point {
const FONT_IMAGE: &'static [u8] = include_bytes!("../data/JunkyardFont12Point.raw");
pub struct Junkyard12Point{}
impl Font for Junkyard12Point {
const FONT_IMAGE: &'static [u8] = include_bytes!("../data/Junkyard12Point.raw");
const CHARACTER_SIZE: Size = Size::new(9, 12);
const FONT_IMAGE_WIDTH: u32 = Self::CHARACTER_SIZE.width * CHARS_PER_ROW;
fn char_offset(c: char) -> u32 {
@ -47,9 +47,9 @@ use {char_offset_impl, CHARS_PER_ROW};
}
/// The 14 point size with a character size of 11x14 pixels.
#[derive(Debug, Copy, Clone)]
pub struct JunkyardFont14Point{}
impl Font for JunkyardFont14Point {
const FONT_IMAGE: &'static [u8] = include_bytes!("../data/JunkyardFont14Point.raw");
pub struct Junkyard14Point{}
impl Font for Junkyard14Point {
const FONT_IMAGE: &'static [u8] = include_bytes!("../data/Junkyard14Point.raw");
const CHARACTER_SIZE: Size = Size::new(11, 14);
const FONT_IMAGE_WIDTH: u32 = Self::CHARACTER_SIZE.width * CHARS_PER_ROW;
fn char_offset(c: char) -> u32 {
@ -58,9 +58,9 @@ use {char_offset_impl, CHARS_PER_ROW};
}
/// The 18 point size with a character size of 13x18 pixels.
#[derive(Debug, Copy, Clone)]
pub struct JunkyardFont18Point{}
impl Font for JunkyardFont18Point {
const FONT_IMAGE: &'static [u8] = include_bytes!("../data/JunkyardFont18Point.raw");
pub struct Junkyard18Point{}
impl Font for Junkyard18Point {
const FONT_IMAGE: &'static [u8] = include_bytes!("../data/Junkyard18Point.raw");
const CHARACTER_SIZE: Size = Size::new(13, 18);
const FONT_IMAGE_WIDTH: u32 = Self::CHARACTER_SIZE.width * CHARS_PER_ROW;
fn char_offset(c: char) -> u32 {
@ -69,23 +69,133 @@ use {char_offset_impl, CHARS_PER_ROW};
}
/// The 24 point size with a character size of 17x23 pixels.
#[derive(Debug, Copy, Clone)]
pub struct JunkyardFont24Point{}
impl Font for JunkyardFont24Point {
const FONT_IMAGE: &'static [u8] = include_bytes!("../data/JunkyardFont24Point.raw");
pub struct Junkyard24Point{}
impl Font for Junkyard24Point {
const FONT_IMAGE: &'static [u8] = include_bytes!("../data/Junkyard24Point.raw");
const CHARACTER_SIZE: Size = Size::new(17, 23);
const FONT_IMAGE_WIDTH: u32 = Self::CHARACTER_SIZE.width * CHARS_PER_ROW;
fn char_offset(c: char) -> u32 {
char_offset_impl(c)
}
}
/// The 60 point size with a character size of 41x56 pixels.
#[derive(Debug, Copy, Clone)]
pub struct Junkyard60Point{}
impl Font for Junkyard60Point {
const FONT_IMAGE: &'static [u8] = include_bytes!("../data/Junkyard60Point.raw");
const CHARACTER_SIZE: Size = Size::new(41, 56);
const FONT_IMAGE_WIDTH: u32 = Self::CHARACTER_SIZE.width * CHARS_PER_ROW;
fn char_offset(c: char) -> u32 {
char_offset_impl(c)
}
}
/// The 70 point size with a character size of 47x66 pixels.
#[derive(Debug, Copy, Clone)]
pub struct JunkyardFont70Point{}
impl Font for JunkyardFont70Point {
const FONT_IMAGE: &'static [u8] = include_bytes!("../data/JunkyardFont70Point.raw");
pub struct Junkyard70Point{}
impl Font for Junkyard70Point {
const FONT_IMAGE: &'static [u8] = include_bytes!("../data/Junkyard70Point.raw");
const CHARACTER_SIZE: Size = Size::new(47, 66);
const FONT_IMAGE_WIDTH: u32 = Self::CHARACTER_SIZE.width * CHARS_PER_ROW;
fn char_offset(c: char) -> u32 {
char_offset_impl(c)
}
}
/// The 7 point size with a character size of 6x8 pixels.
#[derive(Debug, Copy, Clone)]
pub struct GNUTypeWriter7Point{}
impl Font for GNUTypeWriter7Point {
const FONT_IMAGE: &'static [u8] = include_bytes!("../data/GNUTypeWriter7Point.raw");
const CHARACTER_SIZE: Size = Size::new(6, 8);
const FONT_IMAGE_WIDTH: u32 = Self::CHARACTER_SIZE.width * CHARS_PER_ROW;
fn char_offset(c: char) -> u32 {
char_offset_impl(c)
}
}
/// The 9 point size with a character size of 7x10 pixels.
#[derive(Debug, Copy, Clone)]
pub struct GNUTypeWriter9Point{}
impl Font for GNUTypeWriter9Point {
const FONT_IMAGE: &'static [u8] = include_bytes!("../data/GNUTypeWriter9Point.raw");
const CHARACTER_SIZE: Size = Size::new(7, 10);
const FONT_IMAGE_WIDTH: u32 = Self::CHARACTER_SIZE.width * CHARS_PER_ROW;
fn char_offset(c: char) -> u32 {
char_offset_impl(c)
}
}
/// The 10 point size with a character size of 8x11 pixels.
#[derive(Debug, Copy, Clone)]
pub struct GNUTypeWriter10Point{}
impl Font for GNUTypeWriter10Point {
const FONT_IMAGE: &'static [u8] = include_bytes!("../data/GNUTypeWriter10Point.raw");
const CHARACTER_SIZE: Size = Size::new(8, 11);
const FONT_IMAGE_WIDTH: u32 = Self::CHARACTER_SIZE.width * CHARS_PER_ROW;
fn char_offset(c: char) -> u32 {
char_offset_impl(c)
}
}
/// The 12 point size with a character size of 9x13 pixels.
#[derive(Debug, Copy, Clone)]
pub struct GNUTypeWriter12Point{}
impl Font for GNUTypeWriter12Point {
const FONT_IMAGE: &'static [u8] = include_bytes!("../data/GNUTypeWriter12Point.raw");
const CHARACTER_SIZE: Size = Size::new(9, 13);
const FONT_IMAGE_WIDTH: u32 = Self::CHARACTER_SIZE.width * CHARS_PER_ROW;
fn char_offset(c: char) -> u32 {
char_offset_impl(c)
}
}
/// The 14 point size with a character size of 10x15 pixels.
#[derive(Debug, Copy, Clone)]
pub struct GNUTypeWriter14Point{}
impl Font for GNUTypeWriter14Point {
const FONT_IMAGE: &'static [u8] = include_bytes!("../data/GNUTypeWriter14Point.raw");
const CHARACTER_SIZE: Size = Size::new(10, 15);
const FONT_IMAGE_WIDTH: u32 = Self::CHARACTER_SIZE.width * CHARS_PER_ROW;
fn char_offset(c: char) -> u32 {
char_offset_impl(c)
}
}
/// The 18 point size with a character size of 13x19 pixels.
#[derive(Debug, Copy, Clone)]
pub struct GNUTypeWriter18Point{}
impl Font for GNUTypeWriter18Point {
const FONT_IMAGE: &'static [u8] = include_bytes!("../data/GNUTypeWriter18Point.raw");
const CHARACTER_SIZE: Size = Size::new(13, 19);
const FONT_IMAGE_WIDTH: u32 = Self::CHARACTER_SIZE.width * CHARS_PER_ROW;
fn char_offset(c: char) -> u32 {
char_offset_impl(c)
}
}
/// The 24 point size with a character size of 17x25 pixels.
#[derive(Debug, Copy, Clone)]
pub struct GNUTypeWriter24Point{}
impl Font for GNUTypeWriter24Point {
const FONT_IMAGE: &'static [u8] = include_bytes!("../data/GNUTypeWriter24Point.raw");
const CHARACTER_SIZE: Size = Size::new(17, 25);
const FONT_IMAGE_WIDTH: u32 = Self::CHARACTER_SIZE.width * CHARS_PER_ROW;
fn char_offset(c: char) -> u32 {
char_offset_impl(c)
}
}
/// The 60 point size with a character size of 39x62 pixels.
#[derive(Debug, Copy, Clone)]
pub struct GNUTypeWriter60Point{}
impl Font for GNUTypeWriter60Point {
const FONT_IMAGE: &'static [u8] = include_bytes!("../data/GNUTypeWriter60Point.raw");
const CHARACTER_SIZE: Size = Size::new(39, 62);
const FONT_IMAGE_WIDTH: u32 = Self::CHARACTER_SIZE.width * CHARS_PER_ROW;
fn char_offset(c: char) -> u32 {
char_offset_impl(c)
}
}
/// The 70 point size with a character size of 46x73 pixels.
#[derive(Debug, Copy, Clone)]
pub struct GNUTypeWriter70Point{}
impl Font for GNUTypeWriter70Point {
const FONT_IMAGE: &'static [u8] = include_bytes!("../data/GNUTypeWriter70Point.raw");
const CHARACTER_SIZE: Size = Size::new(46, 73);
const FONT_IMAGE_WIDTH: u32 = Self::CHARACTER_SIZE.width * CHARS_PER_ROW;
fn char_offset(c: char) -> u32 {
char_offset_impl(c)
}
}

31
src/lib.rs

@ -1,36 +1,5 @@
#![no_std]
//! 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)
//!
//! ```ignore
//! display.draw(
//! Text::new("Hello World")
//! into_styled(text_style!(
//! font = ProFont24Point,
//! text_color = Black,
//! background_color = White
//! ))
//! .translate(Point::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;
#[cfg(not(feature = "exe"))]

Loading…
Cancel
Save