Re: Drawing antialiased text
Re: Drawing antialiased text
- Subject: Re: Drawing antialiased text
- From: Brock Brandenberg <email@hidden>
- Date: Thu, 15 Aug 2002 13:24:13 -0500
Hi Andrew.
>
I suppose "antialiased" isn't the exact word I'm looking for. When you
>
have a square button, and put some text in it, it looks a certain way by
>
default; if you select the text-only icon in Interface Builder, the text
>
gets a soft edge and a shadow. So, for example:
>
>
The "H" is the title of the button, while the "1" is what I have drawn.
>
I would like the one to be a bit smaller, and to appear soft. I've used
>
>
[NSFont labelFontOfSize:[NSFont labelFontSize]]
>
>
in setting the string to draw, but the number still appears large, as in
>
the picture.
Now I see what you're after. The color of the "H" in your snapshot is odd,
though. Under 10.2 (what I'm running right now), the color is truly black
and there doesn't appear to be a shadow beneath the number. It has a crisper
look to go along with the glossier control look in Jag. I just compared your
snapshot with two buttons in the Jag IB to make sure that the "H" in your
button and the "1" drawn over it at labelFontSize were indeed being rendered
the same size and that it was just shadowing and the button effects in 10.1
making the "H" and "1" look different. It is.
What this means is that if you work to simulate the shadow effect under
10.1, it may no longer match in Jaguar. Something to think about.
Regarding the font size which you want to reduce anyway, the labelFontSize:
method returns a float value so I would just subtract a relative amount to
get smaller type, which insures that your drawing will still work on future
system versions. Even if the label font size changes, you'll always be
relative to it, kind of like HTML and the +1, +2 font size parameters.
[NSFont labelFontOfSize:( 0.8 * [NSFont labelFontSize] )]
As for the shadow, someone just kindly posted a very simple class as an
example of using the CG calls to draw shadows in an NSView. Unlike the
undocumented APIs used by the ASM menu addition, these are real CG calls. I
haven't used the method yet with type, but it seems that it should work
properly, so you could conditionally use it to draw a shadow under the
number in 10.1, and not draw one under 10.2. If the method doesn't work with
type (something I'll test later today), you can easily get the outline for
the glyph and draw it which will definitely work. I have code I can send you
to do that.
Does this help a little?
Brock
----- industrial design @ www.bergdesign.com ------
[demime 0.98b removed an attachment of type application/pdf which had a name of Picture 1.pdf"; x-mac-creator="3F3F3F3F"; x-mac-type="50444620]
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.