Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8589111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:58:08+00:00 2026-06-11T22:58:08+00:00

I am writing some text to a quartz context. I have a box of

  • 0

I am writing some text to a quartz context.

I have a box of 500 x 200 pixels and I am writing some text inside. The box can have any aspect ratio but the text will always write with the font proportions as it is. What I want is to scale the font vertically and keep the horizontal scale.

See the picture. The first box represents what I am getting, the second one, what I want.

enter image description here

this is how I am writing it…

CGRect rect = CGRectMake(0,0,500,200);
[myText drawInRect:rect
        withFont:aFont
        lineBreakMode:UILineBreakModeTailTruncation
        alignment:UITextAlignmentCenter];

is there a way to scale the font vertically?

NOTE: as this is being written in a PDF context, I don’t want to
render the text to a image context and scale it vertically, because I
don’t want to lose resolution.

thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T22:58:10+00:00Added an answer on June 11, 2026 at 10:58 pm
      - (void) scaleTextVerticallyWithContext:(CGContextRef)myContext withRect:(CGRect)contextRect
    {
        CGFloat w, h;
        w = contextRect.size.width;
        h = contextRect.size.height;
    
        CGAffineTransform myTextTransform;    
        CGContextSelectFont (myContext, "Helvetica-Bold", h/10, kCGEncodingMacRoman);
        CGContextSetCharacterSpacing (myContext, 10);
        CGContextSetTextDrawingMode (myContext, kCGTextFillStroke); 
    
        CGContextSetRGBFillColor (myContext, 0, 1, 0, .5);
        CGContextSetRGBStrokeColor (myContext, 0, 0, 1, 1);  
    
             /*  
              *  CGAffineTransformMakeScale ( CGFloat sx, CGFloat sy );
              *  sx: The factor by which to scale the x-axis of the coordinate system.
              *  sy: The factor by which to scale the y-axis of the coordinate system.  
              */
    
        myTextTransform = CGAffineTransformMakeScale(1,8);
    
        CGContextSetTextMatrix (myContext, myTextTransform);
        CGContextShowTextAtPoint (myContext, 40, 0, "Hello There", 9);
    }
    
    - (void)drawRect:(CGRect)rect{
    
        // Drawing code
        CGContextRef context = UIGraphicsGetCurrentContext();
        CGRect viewBounds = self.bounds;
        CGContextTranslateCTM(context, 0, viewBounds.size.height);
        CGContextScaleCTM(context, 1, -1);
    
        [self scaleTextVerticallyWithContext:context withRect:viewBounds];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing some JavaScript to implement placeholder text in browsers that don't have it.
I have a textarea. After writing some misspelled text and using rightclick -> correction
I'm writing some simple script to translate text to and from rot13. So inside
Here Is My Code... Here i have one TextBox. When writing some text automatically
I have a php script, that contains some text file writing operation. Now if
Just writing some CSS and I have a pretty cool Search form where you
I am writing some BASH script and I want it have some error handling
I'm writing a Bash script that prints some text to the screen: echo Some
I'm writing a script to parse some text files, and insert the data that
This is a program I'm writing that's supposed to display some text in a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.