Browse Source

Regenerate data files with profont tool

pr/update_fontkit
Wesley Moore 4 years ago
parent
commit
d5507bcf38
No known key found for this signature in database
GPG Key ID: BF67766C0BC2D0EE
  1. 11
      data/Makefile
  2. BIN
      data/ProFont10Point.png
  3. BIN
      data/ProFont10Point.raw
  4. BIN
      data/ProFont12Point.png
  5. BIN
      data/ProFont12Point.raw
  6. BIN
      data/ProFont14Point.png
  7. BIN
      data/ProFont14Point.raw
  8. BIN
      data/ProFont18Point.png
  9. BIN
      data/ProFont18Point.raw
  10. BIN
      data/ProFont24Point.png
  11. BIN
      data/ProFont24Point.raw
  12. BIN
      data/ProFont7Point.png
  13. BIN
      data/ProFont7Point.raw
  14. BIN
      data/ProFont9Point.png
  15. BIN
      data/ProFont9Point.raw
  16. 12
      src/lib.rs
  17. 2
      src/main.rs

11
data/Makefile

@ -3,7 +3,18 @@ RAW = ${PNG:.png=.raw}
all: ${RAW}
pngs:
cargo run --release -- 7
cargo run --release -- 9
cargo run --release -- 10
cargo run --release -- 12
cargo run --release -- 14
cargo run --release -- 18
cargo run --release -- 24
.SUFFIXES: .png .raw
.png.raw:
convert ${.IMPSRC} -depth 1 gray:${.TARGET}
.PHONY: pngs

BIN
data/ProFont10Point.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
data/ProFont10Point.raw

Binary file not shown.

BIN
data/ProFont12Point.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

BIN
data/ProFont12Point.raw

Binary file not shown.

BIN
data/ProFont14Point.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

BIN
data/ProFont14Point.raw

Binary file not shown.

BIN
data/ProFont18Point.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

BIN
data/ProFont18Point.raw

Binary file not shown.

BIN
data/ProFont24Point.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 8.7 KiB

BIN
data/ProFont24Point.raw

Binary file not shown.

BIN
data/ProFont7Point.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
data/ProFont7Point.raw

Binary file not shown.

BIN
data/ProFont9Point.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

BIN
data/ProFont9Point.raw

Binary file not shown.

12
src/lib.rs

@ -5,6 +5,8 @@ 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;
@ -14,7 +16,7 @@ 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;
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 < ' ' {
@ -39,7 +41,7 @@ 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 = 240;
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 < ' ' {
@ -64,7 +66,7 @@ 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;
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 < ' ' {
@ -87,9 +89,9 @@ pub type ProFont18Point<'a, C> = FontBuilder<'a, C, ProFont18PointConf>;
pub enum ProFont24PointConf {}
impl FontBuilderConf for ProFont24PointConf {
const FONT_IMAGE: &'static [u8] = include_bytes!("../data/ProFont24Point.raw");
const CHAR_HEIGHT: u32 = 29;
const CHAR_HEIGHT: u32 = 30;
const CHAR_WIDTH: u32 = 16;
const FONT_IMAGE_WIDTH: u32 = 640;
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 < ' ' {

2
src/main.rs

@ -142,7 +142,7 @@ fn main() {
}
}
let filename = format!("data/ProFont{}Point.png", font_size);
let filename = format!("ProFont{}Point.png", font_size);
imgbuf.save(&filename).expect("error saving PNG");
println!("Wrote {} with character size of {}", filename, char_size);
}

Loading…
Cancel
Save