Hi
Is there a simple way to rotate text using GDI?
I know I know write to a Buffer or Memory DC and rotate then
display, I wanna know if there's a faster way.
thanks
awni
Printable View
Hi
Is there a simple way to rotate text using GDI?
I know I know write to a Buffer or Memory DC and rotate then
display, I wanna know if there's a faster way.
thanks
awni
Yes - when creating a font (either with ::CreateFont or CFont::CreateFont), you can specify an angle (in tenths of degrees) as the nOrientation parameter.Quote:
Originally posted by awni
Is there a simple way to rotate text using GDI?
I know I know write to a Buffer or Memory DC and rotate then
display, I wanna know if there's a faster way.
thank you , saved me more time than you think
awni
Actually the nEscapement is responsible for the angle of a row of text. The escapement vector is parallel to the baseline of a row of characters. The escapement angle is the angle between the escapement vector and the x axis of a device. The orientation is the angle between each individual character and the x axis. On Win 95,98 and ME the orientation value is not used and the escapement specifies both the orientation and escapement (ususally the 2 are set to the same value). On Win 2000 and XP it is possible to specify each independently.Quote:
Yes - when creating a font (either with ::CreateFont or CFont::CreateFont), you can specify an angle (in tenths of degrees) as the nOrientation parameter.
TDM
See attached bitmap for a comparison between orientation and escapement.
TDM
Thanks, i did use both escapement and orientation, I'm still trying
to write the names of streets on a map. Streets are made up of segments and each segment needs the name written next to it, and the text needs to be at an angle. Some segments are too small, so no writing there.
awni
Hi,
i have the problem that i need a font that has to be fully scalable (vector font) and rotateable... Can anyone help me with this...?
Thank you!! :-)
Hi, awni.
Few month ago I written the map program. I also encountered problem with font like this. After I tried this method (escapement and orientation), I developed my own font in file with my own format, that was simple to rotate to any angle with "rotate matrix". It's all because standart font was a little buggy. Also (I written map program for both PC and PocketPC) this method is wery slow (using my own font is about 10 times faster!).
Also I added logical circles around letters. I put a letter in this place only if current letter is not overlapping another circles - this prevents overlapping letters.
So, you can follow my steps.
Hi,
For drawing text with any angle or other features,I think you need try the following MFC Source Code Flow/Diagram Kit:
http://www.********.net/index.htm
It includes all the features for drawing and manage shapes on the canvas.
Regards
anwi, you can also look at TEXTFX sample from MSDN. Draw two lines and take a look to text, that appears between these lines.
Sample attached.
Could you please stop with posting this to each graphics problem! This is often not helpfull, as the mentioned diagram kit it not free (the cheapest license is more than $600) and spending $600 just to be able to draw rotated text is a bit too much, don't you think so... :mad:Quote:
Originally Posted by jack_onlyone
Hello
I used following code in order to get the vertical text, say mark on Y axis of scale to display Units of plot like Length (meter), etc
But i landed up with just a line at the position of text, where it was supposed to start and move upwords.
Sandeep Arya
NOTE: I had even tried using 0 for nEscapement, but still things are same.
Code:// This function will take care of drawing vertical label
void CLabel::DrawVertical(CDC *pDC)
{
CFont Font;
Font.CreateFont(m_FontSize, // nHeight
0, // nWidth
900, // nEscapement
900, // nOrientation
FW_NORMAL, // nWeight
FALSE, // bItalic
FALSE, // bUnderline
0, // cStrikeOut
ANSI_CHARSET, // nCharSet
OUT_DEFAULT_PRECIS, // nOutPrecision
CLIP_DEFAULT_PRECIS, // nClipPrecision
DEFAULT_QUALITY, // nQuality
DEFAULT_PITCH | FF_SWISS, // nPitchAndFamily
"Arial");
CFont *OldFont = pDC->SelectObject(&Font);
pDC->TextOut(m_Position.x, m_Position.y, m_Text);
pDC->SelectObject(OldFont);
Font.DeleteObject ();
}
Strange...
Could you post a screenshot?
Are you sure all variables have correct values?
I just tried your code and got the result as you see in the screenshot below.
Code:dc.SetBkMode(TRANSPARENT);
CFont Font;
Font.CreateFont(24, // nHeight
0, // nWidth
900, // nEscapement
900, // nOrientation
FW_NORMAL, // nWeight
FALSE, // bItalic
FALSE, // bUnderline
0, // cStrikeOut
ANSI_CHARSET, // nCharSet
OUT_DEFAULT_PRECIS, // nOutPrecision
CLIP_DEFAULT_PRECIS, // nClipPrecision
DEFAULT_QUALITY, // nQuality
DEFAULT_PITCH | FF_SWISS, // nPitchAndFamily
"Arial");
CFont *OldFont = dc.SelectObject(&Font);
dc.TextOut(100,100, "Test text");
dc.SelectObject(OldFont);
Font.DeleteObject ();
Please can any body explain hoy to achieve this rotarion in a pure Win32 not MFC, createfont does not exist in pure win32. Thanks a lot.
I am sure tha t there is an API function CreateFont to do so.
HFONT CreateFont(
int nHeight, // logical height of font
int nWidth, // logical average character width
int nEscapement, // angle of escapement
int nOrientation, // base-line orientation angle
int fnWeight, // font weight
DWORD fdwItalic, // italic attribute flag
DWORD fdwUnderline, // underline attribute flag
DWORD fdwStrikeOut, // strikeout attribute flag
DWORD fdwCharSet, // character set identifier
DWORD fdwOutputPrecision, // output precision
DWORD fdwClipPrecision, // clipping precision
DWORD fdwQuality, // output quality
DWORD fdwPitchAndFamily, // pitch and family
LPCTSTR lpszFace // pointer to typeface name string
);