Texts are slightly cut on the right on native platforms (NME)
I don't really know where to start investigating. It seems on NME, the dimensions of the texts are not correctly measured, and thus the draw surface is slightly too small.
Rendering and measuring of the text for flash and NME is done here : https://github.com/silexlabs/Cocktail/blob/master/cocktail/port/platform/flash_player/NativeText.hx
The "getBimap" method draws a native flash/NME TextField onto a flash/NME BitmapData, which is then used to draw text during the document's rendering.
In this same class, you can see "get_width" return the width of the native flash/NME TextField, which seems to be too small for NME, explaining the crop.
I'd suggest measuring "textWidth" for the same word in flash and NME and see if it's different. If it is, then NME measure is wrong, or at least not consistent with the flash player. You can either hack something in this class or (better), fix in NME.
I'll also look in 'getBitmap" at the part offsetting flash player "gutter" for the text field (see line 83). Maybe it shouldn't be applied for NME.
There is another class dealing with font measurement but it takes care of vertical measurement and is unlikely to be responsible for your bug : https://github.com/silexlabs/Cocktail/blob/master/cocktail/port/platform/flash_player/FontBuilder.hx
I've tried to change some values here and there, but the crop is still here. I suspect bitmap.draw() is responsible for the crop...
Ok, I assume you tried to augment the witdth of the BitmapData, if that's the case, I'm afraid it will need to be fixed in NME.
Maybe its the styling of the text, is it in italic or something like this ?
Yes, I've tried to change width, offset (_matrix), etc but it's still cropped. The text is bold.
Do you have the same bug when the text is regular (not bold) ?
2014/1/17 Clément Charmet [email protected]
Yes, I've tried to change width, offset (_matrix), etc but it's still cropped. The text is bold.
— Reply to this email directly or view it on GitHubhttps://github.com/silexlabs/Cocktail/issues/395#issuecomment-32614834 .