Rotate text

Rotate text

Post by Tim Chemal » Wed, 01 Mar 2000 04:00:00



Hi
How can I rotate text. I've got the following piece of code but it does
not work!

void TForm1::AngleTextOut(TCanvas* CV, AnsiString sText, int x, int y,
int angle)
{
  TLogFont* LogFon;
  TFont* SaveFont;

  SaveFont = new TFont();
  LogFont = new TLogFont();
  SaveFont->Assign(CV->Font);
  GetObject(SaveFont->Handle, sizeof(TLogFont), LogFont);
  LogFont->lfEscapement = angle *10;
  LogFont->lfPitchAndFamily = FIXED_PITCH || FF_DONTCARE;
  CV->Font->Handle = CreateFontIndirect(LogFont);
  SetBkMode(CV->Handle, TRANSPARENT);
  CV->TextOut(x, y, sText);
  CV->Font->Assign(SaveFont);

  delete SaveFont;

Quote:}

Thanks for any help
Tim
 
 
 

Rotate text

Post by Team » Wed, 01 Mar 2000 04:00:00


I think you need to set the orientation as well as the escapement. The
following code works:

Canvas->Font->Name = "Arial";
Canvas->Font->Size = 20;
LOGFONT lf;
GetObject(Canvas->Font->Handle, sizeof(LOGFONT), &lf);
lf.lfEscapement = 450;
lf.lfOrientation = 450;
Canvas->Font->Handle = CreateFontIndirect(&lf);
Canvas->Brush->Style = bsClear;
Canvas->TextOut(20, 120, "Hey, it works!!");

Also,

Quote:>>  LogFont->lfPitchAndFamily = FIXED_PITCH || FF_DONTCARE;

I think you meant to use:

  LogFont->lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE;

--
Kent (TeamB and TurboPower Software)
C++Builder Developer's Journal
http://www.reisdorph.com

 
 
 

Rotate text

Post by Jeff Cottingha » Wed, 01 Mar 2000 04:00:00


FWIW
I included and example the help files in BCB 5 on how to do this.
-goldilocks

> I think you need to set the orientation as well as the escapement. The
> following code works:

> Canvas->Font->Name = "Arial";
> Canvas->Font->Size = 20;
> LOGFONT lf;
> GetObject(Canvas->Font->Handle, sizeof(LOGFONT), &lf);
> lf.lfEscapement = 450;
> lf.lfOrientation = 450;
> Canvas->Font->Handle = CreateFontIndirect(&lf);
> Canvas->Brush->Style = bsClear;
> Canvas->TextOut(20, 120, "Hey, it works!!");

> Also,

> >>  LogFont->lfPitchAndFamily = FIXED_PITCH || FF_DONTCARE;

> I think you meant to use:

>   LogFont->lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE;

> --
> Kent (TeamB and TurboPower Software)
> C++Builder Developer's Journal
> http://www.reisdorph.com

 
 
 

Rotate text

Post by J.A. Bijsterbosc » Thu, 02 Mar 2000 04:00:00


Hello Tim,



Quote:> Hi
> How can I rotate text. I've got the following piece of code but it does
> not work!

>   SaveFont = new TFont();
>   LogFont = new TLogFont();
>   SaveFont->Assign(CV->Font);

Hmm, additional to Kent's advice, rotating fonts only works with TrueType
fonts. If you haven't changed CV->Font anywhere in your code you have the
default wich is 'Ms Sans Serife' on my system and isn't TrueType....

Quote:> Tim

--
Greetings from overcast Amsterdam

                Jan


http://home.worldonline.nl/~bijster

 
 
 

Rotate text

Post by Team » Fri, 03 Mar 2000 04:00:00


Quote:>>rotating fonts only works with TrueType fonts.

Correct. If you want Windows to always use a TrueType font, regardless of
the font that was selected, you can do this:
lf.lfOutPrecision = OUT_TT_ONLY_PRECIS;

--
Kent (TeamB and TurboPower Software)
C++Builder Developer's Journal
http://www.reisdorph.com

 
 
 

1. Rotating Text Around Center?

I am making an animation, and I am trying to rotate a single word around in
a circle.  The problem is that since text starts at the lower left corner(in
POVray, which is what I'm using) it rotates by its edge instead of by the
middle.  For example, it rotates more like the hand of a clock than a plane
propeller.  How can I get around this.  There must be some fancy thing I can
do with sin and cosine, etc...  If you wouldn't mind, please email me a copy

2. Getting started??

3. Rotate Text

4. Supermac Thunder vs Radius PrecisionColor

5. how do you rotate text on the y axis

6. off topic but need help!

7. povray simple rotating text question

8. Feedback request on entry level PC 3D graphic hardware.

9. rotated text, non-PS printer, low resolution?

10. Rotated text and Persuasion4?

11. SuperPaint Rotated Text Disappears

12. Canvas and Rotated text

13. Canvas, rotated text and slides