Adobe Flex 4 text height - flex4

I remember in Flex 3 text width/height could be calculated (not the text UI component but the text itself):
new Text().textHeight;
or
new Text().getTextField().measuredHeight;
Does anyone know how can that be done in Flex 4 with its Text Layout Framework now?
Thanks.

I've found an answer myself. If someone has any better ideas - you're welcome.
I use to assume that width of text content is not so important cause each time the size changes the value used below are updated. So I check the height of text (assuming width is fixed) as:
var textHeight: Number = (_text.textLines.length-1) * _text.textFlow.lineHeight + _text.textFlow.fontSize
where _text is s:RichText.
I needed to know whether the text inside did not exceeded the space available, that's why the only thing I need now is to check whether textHeight < _text.height
That's it. Be sure the text is rendered correctly before checking the height (I use to listen to UDPATE_COMPLETE event).

Related

I don't understand TYPO3's image management, Images are not properly sized

I am new in TYPO3, and I am trying something simple, add an image.
Iam doing the following:
I added Content Element "Text & Images"
In the tab "Images" i uploaded an image 1920 x 262
Save
The image loaded is the resolution 600 x 81, i don't understan why.
In the properties i try set 1920 in the field width but same.
In the future i want to know how establish the srcset but first the simple.
(sorry my english)
Sorry to confuse you but there are some rules applied to the maximum size which date back to those days where 600 was already quite large.
the following typoscript constants are relevant:
styles.content {
maxW = 600
maxWInText = 300
}
Depending on the selected value of the field Position and Alignment, one of those 2 applies. So If e.g. "in text, right" is selected, the maximum width is 300.
As a solution you can override the constants to same values which fit more properly.
Most people don't use the default content elements anymore and create custom ones using extensions like mask or dce or without any 3rd party code.

How to measure margin between font-elements in XD?

It seems not possible to view the exact margin between font-elements in XD (dev-view). Below you'll find a screenshot of a situation where we need to measure the exact distance between two Font-elements (XD developer-view).
It needs to bypass the line-height, but it doesn't. To be able to do this, we need the line-height to be zero. But when we edit the line-height in XD for a word or sentence on a single row, XD does not change that line-height.
Anybody encountered the same situation?
In this example the line-height is 32. We go to XD. Change it to zero, save it and SHARE FOR DEVELOPMENT. But the line-height remains 32. Also changing it to 1 instead of zero won't make any difference.
To fix this issue, you have to select the Text within Adobe XD. Right Click and select Path > Convert to Path. The margins around the Text will disappear and when in DEVELOPMENT view it becomes possible to see the right margin. A small problem remains. When you want to edit the text when it's a shape, you have to delete it and place a new text and turn it into a shape again. the text when converted to a shape
The default selector in Adobe XD will not give you the exact margin between two text. You have to convert the text layer into paths (Convert to Outlines) to get the exact margin.
But remember after converting text layer into path the text cannot be edited because now the letter are separate vector shapes.
To convert text layer into Path, select the layer and goto Object>Path>Click Convert to Path
You can use the Guides to drag one below your text and another one on top of the second text, and then you can see the distance between the 2 guides.
Check this youtube video for a quick tutorial on it. This is going to be a manual action. I don't think there's a key to press to check the distance automatically.

DPI awareness: could I be told when I need to recalculate my text height so I don't have to do it all the time? And SM_CYSMICON/checkbox heights too?

A frequent operation in my Windows Table control, which I am reworking and moving into a DLL, is to get the height of a row. This is the maximum of
the height of text in the current font, in pixels
the current small icon height, in pixels (GetSystemMetrics(SM_CYSMICON))
the height of checkboxes, in pixels (determined on a WM_THEMECHANGED, when checkbox information is recalculated)
Calculating the text height, as far as I know, requires getting a DC, selecting the font in (and getting the SYSTEM_FONT if that's NULL), getting the text metrics, selecting the font out, and releasing the DC, all of which can error out/fail/etc. This means that virtually every function in my control can fail.
I can avoid this by storing the text height somewhere else, only calculating it when it changes. I know that text height is a property related to the DPI of the DC that GetDC(hwnd) returns. I would like my control to be DPI-agnostic because DPI awareness is per-process, not per-DLL/per-window.
At the same time, knowing when GetSystemMetrics(SM_CYSMICON) changes would also be useful.
So my questions are simple:
Is there a message that I can look for that will tell me that my DPI has changed and that I need to recalculate my text height?
Is there a message that will tell me that SM_CYSMICON has changed and that I need to recalculate everything? Is it the same one? (I know there is no reliable way to detect a GetSystemMetrics() failure (since 0 is a valid return and it does not set the last error code), so I am assuming it cannot fail with a valid parameter and am simply calling it each time I need to calculate the row height; this is just so I can queue a redraw when the value does change.) Would it also work for SM_CXSMICON?
In addition, looking back at my code, GetThemePartSize() takes a DC as well; do theme items like checkbox images scale with DPI? And if so, what messages do I look for in that case? The same one?
Alternative: is there a non-failing way to get the text height that I don't know about, given only a HWND and HFONT?
I will be happy to take a solution that was introduced in either Windows XP or Windows Vista; if there's a solution that was introduced in a newer version of Windows, then knowing about it could also be beneficial.
Thanks.

RDLC page width and e.g. line length

I have a RDLC report.
The page is 21cm wide with 1cm margins on both sides (which leaves us 19cm for contents).
The body of the report is 18.96cm wide
There is a line element inside the report with Location = (0cm; 0cm) and EndPoint = (18.95cm, 0cm) thus the length is 18.95cm. This is like a horizontal separator line inside the report.
So, as you see the body should be enough to contain the line (19cm > 18.96cm > 18.95cm). But when I go and display the report in the ReportViewer/PrintLayout control the line actually generates an additional page (because it grows wider for some reason). And this shows up on the actual printed document (if you print it out).
Just in case - the simple view in ReportViewer and the exported report both look fine, no additional pages present.
Please tell me - how does this happen and if there are any workarounds to get a good PrintLayout view inside the ReportViewer control? I do not care about the PrintLayout view itself, but I care about printing the document out, which uses the same PrintLayout.
Yours is a strange scenario. Try giving a tolerance of 5mm (0.5cm) instead and let's see what happens.
In other words set the following
Body: 18.5cm
Line: Location = (0.25cm; 0cm) and End Point = (18.0cm; 0cm)
If that doesn't work, it probably means your page is taller than the size of paper you desire to print on.
A4 is 21cm x 29.7cm so make sure the height of your body is less than 29.7cm. If you have top and bottom margins, you'll have to subtract their values as well so the maximum height will be given as follows:
Max Height = 29.7 - (Top Margin Height + Bottom Margin Height + tolerance)
tolerance value should be approximately 0.5cm

How to get number of word wrap breaks in richtextboxusing c#?

I am working with the rich text box where i need to in crease its size whenever i get the word wrap....as of now i m just counting the number of character and if character goes above the limit i m just changing the height of the rich text box.... I know this is not proper way so i m searching for answer where i can get the word wrap count. So i can increase the height that many times....Please Help me.....
Thanks in advance.....
Couldn't you check the VerticalScrollBarVisibility property to determine whether there is a scroll bar - and increase the height if there is?

Resources