mirror of
https://github.com/emilk/egui.git
synced 2026-08-29 04:40:03 -04:00
cleanup
This commit is contained in:
@@ -551,10 +551,13 @@ impl FontFace {
|
||||
} = *shaped;
|
||||
|
||||
if glyph_id == GlyphId::NOTDEF {
|
||||
// invisible
|
||||
return (GlyphAllocation::default(), h_pos.round() as i32);
|
||||
}
|
||||
|
||||
let (h_pos_round, bin) = if is_cjk {
|
||||
// CJK scripts contain a lot of characters and could hog the glyph atlas
|
||||
// if we stored 4 subpixel offsets per glyph.
|
||||
(h_pos.round() as i32, SubpixelBin::Zero)
|
||||
} else {
|
||||
SubpixelBin::new(h_pos)
|
||||
@@ -562,18 +565,11 @@ impl FontFace {
|
||||
|
||||
let cache_key = GlyphCacheKey::new(glyph_id, metrics, bin);
|
||||
|
||||
let alloc = if let Some(cached) = self.glyph_alloc_cache.get(&cache_key) {
|
||||
*cached
|
||||
} else {
|
||||
let alloc = self
|
||||
.font
|
||||
let alloc = *self.glyph_alloc_cache.entry(cache_key).or_insert_with(|| {
|
||||
self.font
|
||||
.allocate_glyph_uncached(atlas, metrics, glyph_id, bin, (&metrics.location).into())
|
||||
.unwrap_or_default();
|
||||
|
||||
self.glyph_alloc_cache.insert(cache_key, alloc);
|
||||
|
||||
alloc
|
||||
};
|
||||
.unwrap_or_default()
|
||||
});
|
||||
|
||||
(alloc, h_pos_round)
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ use crate::{
|
||||
Color32, Mesh, Stroke, Vertex,
|
||||
stroke::PathStroke,
|
||||
text::{
|
||||
TAB_SIZE,
|
||||
font::{StyledMetrics, is_cjk, is_cjk_break_allowed},
|
||||
fonts::FontFaceKey,
|
||||
},
|
||||
@@ -227,8 +228,8 @@ fn layout_shaped_run(
|
||||
// Override the advance width to TAB_SIZE × space width.
|
||||
if chr == '\t' {
|
||||
let (_, space_info) = font.glyph_info(' ');
|
||||
advance_width_px =
|
||||
crate::text::TAB_SIZE as f32 * space_info.advance_width_unscaled.0 * px_scale;
|
||||
let space_width_px = space_info.advance_width_unscaled.0 * px_scale;
|
||||
advance_width_px = TAB_SIZE as f32 * space_width_px;
|
||||
}
|
||||
|
||||
// Apply extra_letter_spacing only at cluster boundaries,
|
||||
|
||||
Reference in New Issue
Block a user