One of our DWF Partner developers sent in the following question:
I am reading a 2D DWF file using DWF (Whip) toolkit. I have a class derived from WT_FileExt and registered various processing actions (including WT_Font and WT_Text). In testing my application, I received a DWF file with four text variants: simple, mirrored, upside down, and backward). In my process_text/process_font callback function - how can I find if the text is mirrored (or upside down or backward)?
Our newest Software Engineer and DWF Technical Evangelist, Gyorgy Ordody, provided the answer:
The answer is in the WHIP! Format specification: You have to set the font flags. The "Flags" paragraph of the "Set Font" function specification indicates that Flag bits reserved for the DWF data generator's use. For example, the AutoCAD DWF ePlot driver uses the Flags field to set one or more of the following flags:
Attribute | Bit mask | Comment |
---|---|---|
VERTICAL | 0x0001 | // TVERT |
MIRROR_X | 0x0002 | // TXMIR |
MIRROR_Y | 0x0004 | // TYMIR |
UNDERSCORE | 0x0008 | // TUNDER |
OVERSCORE | 0x0010 | // TOVER |
MTEXT_START | 0x0020 | // TMSTART |
MTEXT_END | 0x0040 | // TMEND |
MTEXT | 0x0080 | // TMTEXT |
GREEK_TEXT | 0x1000 | // Whip and GDI font engine only |
PATH_TEXT | 0x2000 | // Whip and GDI font engine only |
OUTLINE_TEXT | 0x4000 | // Outline Text Only |
This means that you have to set the font flags as in this example:
// let's mirror
whip_file.desired_rendition().font().flags().set(0x0002);
text = WT_Text(WT_Logical_Point(2147482677,2714), WT_String("Testing
Mirrored Test")); WD_CHECK(text.serialize(whip_file));
// upside down:
whip_file.desired_rendition().font().flags().set(0x0004);
text = WT_Text(WT_Logical_Point(2147481079,2123), WT_String("Upside
Down Test")); WD_CHECK(text.serialize(whip_file));
// upside down and backwards
whip_file.desired_rendition().font().flags().set(0x0006);
text = WT_Text(WT_Logical_Point(2147482772,1237), WT_String("Upside
down and backwards")); WD_CHECK(text.serialize(whip_file));
// Straight text
whip_file.desired_rendition().font().flags().set(0);
whip_file.desired_rendition().font().height() = 151; text =
WT_Text(WT_Logical_Point(2147482772,1237), WT_String("Straight
Text")); WD_CHECK(text.serialize(whip_file));
As mentioned in previous blog postings on fonts, text processing is an important part of DWF.