Cocktail icon indicating copy to clipboard operation
Cocktail copied to clipboard

Texts are slightly cut on the right on native platforms (NME)

Open clemos opened this issue 11 years ago • 6 comments

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.

clemos avatar Jan 17 '14 12:01 clemos

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.

yanhick avatar Jan 17 '14 13:01 yanhick

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

yanhick avatar Jan 17 '14 13:01 yanhick

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

clemos avatar Jan 17 '14 13:01 clemos

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 ?

yanhick avatar Jan 17 '14 15:01 yanhick

Yes, I've tried to change width, offset (_matrix), etc but it's still cropped. The text is bold.

clemos avatar Jan 17 '14 15:01 clemos

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 .

yanhick avatar Jan 17 '14 15:01 yanhick