core: Add default_font feature which enables the fallback font
This commit is contained in:
parent
74a7ab5afe
commit
ec21ad8658
|
@ -79,6 +79,7 @@ known_stubs = ["linkme"]
|
|||
default_compatibility_rules = []
|
||||
egui = ["dep:egui", "dep:egui_extras", "png"]
|
||||
jpegxr = ["dep:jpegxr"]
|
||||
default_font = []
|
||||
|
||||
[build-dependencies]
|
||||
build_playerglobal = { path = "build_playerglobal" }
|
||||
|
|
|
@ -790,12 +790,13 @@ impl Default for TextRenderSettings {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::font::{EvalParameters, Font};
|
||||
use crate::player::FALLBACK_DEVICE_FONT_TAG;
|
||||
use crate::string::WStr;
|
||||
use gc_arena::{rootless_arena, Mutation};
|
||||
use ruffle_render::backend::{null::NullRenderer, ViewportDimensions};
|
||||
use swf::Twips;
|
||||
|
||||
const DEVICE_FONT_TAG: &[u8] = include_bytes!("../assets/noto-sans-definefont3.bin");
|
||||
|
||||
fn with_device_font<F>(callback: F)
|
||||
where
|
||||
F: for<'gc> FnOnce(&Mutation<'gc>, Font<'gc>),
|
||||
|
@ -806,7 +807,7 @@ mod tests {
|
|||
height: 0,
|
||||
scale_factor: 1.0,
|
||||
});
|
||||
let mut reader = swf::read::Reader::new(FALLBACK_DEVICE_FONT_TAG, 8);
|
||||
let mut reader = swf::read::Reader::new(DEVICE_FONT_TAG, 8);
|
||||
let device_font = Font::from_swf_tag(
|
||||
mc,
|
||||
&mut renderer,
|
||||
|
|
|
@ -69,6 +69,7 @@ use tracing::{info, instrument};
|
|||
/// `player_version`.
|
||||
pub const NEWEST_PLAYER_VERSION: u8 = 32;
|
||||
|
||||
#[cfg(feature = "default_font")]
|
||||
pub const FALLBACK_DEVICE_FONT_TAG: &[u8] = include_bytes!("../assets/noto-sans-definefont3.bin");
|
||||
|
||||
#[derive(Collect)]
|
||||
|
@ -2531,15 +2532,18 @@ impl PlayerBuilder {
|
|||
// Finalize configuration and load the movie.
|
||||
let mut player_lock = player.lock().unwrap();
|
||||
|
||||
// TODO: This should be done by the frontend... probably?
|
||||
let mut font_reader = swf::read::Reader::new(FALLBACK_DEVICE_FONT_TAG, 8);
|
||||
let font_tag = font_reader
|
||||
.read_define_font_2(3)
|
||||
.expect("Built-in font should compile");
|
||||
player_lock.register_device_font(FontDefinition::SwfTag(font_tag, font_reader.encoding()));
|
||||
player_lock.set_default_font(DefaultFont::Sans, vec!["Noto Sans".to_string()]);
|
||||
player_lock.set_default_font(DefaultFont::Serif, vec!["Noto Sans".to_string()]);
|
||||
player_lock.set_default_font(DefaultFont::Typewriter, vec!["Noto Sans".to_string()]);
|
||||
#[cfg(feature = "default_font")]
|
||||
{
|
||||
let mut font_reader = swf::read::Reader::new(FALLBACK_DEVICE_FONT_TAG, 8);
|
||||
let font_tag = font_reader
|
||||
.read_define_font_2(3)
|
||||
.expect("Built-in font should compile");
|
||||
player_lock
|
||||
.register_device_font(FontDefinition::SwfTag(font_tag, font_reader.encoding()));
|
||||
player_lock.set_default_font(DefaultFont::Sans, vec!["Noto Sans".to_string()]);
|
||||
player_lock.set_default_font(DefaultFont::Serif, vec!["Noto Sans".to_string()]);
|
||||
player_lock.set_default_font(DefaultFont::Typewriter, vec!["Noto Sans".to_string()]);
|
||||
}
|
||||
|
||||
player_lock.mutate_with_update_context(|context| {
|
||||
Avm2::load_player_globals(context).expect("Unable to load AVM2 globals");
|
||||
|
|
|
@ -14,7 +14,7 @@ egui = { workspace = true }
|
|||
egui-wgpu = { version = "0.23.0", features = ["winit"] }
|
||||
egui-winit = "0.23.0"
|
||||
fontdb = "0.15"
|
||||
ruffle_core = { path = "../core", features = ["audio", "clap", "mp3", "nellymoser", "default_compatibility_rules", "egui"] }
|
||||
ruffle_core = { path = "../core", features = ["audio", "clap", "mp3", "nellymoser", "default_compatibility_rules", "egui", "default_font"] }
|
||||
ruffle_render = { path = "../render", features = ["clap"] }
|
||||
ruffle_render_wgpu = { path = "../render/wgpu", features = ["clap"] }
|
||||
ruffle_video_software = { path = "../video/software", optional = true }
|
||||
|
|
|
@ -10,7 +10,7 @@ version.workspace = true
|
|||
[dependencies]
|
||||
clap = { version = "4.4.6", features = ["derive"] }
|
||||
futures = "0.3"
|
||||
ruffle_core = { path = "../core", features = ["deterministic"] }
|
||||
ruffle_core = { path = "../core", features = ["deterministic", "default_font"] }
|
||||
ruffle_render_wgpu = { path = "../render/wgpu", features = ["clap"] }
|
||||
image = { version = "0.24.7", default-features = false, features = ["png"] }
|
||||
log = "0.4"
|
||||
|
|
|
@ -9,7 +9,7 @@ version.workspace = true
|
|||
|
||||
[dependencies]
|
||||
futures = "0.3.28"
|
||||
ruffle_core = { path = "../core", features = ["deterministic", "timeline_debug", "avm_debug", "audio", "mp3"] }
|
||||
ruffle_core = { path = "../core", features = ["deterministic", "timeline_debug", "avm_debug", "audio", "mp3", "default_font"] }
|
||||
ruffle_render_wgpu = { path = "../render/wgpu" }
|
||||
ruffle_render = { path = "../render" }
|
||||
ruffle_input_format = { path = "input-format" }
|
||||
|
|
|
@ -56,7 +56,7 @@ gloo-net = { version = "0.4.0", default-features = false, features = ["websocke
|
|||
[dependencies.ruffle_core]
|
||||
path = "../core"
|
||||
default-features = false
|
||||
features = ["audio", "mp3", "nellymoser", "wasm-bindgen", "default", "default_compatibility_rules"]
|
||||
features = ["audio", "mp3", "nellymoser", "wasm-bindgen", "default", "default_compatibility_rules", "default_font"]
|
||||
|
||||
[dependencies.web-sys]
|
||||
version = "0.3.64"
|
||||
|
|
Loading…
Reference in New Issue