airsdk / Adobe-Runtime-Support

Report, track and discuss issues in Adobe AIR. Monitored by Adobe - and HARMAN - and maintained by the AIR community.
199 stars 11 forks source link

Italic textField cuts off by autoSize property #78

Open itlancer opened 5 years ago

itlancer commented 5 years ago

Problem Description

Italic TextField (italic property of TextFormat is true) cuts off last symbol when autoSize property used. No matter font and size. It's very old bug described even there in 2009: http://stackoverflow.com/questions/1516391/textfield-autosizeitalics-cuts-of-last-character It has been tested with many different Flash Player, AIR versions and devices and its architectures even with latests AIR 32.0.0.144 beta and AIR 33.0.1.220. Always the same problem.

Tracker link: https://tracker.adobe.com/#/view/AIR-3810978

Steps to Reproduce

Create TextField with italic formatting and set autoSize property to TextFieldAutoSize.LEFT, for example. Launch code below.

var textFormat:TextFormat = new TextFormat();
textFormat.italic = true;
textFormat.size = 72;
var textField:TextField = new TextField();
textField.defaultTextFormat = textFormat;
textField.text = "Italic text cuts off";
textField.autoSize = TextFieldAutoSize.LEFT;
this.addChild(textField);

Actual Result: Last symbol cuts off. See attached screenshot. screenshot

Expected Result: Autosized TextField field with correct displaying all symbols.

Known Workarounds

Manually control size of TextField field like here http://stackoverflow.com/questions/1516391/textfield-autosizeitalics-cuts-of-last-character

ajwfrost commented 4 years ago

FYI one of the guys has investigated this, we get text metrics back from Android or whichever platform it is, and these don't appear to take account of italic text like this: https://stackoverflow.com/questions/6745047/android-measuretext-on-paint-object-for-italic-rendered-fonts

So it's a bit of a workaround but if we detect the character is italic, we can add some additional width for the field based on the height of the text and the italic slant (Android apparently has 0.25; Flash uses 0.21 for embedded rendering)...

itlancer commented 4 years ago

Hi, @ajwfrost It's not Android specific. The same problem with AIR on all platforms: Windows, Android, macOS, iOS if you use non-embedded fonts. Embedded fonts with TextField::embedFonts=true displays correctly in such cases. So described problem only with device (system installed) fonts or default _sans etc.

ajwfrost commented 4 years ago

Yes, it seems pretty prevalent across all platforms - e.g. here's some folk trying to work around the same problem on Windows: https://www.codeproject.com/Articles/14915/Width-of-Text-in-Italic-Font

We're trying to ensure the changes we're making will help both when using autoSize and, and also just when measuring textWidth (so e.g. textField.width = textField.textWidth; has the same issue currently..)

itlancer commented 4 years ago

Thank you! Waiting for a new release.

itlancer commented 4 years ago

Fixed and looks great with AIR 33.0.2.315 for Android! But issue still exists for other platforms.

itlancer commented 4 years ago

With AIR 33.0.2.338 also fixed for Windows. Great job! Waiting fixes for macOS and iOS.

itlancer commented 4 years ago

With AIR 33.1.0.16 it fixed for macOS and iOS too. Waiting same fix for tvOS and would like to see it in production release.