Author: fejj Date: 2008-02-20 15:56:42 -0500 (Wed, 20 Feb 2008) New Revision: 96316
Modified: trunk/moon/src/ChangeLog trunk/moon/src/font.cpp trunk/moon/src/text.cpp Log: 2008-02-20 Jeffrey Stedfast <[EMAIL PROTECTED]> Fixes the TextBlockFontDownloads.htm test. * font.cpp (TextFontDescription::Set*): If the new value is not the same as the old, invalidate the loaded TextFont. (TextFont::TextFont): Always compare family names unless we're requesting the "Sans" (e.g. last) fallback font. (TextFont::TextFont): If the requested family name does not match the specified font file, fall back to a system font of the same name (we were doing this for zip archievs before, but not for specified ttf font files). * text.cpp (TextBlock::SetFontSource): If the downloader is null, set the font filename to null and invalidate the textblock. Modified: trunk/moon/src/ChangeLog =================================================================== --- trunk/moon/src/ChangeLog 2008-02-20 20:47:01 UTC (rev 96315) +++ trunk/moon/src/ChangeLog 2008-02-20 20:56:42 UTC (rev 96316) @@ -1,14 +1,32 @@ +2008-02-20 Jeffrey Stedfast <[EMAIL PROTECTED]> + + Fixes the TextBlockFontDownloads.htm test. + + * font.cpp (TextFontDescription::Set*): If the new value is not + the same as the old, invalidate the loaded TextFont. + (TextFont::TextFont): Always compare family names unless we're + requesting the "Sans" (e.g. last) fallback font. + (TextFont::TextFont): If the requested family name does not match + the specified font file, fall back to a system font of the same + name (we were doing this for zip archievs before, but not for + specified ttf font files). + + * text.cpp (TextBlock::SetFontSource): If the downloader is null, + set the font filename to null and invalidate the textblock. + 2008-02-20 Rolf Bjarne Kvinge <[EMAIL PROTECTED]> - * media.cpp: Add a printf to inform when we're trying to load an mms stream. - Helps a lot when trying to identify sites depending on mms/streaming - support. - * runtime.cpp: Unref debug_selected_element upon destruction. Fixes a leak. + * media.cpp: Add a printf to inform when we're trying to load an + mms stream. Helps a lot when trying to identify sites depending + on mms/streaming support. + * runtime.cpp: Unref debug_selected_element upon + destruction. Fixes a leak. + 2008-02-20 Michael Dominic K. <[EMAIL PROTECTED]> - * src/shape.cpp: Fixing the shape caching to work also with Path/Geometry. - Fixes: #362021. + * src/shape.cpp: Fixing the shape caching to work also with + Path/Geometry. Fixes: #362021. 2008-02-20 Rolf Bjarne Kvinge <[EMAIL PROTECTED]> Modified: trunk/moon/src/font.cpp =================================================================== --- trunk/moon/src/font.cpp 2008-02-20 20:47:01 UTC (rev 96315) +++ trunk/moon/src/font.cpp 2008-02-20 20:56:42 UTC (rev 96316) @@ -458,8 +458,14 @@ d(fprintf (stderr, "\t\t* extracting %s...\n", filename)); - g_string_append (packdir, filename); + // use the file's base name, we don't care about recreating the file heirarchy + if (!(name = strrchr (filename, '/'))) + name = filename; + else + name++; + g_string_append (packdir, name); + // we first try using the file's original name... fd = open (packdir->str, O_WRONLY | O_CREAT | O_EXCL, 0600); if (fd == -1 && errno == EEXIST) { @@ -643,7 +649,7 @@ d(fprintf (stderr, "\t* loading font from `%s' (index=%d)... ", filename, id)); if ((err = FT_New_Face (libft2, (const char *) filename, id, &face)) == 0) { - if (fromFile || attempt > 0 || !family_name || !face->family_name) { + if (!family_name || !face->family_name) { d(fprintf (stderr, "success!\n")); break; } @@ -667,17 +673,18 @@ d(fprintf (stderr, "failed :(\n")); } - if (fromFile && err == FT_Err_Unknown_File_Format) { - // fromFile indicates that an absolute path was given... + // fromFile indicates that an absolute path was given... + if (fromFile) { // check if it is a zipped font collection. - if (OpenZipArchiveFont (pattern, (const char *) filename)) { + if (err == FT_Err_Unknown_File_Format && + OpenZipArchiveFont (pattern, (const char *) filename)) { d(fprintf (stderr, "\t* success!\n")); break; } fromFile = false; - // We couldn't find the font in the zip archive, but if the pattern + // We couldn't find the font in the zip archive/specified font file, but if the pattern // has a family specified then try checking if we have a font that // matches it on the system. if (FcPatternGetString (matched, FC_FAMILY, 0, &family) == FcResultMatch) { @@ -712,6 +719,10 @@ face = NULL; attempt++; + + // if we're on our last attempt, the family_name no longer matters + if (attempt == G_N_ELEMENTS (fallback_fonts)) + family_name = NULL; } while (attempt <= G_N_ELEMENTS (fallback_fonts)); FcPatternDestroy (matched); @@ -1440,15 +1451,28 @@ void TextFontDescription::SetFilename (const char *filename) { - g_free (this->filename); + bool changed; if (filename) { - this->filename = g_strdup (filename); - set |= FontMaskFilename; + if (!this->filename || strcmp (this->filename, filename) != 0) { + g_free (this->filename); + this->filename = g_strdup (filename); + set |= FontMaskFilename; + changed = true; + } else { + changed = false; + } } else { + changed = this->filename != NULL; + set &= ~FontMaskFilename; + g_free (this->filename); this->filename = NULL; - set &= ~FontMaskFilename; } + + if (changed && font != NULL) { + font->unref (); + font = NULL; + } } int @@ -1460,7 +1484,14 @@ void TextFontDescription::SetIndex (int index) { + bool changed = this->index != index; + this->index = index; + + if (changed && font != NULL) { + font->unref (); + font = NULL; + } } const char * @@ -1475,15 +1506,28 @@ void TextFontDescription::SetFamily (const char *family) { - g_free (this->family); + bool changed; if (family) { - this->family = g_strdup (family); - set |= FontMaskFamily; + if (!this->family || g_ascii_strcasecmp (this->family, family) != 0) { + g_free (this->family); + this->family = g_strdup (family); + set |= FontMaskFamily; + changed = true; + } else { + changed = false; + } } else { + changed = this->family != NULL; + set &= ~FontMaskFamily; + g_free (this->family); this->family = NULL; - set &= ~FontMaskFamily; } + + if (changed && font != NULL) { + font->unref (); + font = NULL; + } } FontStyles @@ -1495,8 +1539,15 @@ void TextFontDescription::SetStyle (FontStyles style) { + bool changed = this->style != style; + this->style = style; set |= FontMaskStyle; + + if (changed && font != NULL) { + font->unref (); + font = NULL; + } } FontWeights @@ -1508,8 +1559,15 @@ void TextFontDescription::SetWeight (FontWeights weight) { + bool changed = this->weight != weight; + this->weight = weight; set |= FontMaskWeight; + + if (changed && font != NULL) { + font->unref (); + font = NULL; + } } FontStretches @@ -1521,8 +1579,15 @@ void TextFontDescription::SetStretch (FontStretches stretch) { + bool changed = this->stretch != stretch; + this->stretch = stretch; set |= FontMaskStretch; + + if (changed && font != NULL) { + font->unref (); + font = NULL; + } } double @@ -1534,8 +1599,15 @@ void TextFontDescription::SetSize (double size) { + bool changed = this->size != size; + this->size = size; set |= FontMaskSize; + + if (changed && font != NULL) { + font->unref (); + font = NULL; + } } char * Modified: trunk/moon/src/text.cpp =================================================================== --- trunk/moon/src/text.cpp 2008-02-20 20:47:01 UTC (rev 96315) +++ trunk/moon/src/text.cpp 2008-02-20 20:56:42 UTC (rev 96316) @@ -448,6 +448,12 @@ // This is what actually triggers the download downloader->Send (); } + } else { + font.custom->SetFilename (NULL); + dirty = true; + + UpdateBounds (true); + Invalidate (); } } _______________________________________________ Mono-patches maillist - Mono-patches@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-patches