fixed the glyph panic, this still is very wrong
This commit is contained in:
@@ -8,8 +8,7 @@ use crate::canvas::managed::shader::dynamic_vertex::RuntimeVertexDef;
|
||||
use crate::canvas::managed::handles::{CanvasTextureHandle, CanvasImageHandle, CanvasFontHandle};
|
||||
use crate::canvas::managed::shader::text_shader::GlyphInstance;
|
||||
|
||||
/// I dont know why this isnt working
|
||||
/// fqowiejf
|
||||
|
||||
pub struct CanvasFrame {
|
||||
pub colored_drawables: Vec<RuntimeVertexDef>,
|
||||
pub textured_drawables: HashMap<Arc<CanvasTextureHandle>, Vec<Vec<RuntimeVertexDef>>>,
|
||||
|
||||
@@ -26,7 +26,7 @@ use vulkano::memory::pool::PotentialDedicatedAllocation::Generic;
|
||||
use std::borrow::Borrow;
|
||||
use std::fs::File;
|
||||
use std::io::Read;
|
||||
use rusttype::{Font, PositionedGlyph, Scale, Rect, point, GlyphId};
|
||||
use rusttype::{Font, PositionedGlyph, Scale, Rect, point, GlyphId, Line, Curve, Segment};
|
||||
use vulkano::pipeline::vertex::VertexDefinition;
|
||||
use crate::canvas::managed::shader::dynamic_vertex::RuntimeVertexDef;
|
||||
use crate::canvas::managed::handles::{CanvasTextureHandle, CanvasImageHandle, CanvasFontHandle, CompiledGraphicsPipelineHandle, Handle};
|
||||
@@ -344,15 +344,29 @@ impl CanvasState {
|
||||
|
||||
let mut accumulator = Vec::new();
|
||||
|
||||
|
||||
for i in (0..255) {
|
||||
let glyph = font.glyph(GlyphId { 0: 40 });
|
||||
let glyph = font.glyph('d');
|
||||
|
||||
let glyph_data = glyph.get_data().unwrap();
|
||||
let s = glyph.scaled(Scale{ x: 1.0, y: 1.0 });
|
||||
|
||||
for vertex in glyph_data.clone().shape.clone().unwrap() {
|
||||
accumulator.push(TextVertex3D {
|
||||
position: [vertex.x as f32, vertex.y as f32, 0.0],
|
||||
});
|
||||
let shape = s.shape().unwrap();
|
||||
|
||||
for contour in shape {
|
||||
for segment in contour.segments {
|
||||
match segment {
|
||||
Segment::Line(l) => {
|
||||
accumulator.push(TextVertex3D {
|
||||
position: [l.p[0].x as f32, l.p[0].y as f32, 0.0],
|
||||
});
|
||||
},
|
||||
Segment::Curve(c) => {
|
||||
accumulator.push(TextVertex3D {
|
||||
position: [c.p[0].x as f32, c.p[0].y as f32, 0.0],
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user