Re: Displaying Keyboard Key Glyphs
Re: Displaying Keyboard Key Glyphs
- Subject: Re: Displaying Keyboard Key Glyphs
- From: Steve Bennett <email@hidden>
- Date: Fri, 15 Mar 2002 16:17:15 -0500
Thanks for the reply. After doing a lot of web-searching, I found the
Unicode site (www.unicode.org) which has all of the character code charts,
and after perusing them very carefully, I was able to find the Unicode codes
for all of the keys I was interested in. The appearance of the character in
the charts isn't *quite* identical to the ones in our fonts, but the charts
also list descriptions for the use of each character.
Match those up with our keys, use the Unicode Hex Input keyboard mapping to
enter the codes in a Unicode-aware text editor, and they appear just like
they used to look in classic.
Good thing too -- I wouldn't have been able to display glyphs easily, since
I needed these characters to be embedded in localizable text fields with
other text...
-->Steve Bennett
on 3/14/02 8:06 PM, Aki Inoue at email@hidden wrote:
>
Steve,
>
>
These symbols can be rendered with ".Keyboard" font, one of hidden
>
system fonts.
>
Unfortunately the font doesn't have coherent Unicode mapping (partly
>
because about half of the glyphs are not in Unicode).
>
>
So, you need to render using glyph ID.
>
>
The following code shows how to dump the font glyphs.
>
>
- (void)drawRect:(NSRect)theRect {
>
NSGraphicsContext *currentContext = [NSGraphicsContext
>
currentContext];
>
CGContextRef cgContext = (CGContextRef)[currentContext graphicsPort];
>
static NSFont *keyboardFont = nil;
>
static CGGlyph *glyphs = NULL;
>
static int count = 0;
>
int index;
>
>
if (!keyboardFont) {
>
keyboardFont = [NSFont fontWithName:@".Keyboard" size:34.0];
>
>
count = [keyboardFont numberOfGlyphs];
>
glyphs = (CGGlyph *)NSZoneMalloc([self zone], sizeof(CGGlyph) *
>
count);
>
for (index = 0;index < count;index++) glyphs[index] = index;
>
}
>
>
[keyboardFont set];
>
>
for (index = 0;index < count / 16;index++) {
>
CGContextSetTextPosition(cgContext, 0.0, 34.0 * index);
>
CGContextShowGlyphs(cgContext, glyphs + (index * 16), 16);
>
}
>
}
>
>
Aki
>
>
On 2002.03.14, at 15:11, Steve Bennett wrote:
>
>
> Hi!
>
>
>
> Back in the Classic days (and still visible in the classic version of
>
> Key
>
> Caps today) it was possible to display characters using the system font
>
> which represented a whole variety of special keys on the keyboard, such
>
> as
>
> the Command, Control, or Option key, the arrow keys, insert/delete, and
>
> many
>
> more. In fact most of the keys on the keyboard had a glyph associated
>
> with
>
> it that was in the system font. Most of these were obtained using a
>
> control
>
> key sequence -- for example, the character symbol representing the
>
> Option
>
> key was displayed as a Ctrl+G.
>
>
>
> A quick look at the native Key Caps application shows that this is no
>
> longer
>
> the case, presumably due to the switchover to Unicode everywhere. After
>
> quite a bit of searching, I found docs which pointed me to system
>
> preferences and turning on the Symbols keyboard layout in the
>
> International
>
> preferences. With that layout selected, the Command key glyph was
>
> obtainable in Key Caps (and other Unicode-savvy apps) by typing
>
> Shift+Option+Semicolon.
>
>
>
> However, I have been unable to find all of the symbols on this layout
>
> (or on
>
> any other I've tried), and can't find docs on these either.
>
> Specifically,
>
> I'm still looking for the symbols for Control, Option, and Shift, and
>
> ideally all the other symbols which existed back in the Classic system
>
> font.
>
> Any suggestions on whether these symbols still exist (I *really* hope
>
> so)
>
> and if so, where to find them?
>
>
>
> Thanks,
>
>
>
> -->Steve Bennett
>
> _______________________________________________
>
> 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.
_______________________________________________
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.