mirror of
https://github.com/griffi-gh/hUI.git
synced 2024-11-22 07:08:42 -06:00
add docs
This commit is contained in:
parent
f8b80040f3
commit
9acdacaa32
|
@ -8,6 +8,7 @@ mod font;
|
||||||
mod ftm;
|
mod ftm;
|
||||||
mod stack;
|
mod stack;
|
||||||
|
|
||||||
|
/// Built-in font handle
|
||||||
#[cfg(feature="builtin_font")]
|
#[cfg(feature="builtin_font")]
|
||||||
pub use font::BUILTIN_FONT;
|
pub use font::BUILTIN_FONT;
|
||||||
pub use font::FontHandle;
|
pub use font::FontHandle;
|
||||||
|
@ -17,7 +18,7 @@ use ftm::FontTextureManager;
|
||||||
use ftm::GlyphCacheEntry;
|
use ftm::GlyphCacheEntry;
|
||||||
use stack::FontStack;
|
use stack::FontStack;
|
||||||
|
|
||||||
pub struct TextRenderer {
|
pub(crate) struct TextRenderer {
|
||||||
manager: FontManager,
|
manager: FontManager,
|
||||||
ftm: FontTextureManager,
|
ftm: FontTextureManager,
|
||||||
stack: FontStack,
|
stack: FontStack,
|
||||||
|
@ -63,15 +64,18 @@ impl Default for TextRenderer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Size of measured text
|
||||||
pub struct TextMeasureResponse {
|
pub struct TextMeasureResponse {
|
||||||
pub max_width: f32,
|
pub max_width: f32,
|
||||||
pub height: f32,
|
pub height: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Context for measuring text
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
pub struct TextMeasure<'a>(&'a TextRenderer);
|
pub struct TextMeasure<'a>(&'a TextRenderer);
|
||||||
|
|
||||||
impl<'a> TextMeasure<'a> {
|
impl<'a> TextMeasure<'a> {
|
||||||
|
/// Measure the given string of text with the given font and size
|
||||||
pub fn measure(&self, font: FontHandle, size: u16, text: &str) -> TextMeasureResponse {
|
pub fn measure(&self, font: FontHandle, size: u16, text: &str) -> TextMeasureResponse {
|
||||||
use fontdue::layout::{Layout, CoordinateSystem, TextStyle};
|
use fontdue::layout::{Layout, CoordinateSystem, TextStyle};
|
||||||
let mut layout = Layout::new(CoordinateSystem::PositiveYDown);
|
let mut layout = Layout::new(CoordinateSystem::PositiveYDown);
|
||||||
|
|
Loading…
Reference in a new issue