Changing font characteristics word-by-word in a block of wrapped text

Changing font characteristics word-by-word in a block of wrapped text

Post by Jeff » Tue, 11 Jul 2000 04:00:00



I have a lot of experience drawing text to canvases (both screen and
printer). However, I am faced with recreating the static text on some
government forms that include blocks of text within which certain words are
highlighted by bold, italic, underline and sometimes even a font family
change.

I usually use the DrawText function to handle wrapped text blocks, and I was
hoping there was a way to pass it (or another API call) RichText or
something similar to achieve the desired results -- but it appears not to be
available in the API.

Have I missed something in the API? Or, am I going to have to write my own
routine for this? If so -- any suggestions?

Basically I need something where I can pass a canvas, a string of tagged
text, and a TRect for the wrapping boundary, and have it output something
like:

"This is some test text in which this word is *BOLD*
and another word might be *ITALIC* and the whole
thing wraps to a rectangle."

Thanks,
Jeff Hamblin

 
 
 

Changing font characteristics word-by-word in a block of wrapped text

Post by Team » Tue, 11 Jul 2000 04:00:00


On Mon, 10 Jul 2000 11:04:52 -0700, "Jeff H"


> Have I missed something in the API?

No.

Quote:> Or, am I going to have to write my own
> routine for this?

Yes.

Quote:> If so -- any suggestions?

Use inline markup to indicate the inline font changes. You might as
well use the standard HTML tags where you can, like this:

"This is some test text in which this word is <B>BOLD</B> and another
word might be <I>ITALIC</I> and the whole thing wraps to a rectangle."

You could also use an XML parser to parse this into its constituent
parts. The drawing isn't hard, but it is mundane... you'll just need
to call DrawText multiple times, keeping track of state and position.
--
Rick Rogers (TeamB)
www.fenestra.com and www.componentfactory.com

 
 
 

Changing font characteristics word-by-word in a block of wrapped text

Post by Jeff » Sun, 16 Jul 2000 04:00:00


Thanks for the response, Rick. I was afraid of that :)

I have written a function DrawHTMLText to draw formatted text to a canvas.
The function parameters are very similar to DrawText.

If you (or anyone else) are interested in having a look or are in need of
something like this, I put the unit on borland.public.attachments as:
"DrawHTMLtext draws formatted text to Canvas"

It's also on my company's website at:
http://www.qtools.com/dev/DrawHTMLText.zip

Regards,
Jeff Hamblin
Qtools Software



> > Have I missed something in the API?

> No.

> > Or, am I going to have to write my own
> > routine for this?

> Yes.

> > If so -- any suggestions?

> Use inline markup to indicate the inline font changes. You might as
> well use the standard HTML tags where you can, like this:

> "This is some test text in which this word is <B>BOLD</B> and another
> word might be <I>ITALIC</I> and the whole thing wraps to a rectangle."

> You could also use an XML parser to parse this into its constituent
> parts. The drawing isn't hard, but it is mundane... you'll just need
> to call DrawText multiple times, keeping track of state and position.
> --
> Rick Rogers (TeamB)
> www.fenestra.com and www.componentfactory.com

 
 
 

Changing font characteristics word-by-word in a block of wrapped text

Post by Jon T. Cam » Tue, 18 Jul 2000 04:00:00


Have you considered using a rich edit control and EM_FORMATRANGE??  Perhaps
this would be appropriate with your app.  HTH

Regards,

Jon T. Camp
Applied Research Associates


> I have a lot of experience drawing text to canvases (both screen and
> printer). However, I am faced with recreating the static text on some
> government forms that include blocks of text within which certain words
are
> highlighted by bold, italic, underline and sometimes even a font family
> change.

> I usually use the DrawText function to handle wrapped text blocks, and I
was
> hoping there was a way to pass it (or another API call) RichText or
> something similar to achieve the desired results -- but it appears not to
be
> available in the API.

> Have I missed something in the API? Or, am I going to have to write my own
> routine for this? If so -- any suggestions?

> Basically I need something where I can pass a canvas, a string of tagged
> text, and a TRect for the wrapping boundary, and have it output something
> like:

> "This is some test text in which this word is *BOLD*
> and another word might be *ITALIC* and the whole
> thing wraps to a rectangle."

> Thanks,
> Jeff Hamblin

 
 
 

1. word wrap in text

Hello Pi  users,   I cant write more than 1 line of text, the more I write
the longer the line gets,
is there a way to word-wrap in pi 4.2  ?  or have I just overlooked the
obvious?

Thanks

Tony

2. Rainbow Runner + NT

3. Word wrap with text tool?

4. Graphic output to the RAM ?

5. Text word wrap

6. Question

7. QuarkXPress word wrap?

8. Plot Circle ?

9. Word wrap

10. Circle Word Wrap

11. Printing with Word Wrap

12. Circle Word Wrap