@ -6,12 +6,8 @@ use skia_safe::{font::Edging, Data, Font, FontHinting, FontMgr, FontStyle, Typef
use super ::font_options ::FontOptions ;
use super ::font_options ::FontOptions ;
use super ::swash_font ::SwashFont ;
use super ::swash_font ::SwashFont ;
#[ derive(RustEmbed) ]
static DEFAULT_FONT : & [ u8 ] = include_bytes! ( "../../../assets/fonts/FiraCode-Regular.ttf" ) ;
#[ folder = " assets/fonts/ " ]
static LAST_RESORT_FONT : & [ u8 ] = include_bytes! ( "../../../assets/fonts/LastResort-Regular.ttf" ) ;
pub struct Asset ;
const DEFAULT_FONT : & str = "FiraCode-Regular.ttf" ;
const LAST_RESORT_FONT : & str = "LastResort-Regular.ttf" ;
pub struct FontPair {
pub struct FontPair {
pub skia_font : Font ,
pub skia_font : Font ,
@ -141,14 +137,12 @@ impl FontLoader {
FontPair ::new ( Font ::from_typeface ( typeface , self . font_size ) )
FontPair ::new ( Font ::from_typeface ( typeface , self . font_size ) )
}
}
FontSelection ::Default = > {
FontSelection ::Default = > {
let default_font_data = Asset ::get ( DEFAULT_FONT ) . unwrap ( ) ;
let data = Data ::new_copy ( DEFAULT_FONT ) ;
let data = Data ::new_copy ( & default_font_data ) ;
let typeface = Typeface ::from_data ( data , 0 ) . unwrap ( ) ;
let typeface = Typeface ::from_data ( data , 0 ) . unwrap ( ) ;
FontPair ::new ( Font ::from_typeface ( typeface , self . font_size ) )
FontPair ::new ( Font ::from_typeface ( typeface , self . font_size ) )
}
}
FontSelection ::LastResort = > {
FontSelection ::LastResort = > {
let default_font_data = Asset ::get ( LAST_RESORT_FONT ) . unwrap ( ) ;
let data = Data ::new_copy ( LAST_RESORT_FONT ) ;
let data = Data ::new_copy ( & default_font_data ) ;
let typeface = Typeface ::from_data ( data , 0 ) . unwrap ( ) ;
let typeface = Typeface ::from_data ( data , 0 ) . unwrap ( ) ;
FontPair ::new ( Font ::from_typeface ( typeface , self . font_size ) )
FontPair ::new ( Font ::from_typeface ( typeface , self . font_size ) )
}
}