Author: fejj
Date: 2008-01-24 12:23:03 -0500 (Thu, 24 Jan 2008)
New Revision: 93818
Modified:
trunk/moon/src/font.cpp
trunk/moon/src/font.h
Log:
added debugging for font loading
Modified: trunk/moon/src/font.cpp
===================================================================
--- trunk/moon/src/font.cpp 2008-01-24 16:48:32 UTC (rev 93817)
+++ trunk/moon/src/font.cpp 2008-01-24 17:23:03 UTC (rev 93818)
@@ -22,6 +22,9 @@
#include FT_OUTLINE_H
+#define d(x) x
+
+
struct GlyphBitmap {
cairo_surface_t *surface;
unsigned char *buffer;
@@ -139,7 +142,7 @@
#define LOAD_FLAGS (FT_LOAD_NO_BITMAP | FT_LOAD_TARGET_NORMAL)
-TextFont::TextFont (FcPattern *pattern)
+TextFont::TextFont (FcPattern *pattern, const char *name)
{
FcChar8 *filename = NULL;
FcPattern *matched, *sans;
@@ -148,6 +151,8 @@
double size;
int id;
+ d(fprintf (stderr, "Attempting to load %s\n", name));
+
FcPatternGetDouble (pattern, FC_PIXEL_SIZE, 0, &size);
FcPatternGetDouble (pattern, FC_SCALE, 0, &scale);
FcPatternReference (pattern);
@@ -157,20 +162,26 @@
if (FcPatternGetString (matched, FC_FILE, 0, &filename) !=
FcResultMatch)
goto fail;
- //printf ("loading font from `%s'\n", filename);
+ d(fprintf (stderr, "\t* loading font from `%s'\n", filename));
if (FcPatternGetInteger (matched, FC_INDEX, 0, &id) !=
FcResultMatch)
goto fail;
+ d(fprintf (stderr, "\t* using font index=%d\n", id));
+
if (FT_New_Face (libft2, (const char *) filename, id, &face) ==
0)
break;
fail:
+ d(fprintf (stderr, "\t* failed.\n"));
+
if (retried) {
face = NULL;
break;
}
+ d(fprintf (stderr, "* Falling back to Sans...\n"));
+
sans = FcPatternBuild (NULL, FC_FAMILY, FcTypeString, "sans",
FC_PIXEL_SIZE, FcTypeDouble, size,
FC_DPI, FcTypeDouble, dpi, NULL);
@@ -228,7 +239,7 @@
}
TextFont *
-TextFont::Load (FcPattern *pattern)
+TextFont::Load (FcPattern *pattern, const char *name)
{
TextFont *font;
@@ -237,7 +248,7 @@
return font;
}
- return new TextFont (pattern);
+ return new TextFont (pattern, name);
}
void
@@ -763,11 +774,14 @@
TextFontDescription::GetFont ()
{
FcPattern *pattern;
+ char *name = NULL;
if (font == NULL) {
+ d(name = ToString ());
pattern = CreatePattern ();
- font = TextFont::Load (pattern);
+ font = TextFont::Load (pattern, name);
FcPatternDestroy (pattern);
+ d(g_free (name));
}
if (font)
@@ -1013,7 +1027,9 @@
g_string_append (str, "font:");
g_string_append (str, filename);
g_string_append_printf (str, "?index=%d", index);
- g_string_append (str, "?family=");
+
+ if (set & FontMaskFamily)
+ g_string_append (str, "?family=");
}
if (set & FontMaskFamily) {
Modified: trunk/moon/src/font.h
===================================================================
--- trunk/moon/src/font.h 2008-01-24 16:48:32 UTC (rev 93817)
+++ trunk/moon/src/font.h 2008-01-24 17:23:03 UTC (rev 93818)
@@ -118,7 +118,7 @@
GlyphInfo *glyphs;
- TextFont (FcPattern *pattern);
+ TextFont (FcPattern *pattern, const char *name);
void RenderGlyphPath (cairo_t *cr, GlyphInfo *glyph, double x, double
y);
void RenderGlyphBitmap (cairo_t *cr, GlyphInfo *glyph, double x, double
y);
@@ -130,7 +130,7 @@
void ref ();
void unref ();
- static TextFont *Load (FcPattern *pattern);
+ static TextFont *Load (FcPattern *pattern, const char *name);
GlyphInfo *GetGlyphInfo (gunichar unichar);
GlyphInfo *GetGlyphInfoByIndex (uint32_t index);
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches