Drawing Text at an angle WITH a character underlined

Drawing Text at an angle WITH a character underlined

Post by Pete Cozen » Wed, 25 Aug 1999 04:00:00



I'm looking to draw a string onto a Form or UserControl given an HDC, the X
and Y co-ords, and the string.

Ordinarily this is simple enough using the TextOut() api.

The problems that I face are twofold :

The first is that TextOut does not replace the '&' character in the string
with an underline under the next character.

The second is that I need to be able to rotate the string (at the moment
only by 0, 90, or 270 degrees, but I'm trying to write some generic
routines that can handle any angle...)

The DrawText() api does support this replacement, but does not support
rotated text.

Any Ideas?

Cheers
--
Pete Cozens

 
 
 

Drawing Text at an angle WITH a character underlined

Post by Stephen Leban » Wed, 25 Aug 1999 04:00:00


Hi Pete,
DrawText by default processes prefix characters in the manner you
describe. Unfortunately it does not support Fonts that have an
escapement(rotation) value greater than 0. Since TextOut cannot print a
line of Text with mixed attributes, I think you will have to break up
your string and print the strings before and after the character with
the desired underline. Unfortunately this is going to make it somewhat
difficult determining X,Y starting positions for the next string of
rotated text.

Anyhow, on my Web page is a Rotated Text ActiveX control for Microsoft
Access. It is written in VB6 and posted with source code. Rod Stephens
was kind enough to give me permission to use his example of trig
routines to calculate bounding rectangles of rotated text. You will need
this functionality of you try to print several seperate strings of
rotated text on the same angle.

Personally, I think it might be easier for you to render your rotated
text as one complete string. Then simply go back and draw a line under
the characters you want underlined.

It's really a shame, but understandable, that DrawText doesn't support
rotated fonts. The formatting capabilities of DrawText are obviously far
superior to plain jane TextOut.

Good luck .

--
Stephen Lebans

http://www.geocities.com/~slebans/

Pete Cozens

Quote:> I'm looking to draw a string onto a Form or UserControl given an HDC,
the X
> and Y co-ords, and the string.

> Ordinarily this is simple enough using the TextOut() api.

> The problems that I face are twofold :

> The first is that TextOut does not replace the '&' character in the
string
> with an underline under the next character.

> The second is that I need to be able to rotate the string (at the
moment
> only by 0, 90, or 270 degrees, but I'm trying to write some generic
> routines that can handle any angle...)

> The DrawText() api does support this replacement, but does not support
> rotated text.

SNIP

 
 
 

Drawing Text at an angle WITH a character underlined

Post by Alex Russel » Mon, 13 Sep 1999 04:00:00


Luckily I have a book called Microsoft Visual Basic 5.0 Developers Workshop and luckily there is an example inside it of how to rotate text to any angle - the problem is that the code is long. So I have zipped it up and I wiil send it to you personally. As always, anyone else who wants it can e-mail me for it.

Anyway, I hope it is what you want - I personally don't understand it - well actually I haven't read it                     properly but who cares ?

Bye,
    Alex

---------------------------------------------------------

From Alex Russell



| I'm looking to draw a string onto a Form or UserControl given an HDC, the X
| and Y co-ords, and the string.
|
| Ordinarily this is simple enough using the TextOut() api.
|
| The problems that I face are twofold :
|
| The first is that TextOut does not replace the '&' character in the string
| with an underline under the next character.
|
| The second is that I need to be able to rotate the string (at the moment
| only by 0, 90, or 270 degrees, but I'm trying to write some generic
| routines that can handle any angle...)
|
| The DrawText() api does support this replacement, but does not support
| rotated text.
|
| Any Ideas?
|
| Cheers
| --
| Pete Cozens

 
 
 

1. SnappyLine -- Draw Lines with Text Label at Any Angle

Gordon Whittam contributed a very interesting "Snappy Line" project to my Computer Lab.

With the SnappyLine program you can draw "free" lines, which are lines that snap to each other and measure angles.  Lines can be
highlighted with a trackbar and erased when the trackbar is released. SnappyLine also demonstrates the creation of a LogFont for
drawing the text dimensions at any angle.

Take a look at the Snappy Line Lab Report at
www.efg2.com/lab/Graphics/SnappyLine.htm

efg
_________________________________
efg's Computer Lab:       www.efg2.com/lab
Delphi Books:  www.efg2.com/lab/TechBooks/Delphi.htm


Overland Park, KS  USA

2. POV: Using checker with media

3. Underlining Text in PS CS

4. Again: How to interpolate a quadrangle?

5. PS5 - Can't underline text?

6. lw 6.0

7. (CD8) Text entry produces underline - CD8

8. Lip Modeling in Facial Animation

9. Are there any Text drawing functions that can identify and draw URL Highlighted Text

10. Why does drawing text changes the way successive drawings are displayed

11. ? Intersection of 2 rectangles drawn at an angle ?

12. Drawing elliptical arcs at an angle