comparison src/ftfont.c @ 91214:998b9da240f0

(struct OpenTypeSpec): Members script_tag renamed to script, langsys_tag renamed to langsys, new member script. (OTF_TAG_STR): Terminate by '\0'. (ftfont_get_open_type_spec): If :otf prop is is spec, Limit the listing to the script specified in that property. Fix arg to OTF_check_features.
author Kenichi Handa <handa@m17n.org>
date Sun, 09 Dec 2007 12:29:51 +0000
parents 5bce041b93dc
children 4f21471103e6
comparison
equal deleted inserted replaced
91213:aaf0103455b0 91214:998b9da240f0
322 return freetype_font_cache; 322 return freetype_font_cache;
323 } 323 }
324 324
325 struct OpenTypeSpec 325 struct OpenTypeSpec
326 { 326 {
327 unsigned int script, langsys; 327 Lisp_Object script;
328 unsigned int script_tag, langsys_tag;
328 int nfeatures[2]; 329 int nfeatures[2];
329 unsigned int *features[2]; 330 unsigned int *features[2];
330 }; 331 };
331 332
332 #define OTF_SYM_TAG(SYM, TAG) \ 333 #define OTF_SYM_TAG(SYM, TAG) \
339 do { \ 340 do { \
340 (P)[0] = (char) (TAG >> 24); \ 341 (P)[0] = (char) (TAG >> 24); \
341 (P)[1] = (char) ((TAG >> 16) & 0xFF); \ 342 (P)[1] = (char) ((TAG >> 16) & 0xFF); \
342 (P)[2] = (char) ((TAG >> 8) & 0xFF); \ 343 (P)[2] = (char) ((TAG >> 8) & 0xFF); \
343 (P)[3] = (char) (TAG & 0xFF); \ 344 (P)[3] = (char) (TAG & 0xFF); \
345 (P)[4] = '\0'; \
344 } while (0) 346 } while (0)
345 347
346 static struct OpenTypeSpec * 348 static struct OpenTypeSpec *
347 ftfont_get_open_type_spec (Lisp_Object otf_spec) 349 ftfont_get_open_type_spec (Lisp_Object otf_spec)
348 { 350 {
350 Lisp_Object val; 352 Lisp_Object val;
351 int i, j, negative; 353 int i, j, negative;
352 354
353 if (! spec) 355 if (! spec)
354 return NULL; 356 return NULL;
355 val = XCAR (otf_spec); 357 spec->script = XCAR (otf_spec);
356 if (! NILP (val)) 358 if (! NILP (val))
357 OTF_SYM_TAG (val, spec->script); 359 {
360 OTF_SYM_TAG (spec->script, spec->script_tag);
361 val = assq_no_quit (spec->script, Votf_script_alist);
362 if (CONSP (val) && SYMBOLP (XCDR (val)))
363 spec->script = XCDR (val);
364 else
365 spec->script = Qnil;
366 }
358 else 367 else
359 spec->script = 0x44464C54; /* "DFLT" */ 368 spec->script_tag = 0x44464C54; /* "DFLT" */
360 otf_spec = XCDR (otf_spec); 369 otf_spec = XCDR (otf_spec);
361 val = XCAR (otf_spec); 370 val = XCAR (otf_spec);
362 if (! NILP (val)) 371 if (! NILP (val))
363 OTF_SYM_TAG (val, spec->langsys); 372 OTF_SYM_TAG (val, spec->langsys_tag);
364 else 373 else
365 spec->langsys = 0; 374 spec->langsys_tag = 0;
366 spec->nfeatures[0] = spec->nfeatures[1] = 0; 375 spec->nfeatures[0] = spec->nfeatures[1] = 0;
367 for (i = 0; i < 2; i++) 376 for (i = 0; i < 2; i++)
368 { 377 {
369 Lisp_Object len; 378 Lisp_Object len;
370 379
462 tmp = XCAR (extra); 471 tmp = XCAR (extra);
463 key = XCAR (tmp), val = XCDR (tmp); 472 key = XCAR (tmp), val = XCDR (tmp);
464 if (EQ (key, QCotf)) 473 if (EQ (key, QCotf))
465 { 474 {
466 otspec = ftfont_get_open_type_spec (val); 475 otspec = ftfont_get_open_type_spec (val);
467 if (otspec) 476 if (! otspec)
468 return null_vector; 477 return null_vector;
469 strcat (otlayout, "otlayout:"); 478 strcat (otlayout, "otlayout:");
470 OTF_TAG_STR (otspec->script, otlayout + 9); 479 OTF_TAG_STR (otspec->script_tag, otlayout + 9);
480 script = otspec->script;
471 } 481 }
472 else if (EQ (key, QClanguage)) 482 else if (EQ (key, QClanguage))
473 { 483 {
474 langset = FcLangSetCreate (); 484 langset = FcLangSetCreate ();
475 if (! langset) 485 if (! langset)
632 != FcResultMatch) 642 != FcResultMatch)
633 continue; 643 continue;
634 otf = OTF_open ((char *) file); 644 otf = OTF_open ((char *) file);
635 if (! otf) 645 if (! otf)
636 continue; 646 continue;
637 if (OTF_check_features (otf, 0, 647 if (OTF_check_features (otf, 1,
638 otspec->script, otspec->langsys, 648 otspec->script_tag, otspec->langsys_tag,
639 otspec->features[0], 649 otspec->features[0],
640 otspec->nfeatures[0]) != 1 650 otspec->nfeatures[0]) != 1
641 || OTF_check_features (otf, 1, 651 || OTF_check_features (otf, 0,
642 otspec->script, otspec->langsys, 652 otspec->script_tag, otspec->langsys_tag,
643 otspec->features[1], 653 otspec->features[1],
644 otspec->nfeatures[1]) != 1) 654 otspec->nfeatures[1]) != 1)
645 continue; 655 continue;
646 } 656 }
647 #endif /* HAVE_LIBOTF */ 657 #endif /* HAVE_LIBOTF */