Format code properly
This commit is contained in:
parent
a26470961d
commit
8cbf7238f8
@ -11,7 +11,9 @@ pub struct GlyphBrushBuilder<'a, H = DefaultSectionHasher> {
|
|||||||
inner: glyph_brush::GlyphBrushBuilder<'a, H>,
|
inner: glyph_brush::GlyphBrushBuilder<'a, H>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, H> From<glyph_brush::GlyphBrushBuilder<'a, H>> for GlyphBrushBuilder<'a, H> {
|
impl<'a, H> From<glyph_brush::GlyphBrushBuilder<'a, H>>
|
||||||
|
for GlyphBrushBuilder<'a, H>
|
||||||
|
{
|
||||||
fn from(inner: glyph_brush::GlyphBrushBuilder<'a, H>) -> Self {
|
fn from(inner: glyph_brush::GlyphBrushBuilder<'a, H>) -> Self {
|
||||||
GlyphBrushBuilder { inner }
|
GlyphBrushBuilder { inner }
|
||||||
}
|
}
|
||||||
@ -20,7 +22,9 @@ impl<'a> GlyphBrushBuilder<'a> {
|
|||||||
/// Specifies the default font data used to render glyphs.
|
/// Specifies the default font data used to render glyphs.
|
||||||
/// Referenced with `FontId(0)`, which is default.
|
/// Referenced with `FontId(0)`, which is default.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn using_font_bytes<B: Into<SharedBytes<'a>>>(font_0_data: B) -> Result<Self, Error> {
|
pub fn using_font_bytes<B: Into<SharedBytes<'a>>>(
|
||||||
|
font_0_data: B,
|
||||||
|
) -> Result<Self, Error> {
|
||||||
let font = Font::from_bytes(font_0_data)?;
|
let font = Font::from_bytes(font_0_data)?;
|
||||||
|
|
||||||
Ok(Self::using_font(font))
|
Ok(Self::using_font(font))
|
||||||
@ -65,7 +69,10 @@ impl<'a, H: BuildHasher> GlyphBrushBuilder<'a, H> {
|
|||||||
/// internal use.
|
/// internal use.
|
||||||
///
|
///
|
||||||
/// Defaults to [seahash](https://docs.rs/seahash).
|
/// Defaults to [seahash](https://docs.rs/seahash).
|
||||||
pub fn section_hasher<T: BuildHasher>(self, section_hasher: T) -> GlyphBrushBuilder<'a, T> {
|
pub fn section_hasher<T: BuildHasher>(
|
||||||
|
self,
|
||||||
|
section_hasher: T,
|
||||||
|
) -> GlyphBrushBuilder<'a, T> {
|
||||||
GlyphBrushBuilder {
|
GlyphBrushBuilder {
|
||||||
inner: self.inner.section_hasher(section_hasher),
|
inner: self.inner.section_hasher(section_hasher),
|
||||||
}
|
}
|
||||||
|
|||||||
43
src/lib.rs
43
src/lib.rs
@ -14,9 +14,10 @@ use pipeline::{Instance, Pipeline};
|
|||||||
pub use builder::GlyphBrushBuilder;
|
pub use builder::GlyphBrushBuilder;
|
||||||
pub use glyph_brush::{
|
pub use glyph_brush::{
|
||||||
rusttype::{self, Font, Point, PositionedGlyph, Rect, Scale, SharedBytes},
|
rusttype::{self, Font, Point, PositionedGlyph, Rect, Scale, SharedBytes},
|
||||||
BuiltInLineBreaker, FontId, FontMap, GlyphCruncher, GlyphPositioner, HorizontalAlign, Layout,
|
BuiltInLineBreaker, FontId, FontMap, GlyphCruncher, GlyphPositioner,
|
||||||
LineBreak, LineBreaker, OwnedSectionText, OwnedVariedSection, PositionedGlyphIter, Section,
|
HorizontalAlign, Layout, LineBreak, LineBreaker, OwnedSectionText,
|
||||||
SectionGeometry, SectionText, VariedSection, VerticalAlign,
|
OwnedVariedSection, PositionedGlyphIter, Section, SectionGeometry,
|
||||||
|
SectionText, VariedSection, VerticalAlign,
|
||||||
};
|
};
|
||||||
|
|
||||||
use core::hash::BuildHasher;
|
use core::hash::BuildHasher;
|
||||||
@ -58,8 +59,11 @@ impl<'font, H: BuildHasher> GlyphBrush<'font, H> {
|
|||||||
///
|
///
|
||||||
/// Benefits from caching, see [caching behaviour](#caching-behaviour).
|
/// Benefits from caching, see [caching behaviour](#caching-behaviour).
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn queue_custom_layout<'a, S, G>(&mut self, section: S, custom_layout: &G)
|
pub fn queue_custom_layout<'a, S, G>(
|
||||||
where
|
&mut self,
|
||||||
|
section: S,
|
||||||
|
custom_layout: &G,
|
||||||
|
) where
|
||||||
G: GlyphPositioner,
|
G: GlyphPositioner,
|
||||||
S: Into<Cow<'a, VariedSection<'a>>>,
|
S: Into<Cow<'a, VariedSection<'a>>>,
|
||||||
{
|
{
|
||||||
@ -85,8 +89,11 @@ impl<'font, H: BuildHasher> GlyphBrush<'font, H> {
|
|||||||
/// Should not be necessary unless using multiple draws per frame with
|
/// Should not be necessary unless using multiple draws per frame with
|
||||||
/// distinct transforms, see [caching behaviour](#caching-behaviour).
|
/// distinct transforms, see [caching behaviour](#caching-behaviour).
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn keep_cached_custom_layout<'a, S, G>(&mut self, section: S, custom_layout: &G)
|
pub fn keep_cached_custom_layout<'a, S, G>(
|
||||||
where
|
&mut self,
|
||||||
|
section: S,
|
||||||
|
custom_layout: &G,
|
||||||
|
) where
|
||||||
S: Into<Cow<'a, VariedSection<'a>>>,
|
S: Into<Cow<'a, VariedSection<'a>>>,
|
||||||
G: GlyphPositioner,
|
G: GlyphPositioner,
|
||||||
{
|
{
|
||||||
@ -130,10 +137,13 @@ impl<'font, H: BuildHasher> GlyphBrush<'font, H> {
|
|||||||
// This is currently not possible I think. Ask!
|
// This is currently not possible I think. Ask!
|
||||||
let max_image_dimension = 2048;
|
let max_image_dimension = 2048;
|
||||||
|
|
||||||
let (new_width, new_height) = if (suggested.0 > max_image_dimension
|
let (new_width, new_height) = if (suggested.0
|
||||||
|
> max_image_dimension
|
||||||
|| suggested.1 > max_image_dimension)
|
|| suggested.1 > max_image_dimension)
|
||||||
&& (self.glyph_brush.texture_dimensions().0 < max_image_dimension
|
&& (self.glyph_brush.texture_dimensions().0
|
||||||
|| self.glyph_brush.texture_dimensions().1 < max_image_dimension)
|
< max_image_dimension
|
||||||
|
|| self.glyph_brush.texture_dimensions().1
|
||||||
|
< max_image_dimension)
|
||||||
{
|
{
|
||||||
(max_image_dimension, max_image_dimension)
|
(max_image_dimension, max_image_dimension)
|
||||||
} else {
|
} else {
|
||||||
@ -150,7 +160,8 @@ impl<'font, H: BuildHasher> GlyphBrush<'font, H> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
pipeline.increase_cache_size(context, new_width, new_height);
|
pipeline
|
||||||
|
.increase_cache_size(context, new_width, new_height);
|
||||||
self.glyph_brush.resize_texture(new_width, new_height);
|
self.glyph_brush.resize_texture(new_width, new_height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -175,7 +186,10 @@ impl<'font, H: BuildHasher> GlyphBrush<'font, H> {
|
|||||||
/// Adds an additional font to the one(s) initially added on build.
|
/// Adds an additional font to the one(s) initially added on build.
|
||||||
///
|
///
|
||||||
/// Returns a new [`FontId`](struct.FontId.html) to reference this font.
|
/// Returns a new [`FontId`](struct.FontId.html) to reference this font.
|
||||||
pub fn add_font_bytes<'a: 'font, B: Into<SharedBytes<'a>>>(&mut self, font_data: B) -> FontId {
|
pub fn add_font_bytes<'a: 'font, B: Into<SharedBytes<'a>>>(
|
||||||
|
&mut self,
|
||||||
|
font_data: B,
|
||||||
|
) -> FontId {
|
||||||
self.glyph_brush.add_font_bytes(font_data)
|
self.glyph_brush.add_font_bytes(font_data)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,7 +202,10 @@ impl<'font, H: BuildHasher> GlyphBrush<'font, H> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'font, H: BuildHasher> GlyphBrush<'font, H> {
|
impl<'font, H: BuildHasher> GlyphBrush<'font, H> {
|
||||||
fn new(gl: &glow::Context, raw_builder: glyph_brush::GlyphBrushBuilder<'font, H>) -> Self {
|
fn new(
|
||||||
|
gl: &glow::Context,
|
||||||
|
raw_builder: glyph_brush::GlyphBrushBuilder<'font, H>,
|
||||||
|
) -> Self {
|
||||||
let glyph_brush = raw_builder.build();
|
let glyph_brush = raw_builder.build();
|
||||||
let (cache_width, cache_height) = glyph_brush.texture_dimensions();
|
let (cache_width, cache_height) = glyph_brush.texture_dimensions();
|
||||||
GlyphBrush {
|
GlyphBrush {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user