Re: Visible difference in text: NSTextField vs drawInRect:

2017-04-12 Thread Navneet Kumar
Hi,

Thanks for the valuable insights.

Wishes,
Navneet

> On 12-Apr-2017, at 12:42 AM, Quincey Morris 
>  wrote:
> 
> On Apr 11, 2017, at 08:32 , Navneet Kumar  > wrote:
>> 
>>> 4. Anti-aliasing. There is some behind the scenes magic when drawing text, 
>>> that determines whether it knows the background color and therefore whether 
>>> it anti-aliases using the background color.
>>> 
>> Tried anti-aliasing, explicitly turning it ON and OFF. No change.
> 
> Well, I nearly had the right answer here. I tried a simple test project, 
> using black text, and saw the effect you describe. Zooming into the display 
> (Control+scroll) revealed the difference pretty clearly, since I could see 
> the colors of the anti-aliased pixels. In the NSTextField text, LCD font 
> smoothing is being used; in the drawn text, it is not. There is behind the 
> scenes magic when drawing text, that determines whether it knows that LCD 
> smoothing can be applied.
> 
> When I turned the LCD smoothing option off in System Preferences -> General, 
> the text rendered the same in both cases.
> 
> Note that your choice of text color made the problem appear worse, because 
> sub pixels were apparently being turned on both for smoothing and for 
> coloring, which made the text look bolder than if it had been black.
> 

___

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: Visible difference in text: NSTextField vs drawInRect:

2017-04-11 Thread Quincey Morris
On Apr 11, 2017, at 08:32 , Navneet Kumar  wrote:
> 
>> 4. Anti-aliasing. There is some behind the scenes magic when drawing text, 
>> that determines whether it knows the background color and therefore whether 
>> it anti-aliases using the background color.
>> 
> Tried anti-aliasing, explicitly turning it ON and OFF. No change.

Well, I nearly had the right answer here. I tried a simple test project, using 
black text, and saw the effect you describe. Zooming into the display 
(Control+scroll) revealed the difference pretty clearly, since I could see the 
colors of the anti-aliased pixels. In the NSTextField text, LCD font smoothing 
is being used; in the drawn text, it is not. There is behind the scenes magic 
when drawing text, that determines whether it knows that LCD smoothing can be 
applied.

When I turned the LCD smoothing option off in System Preferences -> General, 
the text rendered the same in both cases.

Note that your choice of text color made the problem appear worse, because sub 
pixels were apparently being turned on both for smoothing and for coloring, 
which made the text look bolder than if it had been black.

___

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: Visible difference in text: NSTextField vs drawInRect:

2017-04-11 Thread Jens Alfke

> On Apr 11, 2017, at 9:49 AM, Gary L. Wade  
> wrote:
> 
> If you need lightweight drawing, you could use an NSTextFieldCell, which 
> should give you some predictability. I don't recall the details, but there 
> are a number of things that NSTextField does (and NSTextView) that aren't 
> done with "raw" drawing (borders, margins, font resizing, etc.)

+1. I'm still mystified why regular string drawing doesn't work right (pretty 
sure I've done it in the past without problems), but if you want to draw 
something that looks like a control, it's usually best to make a temporary cell 
and draw it.

—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: Visible difference in text: NSTextField vs drawInRect:

2017-04-11 Thread Gary L. Wade
If you need lightweight drawing, you could use an NSTextFieldCell, which should 
give you some predictability. I don't recall the details, but there are a 
number of things that NSTextField does (and NSTextView) that aren't done with 
"raw" drawing (borders, margins, font resizing, etc.)
--
Gary L. Wade
http://www.garywade.com/

> On Apr 11, 2017, at 9:39 AM, Navneet Kumar  wrote:
> 
> Yes, I tried inside drawRect:, both YES and NO. The effect was still there.
> 
> Thanks,
> Navneet 
> 
> Sent from my iPhone
> 
>> On 11-Apr-2017, at 9:31 PM, gerti-cocoa...@bitart.com wrote:
>> 
>> Did you try the
>> 
>>   CGContextRefctx=(CGContextRef)[[NSGraphicsContext 
>> currentContext]graphicsPort];
>> 
>>   CGContextSetShouldSmoothFonts(ctx,YES);
>> 
>> stuff inside the -drawRect: method? That is where it needs to be. Try both 
>> YES and NO. Should be a visible difference.
>> 
>> Gerd
>> 
>> 
>>> On Apr 11, 2017, at 10:55, Navneet Kumar  wrote:
>>> 
>>> Hi,
>>> 
>>> Here is another image with a character in each case zoomed in using 
>>> ColorMeter.
>>> 
>>> http://i66.tinypic.com/2w5m795.jpg
>>> 
>>> Wishes,
>>> Navneet
>>> 
>>> 
 On 11-Apr-2017, at 2:00 AM, Quincey Morris 
  wrote:
 
 On Apr 10, 2017, at 11:20 , Navneet Kumar > wrote:
> 
> Actually I’m using text fields for simplicity at a lot of places. And 
> drawInRect: at some places, in order to vertically centre the multi-line 
> text more conveniently.
 
 Here are some possibilities to consider:
 
 1. Shadow. What happens if you don’t specify the shadow?
 
 2. Resolution. It may be that the text drawing ends up in drawing contexts 
 with different resolution backing stores (1x vs. 2x vs. 3x).
 
 3. Size. Does the weird effect scale with point size? If you draw the text 
 much larger, are the results much closer to each other?
 
 4. Anti-aliasing. There is some behind the scenes magic when drawing text, 
 that determines whether it knows the background color and therefore 
 whether it anti-aliases using the background color.
 
 5. Overlays. It’s possible that NSTextField already draws the text more 
 than once, to give a partial outline effect that increases contrast with 
 mid-level color backgrounds.
 
 6. Traits. NSTextField may be opting into the trait behavior that 
 classifies text as Body, Headline, Caption, etc. These things might cause 
 some adjustment to the font weight. Or the accessibility features that 
 change the font appearance. (But I’m not sure which of those is available 
 on macOS.)
 
 
>>> 
>>> ___
>>> 

___

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: Visible difference in text: NSTextField vs drawInRect:

2017-04-11 Thread Navneet Kumar
Yes, I tried inside drawRect:, both YES and NO. The effect was still there.

Thanks,
Navneet 

Sent from my iPhone

> On 11-Apr-2017, at 9:31 PM, gerti-cocoa...@bitart.com wrote:
> 
> Did you try the
> 
>CGContextRefctx=(CGContextRef)[[NSGraphicsContext 
> currentContext]graphicsPort];
>
>CGContextSetShouldSmoothFonts(ctx,YES);
> 
> stuff inside the -drawRect: method? That is where it needs to be. Try both 
> YES and NO. Should be a visible difference.
> 
> Gerd
> 
> 
>> On Apr 11, 2017, at 10:55, Navneet Kumar  wrote:
>> 
>> Hi,
>> 
>> Here is another image with a character in each case zoomed in using 
>> ColorMeter.
>> 
>> http://i66.tinypic.com/2w5m795.jpg
>> 
>> Wishes,
>> Navneet
>> 
>> 
>>> On 11-Apr-2017, at 2:00 AM, Quincey Morris 
>>>  wrote:
>>> 
>>> On Apr 10, 2017, at 11:20 , Navneet Kumar >> > wrote:
 
 Actually I’m using text fields for simplicity at a lot of places. And 
 drawInRect: at some places, in order to vertically centre the multi-line 
 text more conveniently.
>>> 
>>> Here are some possibilities to consider:
>>> 
>>> 1. Shadow. What happens if you don’t specify the shadow?
>>> 
>>> 2. Resolution. It may be that the text drawing ends up in drawing contexts 
>>> with different resolution backing stores (1x vs. 2x vs. 3x).
>>> 
>>> 3. Size. Does the weird effect scale with point size? If you draw the text 
>>> much larger, are the results much closer to each other?
>>> 
>>> 4. Anti-aliasing. There is some behind the scenes magic when drawing text, 
>>> that determines whether it knows the background color and therefore whether 
>>> it anti-aliases using the background color.
>>> 
>>> 5. Overlays. It’s possible that NSTextField already draws the text more 
>>> than once, to give a partial outline effect that increases contrast with 
>>> mid-level color backgrounds.
>>> 
>>> 6. Traits. NSTextField may be opting into the trait behavior that 
>>> classifies text as Body, Headline, Caption, etc. These things might cause 
>>> some adjustment to the font weight. Or the accessibility features that 
>>> change the font appearance. (But I’m not sure which of those is available 
>>> on macOS.)
>>> 
>>> 
>> 
>> ___
>> 
>> 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/gerti-cocoadev%40bitart.com
>> 
>> This email sent to gerti-cocoa...@bitart.com
> 
___

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: Visible difference in text: NSTextField vs drawInRect:

2017-04-11 Thread gerti-cocoadev
Did you try the

CGContextRefctx=(CGContextRef)[[NSGraphicsContext 
currentContext]graphicsPort];

CGContextSetShouldSmoothFonts(ctx,YES);

stuff inside the -drawRect: method? That is where it needs to be. Try both YES 
and NO. Should be a visible difference.

Gerd


> On Apr 11, 2017, at 10:55, Navneet Kumar  wrote:
> 
> Hi,
> 
> Here is another image with a character in each case zoomed in using 
> ColorMeter.
> 
> http://i66.tinypic.com/2w5m795.jpg
> 
> Wishes,
> Navneet
> 
> 
>> On 11-Apr-2017, at 2:00 AM, Quincey Morris 
>>  wrote:
>> 
>> On Apr 10, 2017, at 11:20 , Navneet Kumar > > wrote:
>>> 
>>> Actually I’m using text fields for simplicity at a lot of places. And 
>>> drawInRect: at some places, in order to vertically centre the multi-line 
>>> text more conveniently.
>> 
>> Here are some possibilities to consider:
>> 
>> 1. Shadow. What happens if you don’t specify the shadow?
>> 
>> 2. Resolution. It may be that the text drawing ends up in drawing contexts 
>> with different resolution backing stores (1x vs. 2x vs. 3x).
>> 
>> 3. Size. Does the weird effect scale with point size? If you draw the text 
>> much larger, are the results much closer to each other?
>> 
>> 4. Anti-aliasing. There is some behind the scenes magic when drawing text, 
>> that determines whether it knows the background color and therefore whether 
>> it anti-aliases using the background color.
>> 
>> 5. Overlays. It’s possible that NSTextField already draws the text more than 
>> once, to give a partial outline effect that increases contrast with 
>> mid-level color backgrounds.
>> 
>> 6. Traits. NSTextField may be opting into the trait behavior that classifies 
>> text as Body, Headline, Caption, etc. These things might cause some 
>> adjustment to the font weight. Or the accessibility features that change the 
>> font appearance. (But I’m not sure which of those is available on macOS.)
>> 
>> 
> 
> ___
> 
> 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/gerti-cocoadev%40bitart.com
> 
> This email sent to gerti-cocoa...@bitart.com

___

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: Visible difference in text: NSTextField vs drawInRect:

2017-04-11 Thread Navneet Kumar
Hi,

Here is another image with a character in each case zoomed in using ColorMeter.

http://i66.tinypic.com/2w5m795.jpg

Wishes,
Navneet


> On 11-Apr-2017, at 2:00 AM, Quincey Morris 
>  wrote:
> 
> On Apr 10, 2017, at 11:20 , Navneet Kumar  > wrote:
>> 
>> Actually I’m using text fields for simplicity at a lot of places. And 
>> drawInRect: at some places, in order to vertically centre the multi-line 
>> text more conveniently.
> 
> Here are some possibilities to consider:
> 
> 1. Shadow. What happens if you don’t specify the shadow?
> 
> 2. Resolution. It may be that the text drawing ends up in drawing contexts 
> with different resolution backing stores (1x vs. 2x vs. 3x).
> 
> 3. Size. Does the weird effect scale with point size? If you draw the text 
> much larger, are the results much closer to each other?
> 
> 4. Anti-aliasing. There is some behind the scenes magic when drawing text, 
> that determines whether it knows the background color and therefore whether 
> it anti-aliases using the background color.
> 
> 5. Overlays. It’s possible that NSTextField already draws the text more than 
> once, to give a partial outline effect that increases contrast with mid-level 
> color backgrounds.
> 
> 6. Traits. NSTextField may be opting into the trait behavior that classifies 
> text as Body, Headline, Caption, etc. These things might cause some 
> adjustment to the font weight. Or the accessibility features that change the 
> font appearance. (But I’m not sure which of those is available on macOS.)
> 
> 

___

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: Visible difference in text: NSTextField vs drawInRect:

2017-04-11 Thread Navneet Kumar
Hi,

The image with bigger (21.0 points) Arial font is uploaded here: 
http://i65.tinypic.com/118g0fl.jpg
The effect is clearly visible.
The window is of a new small project made to show/resolve this issue only.
I can send this small (around 50KB) project via email if you want.

Please look at my responses to the points raised below.

> On 11-Apr-2017, at 2:00 AM, Quincey Morris 
>  wrote:
> 
> On Apr 10, 2017, at 11:20 , Navneet Kumar  > wrote:
>> 
>> Actually I’m using text fields for simplicity at a lot of places. And 
>> drawInRect: at some places, in order to vertically centre the multi-line 
>> text more conveniently.
> 
> Here are some possibilities to consider:
> 
> 1. Shadow. What happens if you don’t specify the shadow?
> 
I have not specified any shadow to text field.

> 2. Resolution. It may be that the text drawing ends up in drawing contexts 
> with different resolution backing stores (1x vs. 2x vs. 3x).
> 
I do have retina display, but shouldn’t that be same for the two cases (text 
field and drawInRect:).

> 3. Size. Does the weird effect scale with point size? If you draw the text 
> much larger, are the results much closer to each other?
> 
Now using the font: “Arial Bold”, 21.0 points. The effect is still there and 
more clear.

> 4. Anti-aliasing. There is some behind the scenes magic when drawing text, 
> that determines whether it knows the background color and therefore whether 
> it anti-aliases using the background color.
> 
Tried anti-aliasing, explicitly turning it ON and OFF. No change.

> 5. Overlays. It’s possible that NSTextField already draws the text more than 
> once, to give a partial outline effect that increases contrast with mid-level 
> color backgrounds.
> 
Is there a way to determine/change overlays by text field?

> 6. Traits. NSTextField may be opting into the trait behavior that classifies 
> text as Body, Headline, Caption, etc. These things might cause some 
> adjustment to the font weight. Or the accessibility features that change the 
> font appearance. (But I’m not sure which of those is available on macOS.)
> 
Tried with changing traits like font weight (for drawInRect:) from 0 to 15, but 
the effect is still there.



> 

___

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: Visible difference in text: NSTextField vs drawInRect:

2017-04-10 Thread Quincey Morris
On Apr 10, 2017, at 11:20 , Navneet Kumar  wrote:
> 
> Actually I’m using text fields for simplicity at a lot of places. And 
> drawInRect: at some places, in order to vertically centre the multi-line text 
> more conveniently.

Here are some possibilities to consider:

1. Shadow. What happens if you don’t specify the shadow?

2. Resolution. It may be that the text drawing ends up in drawing contexts with 
different resolution backing stores (1x vs. 2x vs. 3x).

3. Size. Does the weird effect scale with point size? If you draw the text much 
larger, are the results much closer to each other?

4. Anti-aliasing. There is some behind the scenes magic when drawing text, that 
determines whether it knows the background color and therefore whether it 
anti-aliases using the background color.

5. Overlays. It’s possible that NSTextField already draws the text more than 
once, to give a partial outline effect that increases contrast with mid-level 
color backgrounds.

6. Traits. NSTextField may be opting into the trait behavior that classifies 
text as Body, Headline, Caption, etc. These things might cause some adjustment 
to the font weight. Or the accessibility features that change the font 
appearance. (But I’m not sure which of those is available on macOS.)


___

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: Visible difference in text: NSTextField vs drawInRect:

2017-04-10 Thread Navneet Kumar
Hi,

Checked. Both the fonts (text field’s as well as descAttribs) are same with 
same “spc” values, at run time.
Tried with “Arial Bold”, but same result: text field rendering looks bolder and 
darker.

As Rob suggested, if its a more deeper thing like “updateLayer vs not” case, 
what can be done?

Actually I’m using text fields for simplicity at a lot of places. And 
drawInRect: at some places, in order to vertically centre the multi-line text 
more conveniently.

But it looks odd in contrast when I’m doing both on the same window. I want 
both to match.

Wishes,
Navneet

> On 10-Apr-2017, at 10:50 PM, Jens Alfke  wrote:
> 
> That's weird. I think you'll need to do some detective work.
> - Break at runtime and check what the value of textField.font actually is.
> - Try using a different font and see if it makes any difference.
> 
> —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: Visible difference in text: NSTextField vs drawInRect:

2017-04-10 Thread Jens Alfke
That's weird. I think you'll need to do some detective work.
- Break at runtime and check what the value of textField.font actually is.
- Try using a different font and see if it makes any difference.

—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: Visible difference in text: NSTextField vs drawInRect:

2017-04-10 Thread Rob Petrovec
updateLayer vs not?  By implementing drawRect: it automagically disables 
updateLayer for that view so the drawing mechanics are different under the 
hood.  NSTextField may be using updateLayer while your manual implementation is 
not resulting in a different rendering of the text.  Also try printing out the 
NSAttributedString from the NSTextField and see if there is a difference 
between it and your descAttribs.  Good luck...

—Rob


> On Apr 10, 2017, at 9:59 AM, Navneet Kumar  wrote:
> 
> Yes, the text field seems to draw bold font, but I have set the same bold 
> font in drawInRect: as well.
> Here’s the code snippet.
> ———
> For text field:
>bgColor = [[NSColor orangeColor] blendedColorWithFraction:0.25 
> ofColor:[NSColor yellowColor]];
>[bgColor retain];
>[textField setTextColor:[bgColor shadowWithLevel:0.25]];
>[textField setFont:[NSFont boldSystemFontOfSize:11.0]];
>[textField setStringValue:string];
> For drawInRect:
>NSMutableParagraphStyle * aParagraphStyle = [[[NSMutableParagraphStyle 
> alloc] init] autorelease];
>[aParagraphStyle setLineBreakMode:NSLineBreakByWordWrapping];
>NSDictionary *descAttribs = [NSDictionary 
> dictionaryWithObjectsAndKeys:[NSFont boldSystemFontOfSize:11.0], 
> NSFontAttributeName, [bgColor shadowWithLevel:0.25], 
> NSForegroundColorAttributeName, aParagraphStyle, 
> NSParagraphStyleAttributeName,nil];
> 
>[string drawInRect:rectDrw withAttributes:descAttribs];
> ———
> After trying CGContextSetShouldSmoothFonts(ctx,YES);,
> the result is same as before, the text field seems to display bolder, darker 
> font.
> 
> I have macOS Sierra. Latest Xcode, and latest build settings.
> 
> Thanks,
> Navneet
> 
> 
>> On 10-Apr-2017, at 9:06 PM, Jens Alfke  wrote:
>> 
>> 
>>> On Apr 10, 2017, at 7:41 AM, Navneet Kumar >> > wrote:
>>> 
>>> The image URL to a sample image: http://i63.tinypic.com/xbe0bc.jpg 
>>> 
>>> The top text is using a text field and bottom text is using drawInRect:.
>> 
>> What are the exact text attributes? It looks as though the top line is bold 
>> and the bottom isn't.
>> 
>> —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/petrock%40mac.com
> 
> This email sent to petr...@mac.com

___

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: Visible difference in text: NSTextField vs drawInRect:

2017-04-10 Thread Navneet Kumar
Yes, the text field seems to draw bold font, but I have set the same bold font 
in drawInRect: as well.
Here’s the code snippet.
———
For text field:
bgColor = [[NSColor orangeColor] blendedColorWithFraction:0.25 
ofColor:[NSColor yellowColor]];
[bgColor retain];
[textField setTextColor:[bgColor shadowWithLevel:0.25]];
[textField setFont:[NSFont boldSystemFontOfSize:11.0]];
[textField setStringValue:string];
For drawInRect:
NSMutableParagraphStyle * aParagraphStyle = [[[NSMutableParagraphStyle 
alloc] init] autorelease];
[aParagraphStyle setLineBreakMode:NSLineBreakByWordWrapping];
NSDictionary *descAttribs = [NSDictionary 
dictionaryWithObjectsAndKeys:[NSFont boldSystemFontOfSize:11.0], 
NSFontAttributeName, [bgColor shadowWithLevel:0.25], 
NSForegroundColorAttributeName, aParagraphStyle, 
NSParagraphStyleAttributeName,nil];

[string drawInRect:rectDrw withAttributes:descAttribs];
———
After trying CGContextSetShouldSmoothFonts(ctx,YES);,
the result is same as before, the text field seems to display bolder, darker 
font.

I have macOS Sierra. Latest Xcode, and latest build settings.

Thanks,
Navneet


> On 10-Apr-2017, at 9:06 PM, Jens Alfke  wrote:
> 
> 
>> On Apr 10, 2017, at 7:41 AM, Navneet Kumar > > wrote:
>> 
>> The image URL to a sample image: http://i63.tinypic.com/xbe0bc.jpg 
>> 
>> The top text is using a text field and bottom text is using drawInRect:.
> 
> What are the exact text attributes? It looks as though the top line is bold 
> and the bottom isn't.
> 
> —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: Visible difference in text: NSTextField vs drawInRect:

2017-04-10 Thread Jens Alfke

> On Apr 10, 2017, at 7:41 AM, Navneet Kumar  wrote:
> 
> The image URL to a sample image: http://i63.tinypic.com/xbe0bc.jpg 
> 
> The top text is using a text field and bottom text is using drawInRect:.

What are the exact text attributes? It looks as though the top line is bold and 
the bottom isn't.

—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: Visible difference in text: NSTextField vs drawInRect:

2017-04-10 Thread gerti-cocoadev
This may or may net help:

CGContextRefctx=(CGContextRef)[[NSGraphicsContext 
currentContext]graphicsPort];

CGContextSetShouldSmoothFonts(ctx,YES);

Gerd

> On Apr 10, 2017, at 09:41, Navneet Kumar  wrote:
> 
> Hi,
> 
> There is visible difference in text when setting the same string, same font, 
> same text colour to a text field.
> And when the same is done via NSString drawInRect method having same 
> attributes for text.
> 
> The image URL to a sample image: http://i63.tinypic.com/xbe0bc.jpg
> 
> The top text is using a text field and bottom text is using drawInRect:.
> 
> The rect supplied to drawInRect: is many time bigger than needed.
> 
> I have both ways implemented in my project, so would it be possible to make 
> drawInRect: draw as boldly as a text field?
> 
> Is there any other neater, more consistent way to draw text?
> 
> Thanks,
> Navneet
> 
> ___
> 
> 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/gerti-cocoadev%40bitart.com
> 
> This email sent to gerti-cocoa...@bitart.com

___

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


Visible difference in text: NSTextField vs drawInRect:

2017-04-10 Thread Navneet Kumar
Hi,

There is visible difference in text when setting the same string, same font, 
same text colour to a text field.
And when the same is done via NSString drawInRect method having same attributes 
for text.

The image URL to a sample image: http://i63.tinypic.com/xbe0bc.jpg

The top text is using a text field and bottom text is using drawInRect:.

The rect supplied to drawInRect: is many time bigger than needed.

I have both ways implemented in my project, so would it be possible to make 
drawInRect: draw as boldly as a text field?

Is there any other neater, more consistent way to draw text?

Thanks,
Navneet

___

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