Re: Displaying Keyboard Key Glyphs
Re: Displaying Keyboard Key Glyphs
- Subject: Re: Displaying Keyboard Key Glyphs
- From: Aki Inoue <email@hidden>
- Date: Thu, 14 Mar 2002 17:06:59 -0800
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.