diff --git a/src/lib.rs b/src/lib.rs index d49989c0..40ed042e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -24,6 +24,8 @@ struct Vertex { tex_coords: [f32; 2], } +const TEXT_SCALE: f32 = 4.0; + impl Vertex { fn desc() -> wgpu::VertexBufferLayout<'static> { wgpu::VertexBufferLayout { @@ -695,7 +697,7 @@ impl State { }); let inconsolata = include_bytes!("./Inconsolata-Regular.ttf") as &[u8]; - let inconsolata = text::FontCache::new(&device, inconsolata, 32.0); + let inconsolata = text::FontCache::new(&device, inconsolata, 8.0 * TEXT_SCALE); let mut font_textures = HashMap::new(); { @@ -1251,13 +1253,13 @@ impl<'a> FrameBuilder<'a> { src_top_left: [glyph.x, glyph.y], src_dims: [glyph.w, glyph.h], dest_top_left: [ - cursor_x + (glyph.adjust_x / 2.0), - cursor_y + (glyph.adjust_y / 2.0), + cursor_x + (glyph.adjust_x / TEXT_SCALE), + cursor_y + (glyph.adjust_y / TEXT_SCALE), ], - dest_dims: [glyph.w / 2.0, glyph.h / 2.0], + dest_dims: [glyph.w / TEXT_SCALE, glyph.h / TEXT_SCALE], color, }); - cursor_x += glyph.advance_width / 2.0; + cursor_x += glyph.advance_width / TEXT_SCALE; } for glyph in glyphs { diff --git a/src/text_shader.wgsl b/src/text_shader.wgsl index 7bb9827b..fe618525 100644 --- a/src/text_shader.wgsl +++ b/src/text_shader.wgsl @@ -40,11 +40,11 @@ struct VertexOutput { @fragment fn fs_main(in : VertexOutput)->@location(0) vec4 { // TODO: Should we be sampling here for the shader? - // let tc = vec2(u32(in.tex_coords.x), u32(in.tex_coords.y)); - // let c = textureLoad(t_diffuse, tc, 0); + let tc = vec2(u32(in.tex_coords.x), u32(in.tex_coords.y)); + let c = textureLoad(t_diffuse, tc, 0); - let tc = in.tex_coords / vec2(textureDimensions(t_diffuse)); - let c = textureSample(t_diffuse, s_diffuse, tc); + // let tc = in.tex_coords / vec2(textureDimensions(t_diffuse)); + // let c = textureSample(t_diffuse, s_diffuse, tc); return vec4(c.r,c.r,c.r,c.r);