aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenichi Handa2006-08-01 01:31:39 +0000
committerKenichi Handa2006-08-01 01:31:39 +0000
commit8daf56676086e294cbf0a889349d06cb3f37696a (patch)
tree052f45d5daff2c025e54b5a353ea39749a6ecc09
parentdc3773800d0a3842a5bf106473ae80c657efcf74 (diff)
downloademacs-8daf56676086e294cbf0a889349d06cb3f37696a.tar.gz
emacs-8daf56676086e294cbf0a889349d06cb3f37696a.zip
(ftfont_driver): Set ftfont_driver.match to
ftfont_match. (ftfont_list): Don't check :name property. (ftfont_match): New function.
-rw-r--r--src/ftfont.c142
1 files changed, 84 insertions, 58 deletions
diff --git a/src/ftfont.c b/src/ftfont.c
index d327035e00b..e10b87b1df9 100644
--- a/src/ftfont.c
+++ b/src/ftfont.c
@@ -247,6 +247,7 @@ ftfont_list_generic_family (spec, frame, registry)
247 247
248static Lisp_Object ftfont_get_cache P_ ((Lisp_Object)); 248static Lisp_Object ftfont_get_cache P_ ((Lisp_Object));
249static Lisp_Object ftfont_list P_ ((Lisp_Object, Lisp_Object)); 249static Lisp_Object ftfont_list P_ ((Lisp_Object, Lisp_Object));
250static Lisp_Object ftfont_match P_ ((Lisp_Object, Lisp_Object));
250static Lisp_Object ftfont_list_family P_ ((Lisp_Object)); 251static Lisp_Object ftfont_list_family P_ ((Lisp_Object));
251static void ftfont_free_entity P_ ((Lisp_Object)); 252static void ftfont_free_entity P_ ((Lisp_Object));
252static struct font *ftfont_open P_ ((FRAME_PTR, Lisp_Object, int)); 253static struct font *ftfont_open P_ ((FRAME_PTR, Lisp_Object, int));
@@ -265,6 +266,7 @@ struct font_driver ftfont_driver =
265 (Lisp_Object) NULL, /* Qfreetype */ 266 (Lisp_Object) NULL, /* Qfreetype */
266 ftfont_get_cache, 267 ftfont_get_cache,
267 ftfont_list, 268 ftfont_list,
269 ftfont_match,
268 ftfont_list_family, 270 ftfont_list_family,
269 ftfont_free_entity, 271 ftfont_free_entity,
270 ftfont_open, 272 ftfont_open,
@@ -306,13 +308,14 @@ static Lisp_Object
306ftfont_list (frame, spec) 308ftfont_list (frame, spec)
307 Lisp_Object frame, spec; 309 Lisp_Object frame, spec;
308{ 310{
309 Lisp_Object val, tmp, extra, font_name; 311 Lisp_Object val, tmp, extra;
310 int i; 312 int i;
311 FcPattern *pattern = NULL; 313 FcPattern *pattern = NULL;
312 FcCharSet *charset = NULL; 314 FcCharSet *charset = NULL;
313 FcLangSet *langset = NULL; 315 FcLangSet *langset = NULL;
314 FcFontSet *fontset = NULL; 316 FcFontSet *fontset = NULL;
315 FcObjectSet *objset = NULL; 317 FcObjectSet *objset = NULL;
318 Lisp_Object script;
316 Lisp_Object registry = Qunicode_bmp; 319 Lisp_Object registry = Qunicode_bmp;
317 int weight = 0; 320 int weight = 0;
318 double dpi = -1; 321 double dpi = -1;
@@ -350,85 +353,68 @@ ftfont_list (frame, spec)
350 return val; 353 return val;
351 } 354 }
352 355
353 extra = AREF (spec, FONT_EXTRA_INDEX);
354 font_name = Qnil;
355 otf_script[0] = '\0'; 356 otf_script[0] = '\0';
356 if (CONSP (extra)) 357 script = Qnil;
358 for (extra = AREF (spec, FONT_EXTRA_INDEX);
359 CONSP (extra); extra = XCDR (extra))
357 { 360 {
358 Lisp_Object script = Qnil; 361 Lisp_Object key, val;
359 362
360 tmp = assq_no_quit (QCname, extra); 363 tmp = XCAR (extra);
361 if (CONSP (tmp) && STRINGP (XCDR (tmp)) 364 key = XCAR (tmp), val = XCDR (tmp);
362 && SDATA (XCDR (tmp))[0] == ':') 365 if (EQ (key, QCotf))
363 font_name = XCDR (tmp);
364 tmp = assq_no_quit (QCotf, extra);
365 if (CONSP (tmp) && SYMBOLP (XCDR (tmp)))
366 { 366 {
367 tmp = XCDR (tmp); 367 script = assq_no_quit (val, Votf_script_alist);
368 script = assq_no_quit (tmp, Votf_script_alist);
369 if (CONSP (script) && SYMBOLP (XCDR (script))) 368 if (CONSP (script) && SYMBOLP (XCDR (script)))
370 script = XCDR (script); 369 script = XCDR (script);
371 tmp = SYMBOL_NAME (tmp); 370 tmp = SYMBOL_NAME (val);
372 sprintf (otf_script, "otlayout:%s", (char *) SDATA (tmp)); 371 sprintf (otf_script, "otlayout:%s", (char *) SDATA (tmp));
373 } 372 }
374 tmp = assq_no_quit (QClanguage, extra); 373 else if (EQ (key, QClanguage))
375 if (CONSP (tmp))
376 { 374 {
377 langset = FcLangSetCreate (); 375 langset = FcLangSetCreate ();
378 if (! langset) 376 if (! langset)
379 goto err; 377 goto err;
380 tmp = XCDR (tmp); 378 if (SYMBOLP (val))
381 if (SYMBOLP (tmp))
382 { 379 {
383 if (! FcLangSetAdd (langset, SYMBOL_FcChar8 (tmp))) 380 if (! FcLangSetAdd (langset, SYMBOL_FcChar8 (val)))
384 goto err; 381 goto err;
385 } 382 }
386 else 383 else
387 while (CONSP (tmp)) 384 for (; CONSP (val); val = XCDR (val))
388 { 385 if (SYMBOLP (XCAR (val))
389 if (SYMBOLP (XCAR (tmp)) 386 && ! FcLangSetAdd (langset, SYMBOL_FcChar8 (XCAR (val))))
390 && ! FcLangSetAdd (langset, SYMBOL_FcChar8 (XCAR (tmp)))) 387 goto err;
391 goto err;
392 tmp = XCDR (tmp);
393 }
394 } 388 }
395 tmp = assq_no_quit (QCscript, extra); 389 else if (EQ (key, QCscript))
396 if (CONSP (tmp)) 390 script = val;
397 script = XCDR (tmp); 391 else if (EQ (key, QCdpi))
398 if (! NILP (script) && ! charset) 392 dpi = XINT (val);
399 { 393 else if (EQ (key, QCspacing))
400 Lisp_Object chars 394 spacing = XINT (val);
401 = assq_no_quit (script, Vscript_representative_chars); 395 else if (EQ (key, QCscalable))
396 scalable = ! NILP (val);
397 }
402 398
403 if (CONSP (chars)) 399 if (! NILP (script) && ! charset)
404 { 400 {
405 charset = FcCharSetCreate (); 401 Lisp_Object chars = assq_no_quit (script, Vscript_representative_chars);
406 if (! charset) 402
407 goto err; 403 if (CONSP (chars))
408 for (chars = XCDR (chars); CONSP (chars); chars = XCDR (chars)) 404 {
409 if (CHARACTERP (XCAR (chars)) 405 charset = FcCharSetCreate ();
410 && ! FcCharSetAddChar (charset, XUINT (XCAR (chars)))) 406 if (! charset)
411 goto err; 407 goto err;
412 } 408 for (chars = XCDR (chars); CONSP (chars); chars = XCDR (chars))
409 if (CHARACTERP (XCAR (chars))
410 && ! FcCharSetAddChar (charset, XUINT (XCAR (chars))))
411 goto err;
413 } 412 }
414 tmp = assq_no_quit (QCdpi, extra);
415 if (CONSP (tmp))
416 dpi = XINT (XCDR (tmp));
417 tmp = assq_no_quit (QCspacing, extra);
418 if (CONSP (tmp))
419 spacing = XINT (XCDR (tmp));
420 tmp = assq_no_quit (QCscalable, extra);
421 if (CONSP (tmp))
422 scalable = ! NILP (XCDR (tmp));
423 } 413 }
424 414
425 if (STRINGP (font_name)) 415 pattern = FcPatternCreate ();
426 pattern = FcNameParse (SDATA (font_name));
427 else
428 pattern = FcPatternCreate ();
429 if (! pattern) 416 if (! pattern)
430 goto err; 417 goto err;
431
432 tmp = AREF (spec, FONT_FOUNDRY_INDEX); 418 tmp = AREF (spec, FONT_FOUNDRY_INDEX);
433 if (SYMBOLP (tmp) && ! NILP (tmp) 419 if (SYMBOLP (tmp) && ! NILP (tmp)
434 && ! FcPatternAddString (pattern, FC_FOUNDRY, SYMBOL_FcChar8 (tmp))) 420 && ! FcPatternAddString (pattern, FC_FOUNDRY, SYMBOL_FcChar8 (tmp)))
@@ -559,6 +545,46 @@ ftfont_list (frame, spec)
559} 545}
560 546
561static Lisp_Object 547static Lisp_Object
548ftfont_match (frame, spec)
549 Lisp_Object frame, spec;
550{
551 Lisp_Object extra, val, entity;
552 FcPattern *pattern = NULL, *match = NULL;
553 FcResult result;
554
555 if (! fc_initialized)
556 {
557 FcInit ();
558 fc_initialized = 1;
559 }
560
561 extra = AREF (spec, FONT_EXTRA_INDEX);
562 val = assq_no_quit (QCname, extra);
563 if (! CONSP (val) || ! STRINGP (XCDR (val)))
564 return Qnil;
565
566 entity = Qnil;
567 pattern = FcNameParse (SDATA (XCDR (val)));
568 if (pattern)
569 {
570 if (FcConfigSubstitute (NULL, pattern, FcMatchPattern) == FcTrue)
571 {
572 FcDefaultSubstitute (pattern);
573 match = FcFontMatch (NULL, pattern, &result);
574 fprintf (stderr, "%s\n", (char *) FcNameUnparse (match));
575 if (match)
576 {
577 entity = ftfont_pattern_entity (match, frame, Qunicode_bmp);
578 FcPatternDestroy (match);
579 }
580 }
581 FcPatternDestroy (pattern);
582 }
583
584 return entity;
585}
586
587static Lisp_Object
562ftfont_list_family (frame) 588ftfont_list_family (frame)
563 Lisp_Object frame; 589 Lisp_Object frame;
564{ 590{