APPROVE COMMIT 21.5
Minor, non-controversial fixes. The printer method for fc-pattern
objects is just a stub, but better than nothing I guess.
src/ChangeLog addition:
2007-04-15 Stephen J. Turnbull <stephen(a)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.
21.5 source patch:
Diff command: cvs -q diff -u
Files affected: src/font-mgr.c
Index: src/font-mgr.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/font-mgr.c,v
retrieving revision 1.4
diff -u -u -r1.4 font-mgr.c
--- src/font-mgr.c 23 Jun 2006 15:45:02 -0000 1.4
+++ src/font-mgr.c 14 Apr 2007 15:55:45 -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(a)informatik.uni-tuebingen.de>
Matthias Neubauer <neubauer(a)informatik.uni-freiburg.de>
Stephen J. Turnbull <stephen(a)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 ();
_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches(a)xemacs.org
http://calypso.tux.org/cgi-bin/mailman/listinfo/xemacs-patches