@ -49,8 +49,7 @@
@@ -49,8 +49,7 @@
static int
get_font_list (
const char * base_font_name_list ,
char * * * flist )
{
char * * * flist ) {
const char * ptr ;
const char * p ;
int nb ;
@ -95,9 +94,7 @@ get_font_list(
@@ -95,9 +94,7 @@ get_font_list(
/** (mainly used for adobe-symbol and adobe-zapfdingbats) **/
/*********************************************************************/
static int
font_spec_enc (
char * font )
{
font_spec_enc ( char * font ) {
int ret ;
char * enc ;
char * end ;
@ -122,11 +119,10 @@ font_spec_enc(
@@ -122,11 +119,10 @@ font_spec_enc(
/** get the sub range of a iso10646-1 font **/
/*********************************************************************/
static void
get_range (
const char * enc ,
get_range ( const char * enc ,
int * min ,
int * max )
{
int * max ) {
const char * ptr = enc ;
const char * ptr1 ;
@ -153,11 +149,10 @@ get_range(
@@ -153,11 +149,10 @@ get_range(
/** get the internal encoding number of each fonts **/
/*********************************************************************/
static int *
get_encodings (
char * * font_name_list ,
get_encodings ( char * * font_name_list ,
int * ranges ,
int nb_font )
{
int nb_font ) {
int * font_encoding_list ;
int i ;
i = 0 ;
@ -180,8 +175,7 @@ get_encodings(
@@ -180,8 +175,7 @@ get_encodings(
if ( * ptr = = ' - ' ) {
ec + + ;
if ( ec = = 13 ) {
font_encoding_list [ i ] =
encoding_number ( ptr + 1 ) ;
font_encoding_list [ i ] = encoding_number ( ptr + 1 ) ;
if ( font_encoding_list [ i ] = = 0 ) {
get_range ( ptr + 1 ,
ranges + i * 2 ,
@ -202,10 +196,9 @@ get_encodings(
@@ -202,10 +196,9 @@ get_encodings(
/** find the first font which matches the name and load it. **/
/*********************************************************************/
XFontStruct *
find_best_font (
Display * dpy ,
char * * name )
{
find_best_font ( Display * dpy ,
char * * name ) {
char * * list ;
int cnt ;
XFontStruct * s ;
@ -225,21 +218,20 @@ find_best_font(
@@ -225,21 +218,20 @@ find_best_font(
/** load all fonts **/
/*********************************************************************/
static void
load_fonts (
Display * dpy ,
XUtf8FontStruct * font_set )
{
load_fonts ( Display * dpy ,
XUtf8FontStruct * font_set ) {
int i ;
char * * list ;
i = 0 ;
list = NULL ;
font_set - > fonts = ( XFontStruct * * )
malloc ( sizeof ( XFontStruct * ) * font_set - > nb_font ) ;
font_set - > fonts = ( XFontStruct * * ) malloc ( sizeof ( XFontStruct * ) *
font_set - > nb_font ) ;
font_set - > ranges = ( int * )
malloc ( sizeof ( int ) * font_set - > nb_font * 2 ) ;
font_set - > ranges = ( int * ) malloc ( sizeof ( int ) *
font_set - > nb_font * 2 ) ;
font_set - > descent = 0 ;
font_set - > ascent = 0 ;
@ -280,8 +272,7 @@ load_fonts(
@@ -280,8 +272,7 @@ load_fonts(
font_set - > ranges [ 2 * j ] = =
font_set - > ranges [ 2 * i ] & &
font_set - > ranges [ ( 2 * j ) + 1 ] & &
font_set - > ranges [ ( 2 * i ) + 1 ] )
{
font_set - > ranges [ ( 2 * i ) + 1 ] ) {
XFreeFont ( dpy , font_set - > fonts [ i ] ) ;
free ( font_set - > font_name_list [ i ] ) ;
font_set - > font_name_list [ i ] = NULL ;
@ -297,14 +288,12 @@ load_fonts(
@@ -297,14 +288,12 @@ load_fonts(
/** list of fonts. XLoad all fonts. **/
/*********************************************************************/
XUtf8FontStruct *
XCreateUtf8FontStruct (
Display * dpy ,
const char * base_font_name_list )
{
XCreateUtf8FontStruct ( Display * dpy ,
const char * base_font_name_list ) {
XUtf8FontStruct * font_set ;
font_set = ( XUtf8FontStruct * )
malloc ( sizeof ( XUtf8FontStruct ) ) ;
font_set = ( XUtf8FontStruct * ) malloc ( sizeof ( XUtf8FontStruct ) ) ;
if ( ! font_set ) {
return NULL ;
@ -328,16 +317,15 @@ XCreateUtf8FontStruct (
@@ -328,16 +317,15 @@ XCreateUtf8FontStruct (
/** draw a Right To Left UTF-8 string using multiple fonts as needed. **/
/*****************************************************************************/
void
XUtf8DrawRtlString (
Display * display ,
XUtf8DrawRtlString ( Display * display ,
Drawable d ,
XUtf8FontStruct * font_set ,
GC gc ,
int x ,
int y ,
const char * string ,
int num_bytes )
{
int num_bytes ) {
int * encodings ; /* encodings array */
XFontStruct * * fonts ; /* fonts array */
XChar2b buf [ 128 ] ; /* drawing buffer */
@ -376,8 +364,7 @@ XUtf8DrawRtlString(
@@ -376,8 +364,7 @@ XUtf8DrawRtlString(
while ( num_bytes > 0 ) {
int ulen ; /* byte length of the UTF-8 char */
unsigned int ucs ; /* Unicode value of the UTF-8 char */
unsigned int no_spc ; /* Spacing char equivalent of a
non - spacing char */
unsigned int no_spc ; /* Spacing char equivalent of a non-spacing char */
if ( i > 120 ) {
/*** draw the buffer **/
@ -388,8 +375,7 @@ XUtf8DrawRtlString(
@@ -388,8 +375,7 @@ XUtf8DrawRtlString(
ptr = buf + 128 ;
}
ulen = XFastConvertUtf8ToUcs ( ( unsigned char * ) string ,
num_bytes , & ucs ) ;
ulen = XFastConvertUtf8ToUcs ( ( unsigned char * ) string , num_bytes , & ucs ) ;
if ( ulen < 1 ) ulen = 1 ;
@ -402,21 +388,18 @@ XUtf8DrawRtlString(
@@ -402,21 +388,18 @@ XUtf8DrawRtlString(
*/
fnum = first ;
while ( fnum < nb_font ) {
if ( fonts [ fnum ] & &
ucs2fontmap ( glyph , ucs , encodings [ fnum ] ) > = 0 )
{
if ( fonts [ fnum ] & & ucs2fontmap ( glyph , ucs , encodings [ fnum ] ) > = 0 ) {
if ( encodings [ fnum ] ! = 0 | |
( ucs > = ranges [ fnum * 2 ] & &
ucs < = ranges [ fnum * 2 + 1 ] ) )
{
( ucs > = ranges [ fnum * 2 ] & & ucs < = ranges [ fnum * 2 + 1 ] ) ) {
break ;
}
}
fnum + + ;
}
if ( fnum = = nb_font ) {
/** the char is not valid in all encodings ->
* draw it using the first font : - ( * */
/* the char is not valid in all encodings ->
* draw it using the first font : - (
*/
fnum = first ;
ucs2fontmap ( glyph , ' ? ' , encodings [ fnum ] ) ;
}
@ -455,16 +438,15 @@ XUtf8DrawRtlString(
@@ -455,16 +438,15 @@ XUtf8DrawRtlString(
/** draw an UTF-8 string using multiple fonts as needed. **/
/*****************************************************************************/
void
XUtf8DrawString (
Display * display ,
XUtf8DrawString ( Display * display ,
Drawable d ,
XUtf8FontStruct * font_set ,
GC gc ,
int x ,
int y ,
const char * string ,
int num_bytes )
{
int num_bytes ) {
int * encodings ; /* encodings array */
XFontStruct * * fonts ; /* fonts array */
XChar2b buf [ 128 ] ; /* drawing buffer */
@ -500,8 +482,7 @@ XUtf8DrawString(
@@ -500,8 +482,7 @@ XUtf8DrawString(
while ( num_bytes > 0 ) {
int ulen ; /* byte length of the UTF-8 char */
unsigned int ucs ; /* Unicode value of the UTF-8 char */
unsigned int no_spc ; /* Spacing char equivalent of a
non - spacing char */
unsigned int no_spc ; /* Spacing char equivalent of a non-spacing char */
if ( i > 120 ) {
/*** draw the buffer **/
@ -511,8 +492,7 @@ XUtf8DrawString(
@@ -511,8 +492,7 @@ XUtf8DrawString(
i = 0 ;
}
ulen = XFastConvertUtf8ToUcs ( ( unsigned char * ) string ,
num_bytes , & ucs ) ;
ulen = XFastConvertUtf8ToUcs ( ( unsigned char * ) string , num_bytes , & ucs ) ;
if ( ulen < 1 ) ulen = 1 ;
@ -525,21 +505,19 @@ XUtf8DrawString(
@@ -525,21 +505,19 @@ XUtf8DrawString(
*/
fnum = first ;
while ( fnum < nb_font ) {
if ( fonts [ fnum ] & &
ucs2fontmap ( glyph , ucs , encodings [ fnum ] ) > = 0 )
{
if ( fonts [ fnum ] & & ucs2fontmap ( glyph , ucs , encodings [ fnum ] ) > = 0 ) {
if ( encodings [ fnum ] ! = 0 | |
( ucs > = ranges [ fnum * 2 ] & &
ucs < = ranges [ fnum * 2 + 1 ] ) )
{
ucs < = ranges [ fnum * 2 + 1 ] ) ) {
break ;
}
}
fnum + + ;
}
if ( fnum = = nb_font ) {
/** the char is not valid in all encodings ->
* draw it using the first font : - ( * */
/* the char is not valid in all encodings ->
* draw it using the first font : - (
*/
fnum = first ;
ucs2fontmap ( glyph , ' ? ' , encodings [ fnum ] ) ;
}
@ -574,11 +552,10 @@ XUtf8DrawString(
@@ -574,11 +552,10 @@ XUtf8DrawString(
/** returns the pixel width of a UTF-8 string **/
/*****************************************************************************/
int
XUtf8TextWidth (
XUtf8FontStruct * font_set ,
XUtf8TextWidth ( XUtf8FontStruct * font_set ,
const char * string ,
int num_bytes )
{
int num_bytes ) {
int x ;
int * encodings ; /* encodings array */
XFontStruct * * fonts ; /* fonts array */
@ -617,8 +594,7 @@ XUtf8TextWidth(
@@ -617,8 +594,7 @@ XUtf8TextWidth(
while ( num_bytes > 0 ) {
int ulen ; /* byte length of the UTF-8 char */
unsigned int ucs ; /* Unicode value of the UTF-8 char */
unsigned int no_spc ; /* Spacing char equivalent of a
non - spacing char */
unsigned int no_spc ; /* Spacing char equivalent of a non-spacing char */
if ( i > 120 ) {
/*** measure the buffer **/
@ -626,8 +602,7 @@ XUtf8TextWidth(
@@ -626,8 +602,7 @@ XUtf8TextWidth(
i = 0 ;
}
ulen = XFastConvertUtf8ToUcs ( ( unsigned char * ) string ,
num_bytes , & ucs ) ;
ulen = XFastConvertUtf8ToUcs ( ( unsigned char * ) string , num_bytes , & ucs ) ;
if ( ulen < 1 ) ulen = 1 ;
@ -642,21 +617,19 @@ XUtf8TextWidth(
@@ -642,21 +617,19 @@ XUtf8TextWidth(
*/
fnum = first ;
while ( fnum < nb_font ) {
if ( fonts [ fnum ] & &
ucs2fontmap ( glyph , ucs , encodings [ fnum ] ) > = 0 )
{
if ( fonts [ fnum ] & & ucs2fontmap ( glyph , ucs , encodings [ fnum ] ) > = 0 ) {
if ( encodings [ fnum ] ! = 0 | |
( ucs > = ranges [ fnum * 2 ] & &
ucs < = ranges [ fnum * 2 + 1 ] ) )
{
ucs < = ranges [ fnum * 2 + 1 ] ) ) {
break ;
}
}
fnum + + ;
}
if ( fnum = = nb_font ) {
/** the char is not valid in all encodings ->
* draw it using the first font : - ( * */
/* the char is not valid in all encodings ->
* draw it using the first font : - (
*/
fnum = first ;
ucs2fontmap ( glyph , ' ? ' , encodings [ fnum ] ) ;
}
@ -667,8 +640,7 @@ XUtf8TextWidth(
@@ -667,8 +640,7 @@ XUtf8TextWidth(
( * buf ) . byte1 = glyph [ 0 ] ;
( * buf ) . byte2 = glyph [ 1 ] ;
if ( no_spc ) {
/* go back to draw the non-spacing char over
* the previous char */
/* go back to draw the non-spacing char over the previous char */
x - = XTextWidth16 ( fonts [ fnum ] , buf , 1 ) ;
}
} else {
@ -690,12 +662,11 @@ XUtf8TextWidth(
@@ -690,12 +662,11 @@ XUtf8TextWidth(
/** get the X font and glyph ID of a UCS char **/
/*****************************************************************************/
int
XGetUtf8FontAndGlyph (
XUtf8FontStruct * font_set ,
XGetUtf8FontAndGlyph ( XUtf8FontStruct * font_set ,
unsigned int ucs ,
XFontStruct * * fnt ,
unsigned short * id )
{
unsigned short * id ) {
int x ;
int * encodings ; /* encodings array */
XFontStruct * * fonts ; /* fonts array */
@ -736,20 +707,19 @@ XGetUtf8FontAndGlyph(
@@ -736,20 +707,19 @@ XGetUtf8FontAndGlyph(
*/
fnum = first ;
while ( fnum < nb_font ) {
if ( fonts [ fnum ] & &
ucs2fontmap ( glyph , ucs , encodings [ fnum ] ) > = 0 )
{
if ( encodings [ fnum ] ! = 0 | | ( ucs > = ranges [ fnum * 2 ] & &
ucs < = ranges [ fnum * 2 + 1 ] ) )
{
if ( fonts [ fnum ] & & ucs2fontmap ( glyph , ucs , encodings [ fnum ] ) > = 0 ) {
if ( encodings [ fnum ] ! = 0 | |
( ucs > = ranges [ fnum * 2 ] & &
ucs < = ranges [ fnum * 2 + 1 ] ) ) {
break ;
}
}
fnum + + ;
}
if ( fnum = = nb_font ) {
/** the char is not valid in all encodings ->
* draw it using the first font : - ( * */
/* the char is not valid in all encodings ->
* draw it using the first font : - (
*/
fnum = first ;
ucs2fontmap ( glyph , ' ? ' , encodings [ fnum ] ) ;
}
@ -763,10 +733,9 @@ XGetUtf8FontAndGlyph(
@@ -763,10 +733,9 @@ XGetUtf8FontAndGlyph(
/** returns the pixel width of a UCS char **/
/*****************************************************************************/
int
XUtf8UcsWidth (
XUtf8FontStruct * font_set ,
unsigned int ucs )
{
XUtf8UcsWidth ( XUtf8FontStruct * font_set ,
unsigned int ucs ) {
int x ;
int * encodings ; /* encodings array */
XFontStruct * * fonts ; /* fonts array */
@ -802,7 +771,6 @@ XUtf8UcsWidth(
@@ -802,7 +771,6 @@ XUtf8UcsWidth(
first = fnum ;
last_fnum = fnum ;
ucs = XUtf8IsNonSpacing ( ucs ) ;
/*
@ -812,19 +780,18 @@ XUtf8UcsWidth(
@@ -812,19 +780,18 @@ XUtf8UcsWidth(
fnum = first ;
while ( fnum < nb_font ) {
if ( fonts [ fnum ] & &
ucs2fontmap ( glyph , ucs , encodings [ fnum ] ) > = 0 )
{
ucs2fontmap ( glyph , ucs , encodings [ fnum ] ) > = 0 ) {
if ( encodings [ fnum ] ! = 0 | | ( ucs > = ranges [ fnum * 2 ] & &
ucs < = ranges [ fnum * 2 + 1 ] ) )
{
ucs < = ranges [ fnum * 2 + 1 ] ) ) {
break ;
}
}
fnum + + ;
}
if ( fnum = = nb_font ) {
/** the char is not valid in all encodings ->
* draw it using the first font : - ( * */
/* the char is not valid in all encodings ->
* draw it using the first font : - (
*/
fnum = first ;
ucs2fontmap ( glyph , ' ? ' , encodings [ fnum ] ) ;
}
@ -841,16 +808,15 @@ XUtf8UcsWidth(
@@ -841,16 +808,15 @@ XUtf8UcsWidth(
/** draw an UTF-8 string and clear the background. **/
/*****************************************************************************/
void
XUtf8DrawImageString (
Display * display ,
XUtf8DrawImageString ( Display * display ,
Drawable d ,
XUtf8FontStruct * font_set ,
GC gc ,
int x ,
int y ,
const char * string ,
int num_bytes )
{
int num_bytes ) {
/* FIXME: must be improved ! */
int w ;
int fill_style ;
@ -895,10 +861,9 @@ XUtf8DrawImageString(
@@ -895,10 +861,9 @@ XUtf8DrawImageString(
/** free the XFontSet and others things created by XCreateUtf8FontSet **/
/*****************************************************************************/
void
XFreeUtf8FontStruct (
Display * dpy ,
XUtf8FontStruct * font_set )
{
XFreeUtf8FontStruct ( Display * dpy ,
XUtf8FontStruct * font_set ) {
int i ;
i = 0 ;
while ( i < font_set - > nb_font ) {