Mercurial > emacs
comparison src/ftfont.c @ 90480:908d27653432
(ftfont_list): Use assq_no_quit, not Fassq. Don't
include weight in listing pattern, instead check weight of each
listed font. Don't include scalable in pattern. Pay attention to
FONT_PIXEL_SIZE_QUANTUM.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Mon, 19 Jun 2006 12:36:58 +0000 |
parents | 8627c9321afb |
children | 60e0667ab709 |
comparison
equal
deleted
inserted
replaced
90479:e507e2cc7f5e | 90480:908d27653432 |
---|---|
309 FcCharSet *charset = NULL; | 309 FcCharSet *charset = NULL; |
310 FcLangSet *langset = NULL; | 310 FcLangSet *langset = NULL; |
311 FcFontSet *fontset = NULL; | 311 FcFontSet *fontset = NULL; |
312 FcObjectSet *objset = NULL; | 312 FcObjectSet *objset = NULL; |
313 Lisp_Object registry = Qunicode_bmp; | 313 Lisp_Object registry = Qunicode_bmp; |
314 int weight = 0; | |
314 | 315 |
315 val = null_vector; | 316 val = null_vector; |
316 | 317 |
317 if (! fc_initialized) | 318 if (! fc_initialized) |
318 { | 319 { |
319 FcInit (); | 320 FcInit (); |
320 fc_initialized = 1; | 321 fc_initialized = 1; |
321 } | 322 } |
322 | 323 |
323 if (! NILP (AREF (spec, FONT_ADSTYLE_INDEX))) | 324 if (! NILP (AREF (spec, FONT_ADSTYLE_INDEX)) |
325 && ! EQ (AREF (spec, FONT_ADSTYLE_INDEX), null_string)) | |
324 return val; | 326 return val; |
327 if (! NILP (AREF (spec, FONT_SLANT_INDEX)) | |
328 && XINT (AREF (spec, FONT_SLANT_INDEX)) < 100) | |
329 /* Fontconfig doesn't support reverse-italic/obligue. */ | |
330 return val; | |
331 | |
325 if (! NILP (AREF (spec, FONT_REGISTRY_INDEX))) | 332 if (! NILP (AREF (spec, FONT_REGISTRY_INDEX))) |
326 { | 333 { |
327 registry = AREF (spec, FONT_REGISTRY_INDEX); | 334 registry = AREF (spec, FONT_REGISTRY_INDEX); |
328 if (EQ (registry, Qiso8859_1)) | 335 if (EQ (registry, Qiso8859_1)) |
329 { | 336 { |
338 | 345 |
339 extra = AREF (spec, FONT_EXTRA_INDEX); | 346 extra = AREF (spec, FONT_EXTRA_INDEX); |
340 font_name = Qnil; | 347 font_name = Qnil; |
341 if (CONSP (extra)) | 348 if (CONSP (extra)) |
342 { | 349 { |
343 tmp = Fassq (QCotf, extra); | 350 tmp = assq_no_quit (QCotf, extra); |
344 if (! NILP (tmp)) | 351 if (! NILP (tmp)) |
345 return val; | 352 return val; |
346 tmp = Fassq (QClanguage, extra); | 353 tmp = assq_no_quit (QClanguage, extra); |
347 if (CONSP (tmp)) | 354 if (CONSP (tmp)) |
348 { | 355 { |
349 langset = FcLangSetCreate (); | 356 langset = FcLangSetCreate (); |
350 if (! langset) | 357 if (! langset) |
351 goto err; | 358 goto err; |
365 } | 372 } |
366 } | 373 } |
367 tmp = Fassq (QCname, extra); | 374 tmp = Fassq (QCname, extra); |
368 if (CONSP (tmp)) | 375 if (CONSP (tmp)) |
369 font_name = XCDR (tmp); | 376 font_name = XCDR (tmp); |
370 tmp = Fassq (QCscript, extra); | 377 tmp = assq_no_quit (QCscript, extra); |
371 if (CONSP (tmp) && ! charset) | 378 if (CONSP (tmp) && ! charset) |
372 { | 379 { |
373 Lisp_Object script = XCDR (tmp); | 380 Lisp_Object script = XCDR (tmp); |
374 Lisp_Object chars = assq_no_quit (script, | 381 Lisp_Object chars = assq_no_quit (script, |
375 Vscript_representative_chars); | 382 Vscript_representative_chars); |
386 } | 393 } |
387 } | 394 } |
388 } | 395 } |
389 | 396 |
390 if (STRINGP (font_name)) | 397 if (STRINGP (font_name)) |
391 { | 398 pattern = FcNameParse (SDATA (font_name)); |
392 pattern = FcNameParse (SDATA (font_name)); | |
393 /* Ignore these values in listing. */ | |
394 FcPatternDel (pattern, FC_PIXEL_SIZE); | |
395 FcPatternDel (pattern, FC_SIZE); | |
396 FcPatternDel (pattern, FC_FAMILY); | |
397 } | |
398 else | 399 else |
399 pattern = FcPatternCreate (); | 400 pattern = FcPatternCreate (); |
400 if (! pattern) | 401 if (! pattern) |
401 goto err; | 402 goto err; |
402 | 403 |
406 goto err; | 407 goto err; |
407 tmp = AREF (spec, FONT_FAMILY_INDEX); | 408 tmp = AREF (spec, FONT_FAMILY_INDEX); |
408 if (SYMBOLP (tmp) && ! NILP (tmp) | 409 if (SYMBOLP (tmp) && ! NILP (tmp) |
409 && ! FcPatternAddString (pattern, FC_FAMILY, SYMBOL_FcChar8 (tmp))) | 410 && ! FcPatternAddString (pattern, FC_FAMILY, SYMBOL_FcChar8 (tmp))) |
410 goto err; | 411 goto err; |
412 /* Emacs conventionally doesn't distinguish normal, regular, and | |
413 medium weight, but fontconfig does. So, we can't restrict font | |
414 listing by weight. We check it after getting a list. */ | |
411 tmp = AREF (spec, FONT_WEIGHT_INDEX); | 415 tmp = AREF (spec, FONT_WEIGHT_INDEX); |
412 if (INTEGERP (tmp) | 416 if (INTEGERP (tmp)) |
413 && ! FcPatternAddInteger (pattern, FC_WEIGHT, XINT (tmp))) | 417 weight = XINT (tmp); |
414 goto err; | |
415 tmp = AREF (spec, FONT_SLANT_INDEX); | 418 tmp = AREF (spec, FONT_SLANT_INDEX); |
416 if (INTEGERP (tmp) | 419 if (INTEGERP (tmp) |
417 && XINT (tmp) >= 100 | |
418 && ! FcPatternAddInteger (pattern, FC_SLANT, XINT (tmp) - 100)) | 420 && ! FcPatternAddInteger (pattern, FC_SLANT, XINT (tmp) - 100)) |
419 goto err; | 421 goto err; |
420 tmp = AREF (spec, FONT_WIDTH_INDEX); | 422 tmp = AREF (spec, FONT_WIDTH_INDEX); |
421 if (INTEGERP (tmp) | 423 if (INTEGERP (tmp) |
422 && ! FcPatternAddInteger (pattern, FC_WIDTH, XINT (tmp))) | 424 && ! FcPatternAddInteger (pattern, FC_WIDTH, XINT (tmp))) |
423 goto err; | 425 goto err; |
424 #if 0 | |
425 if (! FcPatternAddBool (pattern, FC_SCALABLE, FcTrue)) | |
426 goto err; | |
427 #endif | |
428 | 426 |
429 if (charset | 427 if (charset |
430 && ! FcPatternAddCharSet (pattern, FC_CHARSET, charset)) | 428 && ! FcPatternAddCharSet (pattern, FC_CHARSET, charset)) |
431 goto err; | 429 goto err; |
432 if (langset | 430 if (langset |
460 { | 458 { |
461 double this; | 459 double this; |
462 | 460 |
463 if (FcPatternGetDouble (fontset->fonts[i], FC_PIXEL_SIZE, 0, | 461 if (FcPatternGetDouble (fontset->fonts[i], FC_PIXEL_SIZE, 0, |
464 &this) == FcResultMatch | 462 &this) == FcResultMatch |
465 && this != pixel_size) | 463 && ((this < pixel_size - FONT_PIXEL_SIZE_QUANTUM) |
464 || (this > pixel_size + FONT_PIXEL_SIZE_QUANTUM))) | |
465 continue; | |
466 } | |
467 if (weight > 0) | |
468 { | |
469 int this; | |
470 | |
471 if (FcPatternGetInteger (fontset->fonts[i], FC_WEIGHT, 0, | |
472 &this) != FcResultMatch | |
473 || (this != weight | |
474 && (weight != 100 | |
475 || this < FC_WEIGHT_REGULAR | |
476 || this > FC_WEIGHT_MEDIUM))) | |
466 continue; | 477 continue; |
467 } | 478 } |
468 entity = ftfont_pattern_entity (fontset->fonts[i], frame, registry); | 479 entity = ftfont_pattern_entity (fontset->fonts[i], frame, registry); |
469 if (! NILP (entity)) | 480 if (! NILP (entity)) |
470 val = Fcons (entity, val); | 481 val = Fcons (entity, val); |