comparison src/gui_w48.c @ 5714:22d7af9ff3e5 v7.4.202

updated for version 7.4.202 Problem: MS-Windows: non-ASCII font names don't work. Solution: Convert between the current code page and 'encoding'. (Ken Takata)
author Bram Moolenaar <bram@vim.org>
date Wed, 12 Mar 2014 19:24:37 +0100
parents 5481f188dcbb
children 7e826028d399
comparison
equal deleted inserted replaced
5713:7f6acd6dc5b3 5714:22d7af9ff3e5
3067 logfont2name(LOGFONT lf) 3067 logfont2name(LOGFONT lf)
3068 { 3068 {
3069 char *p; 3069 char *p;
3070 char *res; 3070 char *res;
3071 char *charset_name; 3071 char *charset_name;
3072 char *font_name = lf.lfFaceName;
3072 3073
3073 charset_name = charset_id2name((int)lf.lfCharSet); 3074 charset_name = charset_id2name((int)lf.lfCharSet);
3074 res = alloc((unsigned)(strlen(lf.lfFaceName) + 20 3075 #ifdef FEAT_MBYTE
3076 /* Convert a font name from the current codepage to 'encoding'.
3077 * TODO: Use Wide APIs (including LOGFONTW) instead of ANSI APIs. */
3078 if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
3079 {
3080 int len;
3081 acp_to_enc(lf.lfFaceName, strlen(lf.lfFaceName),
3082 (char_u **)&font_name, &len);
3083 }
3084 #endif
3085 res = alloc((unsigned)(strlen(font_name) + 20
3075 + (charset_name == NULL ? 0 : strlen(charset_name) + 2))); 3086 + (charset_name == NULL ? 0 : strlen(charset_name) + 2)));
3076 if (res != NULL) 3087 if (res != NULL)
3077 { 3088 {
3078 p = res; 3089 p = res;
3079 /* make a normal font string out of the lf thing:*/ 3090 /* make a normal font string out of the lf thing:*/
3080 sprintf((char *)p, "%s:h%d", lf.lfFaceName, pixels_to_points( 3091 sprintf((char *)p, "%s:h%d", font_name, pixels_to_points(
3081 lf.lfHeight < 0 ? -lf.lfHeight : lf.lfHeight, TRUE)); 3092 lf.lfHeight < 0 ? -lf.lfHeight : lf.lfHeight, TRUE));
3082 while (*p) 3093 while (*p)
3083 { 3094 {
3084 if (*p == ' ') 3095 if (*p == ' ')
3085 *p = '_'; 3096 *p = '_';
3100 STRCAT(p, ":c"); 3111 STRCAT(p, ":c");
3101 STRCAT(p, charset_name); 3112 STRCAT(p, charset_name);
3102 } 3113 }
3103 } 3114 }
3104 3115
3116 #ifdef FEAT_MBYTE
3117 if (font_name != lf.lfFaceName)
3118 vim_free(font_name);
3119 #endif
3105 return res; 3120 return res;
3106 } 3121 }
3107 3122
3108 3123
3109 #ifdef FEAT_MBYTE_IME 3124 #ifdef FEAT_MBYTE_IME