Sometimes while typing in a textarea in Flex many characters will be rendered at one height then at some point on that same text line the rest of the characters are rendered a couple pixels lower than the rest. Here is an example, look at the last 'I' character, its low:alt text http://img.skitch.com/20091031-ej5n28akygnm3gmxcjx731ic85.jpg
Sometimes changing the font size will fix this but its not consistent and its not something I can detect (and fix even if I could). Anybody got an idea why this happens? It happens for embedded and non-embedded fonts.
Thanks,
Sam
Flash acts strange sometimes when movie clips, textboxes etc are not on whole pixels. Make sure the textbox has integers for it's coordinates. If it is in any movie clips, make sure those movie clips have integers for coordinates too.
The other option would be to fudge around with the anti-aliasing features in Flash, but that's always a hit-or-miss situation.
Related
I need to find a feature or tool that allows me to programmatically create a file in which I will have a sized textbox with text that automatically scales to fit its dimensions and still be visible.
Here is an example of what it would do:
On the left side, an already sized textbox has some text. The text is too long so it goes "out" the textbox, therefore the tool would "scale" it to a size that makes it visible only in the textbox, and not outside. It could scale by changing font size, or "zoom" in any way.
I tried looking at OpenOffice Writer & Impress, Microsoft Word & Powerpoint, with no success. It seems really difficult with CSS according to the resources I could find.
Some resources I found (like Fitty, which is in Javascript. Not what I need, but still possible) will scale it in other manners that do not correspond my needs because they keep the text on one line, and I need them multiline...
See some wrong examples:
Does anyone know any tool that would have such feature?
I've tried using em as well as px, but I cannot get a certain line of text to display at the same size in every browser. I know I'm reaching for a lot but I'm tasked with achieving a pixel-perfect development based on a mock-up, and need a certain text to span the width of an area left-to-right so that it all flushes from side to side with an image.
My last option is to use an image, which I don't want to do. I know that you can specify certain CSS parameters that work on the different browsers such as -moz-SOMECSSPROPERTY:some value; but can you do this with the font size so that one browser has it at one size, and another as another. Oddly enough too though this is actually only happening in the browsers that are on different OS's, i.e. - on my Mac it's as intended, and on Windows (same browsers) different.
Thanks for advice.
It won't be enough to specify the font on a per-browser basis, because (as you noticed) you'll also run into inconsistencies across platforms and devices.
If you want the text to always fit the image flush, the text pretty much has to be an image, too.
I'm currently struggling with implementing text floating in TLF. It does not support it natively, and the only solution I've found so far is to use linked containers and then combine controllers using flowComposer for single textFlow.
However, I need to implement Dropped Initial letter feature in my column layout. Initial is just a first big letter in paragraph, floated by the rest of the text. It looks like this -
The issue here is that for that big letter, the resulting TLF textFlow sprite is bigger than the actual letter. It's because of the baselines (small q vs big A for example). But I don't want these extra gaps. After textFlow is rendered, I would like to learn how big the resulting letter exactly is (in pixels) so that I can crop/shift baseline, etc.
ContainerController.getContentBounds().height or
ContainerController.compositionHeight
gives me height of whole sprite with gaps added, not the letter.
Is there some kind of measure method for this?
Can this be solved differently?
check out the Tiny TLF framework by Paul Taylor. I think he addressed this issue along with many other cool things.
Check it out: https://github.com/trxcllnt/tinytlf
I have a textarea where I measure the textWidth and textHeight to make sure the user cannot enter more text than can fit in the text area. I also extended the textArea with a textHeightNow and textWidthNow that measure the textField's dimensions since they update w/out requiring validation. Now this works great for 90% of the embedded fonts I'm using but any fonts that have giant serifs are not measured properly, for instance look at the 'f's in this text area:
alt text http://img.skitch.com/20091101-xhm5jguma1qgukg6fxrymrwr3u.jpg
You can see they get cut off on both sides because textWidth and textWidthNow both return an incorrect size not taking into account the massive serifs. The font size, coords and dimensions of the text area are all integers so thats not the problem, any other suggestions? I looked to see if textArea has a clipContent argument but it doesn't (that would have been nice).
Thanks
I've run into this problem before and as far as I can tell you have two options, none of them very nice:
Use the new flash.text.engine in
Flash Player 10... its very hard to use but
I think it will measure such fonts
(and ligatures) properly.
Draw the textfield into a bitmapdata
and use getColorBoundsRect to
determine its real dimensions.
I ended up using the latter as changing the whole app to the new engine would have been much much harder. You will need to tweak margins and use a larger textfield (inside some container) to be able to draw it properly, but it should work.
I have an < mx:Label > tag that has a set width, which is usually large enough to display the text it needs to show. Every once in a while though the text is a little too long and gets chopped off and "..." gets appended. Instead of this happening I would like to decrease the font-size just low enough to show the whole text.
Does anyone know of a nice way to do that?
Thanks
Fonts are a complicated beast. For a given text, you can find the string length and calculate the maximum allowable font-size very simply using the following approximate formula:
var max_allowable_size:int = yourLabel.width / yourLabel.text.length;
This could lead to serious issues for some fonts, namely:
Remember not all fonts are equal i.e. they cannot all be resized gracefully.
Anti-aliasing may break
Fonts may not look good/text may become illegible
The above naive formula will probably break when applied to non-roman characters
Also, this is an inefficient way.
I would rather suggest that you define two different styles, one regular and another fallback one with font-size set to the smallest, which you switch to when you encounter longer label texts. You can calculate the threshold limit to switch by using the default font-size on the above mentioned formula. Of course, some experimentation is in order, if you have to support localization/multiple languages.
Finally, always embed the fonts if you are going to use anything other than the most common fonts.
There is a measureText function. Check out:
http://frankieloscavio.blogspot.com/2008/01/flex-use-measuretexttxt-to-calculate.html
http://livedocs.adobe.com/flex/3/langref/mx/core/UITextFormat.html#measureText()
You can probably use measureText and decrease the font size till it fits.