comparison src/os_mswin.c @ 37:fdf55076c53f

updated for version 7.0022
author vimboss
date Sun, 12 Dec 2004 11:33:30 +0000
parents 404aac550f35
children 410fa1a31baf
comparison
equal deleted inserted replaced
36:125e80798a85 37:fdf55076c53f
2094 2094
2095 /* 2095 /*
2096 * Initialise the font according to 'printfont' 2096 * Initialise the font according to 'printfont'
2097 */ 2097 */
2098 memset(&fLogFont, 0, sizeof(fLogFont)); 2098 memset(&fLogFont, 0, sizeof(fLogFont));
2099 if (!get_logfont(&fLogFont, p_pfn, prt_dlg.hDC)) 2099 if (get_logfont(&fLogFont, p_pfn, prt_dlg.hDC, TRUE) == FAIL)
2100 { 2100 {
2101 EMSG2(_("E613: Unknown printer font: %s"), p_pfn); 2101 EMSG2(_("E613: Unknown printer font: %s"), p_pfn);
2102 mch_print_cleanup(); 2102 mch_print_cleanup();
2103 return FALSE; 2103 return FALSE;
2104 } 2104 }
3159 3159
3160 /* Return success */ 3160 /* Return success */
3161 return OK; 3161 return OK;
3162 } 3162 }
3163 3163
3164 /*
3165 * Get font info from "name" into logfont "lf".
3166 * Return OK for a valid name, FAIL otherwise.
3167 */
3164 int 3168 int
3165 get_logfont( 3169 get_logfont(
3166 LOGFONT *lf, 3170 LOGFONT *lf,
3167 char_u *name, 3171 char_u *name,
3168 HDC printer_dc) 3172 HDC printer_dc,
3173 int verbose)
3169 { 3174 {
3170 char_u *p; 3175 char_u *p;
3171 int i; 3176 int i;
3172 static LOGFONT *lastlf = NULL; 3177 static LOGFONT *lastlf = NULL;
3173 3178
3174 *lf = s_lfDefault; 3179 *lf = s_lfDefault;
3175 if (name == NULL) 3180 if (name == NULL)
3176 return 1; 3181 return OK;
3177 3182
3178 if (STRCMP(name, "*") == 0) 3183 if (STRCMP(name, "*") == 0)
3179 { 3184 {
3180 #if defined(FEAT_GUI_W32) 3185 #if defined(FEAT_GUI_W32)
3181 CHOOSEFONT cf; 3186 CHOOSEFONT cf;
3189 cf.lpLogFont = lf; 3194 cf.lpLogFont = lf;
3190 cf.nFontType = 0 ; //REGULAR_FONTTYPE; 3195 cf.nFontType = 0 ; //REGULAR_FONTTYPE;
3191 if (ChooseFont(&cf)) 3196 if (ChooseFont(&cf))
3192 goto theend; 3197 goto theend;
3193 #else 3198 #else
3194 return 0; 3199 return FAIL;
3195 #endif 3200 #endif
3196 } 3201 }
3197 3202
3198 /* 3203 /*
3199 * Split name up, it could be <name>:h<height>:w<width> etc. 3204 * Split name up, it could be <name>:h<height>:w<width> etc.
3200 */ 3205 */
3201 for (p = name; *p && *p != ':'; p++) 3206 for (p = name; *p && *p != ':'; p++)
3202 { 3207 {
3203 if (p - name + 1 > LF_FACESIZE) 3208 if (p - name + 1 > LF_FACESIZE)
3204 return 0; /* Name too long */ 3209 return FAIL; /* Name too long */
3205 lf->lfFaceName[p - name] = *p; 3210 lf->lfFaceName[p - name] = *p;
3206 } 3211 }
3207 if (p != name) 3212 if (p != name)
3208 lf->lfFaceName[p - name] = NUL; 3213 lf->lfFaceName[p - name] = NUL;
3209 3214
3227 { 3232 {
3228 lf->lfFaceName[i] = ' '; 3233 lf->lfFaceName[i] = ' ';
3229 did_replace = TRUE; 3234 did_replace = TRUE;
3230 } 3235 }
3231 if (!did_replace || init_logfont(lf) == FAIL) 3236 if (!did_replace || init_logfont(lf) == FAIL)
3232 return 0; 3237 return FAIL;
3233 } 3238 }
3234 3239
3235 while (*p == ':') 3240 while (*p == ':')
3236 p++; 3241 p++;
3237 3242
3271 { 3276 {
3272 lf->lfCharSet = cp->charset; 3277 lf->lfCharSet = cp->charset;
3273 p += strlen(cp->name); 3278 p += strlen(cp->name);
3274 break; 3279 break;
3275 } 3280 }
3276 if (cp->name == NULL) 3281 if (cp->name == NULL && verbose)
3277 { 3282 {
3278 sprintf((char *)IObuff, _("E244: Illegal charset name \"%s\" in font name \"%s\""), p, name); 3283 sprintf((char *)IObuff, _("E244: Illegal charset name \"%s\" in font name \"%s\""), p, name);
3279 EMSG(IObuff); 3284 EMSG(IObuff);
3280 break; 3285 break;
3281 } 3286 }
3282 break; 3287 break;
3283 } 3288 }
3284 default: 3289 default:
3285 sprintf((char *)IObuff, 3290 if (verbose)
3286 _("E245: Illegal char '%c' in font name \"%s\""), 3291 {
3287 p[-1], name); 3292 sprintf((char *)IObuff,
3288 EMSG(IObuff); 3293 _("E245: Illegal char '%c' in font name \"%s\""),
3289 break; 3294 p[-1], name);
3295 EMSG(IObuff);
3296 }
3297 return FAIL;
3290 } 3298 }
3291 while (*p == ':') 3299 while (*p == ':')
3292 p++; 3300 p++;
3293 } 3301 }
3294 3302
3302 lastlf = (LOGFONT *)alloc(sizeof(LOGFONT)); 3310 lastlf = (LOGFONT *)alloc(sizeof(LOGFONT));
3303 if (lastlf != NULL) 3311 if (lastlf != NULL)
3304 mch_memmove(lastlf, lf, sizeof(LOGFONT)); 3312 mch_memmove(lastlf, lf, sizeof(LOGFONT));
3305 } 3313 }
3306 3314
3307 return 1; 3315 return OK;
3308 } 3316 }
3309 3317
3310 #endif /* defined(FEAT_GUI) || defined(FEAT_PRINTER) */ 3318 #endif /* defined(FEAT_GUI) || defined(FEAT_PRINTER) */