Drawing Text in Quartz - Text on head?

Hi
I have a very strange problem. I draw some text in a UIView.
This looks like that:
CGContextSelectFont(_context,"Courier", 18, kCGEncodingMacRoman);
CGContextSetRGBStrokeColor (_context, 0, 0, 1, 1);
CGContextTranslateCTM(_context, 30,10);
CGContextShowTextAtPoint (_context, point.x, point.y,[aString UTF8String],[aString length]);
CGContextRestoreGState(_context);
The funny thing is, *the text is always painted on the head* ! I must have missed a very stupid thing, but I see no argument where I could change the direction or anything else.
Another thing is transformation. If I do rotation, it works perfectly. If I do translation, nothing happens.
Any hints?
Thanks in advance!
Daniel

Couple of threads discussing this question:
http://discussions.apple.com/thread.jspa?messageID=7891632&#7891632
http://discussions.apple.com/message.jspa?messageID=7865805#7865805
HTH
Mike

Similar Messages

  • How to draw text vertically, or in an angle

    please help me how to draw text vertically, or in an angle

    I robbed the framework from Dr Las or 74phillip (don't remember which) ...
    import java.awt.*;
    import java.awt.geom.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class AngleText extends JPanel {
      private int      degrees = 16;
      private JSpinner degreesSpinner;
      public AngleText () {
        setBackground ( Color.WHITE );
      }  // AngleText constructor
      protected void paintComponent ( Graphics _g ) {
        super.paintComponent ( _g );
        Graphics2D g = (Graphics2D)_g;
        g.setRenderingHint ( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON );
        AffineTransform at = AffineTransform.getRotateInstance ( Math.toRadians ( degrees ) );
        Font f =  g.getFont();
        g.setFont ( f.deriveFont ( at ) );
        g.drawString ( "Rotating Text!", getWidth()/2, getHeight()/2 );
        g.setRenderingHint ( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF );
      }  // paintComponent
      public JPanel getUIPanel () {
        SpinnerModel degreesModel = new SpinnerNumberModel (
                                      degrees  // initial
                                     ,0        // min
                                     ,360      // max
                                     ,2        // step
        degreesSpinner = new JSpinner ( degreesModel );
        degreesSpinner.addChangeListener ( new DegreesTracker() );
        JPanel panel = new JPanel();
        panel.add ( degreesSpinner );
        return panel;
      }  // getUIPanel
      //  DegreesTracker
      private class DegreesTracker implements ChangeListener {
        public void stateChanged ( ChangeEvent e ) {
          Integer i = (Integer)((JSpinner)e.getSource()).getValue();
          degrees   = i.intValue ();
          repaint();
      }  // DegreesTracker
      //  main
      public static void main ( String[] args ) {
        JFrame f = new JFrame ( "AngleText" );
        f.setDefaultCloseOperation ( JFrame.EXIT_ON_CLOSE );
        AngleText app = new AngleText();
        f.getContentPane().add ( app );
        f.getContentPane().add ( app.getUIPanel(), BorderLayout.SOUTH );
        f.setSize ( 200, 200 );
        f.setVisible ( true );
      }  // main
    }  // AngleText

  • 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

  • Item texts and header texts

    hi,
    In which table item texts and header texts avialable.
    Edited by: Ramesh villa on Apr 11, 2009 4:49 PM

    Dear,
    For any queries (simple) recommended to search on group by entering simple search words of your quenry. You will find maximum solved questions.
    Re: PO header and item texts
    Regards,
    Syed Hussain.

  • PHP put page-specific text in header file

    Hello!  I am creating a website, and I have created a header that includes a title bar (ALL of my pages are .php).  This code for the title bar is as follows: 
    <div id="titlebar"><table style="margin:0 auto;"><tr><td>TEST</td></tr></table></div>
    When I put this into each page I create, I use this:
    <?php require("header.php"); ?>
    What I WANT to do is replace "TEST" in my title bar code with a php code that allows me to put in specific titles (which could be Home, Contact, Merch, etc.) in my individual pages.  Is this possible, and if so, how?

    OK, I deleted the table (I had used that when I first started making these pages, I was completely new to html, then learned css, and I'm just now tesing out php).  Works better than I thought it would.  Now, as far as everything else...  this is my website:  http://pcassistant.net  It's a band website, and ALL I'm using the php for is putting the header and footer on my page.  The top image, nav bar, and title bar are included in the header.php, the footer.php contains all normal footer info.  I'm doing this to help out with changing the info in both the header and footer ,that way I don't have to do it to every single page, just that file specifically.
    My index.php code looks like this:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Home</title>
    <link href="http://asc.pcassistant.net/main.css" rel="stylesheet" type="text/css">
    </head>
    <body>
    <div id="wrap">
    <?php require("header.php"); ?>
    <div id="content">
    <p>I STILL have no freakin clue what to put on this page.</p>
    </div>
    <?php require("footer.php"); ?>
    </div>
    </body>
    </html>
    My header.php looks as follows:
    <html>
    <body>
    <div id="image"></div>
    <div id="nav">
       <ul>
       <li><a href="http://asc.pcassistant.net/index.php">HOME</a></li>
       <li><a href="http://asc.pcassistant.net/music.php">MUSIC</a></li>
       <li><a href="http://asc.pcassistant.net/band.php">BAND</a></li>
       <li><a href="http://asc.pcassistant.net/merch.php">MERCH</a></li>
       <li><a href="http://asc.pcassistant.net/contact.php">CONTACT</a></li>
       </ul>
    </div>
    <div id="titlebar"><p>TEST</p></div>
    <br>
    </body>
    </html>
    If you looks as the website, every page displays "TEST" in the titlebar.  I want to be able to change this according to each page, but I want to keep the titlebar located in the header.php file.  These pages are in their very early stages, and there's TONS more info to put on the pages, and more pages to add, so I want to keep all changes required as simple as possible, hence using php.  With all that being said, is there a way to put in my titlebar in my header.php a php code to allow me to edit the title of each page individually.

  • Draw Text in OpenGL ES

    Hi all,
    I tried to use the Texture2D class included in the CrashLanding Example but i saw that I can't set the color of the text (it draws only white text).
    How can i set the color of the text or exists another method to draw text with OpenGL ES?
    Thanks

    There several ways to draw text but not an easy one so far I know. One idea is to have every letter as texture (with alphachannel) and draw an rectangle with a such a texture for each letter. Usually you set the gl drawcolor to white but you can change it to other, so you can color your text.

  • Can someone help me with drawing text and a custom image in cocoa?

    I am trying to learn how to draw, and when I look at the tutorial, instead of getting straight to the point on how to draw text at a coordinate, it talks about the concepts of how to draw. I get that, but exactly what methods and what objects should I use?
    For instance, the java code:
    +public void drawComponent(Graphics g){+
    +Graphics2D g2 = (Graphics2D) g;+
    +g2.drawString("Hello, World!", 10, 20);+
    draws the good old "Hello, World!" on a line starting 20 pixels down and 10 pixels across. How would I do the same in objective-c in a customized view? Based on the tutorial, I need specify the code in the
    +- (void)drawRect: (NSRect) rect+
    method.
    Also, how would I draw a picture(.gif and .png format)?

    Here's a very basic example:
    - (void)drawRect:(NSRect)rect {
    // draw text
    NSString *myString = @"Hello World";
    NSFont *font = [NSFont boldSystemFontOfSize:24];
    NSColor *color = [NSColor blueColor];
    NSDictionary *attrs = [NSDictionary dictionaryWithObjectsAndKeys:
    font, NSFontAttributeName,
    color, NSForegroundColorAttributeName,
    nil];
    [myString drawAtPoint:NSMakePoint(20, 0) withAttributes:attrs];
    // draw image
    NSImage *myImage = [NSImage imageNamed:@"picture1.png"];
    [myImage drawAtPoint:NSMakePoint(20, 40)
    fromRect:NSZeroRect operation:NSCompositeCopy fraction:1.0];
    Since the above uses the imageNamed convenience method of NSImage, the arg must be the name of an image file you've previously added to the main bundle (Project->Add to Project). The code for a gif would be exactly the same.
    For more details see [Drawing Images into a View|https://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Coc oaDrawingGuide/Images/Images.html#//apple_ref/doc/uid/TP40003290-CH208-BCIIBDAD] and [Simple Text Drawing|https://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/ CocoaDrawingGuide/Text/Text.html#//apple_ref/doc/uid/TP40003290-CH209-SW1] in the +Cocoa Drawing Guide+. Btw, the above is for OS X, since you asked about Cocoa. iPhone code is now called Cocoa Touch, so I hope I guessed the platform right. In case you really wanted iPhone, the code would be quite similar, but you'll need to substitute CGPointMake for NSMakePoint, UIColor for NSColor, UIImage for NSImage, and use a method like [drawAtPoint:forWidth:withFont:minFontSize:actualFontSize:lineBreakMode:baselin eAdjustment:|http://developer.apple.com/iphone/library/documentation/UIKit/Refer ence/NSStringUIKit_Additions/Reference/Reference.html#//appleref/doc/uid/TP40006893-CH3-SW14] for your text. You'll also only need one arg for the [drawAtPoint|http://developer.apple.com/iphone/library/documentation/UIKit/Refe rence/UIImageClass/Reference/Reference.html#//appleref/doc/uid/TP40006890-CH3-SW24] method of UIImage.
    Hope that helps get you started!
    - Ray

  • How to draw text to scale in actual inches?

    When I set my document to draw text in inches and then outline the text, its usually smaller than what it was supposed to be. How do I set it to draw to an accurate size while still in edit mode (not outlined)?

    It is exactly the size it is supposed to be. When you enter a type size, it is not the height of the capital letters, it's the distance from the tallest ascender to the lowest descender.
    all the text below is 12 point
    the only way to get what you want is to figure out the point size at which the capitals will equal .5 inches  - as you can see, this point size will vary depending on the font.

  • ME51N Entering Text in Header note

    Dear Experts,
    When I enter the text in Header note in Purchase Requisition-ME51N There is no problem with alphabets but when i enter the numbers,arabic numbers are being enteted instead of numeric numbers. when i double click the header text, header note is expanding, in the expanded form numeric numbers are displaying, but in the normal header note form, arabic numbers are dispalying.
    But in the item details alphbets and numeric numbers are being entered , there is no problem in item details.
    If I enter alphabets and Numeric numbers in MS word, there is no problem.
    Only in Header note arabic numbers are being dispalyed.
    I have checked in English text settings, it is set to English United states-US
    I have checked in the Regional and language settings in contral panel-Here also standard digits is set to 0123456789.
    Please suggest what needs to be done.
    Regards,
    Dayanand

    HI,
    For get about commit_text. First what you do is goto se37, execute the function SAVE_TEXT passing the parameter save_mode_direct = X. Check whether its reflected in transaction. You have pass the proper object values to the function.

  • How draw TEXT to Image

    I have a Image component loaded from file :
    private Image bgImage;
    bgImage           = new ImageIcon("images/BackGround.jpg").getImage();
    And I want draw text to this image.
    How to do it?
    Best Regards.

    Related to this posting:
    http://forum.java.sun.com/thread.jspa?threadID=756975
    It would be nice if the OP will keep all the information together in one place so everybody knows what has already been suggested.

  • [iPhone related] having trouble drawing text with Quartz

    I am unable to get any text to show up using Quartz.
    My context is showing other Quartz shapes like rects.
    Here is the code I'm using:
    string test = "this is a test";
    CGContextSetRGBFillColor(context, 0, 0, 0, 1);
    CGContextSetRGBStrokeColor(context, 1, 1, 1, 1);
    CGContextSelectFont (context, "Times-Bold", 20, kCGEncodingMacRoman);
    CGContextSetTextDrawingMode (context, kCGTextFillStroke);
    CGContextShowTextAtPoint(context, 30, 30, test.c_str(), test.length());
    Any help appreciated.

    I think your problem is that the iPhone only supports a very limited set of fonts.
    As far as i know, "Times-bold" is not one of them.
    The safest way is to do it like so:
    UIFont* font = [[UIFont systemFontOfSize:12.0]];
    CGContextSelectFont(context, [[font.fontName UTF8String]], 12.0, kCGEncodingMacRoman);
    Further more, I don't recommend using the method CGContextShowTextAtPoint() since it doesn't support unicode strings for non-english texts.
    The correct way to display text on the iPhone is like so:
    NSString* myStr = ....
    UIFont* font = [[UIFont systemFontOfSize:12.0]];
    UIGraphicsPushContext(context);
    [[myStr drawInRect: CGRectMake(x, y, w, h) withFont:font lineBreakMode:UILineBreakModeWordWrap alignment:UITextAlignmentCenter]];
    UIGraphicsPopContext();

  • SMS text message header does not display sender information

    When I receive a text message the only header information that displays is the date and time.  The senders information does not display.  The lines are not even there.  There is no way to reply to a text message or tell who the sender is.  This problem is only with SMS messages.  Regular email headers display just fine.  I have done a wipe, reset, reload, everything possible with no luck.  I am the only one in my office with this problem.  I have not been able to find any information or postings from anyone having the same problem.  I can read the text message, but there is no header (except for the date and time).  Any thoughts?
    Blackberry Curve 8350i

    I was able to resolve the problem by uninstalling the Blackberry desktop manager software and reinstalling it selecting Internet Email vs. Blackberry Enterprise Server.  If you get to the screen that asks you to choose which type of email service you use and you accidentally choose the wrong one your phone will work but will do strange things, including sending all sorts of redirect emails.  For me, this seemed to do the trick.

  • Text Input header render lost focus on grid data refresh

    I have create a text input  type header render for datagrid as a filter.  On change event I am dispatching my custom event which refresh the datagrid from
    server side filter but in this the text input in which I am typing lost focus and gain it again on mouce click
    Alreadt tried setFocus and focusManager
    Thanks
    Abha

    I'd probably wait for updateComplete and then call setFocus again.  And/or
    use callLater to defer setting focus.

  • Display Currency Value of User POV for Entity & Value in Text Box (Header)

    I am looking for a function in Financial Reporting Studio that operates the same as the HsCurrency function in Smart View. This would allow batch reports displaying the currency value of the User POV for Entity based on the User POV for Value. Right now I have to have Member Lists for separate reports and different currencies as I am only able to display the Value dimension in the heading of a given report. Users will not be certain of the currency if the Value dimension is <Entity Curr Total>.
    I tried the HFMCurrency text function, however the entity is not defined in a Row / Column / Page reference as the entity is determined by the User's Point of View.
    Is there a way to display the currency value of a User's Point of View for Entity based on the User's Point of View for Value?
    Reference from Oracle Hyperion Smart View for Office, Fusion Edition, User's Guide:
    HsCurrency
    Data sources: Financial Management, Hyperion Enterprise
    HsCurrency retrieves the currency value of the specified dimension member. Entity and Value are the only valid members for the HsCurrency function.
    Syntax
    HsCurrency (“Connection,Entity;Value”)
    Example
    In this example, HsCurrency retrieves the entity currency where the currency for the East Sales entity is USD, and the currency for the UKSales entity is GBR. The EastSales entity displays USD, and UKSales displays GBR.
    HsCurrency(“Comma”,”Entity#EastRegion.EastSales;Value#<Entity Currency>.”)
    HsCurrency(“Comma”,”Entity#EastRegion.UKSales;Value#<Entity Currency>.”)

    Question answered in My Oracle Support Community - Hyperion Reporting Products:
    communities.oracle.com

  • PDF Maker adding text in header and footer

    As I convert documents from MS Word to .pdf, I am experiencing a problem with what looks like additional text being placed in front of a field, which references a bookmark in my Word document.
    The additional code is showing up in header and footers only.
    When I place a reference field in the body of my document it converts properly. However, when it does convert properly in the body, it creates a hyperlink back to the referenced word - which is not my intention. My intent was to create a bookmarked area in my Word document that will propagate its contents throughout the document (in the header/footer etc...).
    The additional text seems to be the code Word uses to reference the Word bookmark.
    I recently updated from Professional 7 to 8 and installed the 8.1.2 update. This is the first time I have had this problem!
    Any advice would be greatly appreciated.
    Thanks,
    Bill

    I had this a long time ago and one of my students pointed out a setting in WORD. Unfortunately I do not remember the item that had to be fixed, but it was definitely a WORD problem.

Maybe you are looking for

  • Exporting a crystal report as PDF and Attaching to an email via code - Filename Issuses?

    Post Author: alynch CA Forum: .NET I need to export a crystal report as a pdf and send it out via email.  I have created a subroutine that works but the attached filename come up as "untitled.txt" so the receiving machine believes it is a text file. 

  • The Favourite Content Portlet could not be populated.

    Hi all, I am new in PORTAL, I made an Instant portlet which was working fine. But then started an error occuring when I view the Portal Page: "The Favorite Content Portlet could not be populated.<br/><br/>Error Message<br/>." This error is show in a

  • Receive error message when trying to open .rtf files.

    I have .rtf files I am trying to open for school and cannot view them in TextEdit, Pages, Word for Mac, TextWringler, or Openoffice.org.  I can open the original file but when I edit them I get this error when I try and open them: "The document 'xxx.

  • Updated osx and flash storage for macbook air and now i can't start up

    I updated my macbook air, and now when it restarts I get a circle with a line through it, then the apple, then the screen turns blue, and then it takes me right to the disk utility.  It wont boot my desktop.  Help!

  • Planning Web Form status message.

    Is there a way to display a custom status message in web form. We are trying to add some resources to a division using a business rule from a web form and have a requirement to display a warning message if the resource already belongs to the division