From f0bc15f5c795ddd3542b684297f4f277ced42781 Mon Sep 17 00:00:00 2001 From: Erin Date: Sun, 5 Nov 2017 20:35:54 -0600 Subject: [PATCH] textium: remove metrics from structs, make a bunch of fields pub --- textium/src/cache.rs | 6 +++--- textium/src/lib.rs | 13 ++----------- textium/src/rasterizer.rs | 6 +----- 3 files changed, 6 insertions(+), 19 deletions(-) diff --git a/textium/src/cache.rs b/textium/src/cache.rs index a043740..29abe97 100644 --- a/textium/src/cache.rs +++ b/textium/src/cache.rs @@ -13,9 +13,9 @@ struct FaceKey { } pub struct CachedFaceData where B: Buffer2d { - buffer: B, - atlas: FontAtlas, - line_height: f32, + pub buffer: B, + pub atlas: FontAtlas, + pub line_height: f32, } #[derive(Debug)] diff --git a/textium/src/lib.rs b/textium/src/lib.rs index c99d35f..f7888b2 100644 --- a/textium/src/lib.rs +++ b/textium/src/lib.rs @@ -29,18 +29,9 @@ pub use rasterizer::Font; #[derive(Debug, Clone)] pub struct GlyphMetadata { /// Bounding box in the packed texture - bounding_box: Rect, + pub bounding_box: Rect, /// Scale that the character was rendered at - scale: f32, - - /// Distance between the bottom of the glyph and the baseline, in ems. - // baseline_distance: f32, - - /// Distance to advance in layout after this character - advance_width: f32, - - /// Horizontal offset between glyph origin and leftmost point of the glyph - left_bearing: f32, + pub scale: f32, } /// Maps glyphs to their size, location, and rendering properties in a glyph atlas. diff --git a/textium/src/rasterizer.rs b/textium/src/rasterizer.rs index 647b1e2..34d8371 100644 --- a/textium/src/rasterizer.rs +++ b/textium/src/rasterizer.rs @@ -12,7 +12,7 @@ use ::packer::{Packer, GrowingPacker, SkylinePacker}; /// Wraps a rusttype font and provides atlas packing and rasterization functions. #[derive(Clone)] pub struct Font<'a> { - font: rusttype::Font<'a>, + pub font: rusttype::Font<'a>, } #[allow(dead_code)] @@ -74,7 +74,6 @@ impl<'a> Font<'a> { None => return None, // propogate missing glyphs out of the function }.scaled(rusttype::Scale::uniform(scale)); - let h_metrics = glyph.h_metrics(); let glyph = glyph.positioned(rusttype::Point {x: 0., y: 0.}); let bbox = match glyph.pixel_bounding_box() { Some(b) => b, @@ -94,9 +93,6 @@ impl<'a> Font<'a> { w: bbox.width() as usize, h: bbox.height() as usize, }, - - advance_width: h_metrics.advance_width, - left_bearing: h_metrics.left_side_bearing, }; Some((data, out))