aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--assets/uwu-alphabet.txt1
-rw-r--r--assets/uwu.fnt22
-rw-r--r--assets/uwu.pngbin0 -> 1120 bytes
-rw-r--r--src/font.rs39
-rw-r--r--src/main.rs7
5 files changed, 65 insertions, 4 deletions
diff --git a/assets/uwu-alphabet.txt b/assets/uwu-alphabet.txt
new file mode 100644
index 0000000..cee1ae4
--- /dev/null
+++ b/assets/uwu-alphabet.txt
@@ -0,0 +1 @@
+Uwspaceybr \ No newline at end of file
diff --git a/assets/uwu.fnt b/assets/uwu.fnt
new file mode 100644
index 0000000..b96d577
--- /dev/null
+++ b/assets/uwu.fnt
@@ -0,0 +1,22 @@
+info face="Cherry Bomb One" size=20 bold=0 italic=0 charset="ANSI" unicode=0 stretchH=100 smooth=0 aa=1 padding=0,0,0,0 spacing=1,1 outline=0
+common lineHeight=20 base=16 scaleW=256 scaleH=32 pages=1 packed=0 alphaChnl=0 redChnl=4 greenChnl=4 blueChnl=4
+page id=0 file="uwu_0.png"
+chars count=10
+char id=85 x=0 y=0 width=10 height=20 xoffset=0 yoffset=0 xadvance=11 page=0 chnl=15
+char id=97 x=39 y=0 width=7 height=20 xoffset=0 yoffset=0 xadvance=7 page=0 chnl=15
+char id=98 x=21 y=0 width=8 height=20 xoffset=0 yoffset=0 xadvance=8 page=0 chnl=15
+char id=99 x=47 y=0 width=7 height=20 xoffset=0 yoffset=0 xadvance=7 page=0 chnl=15
+char id=101 x=55 y=0 width=7 height=20 xoffset=0 yoffset=0 xadvance=7 page=0 chnl=15
+char id=112 x=30 y=0 width=8 height=20 xoffset=0 yoffset=0 xadvance=8 page=0 chnl=15
+char id=114 x=63 y=0 width=7 height=20 xoffset=0 yoffset=0 xadvance=7 page=0 chnl=15
+char id=115 x=79 y=0 width=6 height=20 xoffset=0 yoffset=0 xadvance=7 page=0 chnl=15
+char id=119 x=11 y=0 width=9 height=20 xoffset=0 yoffset=0 xadvance=10 page=0 chnl=15
+char id=121 x=71 y=0 width=7 height=20 xoffset=0 yoffset=0 xadvance=8 page=0 chnl=15
+kernings count=7
+kerning first=97 second=121 amount=-1
+kerning first=114 second=112 amount=-1
+kerning first=114 second=115 amount=-1
+kerning first=114 second=119 amount=-1
+kerning first=114 second=101 amount=-1
+kerning first=114 second=97 amount=-1
+kerning first=114 second=99 amount=-1
diff --git a/assets/uwu.png b/assets/uwu.png
new file mode 100644
index 0000000..68b4fcb
--- /dev/null
+++ b/assets/uwu.png
Binary files differ
diff --git a/src/font.rs b/src/font.rs
index c88b9c3..c97ac8f 100644
--- a/src/font.rs
+++ b/src/font.rs
@@ -1,9 +1,36 @@
pub const UWU_HEIGHT: u32 = 24;
pub const UWU_WIDTH: u32 = 16;
-pub const UWU_SHEET_RAW: &[u8] = include_bytes!("../assets/uwu-logo-font-20px.png");
+
+use std::sync::LazyLock;
+
+pub struct Glyph {
+ x: i32,
+}
+fn insert_value(arr: &mut Vec<*const Glyph>, idx: usize, glyph: *const Glyph) {
+ if arr.len() <= idx {
+ while arr.len() <= idx {
+ arr.push(0 as *const Glyph);
+ }
+ }
+ arr[idx] = glyph;
+}
+
+pub struct Font<'a> {
+ pub texture: &'a [u8],
+ pub glyphs: Vec<*const Glyph>,
+}
+
+pub const MEOW_FONT: LazyLock<Font> = LazyLock::new(|| Font {
+ texture: include_bytes!("../assets/uwu-logo-font-20px.png"),
+ glyphs: {
+ let a: &mut Vec<*const Glyph> = &mut Vec::new();
+ insert_value(a, 32, &Glyph { x: 2 });
+ a.to_vec()
+ },
+});
mod sprite_sheets {
- use super::{UWU_HEIGHT, UWU_SHEET_RAW, UWU_WIDTH};
+ use super::{MEOW_FONT, UWU_HEIGHT, UWU_WIDTH};
use sdl2::{
image::LoadTexture,
pixels::PixelFormatEnum,
@@ -61,7 +88,7 @@ mod sprite_sheets {
let surface = Surface::new(112, 24, PixelFormatEnum::RGB24).unwrap();
let mut canvas = Canvas::from_surface(surface).unwrap();
let tc = canvas.texture_creator();
- let tx = tc.load_texture_bytes(UWU_SHEET_RAW).unwrap();
+ let tx = tc.load_texture_bytes(MEOW_FONT.texture).unwrap();
canvas.copy(&tx, None, None).unwrap();
canvas.present();
let sheet = canvas.into_surface();
@@ -89,7 +116,13 @@ mod sprite_sheets {
pub fn w_surface(&self) -> Surface {
return self.char_to_surface(uwu_w());
}
+
+ pub fn p_surface(&self) -> Surface {
+ return self.char_to_surface(uwu_p());
+ }
}
}
+use std::str::Bytes;
+
pub use sprite_sheets::UwUFont;
diff --git a/src/main.rs b/src/main.rs
index c0a58a5..c3f434a 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -27,6 +27,7 @@ pub fn main() {
let uwu_font = font::UwUFont::new(&texture_creator);
let u_char = uwu_font.u_surface().as_texture(&texture_creator).unwrap();
let w_char = uwu_font.w_surface().as_texture(&texture_creator).unwrap();
+ let p_char = uwu_font.p_surface().as_texture(&texture_creator).unwrap();
canvas
.copy(&u_char, None, UwUFont::pos_to_rect(0, 0))
@@ -37,9 +38,13 @@ pub fn main() {
canvas
.copy(&u_char, None, UwUFont::pos_to_rect(UWU_WIDTH as i32 * 2, 0))
.unwrap();
+ canvas
+ .copy(&p_char, None, UwUFont::pos_to_rect(UWU_WIDTH as i32 * 2, 0))
+ .unwrap();
+
//canvas.clear();
let tc = canvas.texture_creator();
- let sheet = tc.load_texture_bytes(font::UWU_SHEET_RAW).unwrap();
+ let sheet = tc.load_texture_bytes(font::MEOW_FONT.texture).unwrap();
/*
canvas.copy(
&sheet,