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

  • Home
  • SEARCH
  • 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 7644501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:42:17+00:00 2026-05-31T09:42:17+00:00

I’m trying to develop localized help files. It works great with western languages but

  • 0

I’m trying to develop localized help files. It works great with western languages but is not displaying non-western characters (just outputs the image file). Same happens if text is encoded in utf-8 or utf-16
Don’t like posting all this code but I just can’t track down where the issue is.
Any help much appreciated!

    - (IBAction)segmentedControlChanged:(UISegmentedControl *)sender {
    UIImage *helpImage;
    NSArray *helpText;
    if (sender.selectedSegmentIndex == 1) {
        helpImage = [UIImage imageNamed:@"HelpImage.png"];
        helpText = [NSArray arrayWithObjects:
                    [NSDictionary dictionaryWithObjectsAndKeys:
                     NSLocalizedString(@"Tab1 - sample text", nil), kHelpTextKeyString,
                     @"Arial", kHelpTextKeyFontName,
                     //@"Helvetica-Bold", kHelpTextKeyFontName,
                     [NSNumber numberWithInt:20], kHelpTextKeyFontSize,
                     [[UIColor blackColor] CGColor], kHelpTextKeyColor,
                     CGRectCreateDictionaryRepresentation(CGRectMake(30.0, 55.0, 200.0, 28.0)), kHelpTextKeyRect,
                     nil],
                    // CGRectCreateDictionaryRepresentation(CGRectMake(38.0, 55.0, 200.0, 28.0)), kHelpTextKeyRect,
                    //CGRectCreateDictionaryRepresentation(CGRectMake(30.0, 55.0, 200.0, 28.0)), kHelpTextKeyRect,

                    [NSDictionary dictionaryWithObjectsAndKeys:
                     [NSArray arrayWithObjects:
                      NSLocalizedString(@"sample text ", nil),
                      NSLocalizedString(@" ", nil),
                      NSLocalizedString(@"more sample text", nil),
                      nil], kHelpTextKeyString,
                     @"Helvetica-Light", kHelpTextKeyFontName,
                     [NSNumber numberWithInt:10], kHelpTextKeyFontSize,
                     [[UIColor blackColor] CGColor], kHelpTextKeyColor,
                     CGRectCreateDictionaryRepresentation(CGRectMake(10.0, 80.0, 200.0, 28.0)), kHelpTextKeyRect,
                     nil],
                    nil];
    }

    // display actual image
    [self displaySelectedHelpImage:helpImage withTextArray:helpText];
}


/

    / merge selected help image to text
    - (void)displaySelectedHelpImage:(UIImage *)orgImage withTextArray:(NSArray *)textArr {
        CGImageRef cgImage = [orgImage CGImage];
        int pixelsWide              = CGImageGetWidth(cgImage);
        int pixelsHigh              = CGImageGetHeight(cgImage);
        int bitsPerComponent        = CGImageGetBitsPerComponent(cgImage);//8; // fixed
        int bitsPerPixel            = CGImageGetBitsPerPixel(cgImage);//bitsPerComponent * numberOfCompnent;
        int bytesPerRow             = CGImageGetBytesPerRow(cgImage);//(pixelsWide * bitsPerPixel) // 8; // bytes
        int byteCount               = (bytesPerRow * pixelsHigh);
        CGColorSpaceRef colorSpace  = CGImageGetColorSpace(cgImage);//CGColorSpaceCreateDeviceRGB();

    // Allocate data
    NSMutableData *data = [NSMutableData dataWithLength:byteCount];
    // Create a bitmap context
    CGContextRef context = CGBitmapContextCreate([data mutableBytes], pixelsWide, pixelsHigh, bitsPerComponent, bytesPerRow, colorSpace, kCGImageAlphaPremultipliedLast); //kCGImageAlphaPremultipliedLast);//kCGImageAlphaNoneSkipLast); //kCGImageAlphaOnly);
    // Set the blend mode to copy to avoid any alteration of the source data or to invert to invert image
    CGContextSetBlendMode(context, kCGBlendModeCopy);
    // Set alpha
    CGContextSetAlpha(context, 1.0);
    // Color image
    //CGContextSetRGBFillColor(context, 1 ,1, 1, 1.0);
    //CGContextFillRect(context, CGRectMake(0.0, 0.0, pixelsWide, pixelsHigh));
    // Draw the image to extract the alpha channel
    CGContextDrawImage(context, CGRectMake(0.0, 0.0, pixelsWide, pixelsHigh), cgImage);

    // add text to image
    // Changes the origin of the user coordinate system in a context
    //CGContextTranslateCTM (context, pixelsWide, pixelsHigh);
    // Rotate context upright
    //CGContextRotateCTM (context, -180. *  M_PI/180);
    for (NSDictionary *dic in textArr) {

        CGContextSelectFont (context,
                             //todo
                             [[dic objectForKey:kHelpTextKeyFontName] UTF8String],
                             [[dic objectForKey:kHelpTextKeyFontSize] intValue],
                             kCGEncodingMacRoman);
        CGContextSetCharacterSpacing (context, 2);
        CGContextSetTextDrawingMode (context, kCGTextFillStroke);

        CGColorRef color = (CGColorRef)[dic objectForKey:kHelpTextKeyColor];
        CGRect rect;
        CGRectMakeWithDictionaryRepresentation((CFDictionaryRef)[dic objectForKey:kHelpTextKeyRect], &rect);

        CGContextSetFillColorWithColor(context, color);
        CGContextSetStrokeColorWithColor(context, color); 

        if ([[dic objectForKey:kHelpTextKeyString] isKindOfClass:[NSArray class]]) {
            for (NSString *str in [dic objectForKey:kHelpTextKeyString]) {
                CGContextShowTextAtPoint(context,
                                         rect.origin.x,
                                         pixelsHigh - rect.origin.y,
                                         [str cStringUsingEncoding:[NSString defaultCStringEncoding]],
                                         [str length]);
                rect.origin.y += [[dic objectForKey:kHelpTextKeyFontSize] intValue];
            }
        } else {
            CGContextShowTextAtPoint(context,
                                     rect.origin.x,
                                     pixelsHigh - rect.origin.y,
                                     [[dic objectForKey:kHelpTextKeyString] cStringUsingEncoding:[NSString defaultCStringEncoding]],
                                     [[dic objectForKey:kHelpTextKeyString] length]);
        }
    }

    // Now the alpha channel has been copied into our NSData object above, so discard the context and lets make an image mask.
    CGContextRelease(context);
    // Create a data provider for our data object (NSMutableData is tollfree bridged to CFMutableDataRef, which is compatible with CFDataRef)
    CGDataProviderRef dataProvider = CGDataProviderCreateWithCFData((CFMutableDataRef)data);
    // Create our new mask image with the same size as the original image
    //CGImageRef maskingImage = CGImageMaskCreate(pixelsWide, pixelsHigh, bitsPerComponent, bitsPerPixel, bytesPerRow, dataProvider, NULL, YES);

    CGImageRef finalImage = CGImageCreate(pixelsWide,
                                          pixelsHigh,
                                          bitsPerComponent,
                                          bitsPerPixel,
                                          bytesPerRow,
                                          colorSpace,
                                          kCGBitmapByteOrderDefault,
                                          dataProvider,
                                          NULL,
                                          YES,
                                          kCGRenderingIntentDefault);

    // And release the provider.
    CGDataProviderRelease(dataProvider);

    UIImage *theImage = [UIImage imageWithCGImage:finalImage];

    // remove old scroll view
    if (scrollView) {
        [scrollView removeFromSuperview];
    }

    // construct new scroll view and size according to image
    UIScrollView *tempScrollView = [[UIScrollView alloc] initWithFrame:containerView.bounds];
    tempScrollView.contentSize = theImage.size; 
    scrollView = tempScrollView;

    // construct an image view (sized at zero) and assign the help image to it
    UIImageView *tempImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0, 0.0, theImage.size.width, 0.0)];
    [tempImageView setImage:theImage];

    // push image view to scrolle view and scroll view to container view
    [tempScrollView addSubview:tempImageView];
    [containerView addSubview:tempScrollView];

    // animate
    [UIView beginAnimations:@"ResizeImageView" context:NULL];
    [UIView setAnimationDuration:1.0];

    // recover actual image size through animation
    [tempImageView setFrame:CGRectMake(0.0, 0.0, theImage.size.width, theImage.size.height)];

    [UIView setAnimationDelegate:self];
    [UIView setAnimationCurve: UIViewAnimationCurveEaseOut];

    [UIView commitAnimations];- (IBAction)segmentedControlChanged:(UISegmentedControl *)sender {
    UIImage *helpImage;
    NSArray *helpText;
    if (sender.selectedSegmentIndex == 1) {
        helpImage = [UIImage imageNamed:@"HelpImage.png"];
        helpText = [NSArray arrayWithObjects:
                    [NSDictionary dictionaryWithObjectsAndKeys:
                     NSLocalizedString(@"Tab1 - sample text", nil), kHelpTextKeyString,
                     @"Arial", kHelpTextKeyFontName,
                     //@"Helvetica-Bold", kHelpTextKeyFontName,
                     [NSNumber numberWithInt:20], kHelpTextKeyFontSize,
                     [[UIColor blackColor] CGColor], kHelpTextKeyColor,
                     CGRectCreateDictionaryRepresentation(CGRectMake(30.0, 55.0, 200.0, 28.0)), kHelpTextKeyRect,
                     nil],
                    // CGRectCreateDictionaryRepresentation(CGRectMake(38.0, 55.0, 200.0, 28.0)), kHelpTextKeyRect,
                    //CGRectCreateDictionaryRepresentation(CGRectMake(30.0, 55.0, 200.0, 28.0)), kHelpTextKeyRect,

                    [NSDictionary dictionaryWithObjectsAndKeys:
                     [NSArray arrayWithObjects:
                      NSLocalizedString(@"sample text ", nil),
                      NSLocalizedString(@" ", nil),
                      NSLocalizedString(@"more sample text", nil),
                      nil], kHelpTextKeyString,
                     @"Helvetica-Light", kHelpTextKeyFontName,
                     [NSNumber numberWithInt:10], kHelpTextKeyFontSize,
                     [[UIColor blackColor] CGColor], kHelpTextKeyColor,
                     CGRectCreateDictionaryRepresentation(CGRectMake(10.0, 80.0, 200.0, 28.0)), kHelpTextKeyRect,
                     nil],
                    nil];
    }

    // display actual image
    [self displaySelectedHelpImage:helpImage withTextArray:helpText];
}


// merge selected help image to text
- (void)displaySelectedHelpImage:(UIImage *)orgImage withTextArray:(NSArray *)textArr {
    CGImageRef cgImage = [orgImage CGImage];
    int pixelsWide              = CGImageGetWidth(cgImage);
    int pixelsHigh              = CGImageGetHeight(cgImage);
    int bitsPerComponent        = CGImageGetBitsPerComponent(cgImage);//8; // fixed
    int bitsPerPixel            = CGImageGetBitsPerPixel(cgImage);//bitsPerComponent * numberOfCompnent;
    int bytesPerRow             = CGImageGetBytesPerRow(cgImage);//(pixelsWide * bitsPerPixel) // 8; // bytes
    int byteCount               = (bytesPerRow * pixelsHigh);
    CGColorSpaceRef colorSpace  = CGImageGetColorSpace(cgImage);//CGColorSpaceCreateDeviceRGB();

    // Allocate data
    NSMutableData *data = [NSMutableData dataWithLength:byteCount];
    // Create a bitmap context
    CGContextRef context = CGBitmapContextCreate([data mutableBytes], pixelsWide, pixelsHigh, bitsPerComponent, bytesPerRow, colorSpace, kCGImageAlphaPremultipliedLast); //kCGImageAlphaPremultipliedLast);//kCGImageAlphaNoneSkipLast); //kCGImageAlphaOnly);
    // Set the blend mode to copy to avoid any alteration of the source data or to invert to invert image
    CGContextSetBlendMode(context, kCGBlendModeCopy);
    // Set alpha
    CGContextSetAlpha(context, 1.0);
    // Color image
    //CGContextSetRGBFillColor(context, 1 ,1, 1, 1.0);
    //CGContextFillRect(context, CGRectMake(0.0, 0.0, pixelsWide, pixelsHigh));
    // Draw the image to extract the alpha channel
    CGContextDrawImage(context, CGRectMake(0.0, 0.0, pixelsWide, pixelsHigh), cgImage);

    // add text to image
    // Changes the origin of the user coordinate system in a context
    //CGContextTranslateCTM (context, pixelsWide, pixelsHigh);
    // Rotate context upright
    //CGContextRotateCTM (context, -180. *  M_PI/180);
    for (NSDictionary *dic in textArr) {

        CGContextSelectFont (context,
                             //todo
                             [[dic objectForKey:kHelpTextKeyFontName] UTF8String],
                             [[dic objectForKey:kHelpTextKeyFontSize] intValue],
                             kCGEncodingMacRoman);
        CGContextSetCharacterSpacing (context, 2);
        CGContextSetTextDrawingMode (context, kCGTextFillStroke);

        CGColorRef color = (CGColorRef)[dic objectForKey:kHelpTextKeyColor];
        CGRect rect;
        CGRectMakeWithDictionaryRepresentation((CFDictionaryRef)[dic objectForKey:kHelpTextKeyRect], &rect);

        CGContextSetFillColorWithColor(context, color);
        CGContextSetStrokeColorWithColor(context, color); 

        if ([[dic objectForKey:kHelpTextKeyString] isKindOfClass:[NSArray class]]) {
            for (NSString *str in [dic objectForKey:kHelpTextKeyString]) {
                CGContextShowTextAtPoint(context,
                                         rect.origin.x,
                                         pixelsHigh - rect.origin.y,
                                         [str cStringUsingEncoding:[NSString defaultCStringEncoding]],
                                         [str length]);
                rect.origin.y += [[dic objectForKey:kHelpTextKeyFontSize] intValue];
            }
        } else {
            CGContextShowTextAtPoint(context,
                                     rect.origin.x,
                                     pixelsHigh - rect.origin.y,
                                     [[dic objectForKey:kHelpTextKeyString] cStringUsingEncoding:[NSString defaultCStringEncoding]],
                                     [[dic objectForKey:kHelpTextKeyString] length]);
        }
    }

    // Now the alpha channel has been copied into our NSData object above, so discard the context and lets make an image mask.
    CGContextRelease(context);
    // Create a data provider for our data object (NSMutableData is tollfree bridged to CFMutableDataRef, which is compatible with CFDataRef)
    CGDataProviderRef dataProvider = CGDataProviderCreateWithCFData((CFMutableDataRef)data);
    // Create our new mask image with the same size as the original image
    //CGImageRef maskingImage = CGImageMaskCreate(pixelsWide, pixelsHigh, bitsPerComponent, bitsPerPixel, bytesPerRow, dataProvider, NULL, YES);

    CGImageRef finalImage = CGImageCreate(pixelsWide,
                                          pixelsHigh,
                                          bitsPerComponent,
                                          bitsPerPixel,
                                          bytesPerRow,
                                          colorSpace,
                                          kCGBitmapByteOrderDefault,
                                          dataProvider,
                                          NULL,
                                          YES,
                                          kCGRenderingIntentDefault);

    // And release the provider.
    CGDataProviderRelease(dataProvider);

    UIImage *theImage = [UIImage imageWithCGImage:finalImage];

    // remove old scroll view
    if (scrollView) {
        [scrollView removeFromSuperview];
    }

    // construct new scroll view and size according to image
    UIScrollView *tempScrollView = [[UIScrollView alloc] initWithFrame:containerView.bounds];
    tempScrollView.contentSize = theImage.size; 
    scrollView = tempScrollView;

    // construct an image view (sized at zero) and assign the help image to it
    UIImageView *tempImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0, 0.0, theImage.size.width, 0.0)];
    [tempImageView setImage:theImage];

    // push image view to scrolle view and scroll view to container view
    [tempScrollView addSubview:tempImageView];
    [containerView addSubview:tempScrollView];

    // animate
    [UIView beginAnimations:@"ResizeImageView" context:NULL];
    [UIView setAnimationDuration:1.0];

    // recover actual image size through animation
    [tempImageView setFrame:CGRectMake(0.0, 0.0, theImage.size.width, theImage.size.height)];

    [UIView setAnimationDelegate:self];
    [UIView setAnimationCurve: UIViewAnimationCurveEaseOut];

    [UIView commitAnimations];
  • 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-05-31T09:42:18+00:00Added an answer on May 31, 2026 at 9:42 am

    You’re drawing text using CGContextShowTextAtPoint, which has poor support for non-ASCII text.

    Similar issues: one, two. Apple’s documentation explains the issue.

    Use a higher-level API to draw the text, such as the methods in UIKit/UIStringDrawing.h, like -[NSString drawAtPoint:withFont:].

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I need to clean up various Word 'smart' characters in user input, including but
I need a function that will clean a strings' special characters. I do NOT
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

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.