Re: Compose window patch



Hi,

My previous patch for different charsets in the balse compose window had
hard-coded font wildcard, effectively disabling the Michael Johnson's fix
(that read the font name from the preferences). Here comes short fix, that
enables to use both dynamically changed charset and setting the font
wildcard in preferences.
apply with patch -p1

Pawel

178,180c178
< /* the same sequence as in iso_charset_menu; the array stores charset name
<    included in the MIME type information.
<  */
---
> /* the same sequence as in iso_charset_menu */
1527,1580d1524
< /* create_font_name returns iso8859 font name based on given font 
<    wildcard 'base' and given charmap (PS: verify the name).
<    Algorithm: copy max first 12 fields, cutting additionally 
<    at most two last, if they are constant.
< */
< /* the name should really be one_or_two_const_fields_to_end */
< static gint 
< two_const_fields_to_end(const gchar* ptr) {
<    int cnt = 0;
<    while(*ptr && cnt<3) {
<       if(*ptr   == '*') return 0;
<       if(*ptr++ == '-') cnt++;
<    }
<    return cnt<3;
< }
< 
< static gchar* 
< get_font_name(const gchar* base, int code) {
<    static gchar type[] ="iso8859";
<    //g_snprintf(font_name,sizeof(font_name),"%s-%d",base_mask,code);
<    gchar *res;
<    const gchar* ptr = base;
<    int dash_cnt = 0, len;
< 
<    g_return_val_if_fail(base != NULL, NULL);
<    g_return_val_if_fail(code >= 0,    NULL);
< 
<    while(*ptr && dash_cnt<13) {
<       if(*ptr == '-') dash_cnt++;
<       
<       if(two_const_fields_to_end(ptr)) break;
<       ptr++;
<    }
< 
<    // defense against a patologically short base font wildcard implemented
<    // in the chunk below
<    // extra space for dwo dashes and '\0'
<    len = ptr-base;
<    if(dash_cnt>12) len--;
<    if(len<1) len = 1;
<    res = (gchar*)g_malloc(len+sizeof(type)+3+(code>9?2:1));
<    if(balsa_app.debug)
<       fprintf(stderr,"base font name: %s and code :%d\n"
< 	      "mallocating %d bytes\n", base, code,
< 	      len+sizeof(type)+2+(code>9?2:1) );
< 
<    if(len>1) strncpy(res, base, len);
<    else { strncpy(res, "*", 1); len = 1; } 
< 
<    sprintf(res+len,"-%s-%d", type, code);
<    return res;
< }   
< 
< 
1589,1591c1533,1535
< 
< static gint 
< iso_font_set(BalsaSendmsg *msg, gint code, gint idx) {
---
> static gint iso_font_set(BalsaSendmsg *msg, gint code, gint idx) {
> static const char base_mask[] = 
>    "-*-fixed-medium-r-normal--14-*-*-*-c-*-iso8859";
1593c1537
<    gchar* str, *font_name;
---
>    gchar* str;
1594a1539
>    gchar font_name[sizeof(base_mask)+10]; 
1600a1546
>    g_snprintf(font_name,sizeof(font_name),"%s-%d",base_mask,code);
1602d1547
<    font_name = get_font_name(balsa_app.message_font, code);
1606d1550
<       g_free(font_name);
1612,1613d1555
<    g_free(font_name);
<    


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]