fixed the glyph panic, this still is very wrong

This commit is contained in:
2020-02-05 00:15:08 -08:00
parent f3f52becb4
commit 1fde36e42c
5 changed files with 121 additions and 23 deletions

View File

@@ -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>>>,

View File

@@ -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],
});
}
}
}
}
}