From f58d5dc904e7ac3e2fe6462bad48c659626a353c Mon Sep 17 00:00:00 2001 From: Vladislav Zavjalov Date: Fri, 8 Jan 2021 10:45:38 +0000 Subject: [PATCH 2/5] fix font encoding in i18n mode --- xfig/src/w_drawprim.c | 65 +++++++++++++++---------------------------- 1 file changed, 22 insertions(+), 43 deletions(-) diff --git a/xfig/src/w_drawprim.c b/xfig/src/w_drawprim.c index 8834d3a..6440d2f 100644 --- a/xfig/src/w_drawprim.c +++ b/xfig/src/w_drawprim.c @@ -85,6 +85,23 @@ void zXDrawLines (Display *d, Window w, GC gc, zXPoint *points, int n, int coord void scale_pattern (int indx); int SutherlandHodgmanPolygoClip (XPoint *inVertices, XPoint *outVertices, int inLength, int x1, int y1, int x2, int y2); +/* add ISO8859 (if not Symbol font or ZapfDingbats) to font name in non-international mode*/ +void +font_add_enc(const char *template){ + if (strstr(template,"ymbol") != NULL || + strstr(template,"ingbats") != NULL){ + strcat(template,"*-*"); + return; + } +#ifdef I18N + if (appres.international){ + strcat(template,"iso10646-1"); + return; + } +#endif + strcat(template,"ISO8859-*"); +} + void init_font(void) { struct xfont *newfont, *nf; @@ -147,16 +164,7 @@ void init_font(void) for (f = 0; f < NUM_FONTS; f++) { strcpy(template,x_fontinfo[f].template); /* nope, check for font size 0 */ strcat(template,"0-0-*-*-*-*-"); - /* add ISO8859 (if not Symbol font or ZapfDingbats) to font name in non-international mode*/ - if ( -#ifdef I18N - !appres.international && -#endif - strstr(template,"ymbol") == NULL && - strstr(template,"ingbats") == NULL) - strcat(template,"ISO8859-*"); - else - strcat(template,"*-*"); + font_add_enc(template); if ((fontlist = XListFonts(tool_d, template, 1, &count))){ if (appres.DEBUG) @@ -183,19 +191,8 @@ void init_font(void) strcat(template,"*-*-*-*-*-*-"); strcpy(backup_template,x_backup_fontinfo[f].template); strcat(backup_template,"*-*-*-*-*-*-"); - /* add ISO8859 (if not Symbol font or ZapfDingbats) to font name in non-international mode*/ - if ( -#ifdef I18N - !appres.international && -#endif - strstr(template,"ymbol") == NULL && - strstr(template,"ingbats") == NULL) { - strcat(template,"ISO8859-*"); - strcat(backup_template,"ISO8859-*"); - } else { - strcat(template,"*-*"); - strcat(backup_template,"*-*"); - } + font_add_enc(template); + font_add_enc(backup_template); /* don't free the Fontlist because we keep pointers into it */ p = 0; @@ -353,32 +350,14 @@ lookfont(int fnum, int size) strcpy(template,x_fontinfo[fnum].template); /* attach pointsize to font name */ strcat(template,"%d-*-*-*-*-*-"); - /* add ISO8859 (if not Symbol font or ZapfDingbats) to font name in non-international mode */ - if ( -#ifdef I18N - !appres.international && -#endif - strstr(template,"ymbol") == NULL && - strstr(template,"ingbats") == NULL) - strcat(template,"ISO8859-*"); - else - strcat(template,"*-*"); + font_add_enc(template); /* use the pixel field instead of points in the fontname so that the font scales with screen size */ sprintf(fn, template, size); /* do same process with backup font name in case first doesn't exist */ strcpy(template,x_backup_fontinfo[fnum].template); strcat(template,"%d-*-*-*-*-*-"); - /* add ISO8859 (if not Symbol font or ZapfDingbats) to font name in non-international mode */ - if ( -#ifdef I18N - !appres.international && -#endif - strstr(template,"ymbol") == NULL && - strstr(template,"ingbats") == NULL) - strcat(template,"ISO8859-*"); - else - strcat(template,"*-*"); + font_add_enc(template); sprintf(back_fn, template, size); } /* allocate space for the name and put it in the structure */ -- 2.24.1