Tidy up SpriteCache::render_glyph
This commit is contained in:
parent
01bbf20962
commit
0ec984f924
1 changed files with 7 additions and 11 deletions
|
@ -85,15 +85,10 @@ impl SpriteCache {
|
||||||
) -> Option<GlyphSprite> {
|
) -> Option<GlyphSprite> {
|
||||||
const SUBPIXEL_VARIANTS: u8 = 4;
|
const SUBPIXEL_VARIANTS: u8 = 4;
|
||||||
|
|
||||||
let scale_factor = self.scale_factor;
|
let target_position = target_position * self.scale_factor;
|
||||||
let target_position = target_position * scale_factor;
|
|
||||||
let fonts = &self.fonts;
|
|
||||||
let atlases = &mut self.atlases;
|
|
||||||
let subpixel_variant = (
|
let subpixel_variant = (
|
||||||
(target_position.x().fract() * SUBPIXEL_VARIANTS as f32).floor() as u8
|
(target_position.x().fract() * SUBPIXEL_VARIANTS as f32).floor() as u8,
|
||||||
% SUBPIXEL_VARIANTS,
|
(target_position.y().fract() * SUBPIXEL_VARIANTS as f32).floor() as u8,
|
||||||
(target_position.y().fract() * SUBPIXEL_VARIANTS as f32).floor() as u8
|
|
||||||
% SUBPIXEL_VARIANTS,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
self.glyphs
|
self.glyphs
|
||||||
|
@ -108,16 +103,17 @@ impl SpriteCache {
|
||||||
subpixel_variant.0 as f32 / SUBPIXEL_VARIANTS as f32,
|
subpixel_variant.0 as f32 / SUBPIXEL_VARIANTS as f32,
|
||||||
subpixel_variant.1 as f32 / SUBPIXEL_VARIANTS as f32,
|
subpixel_variant.1 as f32 / SUBPIXEL_VARIANTS as f32,
|
||||||
);
|
);
|
||||||
let (glyph_bounds, mask) = fonts.rasterize_glyph(
|
let (glyph_bounds, mask) = self.fonts.rasterize_glyph(
|
||||||
font_id,
|
font_id,
|
||||||
font_size,
|
font_size,
|
||||||
glyph_id,
|
glyph_id,
|
||||||
subpixel_shift,
|
subpixel_shift,
|
||||||
scale_factor,
|
self.scale_factor,
|
||||||
RasterizationOptions::Alpha,
|
RasterizationOptions::Alpha,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let (alloc_id, atlas_bounds) = atlases
|
let (alloc_id, atlas_bounds) = self
|
||||||
|
.atlases
|
||||||
.upload(glyph_bounds.size(), &mask)
|
.upload(glyph_bounds.size(), &mask)
|
||||||
.expect("could not upload glyph");
|
.expect("could not upload glyph");
|
||||||
Some(GlyphSprite {
|
Some(GlyphSprite {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue