Adobe-Runtime-Support icon indicating copy to clipboard operation
Adobe-Runtime-Support copied to clipboard

Italic textField cuts off by autoSize property

Open itlancer opened this issue 6 years ago • 14 comments

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

itlancer avatar Aug 20 '19 10:08 itlancer

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)...

ajwfrost avatar Nov 06 '19 14:11 ajwfrost

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.

itlancer avatar Nov 06 '19 16:11 itlancer

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..)

ajwfrost avatar Nov 07 '19 07:11 ajwfrost

Thank you! Waiting for a new release.

itlancer avatar Nov 07 '19 07:11 itlancer

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

itlancer avatar Nov 14 '19 21:11 itlancer

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

itlancer avatar Dec 13 '19 16:12 itlancer

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.

itlancer avatar Jan 21 '20 16:01 itlancer

@ajwfrost I found that issue still exists if you set up <renderMode>direct</renderMode> in AIR application manifest.

itlancer avatar Sep 29 '24 15:09 itlancer

@ajwfrost With AIR 51.1.2.1 this issue using <renderMode>direct</renderMode> fixed but italic text selection broken. Even without this option. Please take a look:

https://github.com/user-attachments/assets/81d39b82-ca38-4948-bd04-fe28b67a6b7c

itlancer avatar Oct 14 '24 12:10 itlancer

That's a strange side-effect :-( Will check that, we probably have a few small/extra fixes to do so will try to follow up with 51.1.2.2 asap..

thanks

ajwfrost avatar Oct 14 '24 12:10 ajwfrost

Ah - I see what's happening, it's because the text is split into different sections because of the selection. So then it adds the spacing needed for the final italic character of the block..

ajwfrost avatar Oct 14 '24 12:10 ajwfrost

There seem to be a number of issues relating to the selection of italic text. At least from when I'm trying it here (without our recent change that introduced the above issue), if you select text using your mouse by swiping from the right to the left, the selection area will cut off the tops/rightmost parts of the last non-selected character.

I'm hoping that these are all interlinked but it's proving to be quite complex to work out what's actually happening here - our "simple" approach to ensure the width of a text run takes into account the slope of the characters has this obvious side effect, but trying to spot when this should/shouldn't be added is maybe the wrong approach. Interesting area ...

ajwfrost avatar Oct 16 '24 11:10 ajwfrost

if you select text using your mouse by swiping from the right to the left, the selection area will cut off the tops/rightmost parts of the last non-selected character.

@ajwfrost It has always been like this. It's not cool but right now it's ok if it hard to make better in short time. It could be moved to different long-term issue.

itlancer avatar Oct 16 '24 12:10 itlancer

Okay thanks .. so we have a fix for the Windows-specific bit about the rightmost character in auto-size text fields, which doesn't have this side effect; I will open up an internal issue to revisit the selection handling in the text fields (which appears to be a cross-platform problem)

thanks

ajwfrost avatar Oct 16 '24 14:10 ajwfrost

Fixed with latest AIR 51.1.2.2. Thanks!

itlancer avatar Nov 10 '24 14:11 itlancer