Click to See Complete Forum and Search --> : Vertical text in a device context


May 25th, 1999, 02:37 AM
Hi ,
Can anyone tell me how to display text vertically on a line in a device context instead of the usual horizontal ?
I'm writing code to print labels & one of the label is for the 'book-end' side of a 4mm cartridge box .
Any ideas ???

Marqy
May 25th, 1999, 03:38 AM
I've done it in the past by having a bitmap containing the text rendered vertically. It's a bit naff since you can't change the font at run time and it's not easy to change the colour, but it does work (simply bitblt the text into the desired area) and it's cheap to implement.

MJA

May 25th, 1999, 04:35 AM
Thanks , but I need to change the text & font at run time so bitmapping is not an option !
I also have tried modifying the lOrientation & lEscapment variables of the LOGFONT structure , but this only
displays the text vertically instead of horizontally /??

May 25th, 1999, 04:45 AM
Basically what I want to do is -
Print Vertically in a horizontal direction
I can print Horizontally in a vertical direction and horizontally in a horizontal direction but not the above !

Jason Teagle
May 25th, 1999, 05:52 AM
This has got confusing. Two questions:

1) How do you want the line of text to be orientated:

Horizontally, as in

---HELLO




---

or vertically, as in

---H
E
L
L
O




---

2) How do you want each character within the line to be orientated (i.e., which side do you want the top of the character to sit against - character shown is 'A'):

The top:

--- *
* *
***
* *
* *




---

The left:

--- ****
* *
****




---

The right:

---****
* *
****




---

The bottom:

---* *
* *
***
* *
*




---

There are 8 possible permutations of these, so please tell us which you want.

Jerry Coffin
May 25th, 1999, 04:08 PM
When you create a font, the lfOrientation governs the orientation of the individual letters, and lfEscapement governs the orientation of the basline the letters are placed on.

For this to work, you need to use a TrueType font, and run the program under NT. Having met those requirements, the work involved is trivial: call SetGraphicsMode to set the DC to the "advanced" graphics mode, select the font into the DC, and use TextOut (or one of its several relatives) to print the text to the DC.

If you can't meet those requirements, you can still do what you want, but it gets a lot messier in a hurry. Create a font with the lfEscapement set to the angle you want the individual letters to be. Figure out the size of each individual letter by calling GetTextExtentPoint32. Based on that, you can figure out the place to put the letter in a bitmap, an call TextOut to print it to the bitmap. When you've printed all the letters to appropriate places, you can copy the bitmap to whatever other DC you like. Of course, if you're not worried about how quickly you refresh the screen, you can simply do the TextOut to the screen directly instead, but this might be a bit slow.


The universe is a figment of its own imagination.