Rectangle 27 0

This is a problem with the font. Very few fonts contain the musical symbols of Unicode. The UFO symbols that you see are probably generic symbols for strange characters not present in the font. You may need to find a suitable free font and try to bundle it with your application.

A few fonts contain at least some of the musical symbols. The most commonly known of them, FreeSerif, Quivira, and Symbola are listed (with samples) at the Fileformat.info site on page MUSICAL SYMBOL WHOLE NOTE (U+1D15D) Font Support. There is also the Musica font downloadable from the page Unicode Fonts for Ancient Scripts. (The common musical symbols arent that ancient, but the font contains also Byzantine musical symbols.)

Universalia

@TonyMkenu, Universalia is an obscure font, which is probably a mashup of other fonts. I have found descriptions of it only in Russian, and I have great doubts about its being legal (it may have been formed by combining fonts, some of which are free and some not).

@Juan if you want just a few simple notes, like Quarter Note you can still use unicode 2669 ; check MUSICAL NOTE ICONS in zaposphere.com/html-icons-reference-unicode-character-list ...and... @Jukka you are rock + 1 :)

Thank you, I followed the instructions here to add the FreeSerif font to my project and it now works like a charm. @TonyMkenu Thanks, I had also thought of Universalia but I couldn't find its source so I gave up on it. And yeah, I was about to stick with the simple notes. Gladly, FreeSerif worked fine :)

xcode - Displaying Musical Unicode Symbols in iOS UI with Swift - Stac...

ios xcode swift unicode uilabel
Rectangle 27 0

Displaying some characters as "Emojis" is a feature which is e.g. (controversially) discussed here: https://devforums.apple.com/message/487463#487463 (requires Apple Developer login). This feature was introduced in iOS 6.

A solution (from http://stackoverflow.com/a/13836045/1187415) is to append the Unicode "Variation selector" U+FE0E, e.g.

self.myLabel.text = @"\u2B07\uFE0E";
// or:
self.myLabel.text = @"\uFE0E";

Note that on iOS <= 5.x, the Variation selector is not necessary and must not be used, because iOS 5 would display it as a box.

ios - I need help getting a normal looking unicode down arrow in a UIL...

ios objective-c unicode ios6 uilabel
Rectangle 27 0

This is not losing the encoding, try to add the strings from the nsarray to a UILabel or UITextField and it should be correct This behavior of writing the Unicode representation happens only in the console when you NSLog

You are right: they do display correctly in the UILabel. Thanks!

ios - Accented character incorrectly encoding in NSString Array - Stac...

ios encoding nsstring nsmutablearray
Rectangle 27 0

If you're seeing the blue arrow with gloss, you have the right character, but it's showing one of the emoji-style characters. Try changing the font of your UILabel to something like Arial Unicode MS.

Edit After a little testing, it looks like changing the font doesn't actually work. It keeps displaying the glossy arrow. It's probably better to go with the suggestion of the other answer and use a different glyph, like \u2193, which does work:

[nameLabel setText:@"\u2193"];

ios - I need help getting a normal looking unicode down arrow in a UIL...

ios objective-c unicode ios6 uilabel
Rectangle 27 0

For those who tried doing it programmatically, but failed, just use this:

label.text = @"\U0001F50A";

iphone - How to enter unicode characters in a UILabel in Interface Bui...

iphone ios unicode utf-8 interface-builder
Rectangle 27 0

For those who tried doing it programmatically, but failed, just use this:

label.text = @"\U0001F50A";

please make sure to use lower u and not upper U i.e. @"\u0001F50A"

No. Stick to upper U. When I tried this in Xcode 8.3 it spat out compiler error "Universal character name refers to a control character". I've test upper U and can confirm it works great.

iphone - How to enter unicode characters in a UILabel in Interface Bui...

iphone ios unicode utf-8 interface-builder
Rectangle 27 0

Yes, you can click Edit->Special Characters... - there you can find all unicode characters (including the emoji) and copy/paste them where you set the label text in the InterfaceBuilder.

Yes, it works if I search for "speaker". But the symbol seams to be a bitmap and not a true font...

important to know if you're not used to typing literal unicode characters into the Emoji & Characters window: you type 0x followed by the code, so if the unicode is f19c, you type 0xf19c into the search bar, and if it's supported by default, the character will come up, otherwise an empty box character will come up -- that empty box character is your unicode character, double click to insert

iphone - How to enter unicode characters in a UILabel in Interface Bui...

iphone ios unicode utf-8 interface-builder
Rectangle 27 0

Declare an IBOutlet for the Label, with the means of NSString type:

// UTF-8 Hexadecimal Encoding
NSString *myString = [NSString stringWithUTF8String:"0xF09F948A"];

myLabel.text = myString;

+1, but it does not work for the specific symbol. According to fileformat.info/info/unicode/char/1f50a/index.htm I should enter the string "\uD83D\uDD0A". But Xcode says the symbol is invalid

iphone - How to enter unicode characters in a UILabel in Interface Bui...

iphone ios unicode utf-8 interface-builder
Rectangle 27 0

Displaying some characters as "Emojis" is a feature which is e.g. (controversially) discussed here: https://devforums.apple.com/message/487463#487463 (requires Apple Developer login). This feature was introduced in iOS 6.

A solution (from http://stackoverflow.com/a/13836045/1187415) is to append the Unicode "Variation selector" U+FE0E, e.g.

self.myLabel.text = @"\u2B07\uFE0E";
// or:
self.myLabel.text = @"\uFE0E";

Note that on iOS <= 5.x, the Variation selector is not necessary and must not be used, because iOS 5 would display it as a box.

ios - I need help getting a normal looking unicode down arrow in a UIL...

ios objective-c unicode ios6 uilabel
Rectangle 27 0

Reading in xml characters can be interesting. XML doesn't know that \ means "Special character comes next". It knows that "\" means "I want you to write a "\".

So to get what you are looking for you are going to have to read in your string from the dictionary, then do a [string stringByReplacingOccurrencesOfString:@"\\n" withString:@"\n"]; on it to get your carriage returns back.

You can save carriage returns in xml, but not using the "\" method.

ios - String with unicode and UILabel with multiline - Stack Overflow

ios objective-c unicode uilabel
Rectangle 27 0

The arrow with the blue box around it, is the Emoji arrow with the same Unicode. Open Character Viewer on OS X (Control + Option + Space) to look up the codes and check the Unicode for the Arrows section from the left pane. Using that unicode should fix the issue as it won't mess with the Emoji arrow codes!

Update Sorry, I don't have access to a Mac at the moment, therefore I couldn't look up the code myself. Apparently if you add \U0000FE0E to your unicode, that'll avoid the Emoji. So in your case:

NSString *strMore = @"\u2B06" ; //This will map the character to the Emoji icon; the blue up arrow.
NSString *strLess = @"\u2B07" ; //This will map the character to the Emoji icon; the blue down arrow.
NSString *strMore = @"\u2B06\U0000FE0E" ; //This will disable Emoji character mapping and will display the proper unicode character, the black up arrow here.
NSString *strLess = @"\u2B07\U0000FE0E" ; //This will disable Emoji character mapping and will display the proper unicode character, the black down arrow here.

Let me know if that works!

Glad it worked! Didn't want to reference before making sure it works. Apparently this is mentioned in Apple's Developer forum for the paid developers. It's also mentioned in this link and this question.

Thanks for the screenshot. But in Character Viewer as well its showing the same symbol that I am using currently.

Sorry, I'm on a shi**y Windows machine at the moment, that's why I couldn't check it myself. Check out the updated answer.

Thanks Neeku for updated answer. This works perfectly :) Thanks a ton. Just for curiosity , you told me if you add \U0000FE0E to your unicode, that'll avoid the Emoji. - where did you find this ? Can you please share the link as I need to learn :)

Sure! There you go with another update to the answer!

Not sure why the wide-Unicode-escape \U is being used for all these examples, this Variation Selector is a BMP character that should be accessible simply as \uFE0E.

objective c - Unicode symbol for BOLD arrow shows incorrect UI in UILa...

ios objective-c unicode
Rectangle 27 0

Your best bet may be to give up and substitute \u0091 and \u0092 for something else as a preprocessing step before string display. These are control characters and are unprintable in most encodings. But:

If rest of the file is proper UTF, your json file probably has problems: encoding is wrong (CP-1250?) while you read the file as UTF, some error has been made when converting the file, or a similar issue. So another solution is of course fixing your file.

If you're not sure about how your file is encoded, it may simply be encoded in CP-1250 - so reading the file using NSWindowsCP1250StringEncoding might fix your problem.

BTW, if you hardcode a string @"\u0091", you'll get a compilation time error Universal character name refers to a control character. Yes, not even a warning, it's that much unprintable in Unicode ;)

It was Windows-latin-1 indeed. But yes, I have open the file forcing to read as Windows-latin-1 and then I saved it using UTF-8. Thanks!

ios - \u0092 is not printed in UILabel - Stack Overflow

ios objective-c unicode uilabel
Rectangle 27 0

If you're seeing the blue arrow with gloss, you have the right character, but it's showing one of the emoji-style characters. Try changing the font of your UILabel to something like Arial Unicode MS.

Edit After a little testing, it looks like changing the font doesn't actually work. It keeps displaying the glossy arrow. It's probably better to go with the suggestion of the other answer and use a different glyph, like \u2193, which does work:

[nameLabel setText:@"\u2193"];

ios - I need help getting a normal looking unicode down arrow in a UIL...

ios objective-c unicode ios6 uilabel
Rectangle 27 0

#define MM_TEXT_TO_DISPLAY          @"default"

#define MM_FONT             [UIFont systemFontOfSize:MM_FONT_SIZE]
#define MM_FONT_SIZE            25
#define MM_FONT_COLOR           [[UIColor darkGrayColor] colorWithAlphaComponent:0.75f];

#define MM_SHADOW_ENABLED           NO
#define MM_SHADOW_COLOR         [UIColor grayColor]
#define MM_SHADOW_OFFSET            CGSizeMake(-1,-1)


#define MM_CONTENT_EDGE_INSETS_TOP      0
#define MM_CONTENT_EDGE_INSETS_LEFT     10
#define MM_CONTENT_EDGE_INSETS_BOTTON   0
#define MM_CONTENT_EDGE_INSETS_RIGHT    10
#define MM_CONTENT_EDGE_INSETS          UIEdgeInsetsMake(MM_CONTENT_EDGE_INSETS_TOP, MM_CONTENT_EDGE_INSETS_LEFT, MM_CONTENT_EDGE_INSETS_BOTTON, MM_CONTENT_EDGE_INSETS_RIGHT)

#define MM_TEXT_ALIGNMENT           UITextAlignmentCenter
#define MM_BACKGROUND_COLOR         [UIColor clearColor]

#define MM_TIMER_INTERVAL           0.05f
#define MM_HORIZONTAL_SPAN          5


@interface MMAnimatedGradientLabel : UILabel {  

    NSString *textToDisplay;
    int text_length;

    CGGradientRef gradient;

    int current_position_x;
    NSTimer *timer;

    CGPoint alignment;

    CGGlyph *_glyphs;
}

- (id)initWithString:(NSString *)_string;

- (void)startAnimation;
- (void)toggle;
- (BOOL)isAnimating;

@end

#define RGB_COMPONENTS(r, g, b, a)  (r) / 255.0f, (g) / 255.0f, (b) / 255.0f, (a)

@interface MMAnimatedGradientLabel (Private)
- (CGRect)calculateFrame;
@end


@implementation MMAnimatedGradientLabel

// Missing in standard headers.
extern void CGFontGetGlyphsForUnichars(CGFontRef, const UniChar[], const CGGlyph[], size_t);

- (id)init {
    textToDisplay = MM_TEXT_TO_DISPLAY;
    return [self initWithFrame:[self calculateFrame]];
}

- (id)initWithString:(NSString *)_string {
    textToDisplay = _string;
    return [self initWithFrame:[self calculateFrame]];
}

-(id)initWithFrame:(CGRect)frame {  
    if (self = [super initWithFrame:frame]) {

        // set default values
        //
        self.textAlignment      = MM_TEXT_ALIGNMENT;
        self.backgroundColor    = MM_BACKGROUND_COLOR;
        self.font               = MM_FONT;
        self.text               = textToDisplay;
        self.textColor          = MM_FONT_COLOR;

        if (MM_SHADOW_ENABLED) {
            self.shadowColor        = MM_SHADOW_COLOR;
            self.shadowOffset       = MM_SHADOW_OFFSET;
        }

        text_length = -1;

        CGColorSpaceRef rgb = CGColorSpaceCreateDeviceRGB();
        CGFloat colors[] =
        {       
            RGB_COMPONENTS(255.0, 255.0, 255.0, 0.00),
//          RGB_COMPONENTS(255.0, 255.0, 255.0, 0.15),
            RGB_COMPONENTS(255.0, 255.0, 255.0, 0.95),
//          RGB_COMPONENTS(255.0, 255.0, 255.0, 0.15),
            RGB_COMPONENTS(255.0, 255.0, 255.0, 0.00)
        };

        gradient = CGGradientCreateWithColorComponents(rgb, colors, NULL, sizeof(colors)/(sizeof(colors[0])*4));
        CGColorSpaceRelease(rgb);

        current_position_x = -(frame.size.width/2);// - MM_CONTENT_EDGE_INSETS.left - MM_CONTENT_EDGE_INSETS.right); 
    }

    return self;
}

- (CGRect)calculateFrame {
    CGSize size = [textToDisplay sizeWithFont:MM_FONT];
    NSLog(@"size: %f, %f", size.width, size.height);
    return CGRectMake(0, 0, size.width + MM_CONTENT_EDGE_INSETS.left + MM_CONTENT_EDGE_INSETS.right, size.height + MM_CONTENT_EDGE_INSETS.top + MM_CONTENT_EDGE_INSETS.bottom);
}

- (void)tick:(NSTimer*)theTimer {
    if (current_position_x < self.frame.size.width)
        current_position_x = current_position_x + MM_HORIZONTAL_SPAN;
    else
        current_position_x = -(self.frame.size.width/2); // - MM_CONTENT_EDGE_INSETS.left - MM_CONTENT_EDGE_INSETS.right);

    [self setNeedsDisplay]; 
}

- (void)startAnimation {    
    timer = [[NSTimer alloc] initWithFireDate:[NSDate date] 
                                     interval:MM_TIMER_INTERVAL
                                       target:self 
                                     selector:@selector(tick:)
                                     userInfo:nil
                                      repeats:YES];

    [[NSRunLoop currentRunLoop] addTimer:timer forMode:NSDefaultRunLoopMode];
}

- (void)toggle {

    if (!timer) {
        timer = [[NSTimer alloc] initWithFireDate:[NSDate date] 
                                         interval:MM_TIMER_INTERVAL
                                           target:self 
                                         selector:@selector(tick:)
                                         userInfo:nil
                                          repeats:YES];

        [[NSRunLoop currentRunLoop] addTimer:timer forMode:NSDefaultRunLoopMode];
    } else {
        [timer invalidate];
        [timer release];
        timer = nil;

        current_position_x = -(self.frame.size.width/2);
        [self setNeedsDisplay]; 
    }
}

- (BOOL)isAnimating {

    if (timer) 
        return YES;
    else
        return NO;
}

- (void)drawRect:(CGRect)rect {
    CGContextRef ctx = UIGraphicsGetCurrentContext();

    // Get drawing font.
    CGFontRef font = CGFontCreateWithFontName((CFStringRef)[[self font] fontName]);
    CGContextSetFont(ctx, font);
    CGContextSetFontSize(ctx, [[self font] pointSize]);

    // Calculate text drawing point only first time
    // 
    if (text_length == -1) {    

        // Transform text characters to unicode glyphs.
        text_length = [[self text] length];
        unichar chars[text_length];
        [[self text] getCharacters:chars range:NSMakeRange(0, text_length)];

        _glyphs = malloc(sizeof(CGGlyph) * text_length);
        for (int i=0; i<text_length;i ++)
            _glyphs[i] = chars[i] - 29;

        // Measure text dimensions.
        CGContextSetTextDrawingMode(ctx, kCGTextInvisible); 
        CGContextSetTextPosition(ctx, 0, 0);
        CGContextShowGlyphs(ctx, _glyphs, text_length);
        CGPoint textEnd = CGContextGetTextPosition(ctx);

        // Calculate text drawing point.        
        CGPoint anchor = CGPointMake(textEnd.x * (-0.5), [[self font] pointSize] * (-0.25));  
        CGPoint p = CGPointApplyAffineTransform(anchor, CGAffineTransformMake(1, 0, 0, -1, 0, 1));

        if ([self textAlignment] == UITextAlignmentCenter) 
            alignment.x = [self bounds].size.width * 0.5 + p.x;
        else if ([self textAlignment] == UITextAlignmentLeft) 
            alignment.x = 0;
        else 
            alignment.x = [self bounds].size.width - textEnd.x;

        alignment.y = [self bounds].size.height * 0.5 + p.y;
    }

    // Flip back mirrored text.
    CGContextSetTextMatrix(ctx, CGAffineTransformMakeScale(1, -1));

    // Draw shadow.
    CGContextSaveGState(ctx);
    CGContextSetTextDrawingMode(ctx, kCGTextFill);
    CGContextSetFillColorWithColor(ctx, [[self textColor] CGColor]);
    CGContextSetShadowWithColor(ctx, [self shadowOffset], 0, [[self shadowColor] CGColor]);
    CGContextShowGlyphsAtPoint(ctx, alignment.x, alignment.y, _glyphs, text_length);
    CGContextRestoreGState(ctx);

    // Draw text clipping path.
    CGContextSetTextDrawingMode(ctx, kCGTextClip);
    CGContextShowGlyphsAtPoint(ctx, alignment.x, alignment.y, _glyphs, text_length);

    // Restore text mirroring.
    CGContextSetTextMatrix(ctx, CGAffineTransformIdentity);

    if ([self isAnimating]) {
        // Fill text clipping path with gradient.
        CGPoint start = CGPointMake(rect.origin.x + current_position_x, rect.origin.y);
        CGPoint end = CGPointMake(rect.size.width/3*2 + current_position_x, rect.origin.y);

        CGContextDrawLinearGradient(ctx, gradient, start, end, 0);
    }
}


- (void) dealloc {
    free(_glyphs);
    [timer invalidate];
    [timer release];

    CGGradientRelease(gradient);
    [super dealloc];
}

CGFontGetGlyphsForUnichars - some people who use that report they fail the review for using the private API?

ios - iPhone "slide to unlock" animation - Stack Overflow

ios objective-c cocoa-touch core-animation
Rectangle 27 0

#define MM_TEXT_TO_DISPLAY          @"default"

#define MM_FONT             [UIFont systemFontOfSize:MM_FONT_SIZE]
#define MM_FONT_SIZE            25
#define MM_FONT_COLOR           [[UIColor darkGrayColor] colorWithAlphaComponent:0.75f];

#define MM_SHADOW_ENABLED           NO
#define MM_SHADOW_COLOR         [UIColor grayColor]
#define MM_SHADOW_OFFSET            CGSizeMake(-1,-1)


#define MM_CONTENT_EDGE_INSETS_TOP      0
#define MM_CONTENT_EDGE_INSETS_LEFT     10
#define MM_CONTENT_EDGE_INSETS_BOTTON   0
#define MM_CONTENT_EDGE_INSETS_RIGHT    10
#define MM_CONTENT_EDGE_INSETS          UIEdgeInsetsMake(MM_CONTENT_EDGE_INSETS_TOP, MM_CONTENT_EDGE_INSETS_LEFT, MM_CONTENT_EDGE_INSETS_BOTTON, MM_CONTENT_EDGE_INSETS_RIGHT)

#define MM_TEXT_ALIGNMENT           UITextAlignmentCenter
#define MM_BACKGROUND_COLOR         [UIColor clearColor]

#define MM_TIMER_INTERVAL           0.05f
#define MM_HORIZONTAL_SPAN          5


@interface MMAnimatedGradientLabel : UILabel {  

    NSString *textToDisplay;
    int text_length;

    CGGradientRef gradient;

    int current_position_x;
    NSTimer *timer;

    CGPoint alignment;

    CGGlyph *_glyphs;
}

- (id)initWithString:(NSString *)_string;

- (void)startAnimation;
- (void)toggle;
- (BOOL)isAnimating;

@end

#define RGB_COMPONENTS(r, g, b, a)  (r) / 255.0f, (g) / 255.0f, (b) / 255.0f, (a)

@interface MMAnimatedGradientLabel (Private)
- (CGRect)calculateFrame;
@end


@implementation MMAnimatedGradientLabel

// Missing in standard headers.
extern void CGFontGetGlyphsForUnichars(CGFontRef, const UniChar[], const CGGlyph[], size_t);

- (id)init {
    textToDisplay = MM_TEXT_TO_DISPLAY;
    return [self initWithFrame:[self calculateFrame]];
}

- (id)initWithString:(NSString *)_string {
    textToDisplay = _string;
    return [self initWithFrame:[self calculateFrame]];
}

-(id)initWithFrame:(CGRect)frame {  
    if (self = [super initWithFrame:frame]) {

        // set default values
        //
        self.textAlignment      = MM_TEXT_ALIGNMENT;
        self.backgroundColor    = MM_BACKGROUND_COLOR;
        self.font               = MM_FONT;
        self.text               = textToDisplay;
        self.textColor          = MM_FONT_COLOR;

        if (MM_SHADOW_ENABLED) {
            self.shadowColor        = MM_SHADOW_COLOR;
            self.shadowOffset       = MM_SHADOW_OFFSET;
        }

        text_length = -1;

        CGColorSpaceRef rgb = CGColorSpaceCreateDeviceRGB();
        CGFloat colors[] =
        {       
            RGB_COMPONENTS(255.0, 255.0, 255.0, 0.00),
//          RGB_COMPONENTS(255.0, 255.0, 255.0, 0.15),
            RGB_COMPONENTS(255.0, 255.0, 255.0, 0.95),
//          RGB_COMPONENTS(255.0, 255.0, 255.0, 0.15),
            RGB_COMPONENTS(255.0, 255.0, 255.0, 0.00)
        };

        gradient = CGGradientCreateWithColorComponents(rgb, colors, NULL, sizeof(colors)/(sizeof(colors[0])*4));
        CGColorSpaceRelease(rgb);

        current_position_x = -(frame.size.width/2);// - MM_CONTENT_EDGE_INSETS.left - MM_CONTENT_EDGE_INSETS.right); 
    }

    return self;
}

- (CGRect)calculateFrame {
    CGSize size = [textToDisplay sizeWithFont:MM_FONT];
    NSLog(@"size: %f, %f", size.width, size.height);
    return CGRectMake(0, 0, size.width + MM_CONTENT_EDGE_INSETS.left + MM_CONTENT_EDGE_INSETS.right, size.height + MM_CONTENT_EDGE_INSETS.top + MM_CONTENT_EDGE_INSETS.bottom);
}

- (void)tick:(NSTimer*)theTimer {
    if (current_position_x < self.frame.size.width)
        current_position_x = current_position_x + MM_HORIZONTAL_SPAN;
    else
        current_position_x = -(self.frame.size.width/2); // - MM_CONTENT_EDGE_INSETS.left - MM_CONTENT_EDGE_INSETS.right);

    [self setNeedsDisplay]; 
}

- (void)startAnimation {    
    timer = [[NSTimer alloc] initWithFireDate:[NSDate date] 
                                     interval:MM_TIMER_INTERVAL
                                       target:self 
                                     selector:@selector(tick:)
                                     userInfo:nil
                                      repeats:YES];

    [[NSRunLoop currentRunLoop] addTimer:timer forMode:NSDefaultRunLoopMode];
}

- (void)toggle {

    if (!timer) {
        timer = [[NSTimer alloc] initWithFireDate:[NSDate date] 
                                         interval:MM_TIMER_INTERVAL
                                           target:self 
                                         selector:@selector(tick:)
                                         userInfo:nil
                                          repeats:YES];

        [[NSRunLoop currentRunLoop] addTimer:timer forMode:NSDefaultRunLoopMode];
    } else {
        [timer invalidate];
        [timer release];
        timer = nil;

        current_position_x = -(self.frame.size.width/2);
        [self setNeedsDisplay]; 
    }
}

- (BOOL)isAnimating {

    if (timer) 
        return YES;
    else
        return NO;
}

- (void)drawRect:(CGRect)rect {
    CGContextRef ctx = UIGraphicsGetCurrentContext();

    // Get drawing font.
    CGFontRef font = CGFontCreateWithFontName((CFStringRef)[[self font] fontName]);
    CGContextSetFont(ctx, font);
    CGContextSetFontSize(ctx, [[self font] pointSize]);

    // Calculate text drawing point only first time
    // 
    if (text_length == -1) {    

        // Transform text characters to unicode glyphs.
        text_length = [[self text] length];
        unichar chars[text_length];
        [[self text] getCharacters:chars range:NSMakeRange(0, text_length)];

        _glyphs = malloc(sizeof(CGGlyph) * text_length);
        for (int i=0; i<text_length;i ++)
            _glyphs[i] = chars[i] - 29;

        // Measure text dimensions.
        CGContextSetTextDrawingMode(ctx, kCGTextInvisible); 
        CGContextSetTextPosition(ctx, 0, 0);
        CGContextShowGlyphs(ctx, _glyphs, text_length);
        CGPoint textEnd = CGContextGetTextPosition(ctx);

        // Calculate text drawing point.        
        CGPoint anchor = CGPointMake(textEnd.x * (-0.5), [[self font] pointSize] * (-0.25));  
        CGPoint p = CGPointApplyAffineTransform(anchor, CGAffineTransformMake(1, 0, 0, -1, 0, 1));

        if ([self textAlignment] == UITextAlignmentCenter) 
            alignment.x = [self bounds].size.width * 0.5 + p.x;
        else if ([self textAlignment] == UITextAlignmentLeft) 
            alignment.x = 0;
        else 
            alignment.x = [self bounds].size.width - textEnd.x;

        alignment.y = [self bounds].size.height * 0.5 + p.y;
    }

    // Flip back mirrored text.
    CGContextSetTextMatrix(ctx, CGAffineTransformMakeScale(1, -1));

    // Draw shadow.
    CGContextSaveGState(ctx);
    CGContextSetTextDrawingMode(ctx, kCGTextFill);
    CGContextSetFillColorWithColor(ctx, [[self textColor] CGColor]);
    CGContextSetShadowWithColor(ctx, [self shadowOffset], 0, [[self shadowColor] CGColor]);
    CGContextShowGlyphsAtPoint(ctx, alignment.x, alignment.y, _glyphs, text_length);
    CGContextRestoreGState(ctx);

    // Draw text clipping path.
    CGContextSetTextDrawingMode(ctx, kCGTextClip);
    CGContextShowGlyphsAtPoint(ctx, alignment.x, alignment.y, _glyphs, text_length);

    // Restore text mirroring.
    CGContextSetTextMatrix(ctx, CGAffineTransformIdentity);

    if ([self isAnimating]) {
        // Fill text clipping path with gradient.
        CGPoint start = CGPointMake(rect.origin.x + current_position_x, rect.origin.y);
        CGPoint end = CGPointMake(rect.size.width/3*2 + current_position_x, rect.origin.y);

        CGContextDrawLinearGradient(ctx, gradient, start, end, 0);
    }
}


- (void) dealloc {
    free(_glyphs);
    [timer invalidate];
    [timer release];

    CGGradientRelease(gradient);
    [super dealloc];
}

CGFontGetGlyphsForUnichars - some people who use that report they fail the review for using the private API?

ios - iPhone "slide to unlock" animation - Stack Overflow

ios objective-c cocoa-touch core-animation
Rectangle 27 0

Yes, you can click Edit->Special Characters... - there you can find all unicode characters (including the emoji) and copy/paste them where you set the label text in the InterfaceBuilder.

Yes, it works if I search for "speaker". But the symbol seams to be a bitmap and not a true font...

You can right-click on it and click Copy Characted Info, when you paste it you get the actual symbol (with some additional data)...

iphone - How to enter unicode characters in a UILabel in Interface Bui...

iphone ios unicode utf-8 interface-builder
Rectangle 27 0

I found this post on Stackoverflow on superscript styling text using attributed string:

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    UIFont *font = [UIFont fontWithName:@"Helvetica" size:20];

    UILabel *textBlock1 = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height / 2.0)];
    textBlock1.backgroundColor = [UIColor colorWithRed:0.9 green:0.9 blue:0.9 alpha:1.0];
    textBlock1.textAlignment = NSTextAlignmentCenter;
    textBlock1.font = font;

    textBlock1.text = @"57%";





    UILabel *textBlock2 = [[UILabel alloc] initWithFrame:CGRectMake(0, self.view.bounds.size.height / 2.0, self.view.bounds.size.width, self.view.bounds.size.height / 2.0)];
    textBlock2.backgroundColor = [UIColor colorWithRed:0.9 green:0.9 blue:0.9 alpha:1.0];
    textBlock2.textAlignment = NSTextAlignmentCenter;

    NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:@"57%"
                                                                                         attributes:@{NSFontAttributeName: font}];
    [attributedString setAttributes:@{NSFontAttributeName : [UIFont fontWithName:@"Helvetica" size:10]
                                      , NSBaselineOffsetAttributeName : @10} range:NSMakeRange(2, 1)];

    textBlock2.attributedText = attributedString;



    [self.view addSubview:textBlock1];
    [self.view addSubview:textBlock2];
}

thanks for sharing the source. I have achieved the same using the tutorial sketchytech.blogspot.co.uk/2013/12/ suggested by trojanfoe.

@Zhang Can you make a small translation into Swift? Since some commands are changed and I try hard to archive the same. Thanks

ios - How to display superscript % character as string in UIlabel? - S...

ios unicode uilabel
Rectangle 27 0

This seems to be purely a font issue. The character U+2605 BLACK STAR is relatively common in fonts, so it is probably taken from a system font or a fallback font. The character U+2B51 BLACK SMALL STAR is relatively rare; it was added in Unicode 5.1, i.e. rather recently (in the character code world, that is). According to Fileformat.info data, it appears in Code2000, FreeSerif, GNU Unifont, Quivira, STIX, STIXMath, and Symbola. Not much; most computers have none of them (though many Linux systems probably have FreeSerif). Well, it seems that you can add Asana Math and Universalia to the list; still rather limited.

ios - Seemingly unsupported unicode character in UILabel - Stack Overf...

ios unicode nsstring uilabel
Rectangle 27 0

It's fun why few people knew this. You can enter Unicode-symbols directly by holding "Option" and entering hex digit. All you need: (Sierra example) goto "Preference -> Keyboards -> Input Sources" and search for "Unicode Hex". It should appears under "Others" section. Next add it and then you be able enter Unicode-char anywhere just selecting this input source.

For example: = (Alt+2713), - (20ac), etc. Most interesting section from 2100 to 2800. Full list you can found here - Unicode table

One thing to point out. The option key trick only works while you have the Unicode Hex input source selected.

iphone - How to enter unicode characters in a UILabel in Interface Bui...

iphone ios unicode utf-8 interface-builder
Rectangle 27 0

Are you NSLogging it? This is correct, as those are simply the Unicode code points of the Japanese/Chinese characters. If you do present those NSString in the UI (e.g. in a UILabel) they should appear correctly.

"\U5f62\U5f0f" = ""
"\U9023\U63a5\U5230\U5176\U4ed6\U5730\U65b9" = ""
"\U884c\U674e\U8a8d\U9818" = ""
"\U9322" = ""

Hi Kenny, when I NSLog HTTP requests response string and it appears as "" and something different appears on LAbel but not the same as I expect in Japanese format. What should I check now? Thanks.

objective c - Japanese and chinese characters in ios - Stack Overflow

objective-c ios character-encoding nsarray