comparison src/objects-xlike-inc.c @ 4758:75975fd0b7fc

Implement more of the fontconfig API. Improve implementation, avoiding nonsyntactic macros and compiler warnings. Clean up some documentation. Guard against freeing NULL pointers returned from fonconfig.
author Stephen J. Turnbull <stephen@xemacs.org>
date Wed, 18 Nov 2009 22:44:28 +0900
parents a23ac8f90a49
children 0d3ccd5a2509
comparison
equal deleted inserted replaced
4757:a23ac8f90a49 4758:75975fd0b7fc
326 326
327 struct charset_reporter { 327 struct charset_reporter {
328 Lisp_Object *charset; 328 Lisp_Object *charset;
329 /* This is a debug facility, require ASCII. */ 329 /* This is a debug facility, require ASCII. */
330 Extbyte *language; /* ASCII, please */ 330 Extbyte *language; /* ASCII, please */
331 /* Technically this is FcChar8, but fsckin' GCC 4 bitches. */ 331 /* Technically this is FcChar8, but fsckin' GCC 4 bitches.
332 RFC 3066 is a combination of ISO 639 and ISO 3166. */
332 Extbyte *rfc3066; /* ASCII, please */ 333 Extbyte *rfc3066; /* ASCII, please */
333 }; 334 };
334 335
335 static struct charset_reporter charset_table[] = 336 static struct charset_reporter charset_table[] =
336 { 337 {
414 FcInit (); /* No-op if already initialized. 415 FcInit (); /* No-op if already initialized.
415 In fontconfig 2.3.2, this cannot return 416 In fontconfig 2.3.2, this cannot return
416 failure, but that looks like a bug. We 417 failure, but that looks like a bug. We
417 check for it with FcGetCurrentConfig(), 418 check for it with FcGetCurrentConfig(),
418 which *can* fail. */ 419 which *can* fail. */
419 if (!FcConfigGetCurrent()) /* #### We should expose FcInit* interfaces 420 if (!FcConfigGetCurrent())
420 to LISP and decide when to reinitialize
421 intelligently. */
422 stderr_out ("Failed fontconfig initialization\n"); 421 stderr_out ("Failed fontconfig initialization\n");
423 else 422 else
424 { 423 {
425 FcPattern *fontxft; /* long-lived, freed at end of this block */ 424 FcPattern *fontxft; /* long-lived, freed at end of this block */
426 FcResult fcresult; 425 FcResult fcresult;
468 pointless. We're just going to remove this code once the font/ 467 pointless. We're just going to remove this code once the font/
469 face refactoring is done, but until then it could be very useful. 468 face refactoring is done, but until then it could be very useful.
470 */ 469 */
471 { 470 {
472 FcPattern *p = FcFontRenderPrepare (fcc, fontxft, fontxft); 471 FcPattern *p = FcFontRenderPrepare (fcc, fontxft, fontxft);
473 FcChar8 *name; 472 Extbyte *name;
474 473
475 /* full name, including language coverage and repertoire */ 474 /* full name, including language coverage and repertoire */
476 name = FcNameUnparse (p); 475 name = (Extbyte *) FcNameUnparse (p);
477 eicpy_ext (eistr_fullname, 476 eicpy_ext (eistr_fullname,
478 (Extbyte *) (name ? name : "NOT FOUND"), 477 (name ? name : "NOT FOUND"),
479 Qfc_font_name_encoding); 478 Qfc_font_name_encoding);
480 free (name); 479 if (name) free (name);
481 480
482 /* long name, omitting coverage and repertoire, plus a number 481 /* long name, omitting coverage and repertoire, plus a number
483 of rarely useful properties */ 482 of rarely useful properties */
484 FcPatternDel (p, FC_CHARSET); 483 FcPatternDel (p, FC_CHARSET);
485 FcPatternDel (p, FC_LANG); 484 FcPatternDel (p, FC_LANG);
492 FcPatternDel (p, FC_AUTOHINT); 491 FcPatternDel (p, FC_AUTOHINT);
493 FcPatternDel (p, FC_GLOBAL_ADVANCE); 492 FcPatternDel (p, FC_GLOBAL_ADVANCE);
494 FcPatternDel (p, FC_INDEX); 493 FcPatternDel (p, FC_INDEX);
495 FcPatternDel (p, FC_SCALE); 494 FcPatternDel (p, FC_SCALE);
496 FcPatternDel (p, FC_FONTVERSION); 495 FcPatternDel (p, FC_FONTVERSION);
497 name = FcNameUnparse (p); 496 name = (Extbyte *) FcNameUnparse (p);
498 eicpy_ext (eistr_longname, 497 eicpy_ext (eistr_longname,
499 (Extbyte *) (name ? name : "NOT FOUND"), 498 (name ? name : "NOT FOUND"),
500 Qfc_font_name_encoding); 499 Qfc_font_name_encoding);
501 free (name); 500 if (name) free (name);
502 501
503 /* nickname, just family and size, but 502 /* nickname, just family and size, but
504 "family" names usually have style, slant, and weight */ 503 "family" names usually have style, slant, and weight */
505 FcPatternDel (p, FC_FOUNDRY); 504 FcPatternDel (p, FC_FOUNDRY);
506 FcPatternDel (p, FC_STYLE); 505 FcPatternDel (p, FC_STYLE);
508 FcPatternDel (p, FC_WEIGHT); 507 FcPatternDel (p, FC_WEIGHT);
509 FcPatternDel (p, FC_PIXEL_SIZE); 508 FcPatternDel (p, FC_PIXEL_SIZE);
510 FcPatternDel (p, FC_OUTLINE); 509 FcPatternDel (p, FC_OUTLINE);
511 FcPatternDel (p, FC_SCALABLE); 510 FcPatternDel (p, FC_SCALABLE);
512 FcPatternDel (p, FC_DPI); 511 FcPatternDel (p, FC_DPI);
513 name = FcNameUnparse (p); 512 name = (Extbyte *) FcNameUnparse (p);
514 eicpy_ext (eistr_shortname, 513 eicpy_ext (eistr_shortname,
515 (Extbyte *) (name ? name : "NOT FOUND"), 514 (name ? name : "NOT FOUND"),
516 Qfc_font_name_encoding); 515 Qfc_font_name_encoding);
517 free (name); 516 if (name) free (name);
518 517
519 FcPatternDestroy (p); 518 FcPatternDestroy (p);
520 } 519 }
521 520
522 /* The language approach may better in the long run, but we can't use 521 /* The language approach may better in the long run, but we can't use