@@ -224,7 +224,10 @@ fn ab_glyph_font_from_font_data(name: &str, data: &FontData) -> ab_glyph::FontAr
224
224
///
225
225
/// // Install my own font (maybe supporting non-latin characters):
226
226
/// fonts.font_data.insert("my_font".to_owned(),
227
- /// FontData::from_static(include_bytes!("../../../epaint_default_fonts/fonts/Ubuntu-Light.ttf"))); // .ttf and .otf supported
227
+ /// std::sync::Arc::new(
228
+ /// // .ttf and .otf supported
229
+ /// FontData::from_static(include_bytes!("../../../epaint_default_fonts/fonts/Ubuntu-Light.ttf")))
230
+ /// );
228
231
///
229
232
/// // Put my font first (highest priority):
230
233
/// fonts.families.get_mut(&FontFamily::Proportional).unwrap()
@@ -243,7 +246,7 @@ pub struct FontDefinitions {
243
246
/// List of font names and their definitions.
244
247
///
245
248
/// `epaint` has built-in-default for these, but you can override them if you like.
246
- pub font_data : BTreeMap < String , FontData > ,
249
+ pub font_data : BTreeMap < String , Arc < FontData > > ,
247
250
248
251
/// Which fonts (names) to use for each [`FontFamily`].
249
252
///
@@ -310,33 +313,36 @@ impl Default for FontDefinitions {
310
313
/// otherwise this is the same as [`Self::empty`].
311
314
#[ cfg( feature = "default_fonts" ) ]
312
315
fn default ( ) -> Self {
313
- let mut font_data: BTreeMap < String , FontData > = BTreeMap :: new ( ) ;
316
+ let mut font_data: BTreeMap < String , Arc < FontData > > = BTreeMap :: new ( ) ;
314
317
315
318
let mut families = BTreeMap :: new ( ) ;
316
319
317
- font_data. insert ( "Hack" . to_owned ( ) , FontData :: from_static ( HACK_REGULAR ) ) ;
320
+ font_data. insert (
321
+ "Hack" . to_owned ( ) ,
322
+ Arc :: new ( FontData :: from_static ( HACK_REGULAR ) ) ,
323
+ ) ;
318
324
319
325
// Some good looking emojis. Use as first priority:
320
326
font_data. insert (
321
327
"NotoEmoji-Regular" . to_owned ( ) ,
322
- FontData :: from_static ( NOTO_EMOJI_REGULAR ) . tweak ( FontTweak {
328
+ Arc :: new ( FontData :: from_static ( NOTO_EMOJI_REGULAR ) . tweak ( FontTweak {
323
329
scale : 0.81 , // Make smaller
324
330
..Default :: default ( )
325
- } ) ,
331
+ } ) ) ,
326
332
) ;
327
333
328
334
font_data. insert (
329
335
"Ubuntu-Light" . to_owned ( ) ,
330
- FontData :: from_static ( UBUNTU_LIGHT ) ,
336
+ Arc :: new ( FontData :: from_static ( UBUNTU_LIGHT ) ) ,
331
337
) ;
332
338
333
339
// Bigger emojis, and more. <http://jslegers.github.io/emoji-icon-font/>:
334
340
font_data. insert (
335
341
"emoji-icon-font" . to_owned ( ) ,
336
- FontData :: from_static ( EMOJI_ICON ) . tweak ( FontTweak {
342
+ Arc :: new ( FontData :: from_static ( EMOJI_ICON ) . tweak ( FontTweak {
337
343
scale : 0.90 , // Make smaller
338
344
..Default :: default ( )
339
- } ) ,
345
+ } ) ) ,
340
346
) ;
341
347
342
348
families. insert (
@@ -795,7 +801,7 @@ impl FontImplCache {
795
801
pub fn new (
796
802
atlas : Arc < Mutex < TextureAtlas > > ,
797
803
pixels_per_point : f32 ,
798
- font_data : & BTreeMap < String , FontData > ,
804
+ font_data : & BTreeMap < String , Arc < FontData > > ,
799
805
) -> Self {
800
806
let ab_glyph_fonts = font_data
801
807
. iter ( )
0 commit comments