Re: Displaying an arbitrary unicode character using CGContextShowTextAtPoint or CGContextShowGlyphsAtPoint

2012-04-06 Thread Rhythmic Fistman
On 30 March 2012 18:18, Jeff Schriebman j...@leapfrogproductions.com wrote:
 I need to display the upwards arrow character in a specific position in a 
 view.
 The unicode equivalence is U+2B06 and in UTF-8 it is E2 AC 86.

 I can successfully display it in Xcode on the console using NSLog(@This is 
 an up arrow character \u2B06);

 I have not found a way to use CGContextShowTextAtPoint to easily display such 
 a character and the examples I have found using CGContextShowGlyphsAtPoint() 
 seem to require me to use a font containing the upwards arrow glyph. Is there 
 a generic all inclusive unicode font? What is the right approach to this 
 issue? Suggestions are appreciated.

I like CoreText's CTFontGetGlyphsForCharacters (10.5) 
CTFontDrawGlyphs (10.7!).

If you can live with it not working on 10.6 then you're good.

RF

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Displaying an arbitrary unicode character using CGContextShowTextAtPoint or CGContextShowGlyphsAtPoint

2012-03-30 Thread Jens Alfke

On Mar 30, 2012, at 9:18 AM, Jeff Schriebman wrote:

 I have not found a way to use CGContextShowTextAtPoint to easily display such 
 a character and the examples I have found using CGContextShowGlyphsAtPoint() 
 seem to require me to use a font containing the upwards arrow glyph.

I'm not familiar with the CG-level text APIs. But unless they're very low-level 
indeed, as long as they take Unicode strings you should be able to use 
arbitrary characters, and the renderer will substitute glyphs from appropriate 
fonts as needed.

—Jens

smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Displaying an arbitrary unicode character using CGContextShowTextAtPoint or CGContextShowGlyphsAtPoint

2012-03-30 Thread David Duncan
On Mar 30, 2012, at 9:18 AM, Jeff Schriebman wrote:

 I need to display the upwards arrow character in a specific position in a 
 view.
 The unicode equivalence is U+2B06 and in UTF-8 it is E2 AC 86.
 
 I can successfully display it in Xcode on the console using NSLog(@This is 
 an up arrow character \u2B06);
 
 I have not found a way to use CGContextShowTextAtPoint to easily display such 
 a character and the examples I have found using CGContextShowGlyphsAtPoint() 
 seem to require me to use a font containing the upwards arrow glyph. Is there 
 a generic all inclusive unicode font? What is the right approach to this 
 issue? Suggestions are appreciated.


Why not just use the string drawing methods that are added to NSString by 
AppKit or UIKit (based on which your using)?
--
David Duncan


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Displaying an arbitrary unicode character using CGContextShowTextAtPoint or CGContextShowGlyphsAtPoint

2012-03-30 Thread Douglas Davidson

On Mar 30, 2012, at 9:31 AM, Jens Alfke wrote:

 
 On Mar 30, 2012, at 9:18 AM, Jeff Schriebman wrote:
 
 I have not found a way to use CGContextShowTextAtPoint to easily display 
 such a character and the examples I have found using 
 CGContextShowGlyphsAtPoint() seem to require me to use a font containing the 
 upwards arrow glyph.
 
 I'm not familiar with the CG-level text APIs. But unless they're very 
 low-level indeed, as long as they take Unicode strings you should be able to 
 use arbitrary characters, and the renderer will substitute glyphs from 
 appropriate fonts as needed.

They are in fact very low-level indeed, so ignore them unless you're prepared 
to write your own Unicode layout engine on top of them.  Use the string drawing 
APIs instead. 

Douglas Davidson


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Displaying an arbitrary unicode character using CGContextShowTextAtPoint or CGContextShowGlyphsAtPoint

2012-03-30 Thread Jeff Schriebman
This is what I have figured out so far:

According to the Quartz 2D programming guide Quartz 2D provides a limited, 
low-level interface for drawing text encoded in the MacRoman text encoding and 
for drawing glyphs which probably explains my problem with using 
CGContextShowTextAtPoint().

I don't need a layout engine because I only need to put a single glyph at a 
specific location.

I can successfully print a glyph on my view using CGContextShowGlyphs() but as 
of yet I haven't figured a way to actually find the glyph for the unicode 
character U+2B06 / E2 AC 86. If I could find a font that has the character I 
need then I could put it all together. I know the font is available I just 
don't know how to find it.

I'm not sure how to use the string drawing APIs to directly put a unicode UTF8 
character onto a specific X,Y location given a CGContextRef.

Thanks

On Mar 30, 2012, at 9:44 AM, Douglas Davidson wrote:
 On Mar 30, 2012, at 9:31 AM, Jens Alfke wrote:
 
 On Mar 30, 2012, at 9:18 AM, Jeff Schriebman wrote:
 
 I have not found a way to use CGContextShowTextAtPoint to easily display 
 such a character and the examples I have found using 
 CGContextShowGlyphsAtPoint() seem to require me to use a font containing 
 the upwards arrow glyph.
 
 I'm not familiar with the CG-level text APIs. But unless they're very 
 low-level indeed, as long as they take Unicode strings you should be able to 
 use arbitrary characters, and the renderer will substitute glyphs from 
 appropriate fonts as needed.
 
 They are in fact very low-level indeed, so ignore them unless you're prepared 
 to write your own Unicode layout engine on top of them.  Use the string 
 drawing APIs instead. 
 
 Douglas Davidson

Jeff




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Displaying an arbitrary unicode character using CGContextShowTextAtPoint or CGContextShowGlyphsAtPoint

2012-03-30 Thread David Duncan
On Mar 30, 2012, at 11:45 AM, Jeff Schriebman wrote:

 I'm not sure how to use the string drawing APIs to directly put a unicode 
 UTF8 character onto a specific X,Y location given a CGContextRef.


Both AppKit and UIKit have methods for making a CGContextRef current. Lookup 
the NSGraphicsContext class (AppKit) or the UIGraphics functions (UIKit) for 
this information.
--
David Duncan

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Displaying an arbitrary unicode character using CGContextShowTextAtPoint or CGContextShowGlyphsAtPoint

2012-03-30 Thread Jeff Schriebman
Thanks David.

My CGContextRef is the current context. I'm just unfamiliar with how to draw a 
unicode character into it when I don't know the font containing a specific 
unicode glyph.
I'm doing this for OS X 10.7 which is all I need to support.

Thanks.

On Mar 30, 2012, at 11:56 AM, David Duncan wrote:
 On Mar 30, 2012, at 11:45 AM, Jeff Schriebman wrote:
 
 I'm not sure how to use the string drawing APIs to directly put a unicode 
 UTF8 character onto a specific X,Y location given a CGContextRef.
 
 
 Both AppKit and UIKit have methods for making a CGContextRef current. Lookup 
 the NSGraphicsContext class (AppKit) or the UIGraphics functions (UIKit) for 
 this information.
 --
 David Duncan
 

Jeff Schriebman




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Displaying an arbitrary unicode character using CGContextShowTextAtPoint or CGContextShowGlyphsAtPoint

2012-03-30 Thread David Duncan
On Mar 30, 2012, at 12:19 PM, Jeff Schriebman wrote:

 Thanks David.
 
 My CGContextRef is the current context. I'm just unfamiliar with how to draw 
 a unicode character into it when I don't know the font containing a specific 
 unicode glyph.
 I'm doing this for OS X 10.7 which is all I need to support.


So have you tried the previously mentioned NSString methods? Did you encounter 
an issue?
--
David Duncan


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Displaying an arbitrary unicode character using CGContextShowTextAtPoint or CGContextShowGlyphsAtPoint

2012-03-30 Thread Jeff Schriebman
Still having problems.
I've unsuccessfully tried drawAtPoint:withAttributes: but I'm not sure what the 
best way to accomplish what I need to do. I'm not too familiar with the 
NSString methods so any advice is appreciated.

On Mar 30, 2012, at 12:47 PM, David Duncan wrote:
 On Mar 30, 2012, at 12:19 PM, Jeff Schriebman wrote:
 
 Thanks David.
 
 My CGContextRef is the current context. I'm just unfamiliar with how to draw 
 a unicode character into it when I don't know the font containing a specific 
 unicode glyph.
 I'm doing this for OS X 10.7 which is all I need to support.
 
 
 So have you tried the previously mentioned NSString methods? Did you 
 encounter an issue?
 --
 David Duncan
 

Jeff Schriebman





___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Displaying an arbitrary unicode character using CGContextShowTextAtPoint or CGContextShowGlyphsAtPoint

2012-03-30 Thread Kyle Sluder
On Mar 30, 2012, at 1:21 PM, Jeff Schriebman wrote:

 Still having problems.
 I've unsuccessfully tried drawAtPoint:withAttributes: but I'm not sure what 
 the best way to accomplish what I need to do. I'm not too familiar with the 
 NSString methods so any advice is appreciated.

What aspects of the documentation have confused you. What code have you tried?

We can't hold your hand forever.

--Kyle Sluder
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Displaying an arbitrary unicode character using CGContextShowTextAtPoint or CGContextShowGlyphsAtPoint

2012-03-30 Thread Jeff Schriebman
The following code fragment properly displays an up arrow on my view.
Thanks for everyone's patience and help.

NSDictionary* fontAttrs = [NSDictionary dictionaryWithObjectsAndKeys:
[NSColor redColor], NSForegroundColorAttributeName,
[NSFont systemFontOfSize:10], NSFontAttributeName,
nil];

NSString *upArrow = @\u2B06;
[upArrow drawAtPoint:NSMakePoint(100,100) withAttributes:fontAttrs];



On Mar 30, 2012, at 12:47 PM, David Duncan wrote:
 On Mar 30, 2012, at 12:19 PM, Jeff Schriebman wrote:
 
 Thanks David.
 
 My CGContextRef is the current context. I'm just unfamiliar with how to draw 
 a unicode character into it when I don't know the font containing a specific 
 unicode glyph.
 I'm doing this for OS X 10.7 which is all I need to support.
 
 
 So have you tried the previously mentioned NSString methods? Did you 
 encounter an issue?
 --
 David Duncan
 

Jeff Schriebman





___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Displaying an arbitrary unicode character using CGContextShowTextAtPoint or CGContextShowGlyphsAtPoint

2012-03-30 Thread Jens Alfke

On Mar 30, 2012, at 1:21 PM, Jeff Schriebman wrote:

 I've unsuccessfully tried drawAtPoint:withAttributes: but I'm not sure what 
 the best way to accomplish what I need to do. I'm not too familiar with the 
 NSString methods so any advice is appreciated.

What was unsuccessful?
Did you try it using an ASCII character instead to make sure it wasn't some 
issue with the glyph?

You should be able to get some kind of results with a call as simple as
[@X drawAtPoint: NSMakePoint(x,y) withAttributes: [NSDictionary 
dictionary]];
It'll probably be drawn in black 12pt Helvetica since those are the default 
text attributes.

—Jens

smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Displaying an arbitrary unicode character using CGContextShowTextAtPoint or CGContextShowGlyphsAtPoint

2012-03-30 Thread Kevin Bracey
did i miss something, I thought is - (void)drawAtPoint:(NSPoint)point not 
NSAttributedString not NSString.

Cheers
kevin


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Displaying an arbitrary unicode character using CGContextShowTextAtPoint or CGContextShowGlyphsAtPoint

2012-03-30 Thread Jeff Schriebman
The final code ended up looking like this

NSDictionary* fontAttrs = [NSDictionary dictionaryWithObjectsAndKeys:
[NSColor redColor], NSForegroundColorAttributeName,
[NSFont systemFontOfSize:12], NSFontAttributeName,
nil];

NSString *upArrow = @\u2B06;

CGContextSaveGState(ctx);
[upArrow drawAtPoint:NSMakePoint(x, y) 
withAttributes:fontAttrs];
CGContextRestoreGState(ctx);
CGContextSetTextMatrix(ctx, CGAffineTransformIdentity);


I needed to save and restore the graphics state as well as reinitialize the 
text matrix since the ctx state is apparently changed by 
drawAtPoint:withAttributes:.

On Mar 30, 2012, at 4:43 PM, Kevin Bracey wrote:
 did i miss something, I thought is - (void)drawAtPoint:(NSPoint)point not 
 NSAttributedString not NSString.
 
 Cheers
 kevin

Regards,
Jeff Schriebman





___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com