Are you drawing text at an angle with TextRenderer?

This is a question for folks that are aware of the difference in quality of output between TextRenderer.DrawText and (Graphics.DrawString + Graphics.TextRenderingHint = Text.TextRenderingHint.AntiAlias). It is an issue that has been discussed by others,
elsewhere, without resolution, and I'm simply asking if anyone has come up with a workaround.
I want to render text in the quality of TextRenderer.DrawText, at right angles or upside down. TextFormatFlags.PreserveGraphicsTranslateTransform ignores calls to RotateTransform on the Graphics object that exposes IDeviceContext to DrawText, and DrawText doesn't
play nicely with bitmaps.
Has anyone figured out a way to draw text at the same quality provided by TextRenderer.DrawText, at an angle other than 0 degrees?
(For those who need a back story to prove to you that I cannot use a Label or Graphics.DrawString for this, here you go.
There is a cat stuck in a tree in my back yard. I would like to rescue him, but there is a troll standing between me and the tree. He's a nasty troll, but on TV he plays a happy-go-lucky helpful troll, so when I call the police to complain, they just laugh
at me. "Ha! You can't fool us! We watch TV!"
The troll will allow me to reach the cat if I provide him with a UserControl that renders text at the same quality as the Windows.Forms.Label control, but at angles 90, 180 and -90 degrees. He is a clever troll in that he notices details between shoddy and
neat; rough and smooth; ugly and pretty; cat and honey badger. Therefore, I have not been able to fool him into thinking that ugly text is pretty by asserting that ugly text is pretty. Argh. I dislike this troll.)

And this has to do with
Usability Steven's
 issue in what fasion and why are you responding to somebody elses issue
Mick Doherty? Or is this just for my information?
La vida loca
Hi Monkey
This was mainly for info, but the OP did question the difference between GDI and GDIPlus methods of drawing rotated text. Your example only provides a GDIPlus method.
GDI does not respect the Graphics objects rotations, but so long as the PreserveGraphicsTranslateTransform flag is set it will respect Translations.
Here's a simple example to highlight the issue:
Public Class Form1
Public Sub New()
' This call is required by the designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
Me.SetStyle(ControlStyles.ResizeRedraw, True)
End Sub
Private Sub Form1_Paint(sender As System.Object, e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
Dim testString As String = "My Test String"
Dim angle As Single = 0
If Me.CheckBox1.Checked Then angle = 180
Using testFont As New Font("Arial", 24, FontStyle.Regular, GraphicsUnit.Point)
Dim rc As Rectangle = Me.ClientRectangle
rc.Offset(0, -24)
Me.DrawRotatedGDIText(e.Graphics, testString, testFont, rc, Color.Red, angle)
rc.Offset(0, 48)
Me.DrawRotatedGDIPlusText(e.Graphics, testString, testFont, rc, Color.Black, angle)
End Using
End Sub
Private Sub CheckBox1_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles CheckBox1.CheckedChanged
Me.Invalidate()
End Sub
Private Sub DrawRotatedGDIText(graphics As Graphics, text As String, font As Font, bounds As Rectangle, color As Color, rotation As Single)
Dim sz As Size = TextRenderer.MeasureText(text, font)
Dim centre As Point = bounds.Location
centre.Offset(bounds.Width \ 2, bounds.Height \ 2)
Dim offset As Point = New Point(-sz.Width \ 2, -sz.Height \ 2)
graphics.TranslateTransform(centre.X, centre.Y)
graphics.RotateTransform(rotation)
TextRenderer.DrawText(graphics, text, font, offset, color, TextFormatFlags.PreserveGraphicsTranslateTransform)
graphics.ResetTransform()
End Sub
Private Sub DrawRotatedGDIPlusText(graphics As Graphics, text As String, font As Font, bounds As Rectangle, color As Color, rotation As Single)
Dim sz As Size = graphics.MeasureString(text, font).ToSize
Dim centre As Point = bounds.Location
centre.Offset(bounds.Width \ 2, bounds.Height \ 2)
Dim offset As Point = New Point(-sz.Width \ 2, -sz.Height \ 2)
graphics.TranslateTransform(centre.X, centre.Y)
graphics.RotateTransform(rotation)
Using myBrush As New SolidBrush(color)
graphics.DrawString(text, font, myBrush, offset)
End Using
graphics.ResetTransform()
End Sub
End Class
Here you can see the GDI string (red text) is rendered differently to the GDI Plus string (black text) i.e. the GDI Plus text is longer. Both strings have been rendered to the correct location as set by the graphics transformation:
Here a Rotation to the graphics object has been performed, but the GDi method has totally ignored it:
As a rule, Win32 based controls render with GDI rather than GDI+ and so if we wish to draw a custom control which appears similar to a Win32 based control we need to render with GDI. If you've ever tried to ownerdraw a tabcontrol then you will have noticed
that the text does not always fit on the tabs if we've used GDI+. using GDI the text fits perfectly, but when we side align the tabs the text does not rotate. We can, as the OP has done, draw unrotated text to a bitmap and then rotate the bitmap and this
works well if we have a solid background. If we have a textured background however, this method is not acceptable.
Mick Doherty
http://dotnetrix.co.uk
http://glassui.codeplex.com

Similar Messages

  • Is there a way to play video clips that use adobe flash and if not when are you going to resolve your problem with them ? I won't buy another apple product until you do and I Know I,m not the online.

    Is there a way to play video clips that use adobe flash and if not when are you going to resolve your problem with them ? I won't buy another apple product until you do and I Know I,m not the only one.

    Use the search feature and type in Flash and there are like thousands of posts on this.
    You seem to think you are addressing Apple with your post.  This is a user forum and we are all users just like you.

  • Hey Apple when are you going to fix the problems with IOS 8.3??

    Hey Apple when are you going to fix the problems with IOS 8.3??
    Message is working weird.
    I don't have internet service when I'm away from my WiFi, because my phone won't use LTE now.
    Should I wait for a IOS 8.3.1 update or reset my phone to factory and start over?
    If there's a fix coming when will we see it?
    (I'm using iPhone6 plus)
    I've tried everything else to fix the problems I'm having. Soft restart. Hard restart. Used your chat line. Called Verizon. Reset network settings.... Help!!!!!
    I've posted on the Apple Communities about all this and I've sent in a couple of bug reports.
    I live up in the mountains and MUST be able to access my Verizon LTE for information if there is a fire! I'm in California!

    I have a Verizon iPhone 6 and am having none of those problems.
    SueMac wrote:
    Should I wait for a IOS 8.3.1 update or reset my phone to factory and start over?
    Didn't they already have you do that? If you haven't, yes, you should restore your phone as new and test.
    I live up in the mountains and MUST be able to access my Verizon LTE for information if there is a fire! I'm in California!
    If you are in a situation where you may need emergency information, organizations such as the Red Cross recommend things like this:
    http://www.amazon.com/Epica-Emergency-Digital-Flashlight-Certified/dp/B00CZDT30S /ref=sr_1_1?ie=UTF8&qid=1429463666&sr=8-…

  • HT204291 are you able to use airplay mirroring with my mac book pro?

    are you able to use airplay mirroring with my mac book pro?

    The Mac needs to be recent (2011 or later) and running Mountain Lion.

  • Are you using GB 10 for projects with this version ?

    usually the ones who dont write in are happy with what they have
    are some of you happy with GB  as it is or are you patiently waiting for a workable upgrade version?
    i realize one thing: if you dont have the latest Mac computer with optimal RAM OS  etc apps dont work optimally
    this goes for FLICKR etc
    I am writing to those who dont constantly complain if some little bug appears.
    is this what you call a working GB ?
    my previous songs all load nicely into GB 10
    i just notice foreign parts im not used to and doing things with my old songs takes a learning curve and  this means ill use GB 11 for now
    2 things on my mind now
    1.  without a manual/ third party explanation i dont have time to test experiment and start a new learning curve
         with GB 10.  It looks beautiful and probably one day will be so. Fooling around with it will at this time  only lead to more frustration.
    2.  is there a manual for GB 10 and if so where is it located please?

    2.  is there a manual for GB 10 and if so where is it located please?
    I am using the online help:   GarageBand 10.0 Help Online
    And HangTime posted a link to a short video tutorial at Bullets & Bones, but I cannot find it right now.
    1.  without a manual/ third party explanation i dont have time to test experiment and start a new learning curve
    For the time being I create the projects first in GB 6.0.5, to have more patches for vocal tracks and my guitar, and then I finish it in GB 10.0 to add Arpeggiators and Smart drummers.
    It is simply easier to find anything in GB 10.0, if I know what is supposed to be there, because I created it in GB 6.0.5. 

  • What resolution are you running your 30inch Apple monitor with?

    (NTSC)I have an 8core mac with the 30" cinema display. The only resolution that looks sharp with FCP is 2560 by 1600 but the motion adjustment window in FCP is too small. I've tried other resolutions but the only other one that matched the 30" side to side is 2048/1280 but the text looks a little blurry. The other presets don't fit the screen.
    Is there a way to be able to switch to other resolutions?

    In case you didn't know this to be fact - that's the nature of LCD displays (vs old-school tubes, that is), they only look right at a single resolution.
    I take it you can't resize the window in question? In case you weren't aware, you can drag a tab (say the Motion tab) from one window (the Viewer) into another (say the Timeline) to quickly give yourself more wiggle room. Or you can simply drag the tab out and it should stay open in it's own (floating) window, if my memory isn't failing me.
    Or does all that still not get to the heart of your problem?

  • Are you utlizing SAP's Quality Center with Integration to Solution Manager?

    Hello,
    I am interested in hearing from folks who are utilizing SAP's Quality Center with or without Integration to Solution Manager. Please post your experience on setting this up and realizing the benefits, i.e. efforts involved, what features of HPQC you are using, is it a good tool to use for integrated SAP testing etc.
    Thanks in advance for your help!
    Abu

    Hi
    I luv solman so if u ask me i can do all with solman itself and say not  to go with Quality center
    but again it is upto project requirement
    it is very easy to build the automated scripts in QTP etc used with Quality center but again bit more complicated in ECATT
    its upto the ur decision but if u r gng with manual test case management forgot quality center and go with Solman
    So far i have done 5 Test Management implementation including both type of test casees automatic and manual and all are managed with solman
    moreover if u get service desk configured in place then its integrated with solman test management whic helps u a lot.....
    one step ahead go for Change management.
    Hope it ans ur query
    Regards
    Prakhar
    Edited by: Prakhar Saxena on Jun 9, 2010 12:06 AM

  • Shutting down FormsCentral? Why are you not marketing FormsCentral in conjunction with Muse? Perfect audience for FormsCentral.

    I just saw the notification that you'll be shutting down FormsCentral. This will be a pain in the *** for me, but I suspect I'll survive.
    I'm just surprised you're shutting it down. In my eye's Adobe never really even marketed the product. I stumbled across it in a round-about way, but I see it as a perfect companion to Muse. I'm amazed that you don't market it to Muse users, and build it into the Muse platform. You could potentially offer it as an in-app purchase. It is such a natural fit for your Muse demographic.
    Stan Schultz
    Censible Marketing

    Hi schultzee ,
    I appreciate the fact that you have been a great user of forms central.However,Adobe is committed to delivering exceptional software and services to our customers. It’s in our nature to innovate and try new things, and it was in this spirit that we introduced FormsCentral over three years ago. Unfortunately, not enough people have chosen this path. As we look to the future, and all the opportunities ahead, we need to focus our efforts on new areas of growth. Our focus will be to continue to provide world-class PDF creation products and cloud-based services that enable our customers to work with PDFs anywhere, on any device.
    Thanks,
    Vikrantt Singh

  • When are you going to fix the problems with this iOs7 ????

    since I've downloaded iOs7 - everything is  a SLOW-MO!!!  And you can't scale your photos for wallpaper.. Totally disappointed with iOs7

    Mine's running real fast.  Thrilled with IOS-7.

  • Are you a Windows developer that works with the Photoshop SDK?

    We may have some work for you and your company.  Please contact me at [email protected] for more information.
    Thank you.

    The Option "Start up automatically after a power failure" is under Power not UPS.SInce when the UPS settings shuts down the computer it is like a normal shutdown, not a loss of power shutdown. I do not see any setting that would restart the the computer after the UPS setting say shutdown the computer and power to the UPS is restored, to the UPS. It may be hard to do since with the computer shutdown the computer can't receive a startup signal.

  • How do you draw a rectangle in photoshop with rounded corners?

    I can't figure this out for the life of me, am I missing something obvious here?

    Mine doesn't have that option, is there another menu I need to open?

  • Can you view text outside of the canvas? as with the view menu you can see animation paths, bounding boxes and handles??? many thanks

    re: Motion 5
    can you view text outside of the canvas? as when using the view menu you can see animation paths, bounding boxes and handles???
    I'm in the middle of a text animation design treatment and unless my memory is completely failing I thought this was an option.
    An example would be selecting all layers and being able to see all bounding boxes and animation paths while moving along the timeline.
    Of course this could be quite a mess if you couldn't selectively chose which layers, its just with this current project it would be so helpful if
    I could see the text beyond the canvas to aid in my animations.
    many thanks,
    robert
    Motion 5
    2014 MacBook Pro 2.6Ghz i7
    16GB RAM
    OS X 10.9.5
    2011 Mac Pro
    4 Boot drives OS X 10.9.4, 10.10, 10.7, 10.8
    960GB OWC Mercury Accelsior_E2 PCI Express SSD (Current screaming fast boot drive)
    64GB RAM

    thanks for both of your responses
    I do understand shift + v " to "Show Full View Area" and shift + z to fill screen, etc.
    and command + & - for zooming
    what I'd like to do is selectively view, say, the text outside of the canvas as you can see the bounding box
    which contains the text or object when selecting one or all layers in the layers column
    I haven't used this feature in a while though I do recall using it in the past.
    Any help would greatly appreciated
    thanks,
    R.

  • Randomly, text messages I send with my new iPhone 4S are delivered as all squares instead of text.  Any idea how to fix this issue?

    Randomly, text messages I send with my new iPhone 4S are delivered to the recipients as all squares instead of regular characters.  I have heard other people complain about this too.  Any idea how to stop it or why it is happening?  Hardware issue?

    There are a lot of posts in the forums today with people having problems with iMessage.   There was also a published outage yesterday, so it's possible there are still some issues that may be impacting you both.
    I would just wait it out - I'm sure it will be sorted out soon.

  • Trying to decide 9650 or Samsung Facinate, are you happy with your BB?

    Hi,
    I am going to get my upgrade, and getting my first smartphone. I will be using for email, txt, phone, and a little web. Are you guys happy with the blackberry, or is it getting out dated and I should move to the driod platform? Was looking at the 9650.
    Help

    BlackBerry cannot be beat for instant email, texting (the Bold keyboard is amazing), call quality and battery life. Do you have friends with BlackBerrys? You can use BB Messenger to chat with them. In fairness, other smartphone platforms have instant messaging as well, but BBM is just easy and always connected, and you can see when someone has read your message (not sure if others offer this feature). And a big plus for me is I can stick a BB in my pocket and not worry about the screen cracking or scratching.
    I wouldn't worry about the platform being outdated. RIM is still a strong contender because BlackBerrys just work the way they're supposed to. Get what's right for you, because these opinions constantly change. I still see lots of "Back to BlackBerry" threads.
    Since you said "a little web," I think the Bold might be a good choice for you. If you were into heavy browsing, watching videos, or loading up on free apps and games, I'd say check out the Fascinate. If you want fun, innovative stuff that looks amazing onscreen, BB is not known for that.
    As a previous poster said, try out both devices in a store. It's the best way to know. Good luck deciding!

  • Iba allow others to make text edits. What workflow are you guys using to allow others to make text edits once the iBook has been layed out and formatted?  Is it too late? Do I need to export txt then reimport the editted text and reformat it all again?

    iba allow others to make text edits. What workflow are you guys using to allow others to make text edits once the iBook has been layed out and formatted?  Is it too late? Do I need to export txt then reimport the editted text and reformat it all again?

    Hi Ken,
    Thanks for the reply. The project I am working on is a test project for a customer. They could potentially want a number of their educational subjects presented as an interactive text book. The intent of this first project with them is to establish a logical workflow that will allow us to efficiently estimate costs and allow for review throughout the design process. Having worked with customers on creative projects in the past I can anticipate that they will want a number of changes made once they see a working version of the interactive text book.
    It is a grim reality that no project can be fully edited and planned prior to working on it and I know revisions and changes are always made once the customer can see their product. It is ok with me if there is no easy way to pass the text back and forth from the customer and me without having to reformat everything but I just want to know that is the way it works in order to provide a realistic time estimate for the project.
    My hope was I would be able to export the formatted text, allow them to make edits and then reimport that formatted text. The style sheets I am using are from one of the iBooks Author templates.
    Do you know if there is a way to use (or export ) this style sheet so it can be used in a Pages Document?
    Or, would the best option be to have the customer install iBooks Author? This would require the customer to have a mac and the software so it doesn't work for all cases.
    Another idea I was considering would be to export the book as a PDF and have the customer add markup and notes to the PDF.
    All of these options do not seem too great to me.
    I am open to any ideas.
    Thanks,
    Rob

Maybe you are looking for