avm2: Allow TLF to use embedded fonts when requested

This commit is contained in:
Tom Schuster 2024-01-18 19:20:01 +01:00
parent 0a6cf92a53
commit c9c1326d13
2 changed files with 9 additions and 3 deletions

View File

@ -139,7 +139,7 @@ fn apply_format<'gc>(
.get_public_property("fontSize", activation)? .get_public_property("fontSize", activation)?
.coerce_to_number(activation)?; .coerce_to_number(activation)?;
let (font, bold, italic) = if let Value::Object(font_description) = let (font, bold, italic, is_device_font) = if let Value::Object(font_description) =
element_format.get_public_property("fontDescription", activation)? element_format.get_public_property("fontDescription", activation)?
{ {
( (
@ -162,9 +162,13 @@ fn apply_format<'gc>(
.coerce_to_string(activation)? .coerce_to_string(activation)?
== b"italic", == b"italic",
), ),
&font_description
.get_public_property("fontLookup", activation)?
.coerce_to_string(activation)?
== b"device",
) )
} else { } else {
(None, None, None) (None, None, None, true)
}; };
let format = TextFormat { let format = TextFormat {
@ -176,8 +180,11 @@ fn apply_format<'gc>(
..TextFormat::default() ..TextFormat::default()
}; };
display_object.set_is_device_font(&mut activation.context, is_device_font);
display_object.set_text_format(0, text.len(), format.clone(), &mut activation.context); display_object.set_text_format(0, text.len(), format.clone(), &mut activation.context);
display_object.set_new_text_format(format, &mut activation.context); display_object.set_new_text_format(format, &mut activation.context);
} else {
display_object.set_is_device_font(&mut activation.context, true);
} }
display_object.set_word_wrap(true, &mut activation.context); display_object.set_word_wrap(true, &mut activation.context);

View File

@ -399,7 +399,6 @@ impl<'gc> EditText<'gc> {
let text = Self::new(context, swf_movie, x, y, width, height); let text = Self::new(context, swf_movie, x, y, width, height);
text.set_is_tlf(context.gc_context, true); text.set_is_tlf(context.gc_context, true);
text.set_selectable(false, context); text.set_selectable(false, context);
text.set_is_device_font(context, true);
text text
} }