Author: fejj
Date: 2007-09-19 10:20:21 -0400 (Wed, 19 Sep 2007)
New Revision: 86012
Modified:
trunk/moon/src/ChangeLog
trunk/moon/src/font.cpp
trunk/moon/src/font.h
trunk/moon/src/mango.cpp
Log:
2007-09-19 Jeffrey Stedfast <[EMAIL PROTECTED]>
* font.cpp: More hackery.
Modified: trunk/moon/src/ChangeLog
===================================================================
--- trunk/moon/src/ChangeLog 2007-09-19 14:20:15 UTC (rev 86011)
+++ trunk/moon/src/ChangeLog 2007-09-19 14:20:21 UTC (rev 86012)
@@ -1,3 +1,7 @@
+2007-09-19 Jeffrey Stedfast <[EMAIL PROTECTED]>
+
+ * font.cpp: More hackery.
+
2007-09-19 Rolf Bjarne Kvinge <[EMAIL PROTECTED]>
* panel.cpp: Add a null check.
Modified: trunk/moon/src/font.cpp
===================================================================
--- trunk/moon/src/font.cpp 2007-09-19 14:20:15 UTC (rev 86011)
+++ trunk/moon/src/font.cpp 2007-09-19 14:20:21 UTC (rev 86012)
@@ -126,6 +126,8 @@
};
+#define LOAD_FLAGS (FT_LOAD_NO_BITMAP | FT_LOAD_TARGET_NORMAL)
+
Font::Font (FcPattern *pattern, double size)
{
const char *filename = NULL;
@@ -190,6 +192,7 @@
g_free (glyphs);
FT_Done_Face (face);
+
g_hash_table_remove (font_cache, pattern);
FcPatternDestroy (pattern);
}
@@ -234,9 +237,6 @@
return face->height;
}
-
-#define LOAD_FLAGS (FT_LOAD_NO_BITMAP | FT_LOAD_TARGET_NORMAL)
-
const GlyphInfo *
Font::GetGlyphInfo (uint32_t unichar)
{
@@ -978,11 +978,69 @@
}
void
-TextLayout::Render (cairo_t *cr)
+TextLayout::Render (cairo_t *cr, UIElement *element, double x, double y)
{
+ cairo_image_surface_t *surface;
+ int width, height, stride;
+ TextSegment *segment;
+ TextDecorations deco;
+ FT_Bitmap *bitmap;
+ Font *font = NULL;
+ Brush *fg = NULL;
+ GlyphInfo *glyph;
+ TextLine *line;
+ double dx, dy;
+ int i;
+
Layout ();
+ if ((line = (TextLine *) lines->First ()))
+ dy = (double) line->height;
+ dx = 0.0f;
+ while (line) {
+ segment = (TextSegment *) line->segments->First ();
+ while (segment) {
+ deco = segment->deco;
+ font = segment->font;
+
+ if (segment->fg != fg) {
+ fg = segment->fg;
+ fg->SetupBrush (cr, element);
+ }
+
+ for (i = segment->start; i < segment->end; i++) {
+ if (!(glyph = font->GetGlyphInfo
(segment->text[i])))
+ continue;
+
+ bitmap = &glyph->bitmap;
+
+ height = bitmap->rows;
+ width = bitmap->width;
+ stride = bitmap->pitch;
+
+ cairo_move_to (cr, x + dx, y + dy);
+
+ // Render the glyph
+ surface = cairo_image_surface_create_for_data
(bitmap->buffer,
+
CAIRO_FORMAT_A8,
+
width, height,
+
stride);
+
+ cairo_set_source_surface (cr, surface,
glyph->bitmap_left, glyph->bitmap_top);
+
+ cairo_surface_destroy (surface);
+
+ dx += (double) glyph->metrics->horiAdvance;
+ }
+
+ segment = (TextSegment *) segment->next;
+ }
+
+ if ((line = (TextLine *) line->next))
+ dy += (double) line->height;
+ dx = 0.0f;
+ }
}
@@ -991,7 +1049,7 @@
-
+#if 0
void
TextLayout::Layout ()
{
@@ -1097,3 +1155,4 @@
i++;
}
}
+#endif
Modified: trunk/moon/src/font.h
===================================================================
--- trunk/moon/src/font.h 2007-09-19 14:20:15 UTC (rev 86011)
+++ trunk/moon/src/font.h 2007-09-19 14:20:21 UTC (rev 86012)
@@ -216,7 +216,7 @@
void Layout ();
void GetPixelSize (int *w, int *h);
- void Render (cairo_t *cr);
+ void Render (cairo_t *cr, UIElement *element);
};
#endif /* __FONT_H__ */
Modified: trunk/moon/src/mango.cpp
===================================================================
--- trunk/moon/src/mango.cpp 2007-09-19 14:20:15 UTC (rev 86011)
+++ trunk/moon/src/mango.cpp 2007-09-19 14:20:21 UTC (rev 86012)
@@ -262,9 +262,6 @@
{
MangoAttrForeground *fg = (MangoAttrForeground *) attr;
- if (fg->foreground)
- fg->foreground->unref ();
-
g_free (attr);
}
@@ -307,9 +304,6 @@
attr = g_new (MangoAttrForeground, 1);
attr->attr.klass = &klass;
- if (foreground)
- foreground->ref ();
-
attr->element = element;
attr->foreground = foreground;
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches