@ -39,6 +39,7 @@ Fl_Font_Descriptor::Fl_Font_Descriptor(const char* name) {
}
}
Fl_Font_Descriptor * fl_fontsize ;
Fl_Font_Descriptor * fl_fontsize ;
Fl_XFont_On_Demand fl_xfont ;
Fl_Font_Descriptor : : ~ Fl_Font_Descriptor ( ) {
Fl_Font_Descriptor : : ~ Fl_Font_Descriptor ( ) {
# if HAVE_GL
# if HAVE_GL
@ -52,7 +53,10 @@ Fl_Font_Descriptor::~Fl_Font_Descriptor() {
// glDeleteLists(listbase+base,size);
// glDeleteLists(listbase+base,size);
// }
// }
# endif
# endif
if ( this = = fl_fontsize ) fl_fontsize = 0 ;
if ( this = = fl_fontsize ) {
fl_fontsize = 0 ;
fl_xfont = 0 ;
}
XFreeUtf8FontStruct ( fl_display , font ) ;
XFreeUtf8FontStruct ( fl_display , font ) ;
}
}
@ -83,6 +87,8 @@ Fl_Fontdesc* fl_fonts = built_in_table;
# define MAXSIZE 32767
# define MAXSIZE 32767
# define current_font (fl_fontsize->font)
// return dash number N, or pointer to ending null if none:
// return dash number N, or pointer to ending null if none:
const char * fl_font_word ( const char * p , int n ) {
const char * fl_font_word ( const char * p , int n ) {
while ( * p ) { if ( * p = = ' - ' ) { if ( ! - - n ) break ; } p + + ; }
while ( * p ) { if ( * p = = ' - ' ) { if ( ! - - n ) break ; } p + + ; }
@ -256,11 +262,13 @@ static Fl_Font_Descriptor* find(int fnum, int size) {
Fl_Font fl_font_ = 0 ;
Fl_Font fl_font_ = 0 ;
Fl_Fontsize fl_size_ = 0 ;
Fl_Fontsize fl_size_ = 0 ;
//XFontStruct* fl_xfont = 0;
XUtf8FontStruct * fl_xfont ;
void * fl_xftfont = 0 ;
void * fl_xftfont = 0 ;
static GC font_gc ;
static GC font_gc ;
XFontStruct * Fl_XFont_On_Demand : : value ( ) {
return ptr ;
}
void Fl_Device : : font ( Fl_Font fnum , Fl_Fontsize size ) {
void Fl_Device : : font ( Fl_Font fnum , Fl_Fontsize size ) {
if ( fnum = = - 1 ) {
if ( fnum = = - 1 ) {
fl_font_ = 0 ; fl_size_ = 0 ;
fl_font_ = 0 ; fl_size_ = 0 ;
@ -271,28 +279,28 @@ void Fl_Device::font(Fl_Font fnum, Fl_Fontsize size) {
Fl_Font_Descriptor * f = find ( fnum , size ) ;
Fl_Font_Descriptor * f = find ( fnum , size ) ;
if ( f ! = fl_fontsize ) {
if ( f ! = fl_fontsize ) {
fl_fontsize = f ;
fl_fontsize = f ;
fl_xfont = f - > font ;
fl_xfont = current_ font - > fonts [ 0 ] ;
font_gc = 0 ;
font_gc = 0 ;
}
}
}
}
int fl_height ( ) {
int fl_height ( ) {
if ( fl_x font) return ( fl_x font- > ascent + fl_x font- > descent ) ;
if ( current_ font) return ( current_ font- > ascent + current_ font- > descent ) ;
else return - 1 ;
else return - 1 ;
}
}
int fl_descent ( ) {
int fl_descent ( ) {
if ( fl_xfont ) return fl_x font- > descent ;
if ( current_font ) return current_ font- > descent ;
else return - 1 ;
else return - 1 ;
}
}
double fl_width ( const char * c , int n ) {
double fl_width ( const char * c , int n ) {
if ( fl_x font) return ( double ) XUtf8TextWidth ( fl_x font, c , n ) ;
if ( current_ font) return ( double ) XUtf8TextWidth ( current_ font, c , n ) ;
else return - 1 ;
else return - 1 ;
}
}
double fl_width ( unsigned int c ) {
double fl_width ( unsigned int c ) {
if ( fl_x font) return ( double ) XUtf8UcsWidth ( fl_x font, c ) ;
if ( current_ font) return ( double ) XUtf8UcsWidth ( current_ font, c ) ;
else return - 1 ;
else return - 1 ;
}
}
@ -312,12 +320,12 @@ void fl_text_extents(const char *c, int n, int &dx, int &dy, int &W, int &H) {
void Fl_Device : : draw ( const char * c , int n , int x , int y ) {
void Fl_Device : : draw ( const char * c , int n , int x , int y ) {
if ( font_gc ! = fl_gc ) {
if ( font_gc ! = fl_gc ) {
if ( ! fl_x font) fl_font ( FL_HELVETICA , 14 ) ;
if ( ! current_ font) fl_font ( FL_HELVETICA , 14 ) ;
font_gc = fl_gc ;
font_gc = fl_gc ;
XSetFont ( fl_display , fl_gc , fl_x font- > fid ) ;
XSetFont ( fl_display , fl_gc , current_ font- > fid ) ;
}
}
// XDrawString(fl_display, fl_window, fl_gc, x, y, c, n);
// XDrawString(fl_display, fl_window, fl_gc, x, y, c, n);
XUtf8DrawString ( fl_display , fl_window , fl_x font, fl_gc , x , y , c , n ) ;
XUtf8DrawString ( fl_display , fl_window , current_ font, fl_gc , x , y , c , n ) ;
}
}
void Fl_Device : : draw ( int angle , const char * str , int n , int x , int y ) {
void Fl_Device : : draw ( int angle , const char * str , int n , int x , int y ) {
fprintf ( stderr , " ROTATING TEXT NOT IMPLIMENTED \n " ) ;
fprintf ( stderr , " ROTATING TEXT NOT IMPLIMENTED \n " ) ;
@ -329,10 +337,10 @@ void Fl_Device::draw(int angle, const char *str, int n, int x, int y) {
void fl_rtl_draw ( const char * c , int n , int x , int y ) {
void fl_rtl_draw ( const char * c , int n , int x , int y ) {
if ( font_gc ! = fl_gc ) {
if ( font_gc ! = fl_gc ) {
if ( ! fl_x font) fl_font ( FL_HELVETICA , 12 ) ;
if ( ! current_ font) fl_font ( FL_HELVETICA , 12 ) ;
font_gc = fl_gc ;
font_gc = fl_gc ;
}
}
XUtf8DrawRtlString ( fl_display , fl_window , fl_x font, fl_gc , x , y , c , n ) ;
XUtf8DrawRtlString ( fl_display , fl_window , current_ font, fl_gc , x , y , c , n ) ;
}
}
# endif // FL_DOXYGEN
# endif // FL_DOXYGEN
//
//