Chapter 13. Examples of I18N
101
13.1.5 Font Preparation (continued)
After calling
XCreateFontSet()
,
GetFont()
builds a few member variables of
MyFont
, i.e.,
font >height
,
font >y
,
font >ascent
, and
font >descent
. These parameters are easily
get from members of
XFontStruct
structure and are actually often used in TWM. Thus I had to
prepare substitutions for
XFontSet
version. These variables also build for
XFontStruct
version
so that a united method can be used to get these parameters.
13.1.6 Drawing Text using
MyFont
To draw a text,
XDrawString()
and
XDrawImageString()
are used for conventional
XFontStruct
.
On the other hand,
XmbDrawString()
/
XwcDrawString()
and
XmbDrawImageString()
/
XwcDrawImageString()
are used for internationalized
XFontSet
. The difference between
mb
and
wc
versions are whether
the text is given in multibyte characters or in wide characters. Since TWM does not perform any text
processing, I didn't use wide characters and treat strings as they are (in multibyte characters).
TWM has many calls of these functions. Thus I decided to write wrappers which checks
use_fontset
and calls proper version of X function. They are
MyFont_DrawString()
and
MyFont_DrawImageString()
.
Thus all calling of
XDrawString()
and
XDrawImageString()
are replaced with the wrappers.
Since these two are almost identical, I will explain one of them.
void
MyFont_DrawString(dpy, d, font, gc, x, y, string, len)
Display *dpy;
Drawable d;
MyFont *font;
GC gc;
int x,y;
char *string;
int len;
{
if (use_fontset) {
XmbDrawString(dpy, d, font >fontset, gc, x, y, string, len);
return;
}
XDrawString (dpy, d, gc, x, y, string, len);
}
Very simple function! However note that the required paramaters are different in these two func 
tions of conventional version and internationalized version. Font is needed for internationalized
version.






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

indiana web hosting

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Inexpensive Web Hosting  Jsp Web Hosting

Cheapest Web Hosting Jsp Hosting Cheap Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved