Memory map fonts
This commit is contained in:
parent
0365737908
commit
66ab1e6000
2 changed files with 9 additions and 3 deletions
|
|
@ -8,6 +8,7 @@ publish = false
|
|||
[dependencies]
|
||||
ab_glyph = { version = "0.2", optional = true }
|
||||
orbclient = "0.3"
|
||||
memmap2 = "0.5"
|
||||
rusttype = { version = "0.9", optional = true }
|
||||
rustybuzz = "0.5"
|
||||
swash = { version = "0.1", optional = true }
|
||||
|
|
|
|||
|
|
@ -42,10 +42,15 @@ fn main() {
|
|||
("/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc", 2 /* simplified chinese */),
|
||||
("/usr/share/fonts/truetype/noto/NotoColorEmoji.ttf", 0),
|
||||
] {
|
||||
match fs::read(font_path) {
|
||||
Ok(font_data) => font_datas.push((font_path, font_data, *font_index)),
|
||||
match fs::File::open(&font_path) {
|
||||
Ok(font_file) => match unsafe { memmap2::Mmap::map(&font_file) } {
|
||||
Ok(font_data) => font_datas.push((font_path, font_data, *font_index)),
|
||||
Err(err) => {
|
||||
eprintln!("failed to memory map font '{}': {}", font_path, err)
|
||||
}
|
||||
},
|
||||
Err(err) => {
|
||||
eprintln!("failed to read font '{}': {}", font_path, err)
|
||||
eprintln!("failed to open font '{}': {}", font_path, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue