NOTE: This patch has been committed.
APPROVE COMMIT sjt-xft
2005-02-11 Eric Knauel <eric(a)xemacs.org>
* xft-fonts.h: New prototype
* xft-fonts.c (Ffc_name_parse, Ffc_pattern_add, Ffc_pattern_del)
(Ffc_pattern_get, fc_font_real_pattern)
(string_list_to_fcobjectset): Use extract_fcapi_string()
(extract_fcapi_string): New function
XEmacs Xft branch source patch:
Diff command: cvs -q diff -u
Files affected: src/xft-fonts.h src/xft-fonts.c
Index: src/xft-fonts.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/Attic/xft-fonts.c,v
retrieving revision 1.1.2.4
diff -u -p -u -r1.1.2.4 xft-fonts.c
--- src/xft-fonts.c 2005/02/09 12:53:04 1.1.2.4
+++ src/xft-fonts.c 2005/02/11 15:36:36
@@ -139,7 +139,7 @@ Parse an Fc font name and return its rep
CHECK_STRING(name);
- fcpat->fcpatPtr = FcNameParse(XSTRING_DATA(name));
+ fcpat->fcpatPtr = FcNameParse (extract_fcapi_string (name));
fcpat->fontset = Qnil;
return wrap_fcpattern(fcpat);
}
@@ -186,14 +186,14 @@ of the attribute to add, VALUE the value
if (STRINGP(value))
{
res = FcPatternAddString (XFCPATTERN_PTR(fcpat),
- XSTRING_DATA(object),
- (FcChar8 *) XSTRING_DATA(value));
+ extract_fcapi_string (object),
+ (FcChar8 *) extract_fcapi_string (value));
return res ? Qt : Qnil;
}
if (INTP(value))
{
res = FcPatternAddInteger (XFCPATTERN_PTR(fcpat),
- XSTRING_DATA(object),
+ extract_fcapi_string (object),
XINT(value));
return res ? Qt : Qnil;
}
@@ -201,7 +201,7 @@ of the attribute to add, VALUE the value
if (FLOATP(value))
{
res = FcPatternAddDouble (XFCPATTERN_PTR(fcpat),
- XSTRING_DATA(object),
+ extract_fcapi_string (object),
(double) XFLOAT_DATA(value));
return res ? Qt : Qnil;
}
@@ -209,7 +209,7 @@ of the attribute to add, VALUE the value
if (SYMBOLP(value))
{
res = FcPatternAddBool (XFCPATTERN_PTR(fcpat),
- XSTRING_DATA(object),
+ extract_fcapi_string (object),
!NILP(value));
return res ? Qt : Qnil;
}
@@ -227,7 +227,8 @@ Remove attribute OBJECT from fc pattern
CHECK_FCPATTERN(fcpat);
CHECK_STRING(object);
- res = FcPatternDel(XFCPATTERN_PTR(fcpat), XSTRING_DATA(object));
+ res = FcPatternDel(XFCPATTERN_PTR(fcpat),
+ extract_fcapi_string (object));
return res ? Qt : Qnil;
}
@@ -326,7 +327,7 @@ Xft v.2: encoding, charwidth, charheigh
if (STRINGP (property))
{
/* #### need to Mule-ize */
- fc_property = (FcChar8 *) XSTRING_DATA (property);
+ fc_property = (FcChar8 *) extract_fcapi_string (property);
}
else
{
@@ -840,7 +841,7 @@ fc pattern matched by the Fc library. */
dpy = DEVICE_X_DISPLAY (XDEVICE (xdevice));
font = XftFontOpenName (dpy, DefaultScreen(dpy),
- XSTRING_DATA(fontname));
+ extract_fcapi_string (fontname));
if (font == NULL)
return Qnil;
copy = FcPatternDuplicate(font->pattern);
@@ -1006,8 +1007,21 @@ string_list_to_fcobjectset (Lisp_Object
EXTERNAL_LIST_LOOP_2 (elt, list)
{
CHECK_STRING (elt);
- FcObjectSetAdd (os, XSTRING_DATA (elt));
+ FcObjectSetAdd (os, extract_fcapi_string (elt));
}
+}
+
+/*
+ extract the C representation of the Lisp string STR and convert it
+ to the encoding used by the Fontconfig API for property and font
+ names. I suppose that Qnative is the right encoding, the manual
+ doesn't say much about this topic. This functions assumes that STR
+ is a Lisp string.
+*/
+inline static char *
+extract_fcapi_string (Lisp_Object str)
+{
+ return NEW_LISP_STRING_TO_EXTERNAL (str, Qnative);
}
void
Index: src/xft-fonts.h
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/Attic/xft-fonts.h,v
retrieving revision 1.1.2.3
diff -u -p -u -r1.1.2.3 xft-fonts.h
--- src/xft-fonts.h 2005/02/04 16:05:38 1.1.2.3
+++ src/xft-fonts.h 2005/02/11 15:36:36
@@ -93,4 +93,7 @@ Lisp_Object fc_get_pattern_string(Lisp_O
static void
string_list_to_fcobjectset (Lisp_Object, FcObjectSet*);
+inline static char *
+extract_fcapi_string (Lisp_Object str);
+
#endif /* INCLUDED_xft_fonts_h_ */
-Eric
--
"Excuse me --- Di Du Du Duuuuh Di Dii --- Huh Weeeheeee" (Albert King)