mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-12-26 21:58:20 -06:00
text kinda works!
This commit is contained in:
parent
31a2499d26
commit
521b7f3ef2
|
@ -50,7 +50,7 @@ fn main() {
|
||||||
size: (UiSize::Percentage(1.), UiSize::Percentage(1.)),
|
size: (UiSize::Percentage(1.), UiSize::Percentage(1.)),
|
||||||
elements: vec![
|
elements: vec![
|
||||||
Box::new(Text {
|
Box::new(Text {
|
||||||
text: "Heloworld!Loremipsumsimdoloramet".into(),
|
text: "Hello_world".into(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
|
|
|
@ -119,10 +119,9 @@ impl UiDrawPlan {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let vidx = swapper.current().vertices.len() as u32;
|
|
||||||
|
|
||||||
match command {
|
match command {
|
||||||
UiDrawCommand::Rectangle { position, size, color } => {
|
UiDrawCommand::Rectangle { position, size, color } => {
|
||||||
|
let vidx = swapper.current().vertices.len() as u32;
|
||||||
swapper.current_mut().indices.extend([vidx, vidx + 1, vidx + 2, vidx, vidx + 2, vidx + 3]);
|
swapper.current_mut().indices.extend([vidx, vidx + 1, vidx + 2, vidx, vidx + 2, vidx + 3]);
|
||||||
swapper.current_mut().vertices.extend([
|
swapper.current_mut().vertices.extend([
|
||||||
UiVertex {
|
UiVertex {
|
||||||
|
@ -148,33 +147,41 @@ impl UiDrawPlan {
|
||||||
]);
|
]);
|
||||||
},
|
},
|
||||||
UiDrawCommand::Text { position, size, color, text } => {
|
UiDrawCommand::Text { position, size, color, text } => {
|
||||||
|
let mut rpos_x = 0.;
|
||||||
for char in text.chars() {
|
for char in text.chars() {
|
||||||
tr.glyph(FontHandle(0), char, *size);
|
let vidx = swapper.current().vertices.len() as u32;
|
||||||
}
|
let glyph = tr.glyph(FontHandle(0), char, *size);
|
||||||
|
rpos_x += 32.;//glyph.metrics.advance_width;
|
||||||
swapper.current_mut().indices.extend([vidx, vidx + 1, vidx + 2, vidx, vidx + 2, vidx + 3]);
|
swapper.current_mut().indices.extend([vidx, vidx + 1, vidx + 2, vidx, vidx + 2, vidx + 3]);
|
||||||
|
let p0x = glyph.position.x as f32 / 1024.;
|
||||||
|
let p1x = (glyph.position.x + glyph.size.x as i32) as f32 / 1024.;
|
||||||
|
let p0y = glyph.position.y as f32 / 1024.;
|
||||||
|
let p1y = (glyph.position.y + glyph.size.y as i32) as f32 / 1024.;
|
||||||
swapper.current_mut().vertices.extend([
|
swapper.current_mut().vertices.extend([
|
||||||
UiVertex {
|
UiVertex {
|
||||||
position: *position,
|
position: *position + vec2(rpos_x, 0.0),
|
||||||
color: *color,
|
color: *color,
|
||||||
uv: vec2(0.0, 0.0),
|
uv: vec2(p0x, p0y),
|
||||||
},
|
},
|
||||||
UiVertex {
|
UiVertex {
|
||||||
position: *position + vec2(32., 0.0),
|
position: *position + vec2(rpos_x + 32., 0.0),
|
||||||
color: *color,
|
color: *color,
|
||||||
uv: vec2(1.0, 0.0),
|
uv: vec2(p1x, p0y),
|
||||||
},
|
},
|
||||||
UiVertex {
|
UiVertex {
|
||||||
position: *position + vec2(32., 32.),
|
position: *position + vec2(rpos_x + 32., 32.),
|
||||||
color: *color,
|
color: *color,
|
||||||
uv: vec2(1.0, 1.0),
|
uv: vec2(p1x, p1y),
|
||||||
},
|
},
|
||||||
UiVertex {
|
UiVertex {
|
||||||
position: *position + vec2(0.0, 32.),
|
position: *position + vec2(rpos_x + 0.0, 32.),
|
||||||
color: *color,
|
color: *color,
|
||||||
uv: vec2(0.0, 1.0),
|
uv: vec2(p0x, p1y),
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
prev_command = Some(command);
|
prev_command = Some(command);
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,6 +135,6 @@ impl FontTextureManager {
|
||||||
|
|
||||||
impl Default for FontTextureManager {
|
impl Default for FontTextureManager {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self::new(uvec2(2048, 2048))
|
Self::new(uvec2(1024, 1024))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue