Author: fejj
Date: 2007-09-19 22:41:09 -0400 (Wed, 19 Sep 2007)
New Revision: 86058

Modified:
   trunk/moon/src/font.cpp
   trunk/moon/src/font.h
Log:
more rendering fixes



Modified: trunk/moon/src/font.cpp
===================================================================
--- trunk/moon/src/font.cpp     2007-09-20 01:48:24 UTC (rev 86057)
+++ trunk/moon/src/font.cpp     2007-09-20 02:41:09 UTC (rev 86058)
@@ -144,6 +144,8 @@
        
        //FcPatternGetDouble (matched, FC_PIXEL_SIZE, 0, &size);
        
+       //matched = FcFontMatch (NULL, pattern, &result);
+       
 retry:
        
        if (FcPatternGetString (matched, FC_FILE, 0, (FcChar8 **) &filename) != 
FcResultMatch)
@@ -231,6 +233,12 @@
 }
 
 int
+TextFont::Ascender ()
+{
+       return face->ascender / 64;
+}
+
+int
 TextFont::Height ()
 {
        return face->height / 64;
@@ -1045,14 +1053,17 @@
        TextFont *font = NULL;
        Brush *fg = NULL;
        TextLine *line;
+       int bx, by, oy;
        double dx, dy;
+       int ascend;
        int i;
        
        Layout ();
        
-       if ((line = (TextLine *) lines->First ()))
-               dy = (double) line->height;
+       line = (TextLine *) lines->First ();
+       
        dx = 0.0f;
+       dy = 0.0f;
        
        while (line) {
                segment = (TextSegment *) line->segments->First ();
@@ -1060,6 +1071,8 @@
                        deco = segment->deco;
                        font = segment->font;
                        
+                       ascend = font->Ascender ();
+                       
                        if (segment->fg != fg) {
                                fg = segment->fg;
                                fg->SetupBrush (cr, element);
@@ -1076,8 +1089,14 @@
                                        width = bitmap->width;
                                        stride = bitmap->pitch;
                                        
-                                       cairo_move_to (cr, x + dx, y + dy - 
glyph->metrics.horiBearingY);
+                                       bx = glyph->metrics.horiBearingX;
+                                       by = glyph->metrics.horiBearingY;
                                        
+                                       // y-offset for the top of the glyph
+                                       oy = ascend - (line->height - ascend) - 
by;
+                                       
+                                       cairo_move_to (cr, x + dx + bx, y + dy 
+ oy);
+                                       
                                        // Render the glyph
                                        // FIXME: set the surface on the cached 
glyph?
                                        surface = 
cairo_image_surface_create_for_data (bitmap->buffer,
@@ -1086,10 +1105,10 @@
                                                                                
       stride);
                                        
                                        cairo_save (cr);
-                                       cairo_set_source_surface (cr, surface, 
x + dx, y + dy - glyph->metrics.horiBearingY);
+                                       cairo_set_source_surface (cr, surface, 
x + dx + bx, y + dy + oy);
                                        
                                        cairo_new_path (cr);
-                                       cairo_rectangle (cr, x + dx, y + dy - 
glyph->metrics.horiBearingY,
+                                       cairo_rectangle (cr, x + dx + bx, y + 
dy + oy,
                                                         (double) width, 
(double) height);
                                        cairo_close_path (cr);
                                        cairo_fill (cr);
@@ -1104,8 +1123,9 @@
                        segment = (TextSegment *) segment->next;
                }
                
-               if ((line = (TextLine *) line->next))
-                       dy += (double) line->height;
+               dy += (double) line->height;
+               
+               line = (TextLine *) line->next;
                dx = 0.0f;
        }
 }

Modified: trunk/moon/src/font.h
===================================================================
--- trunk/moon/src/font.h       2007-09-20 01:48:24 UTC (rev 86057)
+++ trunk/moon/src/font.h       2007-09-20 02:41:09 UTC (rev 86058)
@@ -110,6 +110,7 @@
        
        const GlyphInfo *GetGlyphInfo (uint32_t unichar);
        
+       int Ascender ();
        int EmSize ();
        int Height ();
        

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to