Mercurial > vim
comparison src/os_mswin.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 | 6b69d8dde19e |
children | 7e826028d399 |
comparison
equal
deleted
inserted
replaced
5713:7f6acd6dc5b3 | 5714:22d7af9ff3e5 |
---|---|
2865 HDC printer_dc, | 2865 HDC printer_dc, |
2866 int verbose) | 2866 int verbose) |
2867 { | 2867 { |
2868 char_u *p; | 2868 char_u *p; |
2869 int i; | 2869 int i; |
2870 int ret = FAIL; | |
2870 static LOGFONT *lastlf = NULL; | 2871 static LOGFONT *lastlf = NULL; |
2872 #ifdef FEAT_MBYTE | |
2873 char_u *acpname = NULL; | |
2874 #endif | |
2871 | 2875 |
2872 *lf = s_lfDefault; | 2876 *lf = s_lfDefault; |
2873 if (name == NULL) | 2877 if (name == NULL) |
2874 return OK; | 2878 return OK; |
2875 | 2879 |
2880 #ifdef FEAT_MBYTE | |
2881 /* Convert 'name' from 'encoding' to the current codepage, because | |
2882 * lf->lfFaceName uses the current codepage. | |
2883 * TODO: Use Wide APIs instead of ANSI APIs. */ | |
2884 if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) | |
2885 { | |
2886 int len; | |
2887 enc_to_acp(name, strlen(name), &acpname, &len); | |
2888 name = acpname; | |
2889 } | |
2890 #endif | |
2876 if (STRCMP(name, "*") == 0) | 2891 if (STRCMP(name, "*") == 0) |
2877 { | 2892 { |
2878 #if defined(FEAT_GUI_W32) | 2893 #if defined(FEAT_GUI_W32) |
2879 CHOOSEFONT cf; | 2894 CHOOSEFONT cf; |
2880 /* if name is "*", bring up std font dialog: */ | 2895 /* if name is "*", bring up std font dialog: */ |
2885 if (lastlf != NULL) | 2900 if (lastlf != NULL) |
2886 *lf = *lastlf; | 2901 *lf = *lastlf; |
2887 cf.lpLogFont = lf; | 2902 cf.lpLogFont = lf; |
2888 cf.nFontType = 0 ; //REGULAR_FONTTYPE; | 2903 cf.nFontType = 0 ; //REGULAR_FONTTYPE; |
2889 if (ChooseFont(&cf)) | 2904 if (ChooseFont(&cf)) |
2890 goto theend; | 2905 ret = OK; |
2891 #else | 2906 #endif |
2892 return FAIL; | 2907 goto theend; |
2893 #endif | |
2894 } | 2908 } |
2895 | 2909 |
2896 /* | 2910 /* |
2897 * Split name up, it could be <name>:h<height>:w<width> etc. | 2911 * Split name up, it could be <name>:h<height>:w<width> etc. |
2898 */ | 2912 */ |
2899 for (p = name; *p && *p != ':'; p++) | 2913 for (p = name; *p && *p != ':'; p++) |
2900 { | 2914 { |
2901 if (p - name + 1 > LF_FACESIZE) | 2915 if (p - name + 1 > LF_FACESIZE) |
2902 return FAIL; /* Name too long */ | 2916 goto theend; /* Name too long */ |
2903 lf->lfFaceName[p - name] = *p; | 2917 lf->lfFaceName[p - name] = *p; |
2904 } | 2918 } |
2905 if (p != name) | 2919 if (p != name) |
2906 lf->lfFaceName[p - name] = NUL; | 2920 lf->lfFaceName[p - name] = NUL; |
2907 | 2921 |
2925 { | 2939 { |
2926 lf->lfFaceName[i] = ' '; | 2940 lf->lfFaceName[i] = ' '; |
2927 did_replace = TRUE; | 2941 did_replace = TRUE; |
2928 } | 2942 } |
2929 if (!did_replace || init_logfont(lf) == FAIL) | 2943 if (!did_replace || init_logfont(lf) == FAIL) |
2930 return FAIL; | 2944 goto theend; |
2931 } | 2945 } |
2932 | 2946 |
2933 while (*p == ':') | 2947 while (*p == ':') |
2934 p++; | 2948 p++; |
2935 | 2949 |
2986 vim_snprintf((char *)IObuff, IOSIZE, | 3000 vim_snprintf((char *)IObuff, IOSIZE, |
2987 _("E245: Illegal char '%c' in font name \"%s\""), | 3001 _("E245: Illegal char '%c' in font name \"%s\""), |
2988 p[-1], name); | 3002 p[-1], name); |
2989 EMSG(IObuff); | 3003 EMSG(IObuff); |
2990 } | 3004 } |
2991 return FAIL; | 3005 goto theend; |
2992 } | 3006 } |
2993 while (*p == ':') | 3007 while (*p == ':') |
2994 p++; | 3008 p++; |
2995 } | 3009 } |
2996 | 3010 ret = OK; |
2997 #if defined(FEAT_GUI_W32) | 3011 |
2998 theend: | 3012 theend: |
2999 #endif | |
3000 /* ron: init lastlf */ | 3013 /* ron: init lastlf */ |
3001 if (printer_dc == NULL) | 3014 if (ret == OK && printer_dc == NULL) |
3002 { | 3015 { |
3003 vim_free(lastlf); | 3016 vim_free(lastlf); |
3004 lastlf = (LOGFONT *)alloc(sizeof(LOGFONT)); | 3017 lastlf = (LOGFONT *)alloc(sizeof(LOGFONT)); |
3005 if (lastlf != NULL) | 3018 if (lastlf != NULL) |
3006 mch_memmove(lastlf, lf, sizeof(LOGFONT)); | 3019 mch_memmove(lastlf, lf, sizeof(LOGFONT)); |
3007 } | 3020 } |
3008 | 3021 #ifdef FEAT_MBYTE |
3009 return OK; | 3022 vim_free(acpname); |
3023 #endif | |
3024 | |
3025 return ret; | |
3010 } | 3026 } |
3011 | 3027 |
3012 #endif /* defined(FEAT_GUI) || defined(FEAT_PRINTER) */ | 3028 #endif /* defined(FEAT_GUI) || defined(FEAT_PRINTER) */ |