Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avm2: Stub more methods from FTE #19277

Merged
merged 2 commits into from
Jan 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions core/src/avm2/globals/flash/text/engine/ElementFormat.as
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
package flash.text.engine {
import __ruffle__.stub_method;

import flash.geom.Rectangle;

[API("662")]
public final class ElementFormat {
private var _alignmentBaseline:String;
Expand Down Expand Up @@ -200,5 +204,13 @@ package flash.text.engine {
public function set typographicCase(value:String):void {
this._typographicCase = value;
}

public function getFontMetrics():FontMetrics {
stub_method("flash.text.engine.ElementFormat", "getFontMetrics");
var emBox:Rectangle = new Rectangle(0, _fontSize * -0.8, _fontSize, _fontSize);
return new FontMetrics(
emBox, -5, 1.2, 1.8, 1.2, 0.075, 0.6, -0.35, 0.6, 0.0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these completely random numbers, or taken from some existing font? :D

Copy link
Member Author

@kjarosh kjarosh Jan 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those are numbers taken from an existing font (roughly). I don't think their exact values matter, but their signs and orders of magnitude might.

);
}
}
}
36 changes: 36 additions & 0 deletions core/src/avm2/globals/flash/text/engine/TextLine.as
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package flash.text.engine {
import __ruffle__.stub_setter;
import __ruffle__.stub_method;

import flash.display.DisplayObject;
import flash.display.DisplayObjectContainer;
import flash.errors.IllegalOperationError;
import flash.geom.Rectangle;
Expand Down Expand Up @@ -113,11 +114,46 @@ package flash.text.engine {
return -1;
}

public function getAtomBidiLevel(index:int):int {
stub_method("flash.text.engine.TextLine", "getAtomBidiLevel");
return 0;
}

public function getAtomBounds(index:int):Rectangle {
stub_method("flash.text.engine.TextLine", "getAtomBounds");
return new Rectangle(0, 0, 0, 0);
}

public function getAtomCenter(index:int):Number {
stub_method("flash.text.engine.TextLine", "getAtomCenter");
return 1.0;
}

public function getAtomGraphic(index:int):DisplayObject {
stub_method("flash.text.engine.TextLine", "getAtomGraphic");
return null;
}

public function getAtomTextBlockBeginIndex(index:int):int {
stub_method("flash.text.engine.TextLine", "getAtomTextBlockBeginIndex");
return 0;
}

public function getAtomTextBlockEndIndex(index:int):int {
stub_method("flash.text.engine.TextLine", "getAtomTextBlockEndIndex");
return 0;
}

public function getAtomTextRotation(index:int):String {
stub_method("flash.text.engine.TextLine", "getAtomTextRotation");
return TextRotation.ROTATE_0;
}

public function getAtomWordBoundaryOnLeft(index:int):Boolean {
stub_method("flash.text.engine.TextLine", "getAtomWordBoundaryOnLeft");
return false;
}

// This function does nothing in Flash Player 32
public function flushAtomData():void { }

Expand Down