Re: CGContextShowTextAtPoint

2015-10-14 Thread Raglan T. Tiger


> On Oct 13, 2015, at 4:56 PM, Graham Cox  wrote:
> 
> Converting this to use string drawing is easy enough:
> 
> NSDictionary* attributes = @{NSFontAttributedName:sysFont};
> NSString* myText = [NSString stringWithUTF8String:txt];   // 
> check encoding if not UTF-8
> 
> [myText drawAtPoint:pt withAttributes:attributes];


I did all the above ... now my text prints upside down andI cannot get it to 
size up regardless of the font size.

Any direction is much appreciated.

-rags
___

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: CGContextShowTextAtPoint

2015-10-14 Thread Jens Alfke

> On Oct 14, 2015, at 8:54 AM, Raglan T. Tiger  wrote:
> 
> I did all the above ... now my text prints upside down andI cannot get it to 
> size up regardless of the font size.

The view is probably using flipped coordinates. Look up flipped coordinates in 
the Cocoa view documentation to understand what they are and how to work around 
the problem.

As for the size, have you set the size of the NSFont in ‘sysFont’?

—Jens
___

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: CGContextShowTextAtPoint

2015-10-14 Thread Conrad Shultz

> On Oct 14, 2015, at 11:41 AM, Raglan T. Tiger <r...@crusaderrabbit.net> wrote:
> 
> 
> 
>> On Oct 14, 2015, at 10:02 AM, Jens Alfke <j...@mooseyard.com> wrote:
>> 
>> The view is probably using flipped coordinates. Look up flipped coordinates 
>> in the Cocoa view documentation to understand what they are and how to work 
>> around the problem.
>> 
>> As for the size, have you set the size of the NSFont in ‘sysFont’?
>> 
> 
> I am using -graphicsContextWithBitmapImageRep and then adding text 
> annotations.  The reason for using CGContextShowTextAtPoint in the first 
> place was to solve this problem when drawing NSStrings.
> 
> I guess the real question is "How to you draw NSStrings as flipped == YES 
> when the current NSGraphicsContext is graphicsContextWithBitmapImageRep which 
> is flipped = NO.

If I understand your question, I’d expect you could set the graphics context’s 
transform (see the CGContextFooCTM() family of functions), draw your text, then 
reset the transform.

-Conrad
___

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: CGContextShowTextAtPoint

2015-10-14 Thread David Duncan
Ensure that the text matrix is sane (its separate from the current ctm and not 
stored with the graphics state).
> On Oct 14, 2015, at 1:36 PM, Raglan T. Tiger <r...@crusaderrabbit.net> wrote:
> 
> 
>> On Oct 13, 2015, at 4:42 PM, Wim Lewis <w...@omnigroup.com> wrote:
>> 
>> 
>> On Oct 13, 2015, at 3:02 PM, Raglan T. Tiger <r...@crusaderrabbit.net> wrote:
>>> CGContextShowTextAtPoint (ctx, pt.x,pt.y,(const char*)txt, len );
>>> 
>>> This has printed my text UNTIL 10.11.
>>> 
>>> I see that CGContextShowTextAtPoint is deprecated in 10.9 ... is it gone in 
>>> 10.11?
>> 
>> As Quincey Morris says, Core Text 
> 
> I have text printing in the correct orientation now using
> 
> CFAttributedStringRef attrString = 
> CFAttributedStringCreate(kCFAllocatorDefault, cfstr, attributes);
> 
> CTLineRef line = CTLineCreateWithAttributedString(attrString);
> 
>// Set text position and draw the line into the graphics context
>CGContextSetTextPosition(ctx, pt.x, pt.y);
>CTLineDraw(line, ctx);
> 
> Now, I cannot increase the font size.  I set up attributes as:
> 
>CFStringRef keys[] = { kCTFontAttributeName };
>CFTypeRef values[] = { [ NSFont systemFontOfSize:48 ] };
> 
>CFDictionaryRef attributes =
>CFDictionaryCreate(kCFAllocatorDefault, (const void**),
>   (const void**), sizeof(keys) / 
> sizeof(keys[0]),
>   ,
>   );
> 
> 
> and see my attributed string as:
> 
> 667 x, 2.3 y{
>NSFont = "\".HelveticaNeueDeskInterface-Regular 48.00 pt. P [] 
> (0x1128ca30) fobj=0x11d04390, spc=12.93\"";
> }
> 
> but the result is like 8 pt not 48. 
> ___
> 
> 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/david.duncan%40apple.com
> 
> This email sent to david.dun...@apple.com

--
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: CGContextShowTextAtPoint

2015-10-14 Thread Raglan T. Tiger

> On Oct 13, 2015, at 4:42 PM, Wim Lewis <w...@omnigroup.com> wrote:
> 
> 
> On Oct 13, 2015, at 3:02 PM, Raglan T. Tiger <r...@crusaderrabbit.net> wrote:
>> CGContextShowTextAtPoint (ctx, pt.x,pt.y,(const char*)txt, len );
>> 
>> This has printed my text UNTIL 10.11.
>> 
>> I see that CGContextShowTextAtPoint is deprecated in 10.9 ... is it gone in 
>> 10.11?
> 
> As Quincey Morris says, Core Text 

I have text printing in the correct orientation now using

CFAttributedStringRef attrString = 
CFAttributedStringCreate(kCFAllocatorDefault, cfstr, attributes);

CTLineRef line = CTLineCreateWithAttributedString(attrString);

// Set text position and draw the line into the graphics context
CGContextSetTextPosition(ctx, pt.x, pt.y);
CTLineDraw(line, ctx);

Now, I cannot increase the font size.  I set up attributes as:

CFStringRef keys[] = { kCTFontAttributeName };
CFTypeRef values[] = { [ NSFont systemFontOfSize:48 ] };

CFDictionaryRef attributes =
CFDictionaryCreate(kCFAllocatorDefault, (const void**),
   (const void**), sizeof(keys) / 
sizeof(keys[0]),
   ,
   );


and see my attributed string as:

667 x, 2.3 y{
NSFont = "\".HelveticaNeueDeskInterface-Regular 48.00 pt. P [] (0x1128ca30) 
fobj=0x11d04390, spc=12.93\"";
}

but the result is like 8 pt not 48. 
___

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: CGContextShowTextAtPoint

2015-10-14 Thread Raglan T. Tiger

-rags



> On Oct 14, 2015, at 2:37 PM, David Duncan  wrote:
> 
> Ensure that the text matrix is sane 


I have been doing this:

CGAffineTransform t = CGAffineTransformMakeScale (1.0, -1.0);
CGContextSetTextMatrix (ctx, t);


changing the sx and sy just scrunches the text into a blob

what the crusade am I not understanding?


-rags


___

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: CGContextShowTextAtPoint

2015-10-14 Thread Raglan T. Tiger


> On Oct 14, 2015, at 10:02 AM, Jens Alfke <j...@mooseyard.com> wrote:
> 
> The view is probably using flipped coordinates. Look up flipped coordinates 
> in the Cocoa view documentation to understand what they are and how to work 
> around the problem.
> 
> As for the size, have you set the size of the NSFont in ‘sysFont’?
> 

I am using -graphicsContextWithBitmapImageRep and then adding text annotations. 
 The reason for using CGContextShowTextAtPoint in the first place was to solve 
this problem when drawing NSStrings.

I guess the real question is "How to you draw NSStrings as flipped == YES when 
the current NSGraphicsContext is graphicsContextWithBitmapImageRep which is 
flipped = NO.


-rags
___

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

CGContextShowTextAtPoint

2015-10-13 Thread Raglan T. Tiger
In my printing code I do some setup:

NSFont *sysFont = [NSFont systemFontOfSize:10];
NSString *sysFontName = [sysFont fontName];
CGContextSelectFont(ctx, [sysFontName 
cStringUsingEncoding:NSASCIIStringEncoding], 90, kCGEncodingMacRoman);
CGContextSetTextDrawingMode(ctx,  kCGTextFill);
Then:

CGContextShowTextAtPoint (ctx, pt.x,pt.y,(const char*)txt, len );

This has printed my text UNTIL 10.11.

I see that CGContextShowTextAtPoint is deprecated in 10.9 ... is it gone in 
10.11?

-rags
___

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: CGContextShowTextAtPoint

2015-10-13 Thread Wim Lewis

On Oct 13, 2015, at 3:02 PM, Raglan T. Tiger <r...@crusaderrabbit.net> wrote:
> CGContextShowTextAtPoint (ctx, pt.x,pt.y,(const char*)txt, len );
> 
> This has printed my text UNTIL 10.11.
> 
> I see that CGContextShowTextAtPoint is deprecated in 10.9 ... is it gone in 
> 10.11?

As Quincey Morris says, Core Text is the recommended low-level API for drawing 
text now. It handles some typographical niceties that a direct PDF-equivalent 
CG call doesn't.

Another option is the -[NSAttributedString drawAtPoint:] method, which is a 
very easy method for simple string drawing.



___

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: CGContextShowTextAtPoint

2015-10-13 Thread Graham Cox

> On 14 Oct 2015, at 9:02 am, Raglan T. Tiger <r...@crusaderrabbit.net> wrote:
> 
>   NSFont *sysFont = [NSFont systemFontOfSize:10];
>   NSString *sysFontName = [sysFont fontName];
>   CGContextSelectFont(ctx, [sysFontName 
> cStringUsingEncoding:NSASCIIStringEncoding], 90, kCGEncodingMacRoman);
>   CGContextSetTextDrawingMode(ctx,  kCGTextFill);

> CGContextShowTextAtPoint (ctx, pt.x,pt.y,(const char*)txt, len );


Converting this to use string drawing is easy enough:

NSDictionary* attributes = @{NSFontAttributedName:sysFont};
NSString* myText = [NSString stringWithUTF8String:txt]; // check 
encoding if not UTF-8

[myText drawAtPoint:pt withAttributes:attributes];



—G.
___

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: CGContextShowTextAtPoint

2015-10-13 Thread Quincey Morris
On Oct 13, 2015, at 15:02 , Raglan T. Tiger <r...@crusaderrabbit.net> wrote:
> 
> I see that CGContextShowTextAtPoint is deprecated in 10.9 ... is it gone in 
> 10.11?

Apparently. There’s this:


https://developer.apple.com/library/prerelease/mac/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_text/dq_text.html#//apple_ref/doc/uid/TP30001066-CH213-TPXREF101

which says:

> "This chapter previously described the basic text support provided by Quartz. 
> However, the low-level support provided by Quartz has been deprecated and 
> superceded by Core Text, an advanced low-level technology for laying out text 
> and handing fonts. Core Text is designed for high performance and ease of use 
> and allows you to draw Unicode text directly to a graphics context. If you 
> are writing an application that needs precise control over how text is 
> displayed, see Core Text Programming Guide."

So it’s time to move on.

___

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-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


Displaying an arbitrary unicode character using CGContextShowTextAtPoint or CGContextShowGlyphsAtPoint

2012-03-30 Thread Jeff Schriebman
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.

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 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


CGContextShowTextAtPoint doesn't show text

2011-08-09 Thread Gabriel Zachmann
I am having a problem with rendering text on a CALayer.
AFAIK, it works just fine with all users ... except one, where the text just 
does not show!

This is my code for printing the text:

@interface TextLayerDelegate : NSObject
{
// ...
}
- (void) drawLayer: (CALayer *) theLayer inContext: (CGContextRef) theContext;
@end

@implementation TextLayerDelegate

- (void) drawLayer: (CALayer *) theLayer inContext: (CGContextRef) ctxt
{
// ...
const char * str = [mesg cStringUsingEncoding: NSMacOSRomanStringEncoding]; 
// encoding must match with CGContextSelectFont() below
if ( str  strlen(str) )
{
CGContextSetShouldAntialias( ctxt, TRUE );
CGContextSetRGBFillColor( ctxt, 1.0, 1.0, 1.0, 1.0 );
CGContextSelectFont( ctxt, AndaleMono, 14, kCGEncodingMacRoman ); // 
Andale Mono doesn't work either
CGColorRef blue = CGColorCreateGenericRGB( 0.0, 0.0, 1.0, 1.0 );
CGContextSetShadowWithColor( ctxt, CGSizeMake(0,0), 10, blue );
CGContextShowTextAtPoint( ctxt, theLayer.bounds.origin.x + 7.0, 
theLayer.bounds.origin.y + 7.0, str, strlen(str) );
CFRelease( blue );
}
}


I have checked that 'str' does actually hold a valid string at the user's 
instance. (I logged it and had him send me the log file.)
I have also tried different font sizes.
I have also googled around.
All to no avail.


Does anybody have an idea what else might be wrong?

Thanks a lot in advance.
Gab.



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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: CGContextShowTextAtPoint doesn't show text

2011-08-09 Thread Graham Cox

On 09/08/2011, at 10:43 PM, Gabriel Zachmann wrote:

 I have checked that 'str' does actually hold a valid string at the user's 
 instance. (I logged it and had him send me the log file.)
 I have also tried different font sizes.
 I have also googled around.
 All to no avail.
 
 
 Does anybody have an idea what else might be wrong?


I've found the Core Graphics text handling methods to be gnarly and awkward the 
few times I've attempted to use them, and always ended up going some other 
route to render text.

In your case, the choice seems simple - just use CATextLayer. Why not?

--Graham


___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: CGContextShowTextAtPoint doesn't show text

2011-08-09 Thread Graham Cox

On 09/08/2011, at 10:43 PM, Gabriel Zachmann wrote:

 I have checked that 'str' does actually hold a valid string at the user's 
 instance. (I logged it and had him send me the log file.)

CGContextSelectFont( ctxt, AndaleMono, 14, kCGEncodingMacRoman ); // 
 Andale Mono doesn't work either


Perhaps he doesn't have Andale Mono on his machine? I'm not sure what CG does 
with text if the font isn't there, does it fall back to something else or just 
silently fail? Maybe the fallback font is too big for the space and it isn't 
rendered as a result?

I think the way your code assumes this font is going to be there is a bit flaky.

But anyway, CATextLayer takes all this pain away for you.

--Graham


___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: CGContextShowTextAtPoint doesn't show text

2011-08-09 Thread Gabriel Zachmann
Thanks a lot for your response ...

 I've found the Core Graphics text handling methods to be gnarly and awkward 
 the few times I've attempted to use them, and always ended up going some 
 other route to render text.

Could you please point me to a few of them?

 
 In your case, the choice seems simple - just use CATextLayer. Why not?

Can CATextLayer render text with a shadow?
Like this:
  CGContextSetShadowWithColor( ctxt, CGSizeMake(0,0), 10, blue );

I really need the shadow to be able to discern it from a background layer, the 
color of which is unknown and changes fairly often.

Best regards,
Gabriel.



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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: CGContextShowTextAtPoint doesn't show text

2011-08-09 Thread Graham Cox

On 10/08/2011, at 12:48 AM, Gabriel Zachmann wrote:

 Could you please point me to a few of them?

NSString, NSAttributedString, Core Text


 Can CATextLayer render text with a shadow?
 Like this:
  CGContextSetShadowWithColor( ctxt, CGSizeMake(0,0), 10, blue );
 
 I really need the shadow to be able to discern it from a background layer, 
 the color of which is unknown and changes fairly often.


Yes. It inherits from CALayer, so it has all of its properties, including all 
the shadow properties.

--Graham___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: CGContextShowTextAtPoint doesn't show text

2011-08-09 Thread glenn andreas

On Aug 9, 2011, at 9:48 AM, Gabriel Zachmann wrote:

 Thanks a lot for your response ...
 
 I've found the Core Graphics text handling methods to be gnarly and awkward 
 the few times I've attempted to use them, and always ended up going some 
 other route to render text.
 
 Could you please point me to a few of them?
 
 
 In your case, the choice seems simple - just use CATextLayer. Why not?
 
 Can CATextLayer render text with a shadow?
 Like this:
  CGContextSetShadowWithColor( ctxt, CGSizeMake(0,0), 10, blue );
 
 I really need the shadow to be able to discern it from a background layer, 
 the color of which is unknown and changes fairly often.


CATextLayer is a subclass of CALayer, which has a wide variety of shadowing 
options:

/** Shadow properties. **/

/* The color of the shadow. Defaults to opaque black. Colors created
 * from patterns are currently NOT supported. Animatable. */

@property CGColorRef shadowColor;

/* The opacity of the shadow. Defaults to 0. Specifying a value outside the
 * [0,1] range will give undefined results. Animatable. */

@property float shadowOpacity;

/* The shadow offset. Defaults to (0, -3). Animatable. */

@property CGSize shadowOffset;

/* The blur radius used to create the shadow. Defaults to 3. Animatable. */

@property CGFloat shadowRadius;

/* When non-null this path defines the outline used to construct the
 * layer's shadow instead of using the layer's composited alpha
 * channel. The path is rendered using the non-zero winding rule.
 * Specifying the path explicitly using this property will usually
 * improve rendering performance, as will sharing the same path
 * reference across multiple layers. Defaults to null. Animatable. */

@property CGPathRef shadowPath;



So not only does it have a shadow that you can change, you can even animate the 
shadow.

Glenn Andreas  gandr...@gandreas.com 
The most merciful thing in the world ... is the inability of the human mind to 
correlate all its contents - HPL

___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: CGContextShowTextAtPoint doesn't show text

2011-08-09 Thread Gabriel Zachmann
CGContextSelectFont( ctxt, AndaleMono, 14, kCGEncodingMacRoman ); 
 // Andale Mono doesn't work either
 
 Perhaps he doesn't have Andale Mono on his machine? I'm not sure what CG 
 does with text if the font isn't there, does it fall back to something else 
 or just silently fail?
 I think the way your code assumes this font is going to be there is a bit 
 flaky.

I didn't find an easy way to check whether a font is installed - do you know 
how to do it?

 But anyway, CATextLayer takes all this pain away for you.

Just checked the doc of CATextLayer but couldn't find a hint on how it helps me 
determine whether or not a font is installed ... can you tell me?

Best regards,
Gabriel.



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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: CGContextShowTextAtPoint doesn't show text

2011-08-09 Thread Graham Cox

On 10/08/2011, at 2:06 AM, Gabriel Zachmann wrote:

 Just checked the doc of CATextLayer but couldn't find a hint on how it helps 
 me determine whether or not a font is installed ... can you tell me?


I doesn't. But it falls back gracefully, AFAIK.

If you need a specific non-standard font, you can bundle it with your app to 
ensure its present.

--Graham


___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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