How do you display 2-byte fonts with Xlib?
From: Nobody (nobody_at_nowhere.com)
Date: 02/29/04
- Next message: Robert Hull: "Re: Need to make Dual boot CD"
- Previous message: Andy Fraser: "Re: Multiple X sessions (switch user)"
- Next in thread: дамјан г.: "Re: How do you display 2-byte fonts with Xlib?"
- Reply: дамјан г.: "Re: How do you display 2-byte fonts with Xlib?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 29 Feb 2004 15:58:18 -0600
Are there any Xlib programming gurus out there? I'm working through the
"Xlib programmin manual" (by Adrian Nye... as far as I can tell, this is
the only printed X programming guide), and it refers to 2-byte fonts, but
doesn't elaborate much as to their use.
I can get text to display fine in the single-byte fonts, but if I switch
to a double-byte font, I can't... I'm assuming I'm just confused as to the
encoding, but I've tried both Unicode and shift-JIS, and nothing seems to
be displaying. Here's what I'm trying to do:
// Open display, etc.
Font current_font;
XFontStruct *font_info;
// For example... any 2-byte font
current_font = XLoadFont( display,
"-jis-fixed-medium-r-normal--16-110-100-100-c-160-jisx0208.1983-0"
);
font_info = XQueryFont( display, current_font );
// Making sure it's really a 2-byte font
if ( font_info->min_byte1 )
{
XChar2b *string16 = ( XChar2b * )
calloc( sizeof( XChar2b ), 10 );
int i;
for ( i = 0; i < 10; i++ )
{
// This assumes shift-JIS
string16[ i ].byte1 = 137;
string16[ i ].byte2 = 159 + i;
// This assumes Unicode
// string16[ i ].byte1 = 0x2f
// string16[ i ].byte2 = i;
// This tries Unicode page 0
// string16[ i ].byte1 = 0;
// string16[ i ].byte2 = 65 + i;
}
XDrawImageString16( display, win, gc,
10, 10 + font_info->ascent,
string16, 10 );
}
But I always get a blank string.. this same code works OK if I use a
single-byte font and a "regular" string, and I know I can display
shift-JIS encoded characters (since I can view web pages in Japanese)...
what am I missing?
Thanks!
- Next message: Robert Hull: "Re: Need to make Dual boot CD"
- Previous message: Andy Fraser: "Re: Multiple X sessions (switch user)"
- Next in thread: дамјан г.: "Re: How do you display 2-byte fonts with Xlib?"
- Reply: дамјан г.: "Re: How do you display 2-byte fonts with Xlib?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]