From: Andi C. S. <ski...@ya...> - 2012-06-15 11:18:03
|
--- On Sun, 6/10/12, Araki Ken <ara...@us...> wrote: > From: Araki Ken <ara...@us...> > Subject: Re: [Mlterm-dev-en] 3.1.0 crash > To: ski...@ya..., mlt...@li... > Date: Sunday, June 10, 2012, 10:01 PM > Hi, > > For now I fixed following two problems. > Please test the attached patch(for > mlterm-3.1.3pre-20120609.tar.gz). > > From: Andi Cristian Serbanescu <ski...@ya...> > Subject: Re: [Mlterm-dev-en] 3.1.0 crash > Date: Sat, 9 Jun 2012 08:29:58 -0700 (PDT) > Message-ID: <133...@we...> > > > > > 1. When modifying the character cell width, > for both > > > xft and core fonts, > > > > the glyph is shown at the very left of the > cell. > > > Shouldn't it be in the > > > > centre? It doesn't look very nice when the > cursor is > > > above it. > > > > > > I fixed. > > > > This one works only for core fonts. > > Do you specify the character cell width by the way like > "DEFAULT = FONTNAME:200" > in ~/.mlterm/font ? > I fixed the problem of this case. > (The previous fix centers characters if the character cell > width is specified > by "letter_space" option.) > Yes, that's how I was doing it (I didn't know about letter_space). It works now. Thanks > > > > 3. If you don't want the option I was talking > about > > > some time ago > > > > (although I hope you will change your mind in > the > > > future), can something > > > > be done to disable bold characters (like > xterm's > > > allowBoldFonts)? > > > > > > I added "use_bold_font" option. > > > Start mlterm with "--bdfont=false" option or > "use_bold_font > > > = false" in > > > ~/.mlterm/main, and bold fonts are disabled. > > > > > > > This one also disables bd_color along with bold fonts > (one may still > > want to represent the bold attributes by means of > colour, even if there > > will be only one font weight). > > Oops. I Fixed. > Works for me too. > Regards, > --- > Araki Ken > ara...@us... > > -----Inline Attachment Follows----- > > diff -r 0d4023fb9cab > xwindow/libtype/x_font_ft.c > --- a/xwindow/libtype/x_font_ft.c Sat Jun > 09 05:10:58 2012 +0900 > +++ b/xwindow/libtype/x_font_ft.c Mon Jun > 11 06:50:00 2012 +0900 > @@ -603,6 +603,10 @@ > > slant = -1 ; /* use > default value */ > > + /* > + * x_off related to percent is > set before ft_font_open while > + * x_off related to > is_vertical and letter_space is set after. > + */ > font->x_off = 0 ; > > if( fontname) > @@ -630,16 +634,30 @@ > { > > /* basic font (e.g. usascii) width */ > > + > /* if font->is_var_col_width is true, > 0 is returned. */ > > ch_width = get_fc_col_width( font , > fontsize_d , percent , > > > letter_space) ; > > + > if( percent > 100 && > use_xft) /* cairo ignores percent. */ > + > { > + > /* > + > * > Centering > + > * (fontsize > * percent / 100 + letter_space = ch_width > + > * > -> fontsize = (ch_width - letter_space) * 100 / percent > + > * > -> fontsize * (percent - 100) / 100 > + > * > = (ch_width - letter_space) * (percent - > 100) > + > * > / percent) > + > */ > + > font->x_off = > (ch_width - letter_space) * > + > > (percent - 100) / percent / 2 ; > + > } > + > > if( font->is_vertical) > > { > > /* > > * !! Notice > !! > > * The width > of full and half character font is the same. > > */ > - > font->x_off = > ch_width / 2 ; > > ch_width *= 2 ; > > } > } > @@ -677,6 +695,8 @@ > { > > goto font_found ; > } > + > + > font->x_off = 0 ; > } > > kik_msg_printf( "Font > %s (for size %f) couldn't be loaded.\n" , > @@ -695,7 +715,6 @@ > > * !! Notice !! > > * The width of full and half > character font is the same. > > */ > - > font->x_off = ch_width / 2 ; > > ch_width *= 2 ; > } > } > @@ -770,12 +789,15 @@ > else > { > > font->width = ch_width ; > - } > > - /* letter_space is > ignored in variable column width mode. */ > - if( ! > font->is_var_col_width) > - { > - > font->x_off += letter_space * font->cols / 2 ; > + > if( font->is_vertical && font->cols == 1) > + { > + > font->x_off += ch_width / 4 > ; /* Centering */ > + } > + > else > + { > + > font->x_off += letter_space * > font->cols / 2 ; > + } > } > > #endif /* USE_TYPE_XFT > */ > @@ -820,6 +842,7 @@ > { > > font->is_proportional = 1 ; > > font->width *= 2 ; > + > font->x_off = font->width / 4 > ; /* Centering */ > } > } > > @@ -828,7 +851,7 @@ > { > > font->is_proportional = 1 ; > > font->width += (letter_space * font->cols) ; > - > font->x_off += (letter_space * font->cols / 2) ; > + > font->x_off += (letter_space * font->cols / 2) ; > /* Centering */ > } > > if( col_width > 0 > /* is not usascii */ && ! font->is_proportional > && > diff -r 0d4023fb9cab xwindow/x_draw_str.c > --- a/xwindow/x_draw_str.c Sat Jun 09 > 05:10:58 2012 +0900 > +++ b/xwindow/x_draw_str.c Mon Jun 11 > 06:50:00 2012 +0900 > @@ -16,11 +16,11 @@ > x_color_manager_t * color_man , > ml_color_t fg_color , > ml_color_t bg_color , > - ml_font_t font , > + int is_bold , > int is_underlined > ) > { > - if( font & FONT_BOLD) > + if( is_bold) > { > /* If bg_color == > ML_FG_COLOR, it seems to be reversed. */ > if( ( fg_color == > ML_FG_COLOR || bg_color == ML_FG_COLOR) && > @@ -139,6 +139,7 @@ > u_int ch_width ; > mkf_charset_t ch_cs ; > x_font_t * xfont ; > + ml_font_t font ; > ml_color_t fg_color ; > ml_color_t bg_color ; > int is_underlined ; > @@ -146,6 +147,7 @@ > u_int comb_size ; > > x_font_t * next_xfont ; > + ml_font_t next_font ; > ml_color_t next_fg_color ; > ml_color_t next_bg_color ; > int next_is_underlined ; > @@ -178,7 +180,8 @@ > > ch_bytes = ml_char_bytes( > &chars[count]) ; > ch_size = ml_char_size( > &chars[count]) ; > - ch_cs = ml_char_cs( &chars[count]) > ; > + xfont = x_get_font( font_man , (font = > ml_char_font( &chars[count]))) ; > + ch_cs = FONT_CS(font) ; > > if( ch_cs == US_ASCII || ch_cs == > ISO8859_1_R || IS_ISCII(ch_cs)) > { > @@ -193,8 +196,6 @@ > state = 2 ; > } > > - xfont = x_get_font( font_man , > ml_char_font( &chars[count])) ; > - > ch_width = x_calculate_char_width( xfont > , ch_bytes , ch_size , ch_cs) ; > > if( ( current_width = x + ch_width) > > window->width || > @@ -228,11 +229,7 @@ > > while( 1) > { > - if( state == 0) > - { > - > str8[str_len++] = ch_bytes[0] ; > - } > - else if( state == 1) > + if( state == 0 || > state == 1) > { > > str8[str_len++] = ch_bytes[0] ; > } > @@ -277,11 +274,12 @@ > { > > ch_bytes = ml_char_bytes( &chars[count]) ; > > ch_size = ml_char_size( &chars[count]) ; > - > ch_cs = ml_char_cs( &chars[count]) ; > + > next_xfont = x_get_font( font_man , > + > (next_font = > ml_char_font( &chars[count]))) ; > + > ch_cs = FONT_CS(next_font) ; > > next_fg_color = ml_char_fg_color( &chars[count]) ; > > next_bg_color = ml_char_bg_color( &chars[count]) ; > > next_is_underlined = ml_char_is_underlined( > &chars[count]) ; > - > next_xfont = x_get_font( font_man , ml_char_font( > &chars[count])) ; > > > if( ch_cs == US_ASCII || ch_cs == ISO8859_1_R || > IS_ISCII(ch_cs)) > { > @@ -307,19 +305,26 @@ > > /* > > * !! Notice !! > > * next_xfont != xfont doesn't > necessarily detect change of 'state' > - > * (for example, same Unicode > font is used for both US_ASCII/ISO8859_1 > - > * and other half-width unicode > characters), 'next_state' is necessary. > + > * (for example, same Unicode > font is used for both US_ASCII and > + > * other half-width unicode > characters) and 'bold'(x_get_font() > + > * might substitute normal > fonts for bold ones), 'next_state' and > + > * 'font & FONT_BOLD' is > necessary. > > */ > > else if( next_xfont != xfont > > || next_fg_color != fg_color > > || next_bg_color != bg_color > > || next_is_underlined != is_underlined > + > /* > + > * Eevn if both is_underline > and next_is_underline are 1, > + > * underline is drawn one by > one in vertical mode. > + > */ > > || (is_underlined && > xfont->is_vertical) > - > || (next_is_underlined && > xfont->is_vertical) > > || comb_chars != NULL > > || state != next_state > > || (next_xfont->is_proportional > && ! next_xfont->is_var_col_width) > - > || (xfont->is_proportional && > ! xfont->is_var_col_width)) > + > || (xfont->is_proportional && > ! xfont->is_var_col_width) > + > /* FONT_BOLD flag is not the same. */ > + > || ((font ^ next_font) & > FONT_BOLD)) > { > > start_draw = 1 ; > } > @@ -342,7 +347,7 @@ > #endif > > > color_adjusted = adjust_bd_ul_color( color_man , fg_color , > bg_color , > - > > xfont->id , is_underlined) ; > + > > font & FONT_BOLD , is_underlined) ; > > > /* > > * clearing background > @@ -444,6 +449,7 @@ > > is_underlined = > next_is_underlined ; > xfont = next_xfont ; > + font = next_font ; > fg_color = > next_fg_color ; > bg_color = > next_bg_color ; > state = next_state ; > @@ -578,12 +584,14 @@ > mkf_charset_t ch_cs ; > u_int ch_width ; > x_font_t * xfont ; > + ml_font_t font ; > ml_color_t fg_color ; > ml_color_t bg_color ; > int is_underlined ; > > u_int next_ch_width ; > x_font_t * next_xfont ; > + ml_font_t next_font ; > ml_color_t next_fg_color ; > ml_color_t next_bg_color ; > int next_is_underlined ; > @@ -617,7 +625,7 @@ > ch_size = ml_char_size( > &chars[count]) ; > ch_cs = ml_char_cs( &chars[count]) > ; > > - xfont = x_get_font( font_man , > ml_char_font( &chars[count])) ; > + xfont = x_get_font( font_man , (font = > ml_char_font( &chars[count]))) ; > > ch_width = x_calculate_char_width( xfont > , ch_bytes , ch_size , ch_cs) ; > > @@ -727,7 +735,8 @@ > > next_fg_color = ml_char_fg_color( &chars[count]) ; > > next_bg_color = ml_char_bg_color( &chars[count]) ; > > next_is_underlined = ml_char_is_underlined( > &chars[count]) ; > - > next_xfont = x_get_font( font_man , ml_char_font( > &chars[count])) ; > + > next_xfont = x_get_font( font_man , > + > (next_font = > ml_char_font( &chars[count]))) ; > > > if( ch_cs == DEC_SPECIAL) > { > @@ -753,19 +762,26 @@ > > /* > > * !! Notice !! > > * next_xfont != xfont doesn't > necessarily detect change of 'state' > - > * (for example, same Unicode > font is used for both US_ASCII/ISO8859_1 > - > * and other half-width unicode > characters), 'next_state' is necessary. > + > * (for example, same Unicode > font is used for both US_ASCII and > + > * other half-width unicode > characters) and 'bold'(x_get_font() > + > * might substitute normal > fonts for bold ones), 'next_state' and > + > * 'font & FONT_BOLD' is > necessary. > > */ > > else if( next_xfont != xfont > > || next_fg_color != fg_color > > || next_bg_color != bg_color > > || next_is_underlined != is_underlined > + > /* > + > * Eevn if both is_underline > and next_is_underline are 1, > + > * underline is drawn one by > one in vertical mode. > + > */ > > || (is_underlined && > xfont->is_vertical) > - > || (next_is_underlined && > xfont->is_vertical) > > || next_state != state > > || comb_chars != NULL > > || (next_xfont->is_proportional > && ! next_xfont->is_var_col_width) > - > || (xfont->is_proportional && > ! xfont->is_var_col_width)) > + > || (xfont->is_proportional && > ! xfont->is_var_col_width) > + > /* FONT_BOLD flag is not the same */ > + > || ((font ^ next_font) & > FONT_BOLD)) > { > > start_draw = 1 ; > } > @@ -788,7 +804,7 @@ > #endif > > > color_adjusted = adjust_bd_ul_color( color_man , fg_color , > bg_color , > - > > xfont->id , is_underlined) ; > + > > font & FONT_BOLD , is_underlined) ; > > > if( ( x_window_has_wall_picture( window) && bg_color > == ML_BG_COLOR) || > > bottom_margin + top_margin > 0 /* == > line space XXX */|| > @@ -916,6 +932,7 @@ > } > > xfont = next_xfont ; > + font = next_font ; > fg_color = > next_fg_color ; > bg_color = > next_bg_color ; > is_underlined = > next_is_underlined ; > diff -r 0d4023fb9cab xwindow/x_font_config.c > --- a/xwindow/x_font_config.c Sat Jun 09 > 05:10:58 2012 +0900 > +++ b/xwindow/x_font_config.c Mon Jun 11 > 06:50:00 2012 +0900 > @@ -1731,7 +1731,6 @@ > char * font_name ; > char * encoding_name ; > int has_percentd ; > - size_t len ; > > if( font_size < min_font_size || > max_font_size < font_size) > { > @@ -1756,7 +1755,9 @@ > } > > #ifndef USE_WIN32GUI > - if( > font_config->type_engine == TYPE_XCORE) > + if( > font_config->type_engine == TYPE_XCORE && > + /* > encoding_name is appended if font_name is XLFD (not alias > name). */ > + ( > strchr( pair->value , '*') || strchr( pair->value , > '-'))) > { > > char ** names ; > > @@ -1789,13 +1790,11 @@ > has_percentd = 0 ; > } > > - len = strlen( pair->value) + > - /* -2 is for "%d" */ > - (has_percentd ? > DIGIT_STR_LEN(font_size) - 2 : 0) + > - /* + 1 is for > "-" */ > - (encoding_name ? > strlen(encoding_name) + 1 : 0) + 1 ; > - > - if( ( font_name = malloc( len)) == > NULL) > + if( ! ( font_name = malloc( strlen( > pair->value) + > + > /* -2 is for "%d" */ > + > (has_percentd ? DIGIT_STR_LEN(font_size) > - 2 : 0) + > + > /* + 1 is for "-" */ > + > (encoding_name ? strlen(encoding_name) + > 1 : 0) + 1))) > { > return NULL ; > } > @@ -1811,7 +1810,22 @@ > > if( encoding_name) > { > - strcat( font_name , > encoding_name) ; > + char * percent > ; > + > + if( ( percent = > strchr( font_name , ':'))) > + { > + /* > -*-:200 -> -*-iso8859-1:200 */ > + > + > size_t len ; > + > + > memmove( percent + (len = strlen(encoding_name)) , percent > , > + > strlen( percent) + 1) ; > + > memcpy( percent , encoding_name , len) ; > + } > + else > + { > + > strcat( font_name , encoding_name) ; > + } > } > > return font_name ; > diff -r 0d4023fb9cab xwindow/xlib/x_font.c > --- a/xwindow/xlib/x_font.c Sat Jun 09 > 05:10:58 2012 +0900 > +++ b/xwindow/xlib/x_font.c Mon Jun 11 > 06:50:00 2012 +0900 > @@ -477,8 +477,9 @@ > > if( parse_xfont_name( > &font_xlfd , &percent_str , p)) > { > - #ifdef __DEBUG > - > kik_debug_printf( KIK_DEBUG_TAG " loading %s font.\n" , > font_xlfd) ; > + #ifdef __DEBUG > + > kik_debug_printf( KIK_DEBUG_TAG " loading %s font (%s > percent).\n" , > + > font_xlfd , percent_str) ; > #endif > > > if( ( xfont = XLoadQueryFont( font->display , > font_xlfd))) > @@ -770,6 +771,10 @@ > > > if( font->width != col_width) > { > + > kik_msg_printf( "Font(id %x) width(%d) is > not matched with " > + > "standard > width(%d).\n" , > + > font->id , > font->width , col_width) ; > + > > font->is_proportional = 1 ; > > > /* is_var_col_width is always false if > is_vertical is true. */ > |