1.Use the DWF Toolkit to extract the DWF file. There are three objects about the text height:
2.Get the Viewport units, which contains the viewport transform matrix:
3.Create a Device Context (HDC);
Create a HFONT from WT_Font;
Draw the WT_Text string in the DC;
Calculate the text height in the DC.
4.Apply the viewport matrix to the text height.
Thanks a lot for the explanation.
After going through the steps, I am observing that the final height is the same as the height given by WT_Font.height();
If the final height is the bounding box height of the “Ground Floor”, the value should be correct (the value depends on the device context the “Ground Floor” draws on):
605 * viewport scale (7.4150283773999996/ 54.986118658772803) ≈ 81.6;
Autodesk Design Review (ADR) gets the height of 620, and attaches the “Test3.jpg” of the final bounding box height of “Ground Floor”.
The bounding box is bigger than each character height; so the next step is to get the more exact height of each character.
If the final height is the height of character “G”, please attach a snap of code to this thread.
The following steps are to get the bounding box of “Ground Floor” in ADR:
I am somewhat confused now after reading your latest notes.
The relevant parts of my code are in the attached text file.
Some explanation on the logic:
Creation and release of the device handle (HDC) are not shown in the code snippet.
I am creating the Window Font (HFONT) in the set_font_action() callback
The creation of the text takes place in the set_text_action() callback. In this function sz.cy is 605, which is the value of font.height(), so I wonder if there is any need for all the calculations with the Windows API.
The viewport transformation matrix elements are shown inside the function.
long textHeight = sz.cy / SCALEY gives me 81.6, which is also what you got.
Now, when I measure "Ground Floor" in ADR, I get the height of "G" to be 61 and the height of the bounding box to be 91. Since "G" is the biggest character in the text, I would expect the text height to be taken as the height of "G".
So, where are we (both you and I) getting 81.6? Either 61 or 91 would have made more sense to me as the text height.
It looks as if the scaling factor used in the transformation of texts from DWG to DWF is not the same factor used in transforming graphics (lines, etc.)
By the way, I am using the RECT values shown in the code because I don't know what else to use. I don't think it makes any difference however. Or does it?
Thanks for your help.
Please try to disperse the character “G” to curves by function GetGlyphOutline; and then calculate the bounding box of the curves, which is also the bounding box of “G”.
Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register
Start with some of our most frequented solutions to get help installing your software.