thanks, jk
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.3 KiB

  1. extern crate textium;
  2. extern crate rusttype;
  3. use rusttype::{FontCollection};
  4. /// An array of all of the ascii printable characters.
  5. pub const ASCII: &'static [char] = &[
  6. ' ', '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/',
  7. ':', ';', '<', '=', '>', '?', '[', ']', '\\', '|', '{', '}', '^', '~', '_', '@',
  8. '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
  9. 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E',
  10. 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U',
  11. 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
  12. ];
  13. fn main() {
  14. let font_data = include_bytes!("Gudea-Regular.ttf");
  15. let font = FontCollection::from_bytes(font_data as &[u8])
  16. .into_font().unwrap();
  17. let font = textium::Font::new(font);
  18. let chrs = ASCII.iter().cloned();
  19. let (atlas, bitmap, line_height) = font.make_atlas(chrs, 40.0, 1, 64, 64);
  20. // println!("{:?}", atlas.glyph_data);
  21. for line in bitmap.lines() {
  22. print!("{:03} ", line.len());
  23. for &pixel in line {
  24. if pixel == 0 {
  25. print!(" ");
  26. } else {
  27. print!("#");
  28. }
  29. }
  30. println!("");
  31. }
  32. }