DWF

Reply
Employee
SilviaCao
Posts: 136
Registered: ‎06-07-2009
Message 11 of 17 (362 Views)

Re: DWFToolkit Text Heights

01-19-2011 12:01 AM in reply to: GBGB1360

1.Use the DWF Toolkit to extract the DWF file. There are three objects about the text height:

   WT_Viewport

   WT_Font

   WT_Text

 

2.Get the Viewport units, which contains the viewport transform matrix:

   WT_Viewport:: viewport_units().application_to_dwf_transform().elements()

 

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.



Silvia Cao
SW Engineer
PSEB-GE- ACRD PSEB
Autodesk, Inc.
Active Contributor
GBGB1360
Posts: 27
Registered: ‎11-27-2009
Message 12 of 17 (355 Views)

Re: DWFToolkit Text Heights

01-19-2011 04:52 AM in reply to: SilviaCao

Hi Sylvia,

 

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();

 

Regards,

 

Gabriel

Employee
SilviaCao
Posts: 136
Registered: ‎06-07-2009
Message 13 of 17 (346 Views)

Re: DWFToolkit Text Heights

01-19-2011 07:28 PM in reply to: GBGB1360

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.

 

More:

The following steps are to get the bounding box of “Ground Floor” in ADR:

  1. Open the Test3.dwf in ADR;
  2. Press “Ctrl+F”, and pop up the “Find” panel in ADR;
  3. Input “Ground” in “Find” panel and search the text;
  4. ADR will find a result in the result panel;
  5. Click the result, ADR will highlight the bounding box of “Ground Floor” in the canvas;
  6. Measure the height of bounding box.


Silvia Cao
SW Engineer
PSEB-GE- ACRD PSEB
Autodesk, Inc.
Active Contributor
GBGB1360
Posts: 27
Registered: ‎11-27-2009
Message 14 of 17 (333 Views)

Re: DWFToolkit Text Heights

01-20-2011 04:08 AM in reply to: SilviaCao

Hi Sylvia,

 

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.

 

Gabriel

 

 

Employee
SilviaCao
Posts: 136
Registered: ‎06-07-2009
Message 15 of 17 (318 Views)

Re: DWFToolkit Text Heights

01-21-2011 02:14 AM in reply to: GBGB1360
  1. The bounds of “G” is not same to the “Ground Floor”, so please test the GetTextExtentPoint32 with the section parameter “G” in the callback function agr_process_text;
  2. The CreateFont needs information from WT_Font which in the callback function agr_process_font.


Silvia Cao
SW Engineer
PSEB-GE- ACRD PSEB
Autodesk, Inc.
Active Contributor
GBGB1360
Posts: 27
Registered: ‎11-27-2009
Message 16 of 17 (316 Views)

Re: DWFToolkit Text Heights

01-21-2011 02:44 AM in reply to: SilviaCao

I am still getting 605 for the size of "G".

Using   GetTextExtentPoint32(hDC,_T("G"),textLength,&sz) gives me sz.cy to be 605.

 

Thanks

 

Gabriel

Employee
SilviaCao
Posts: 136
Registered: ‎06-07-2009
Message 17 of 17 (266 Views)

Re: DWFToolkit Text Heights

01-31-2011 12:40 AM in reply to: GBGB1360

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



Silvia Cao
SW Engineer
PSEB-GE- ACRD PSEB
Autodesk, Inc.

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community