Mercurial > hg > xemacs-beta
changeset 3906:605c915d2b9d
[xemacs-hg @ 2007-04-14 16:10:53 by stephent]
Small fixes for font-mgr.c. <87y7kvudz3.fsf@uwakimon.sk.tsukuba.ac.jp>
author | stephent |
---|---|
date | Sat, 14 Apr 2007 16:10:57 +0000 |
parents | 5d22662e9c81 |
children | e001be4bf3f9 |
files | src/ChangeLog src/font-mgr.c |
diffstat | 2 files changed, 64 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog Fri Apr 13 21:52:37 2007 +0000 +++ b/src/ChangeLog Sat Apr 14 16:10:57 2007 +0000 @@ -1,3 +1,19 @@ +2007-04-15 Stephen J. Turnbull <stephen@xemacs.org> + + * font-mgr.c: Update FSF copyrights. + + * font-mgr.c (print_fc_pattern): New facility for fc-pattern + objects. Comment on need/implementation for equal/hash. + + * font-mgr.c (build_fcapi_string): New convenience macro. + * font-mgr.c (Ffc_name_unparse): + * font-mgr.c (Ffc_pattern_get): + Use it. + + * font-mgr.c (Ffc_name_parse): + * font-mgr.c (Ffc_font_match): + Remove incorrect comments about memory leaks. + 2007-04-01 Stephen J. Turnbull <stephen@xemacs.org> Thanks to OG for review and Aidan Kehoe for useful comments.
--- a/src/font-mgr.c Fri Apr 13 21:52:37 2007 +0000 +++ b/src/font-mgr.c Sat Apr 14 16:10:57 2007 +0000 @@ -2,13 +2,13 @@ Copyright (C) 2003 Eric Knauel and Matthias Neubauer Copyright (C) 2005 Eric Knauel -Copyright (C) 2004, 2005 Free Software Foundation, Inc. +Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc. Authors: Eric Knauel <knauel@informatik.uni-tuebingen.de> Matthias Neubauer <neubauer@informatik.uni-freiburg.de> Stephen J. Turnbull <stephen@xemacs.org> Created: 27 Oct 2003 -Updated: 05 Mar 2005 by Stephen J. Turnbull +Updated: 14 April 2007 by Stephen J. Turnbull This file is part of XEmacs. @@ -96,14 +96,48 @@ } } +static void +print_fc_pattern (Lisp_Object obj, Lisp_Object printcharfun, + int UNUSED(escapeflag)) +{ + struct fc_pattern *c = XFCPATTERN (obj); + if (print_readably) + printing_unreadable_object ("#<fc-pattern 0x%x>", c->header.uid); + write_fmt_string (printcharfun, "#<fc-pattern 0x%x>", c->header.uid); +} + +/* #### We really need an equal method and a hash method (required if you + have an equal method). For the equal method, we can probably use one + or both of + + -- Function: FcBool FcPatternEqual (const FcPattern *pa, const + FcPattern *pb); + Returns whether PA and PB are exactly alike. + + -- Function: FcBool FcPatternEqualSubset (const FcPattern *pa, const + FcPattern *pb, const FcObjectSet *os) + Returns whether PA and PB have exactly the same values for all of + the objects in OS. + + For the hash, we'll have to extract some subset of attributes. + + #### Crap. It's altogether unobvious what we need. x_color_instance + does have a hash method, but fonts are apparently special. I get the + feeling that for this to work properly we're going to need to switch + to fontconfig-based font specifications (although we can allow the + platform syntaxes, the underlying specification object will need to + conform to the fontconfig API, or more precisely the font-mgr API). + + I think the whole `font-truename' interface needs to be dropped. */ + static const struct memory_description fcpattern_description [] = { /* #### nothing here, is this right?? */ { XD_END } }; -DEFINE_LRECORD_IMPLEMENTATION("fc-pattern", fc_pattern, - 0, 0, 0, finalize_fc_pattern, 0, 0, - fcpattern_description, +DEFINE_LRECORD_IMPLEMENTATION("fc-pattern", fc_pattern, 0, + 0, print_fc_pattern, finalize_fc_pattern, + 0, 0, fcpattern_description, struct fc_pattern); /* @@ -122,6 +156,9 @@ #define extract_fcapi_string(str) \ (NEW_LISP_STRING_TO_EXTERNAL ((str), Qfc_font_name_encoding)) +#define build_fcapi_string(str) \ + (build_ext_string ((Extbyte *) (str), Qfc_font_name_encoding)) + /* #### This homebrew lashup should be replaced with FcConstants. fontconfig assumes that objects (property names) are statically allocated, @@ -205,7 +242,7 @@ struct fc_pattern *fcpat = ALLOC_LCRECORD_TYPE (struct fc_pattern, &lrecord_fc_pattern); - CHECK_STRING(name); /* #### MEMORY LEAK!! maybe not ... */ + CHECK_STRING(name); fcpat->fcpatPtr = FcNameParse ((FcChar8 *) extract_fcapi_string (name)); return wrap_fcpattern(fcpat); @@ -219,12 +256,7 @@ (pattern)) { CHECK_FCPATTERN(pattern); - { - Extbyte *temp = (Extbyte *) FcNameUnparse(XFCPATTERN_PTR(pattern)); - Lisp_Object res = build_ext_string (temp, Qfc_font_name_encoding); - free (temp); - return res; - } + return build_fcapi_string (FcNameUnparse (XFCPATTERN_PTR (pattern))); } DEFUN("fc-pattern-duplicate", Ffc_pattern_duplicate, 1, 1, 0, /* @@ -426,8 +458,7 @@ case FcTypeString: return ((!NILP (type) && !EQ (type, Qstring)) ? Qfc_result_type_mismatch - : build_ext_string ((Extbyte *) fc_value.u.s, - Qfc_font_name_encoding)); + : build_fcapi_string (fc_value.u.s)); case FcTypeBool: return ((!NILP (type) && !EQ (type, Qboolean)) ? Qfc_result_type_mismatch : fc_value.u.b ? Qt : Qnil); @@ -466,16 +497,16 @@ (device, pattern)) { FcResult res; + struct fc_pattern *res_fcpat; - struct fc_pattern *res_fcpat = - ALLOC_LCRECORD_TYPE (struct fc_pattern, &lrecord_fc_pattern); - CHECK_FCPATTERN(pattern); /* #### MEMORY LEAKS!!! */ + CHECK_FCPATTERN(pattern); if (NILP(device)) return Qnil; CHECK_X_DEVICE(device); if (!DEVICE_LIVE_P(XDEVICE(device))) return Qnil; + res_fcpat = ALLOC_LCRECORD_TYPE (struct fc_pattern, &lrecord_fc_pattern); { FcPattern *p = XFCPATTERN_PTR(pattern); FcConfig *fcc = FcConfigGetCurrent ();