Skip to content

Commit

Permalink
avm2: Use slot access in remaining TextBlock code
Browse files Browse the repository at this point in the history
  • Loading branch information
Lord-McSweeney authored and Lord-McSweeney committed Dec 10, 2024
1 parent 6dd2d9d commit 2b74c70
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
3 changes: 3 additions & 0 deletions core/src/avm2/globals/flash/text/engine/ElementFormat.as
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package flash.text.engine {

private var _breakOpportunity:String;

[Ruffle(InternalSlot)]
private var _color:uint;

private var _digitCase:String;
Expand All @@ -16,8 +17,10 @@ package flash.text.engine {

private var _dominantBaseline:String;

[Ruffle(InternalSlot)]
private var _fontDescription:FontDescription;

[Ruffle(InternalSlot)]
private var _fontSize:Number;

private var _kerning:String;
Expand Down
4 changes: 4 additions & 0 deletions core/src/avm2/globals/flash/text/engine/FontDescription.as
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@ package flash.text.engine {
import __ruffle__.stub_method;

public final class FontDescription {
[Ruffle(InternalSlot)]
private var _fontName:String;

[Ruffle(InternalSlot)]
private var _fontWeight:String;

[Ruffle(InternalSlot)]
private var _fontPosture:String;

[Ruffle(InternalSlot)]
private var _fontLookup:String;

private var _renderingMode:String;
Expand Down
16 changes: 9 additions & 7 deletions core/src/avm2/globals/flash/text/engine/text_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ use crate::avm2::activation::Activation;
use crate::avm2::error::Error;
use crate::avm2::globals::flash::display::display_object::initialize_for_allocator;
use crate::avm2::globals::slots::flash_text_engine_content_element as element_slots;
use crate::avm2::globals::slots::flash_text_engine_element_format as format_slots;
use crate::avm2::globals::slots::flash_text_engine_font_description as font_desc_slots;
use crate::avm2::globals::slots::flash_text_engine_text_block as block_slots;
use crate::avm2::globals::slots::flash_text_engine_text_line as line_slots;
use crate::avm2::object::{Object, TObject};
Expand Down Expand Up @@ -105,37 +107,37 @@ fn apply_format<'gc>(
if let Some(element_format) = element_format {
// TODO: Support more ElementFormat properties
let color = element_format
.get_public_property("color", activation)?
.get_slot(format_slots::_COLOR)
.coerce_to_u32(activation)?;
let size = element_format
.get_public_property("fontSize", activation)?
.get_slot(format_slots::_FONT_SIZE)
.coerce_to_number(activation)?;

let (font, bold, italic, is_device_font) = if let Value::Object(font_description) =
element_format.get_public_property("fontDescription", activation)?
element_format.get_slot(format_slots::_FONT_DESCRIPTION)
{
(
Some(
font_description
.get_public_property("fontName", activation)?
.get_slot(font_desc_slots::_FONT_NAME)
.coerce_to_string(activation)?
.as_wstr()
.into(),
),
Some(
&font_description
.get_public_property("fontWeight", activation)?
.get_slot(font_desc_slots::_FONT_WEIGHT)
.coerce_to_string(activation)?
== b"bold",
),
Some(
&font_description
.get_public_property("fontPosture", activation)?
.get_slot(font_desc_slots::_FONT_POSTURE)
.coerce_to_string(activation)?
== b"italic",
),
&font_description
.get_public_property("fontLookup", activation)?
.get_slot(font_desc_slots::_FONT_LOOKUP)
.coerce_to_string(activation)?
== b"device",
)
Expand Down

0 comments on commit 2b74c70

Please sign in to comment.