Browse Source

textium: remove metrics from structs, make a bunch of fields pub

master
Erin 8 years ago
parent
commit
f0bc15f5c7
3 changed files with 6 additions and 19 deletions
  1. +3
    -3
      textium/src/cache.rs
  2. +2
    -11
      textium/src/lib.rs
  3. +1
    -5
      textium/src/rasterizer.rs

+ 3
- 3
textium/src/cache.rs View File

@ -13,9 +13,9 @@ struct FaceKey {
}
pub struct CachedFaceData<B> where B: Buffer2d {
buffer: B,
atlas: FontAtlas,
line_height: f32,
pub buffer: B,
pub atlas: FontAtlas,
pub line_height: f32,
}
#[derive(Debug)]


+ 2
- 11
textium/src/lib.rs View File

@ -29,18 +29,9 @@ pub use rasterizer::Font;
#[derive(Debug, Clone)]
pub struct GlyphMetadata {
/// Bounding box in the packed texture
bounding_box: Rect<usize>,
pub bounding_box: Rect<usize>,
/// 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.


+ 1
- 5
textium/src/rasterizer.rs View File

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


Loading…
Cancel
Save