diff options
author | Derek Sollenberger <djsollen@google.com> | 2012-02-15 13:07:27 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-02-15 13:07:27 -0800 |
commit | e7446b617bff9205876c210ca02cb69acf050782 (patch) | |
tree | 60cce4636fa40bb5d91361d9ebee07d1b41ef0c3 /src | |
parent | 208281e97e021dd8d903644d50cb0caa2863722b (diff) | |
parent | 1a2684e4aca61eb1f7617f6d44677162106e92e0 (diff) | |
download | external_skia-e7446b617bff9205876c210ca02cb69acf050782.zip external_skia-e7446b617bff9205876c210ca02cb69acf050782.tar.gz external_skia-e7446b617bff9205876c210ca02cb69acf050782.tar.bz2 |
Merge "Fix regression where we disable fonts with no specified name."
Diffstat (limited to 'src')
-rw-r--r-- | src/ports/SkFontHost_FreeType.cpp | 37 | ||||
-rw-r--r-- | src/ports/SkFontHost_android.cpp | 17 | ||||
-rw-r--r-- | src/ports/SkFontHost_linux.cpp | 20 | ||||
-rw-r--r-- | src/ports/SkFontHost_simple.cpp | 23 |
4 files changed, 42 insertions, 55 deletions
diff --git a/src/ports/SkFontHost_FreeType.cpp b/src/ports/SkFontHost_FreeType.cpp index 61efb95..94cd1b0 100644 --- a/src/ports/SkFontHost_FreeType.cpp +++ b/src/ports/SkFontHost_FreeType.cpp @@ -857,16 +857,6 @@ SkScalerContext_FreeType::~SkScalerContext_FreeType() { this face with other context (at different sizes). */ FT_Error SkScalerContext_FreeType::setupSize() { - /* In the off-chance that a font has been removed, we want to error out - right away, so call resolve just to be sure. - - TODO: perhaps we can skip this, by walking the global font cache and - killing all of the contexts when we know that a given fontID is going - away... - */ - if (!SkFontHost::ValidFontID(fRec.fFontID)) { - return (FT_Error)-1; - } FT_Error err = FT_Activate_Size(fFTSize); @@ -1477,12 +1467,11 @@ SkScalerContext* SkFontHost::CreateScalerContext(const SkDescriptor* desc) { /* Export this so that other parts of our FonttHost port can make use of our ability to extract the name+style from a stream, using FreeType's api. */ -SkTypeface::Style find_name_and_attributes(SkStream* stream, SkString* name, - bool* isFixedWidth) { +bool find_name_and_attributes(SkStream* stream, SkString* name, + SkTypeface::Style* style, bool* isFixedWidth) { FT_Library library; if (FT_Init_FreeType(&library)) { - name->reset(); - return SkTypeface::kNormal; + return false; } FT_Open_Args args; @@ -1509,18 +1498,22 @@ SkTypeface::Style find_name_and_attributes(SkStream* stream, SkString* name, FT_Face face; if (FT_Open_Face(library, &args, 0, &face)) { FT_Done_FreeType(library); - name->reset(); - return SkTypeface::kNormal; + return false; } - name->set(face->family_name); - int style = SkTypeface::kNormal; - + int tempStyle = SkTypeface::kNormal; if (face->style_flags & FT_STYLE_FLAG_BOLD) { - style |= SkTypeface::kBold; + tempStyle |= SkTypeface::kBold; } if (face->style_flags & FT_STYLE_FLAG_ITALIC) { - style |= SkTypeface::kItalic; + tempStyle |= SkTypeface::kItalic; + } + + if (name) { + name->set(face->family_name); + } + if (style) { + *style = (SkTypeface::Style) tempStyle; } if (isFixedWidth) { *isFixedWidth = FT_IS_FIXED_WIDTH(face); @@ -1528,5 +1521,5 @@ SkTypeface::Style find_name_and_attributes(SkStream* stream, SkString* name, FT_Done_Face(face); FT_Done_FreeType(library); - return (SkTypeface::Style)style; + return true; } diff --git a/src/ports/SkFontHost_android.cpp b/src/ports/SkFontHost_android.cpp index b07d93d..0f41818 100644 --- a/src/ports/SkFontHost_android.cpp +++ b/src/ports/SkFontHost_android.cpp @@ -32,8 +32,8 @@ #define SK_FONT_FILE_PREFIX "/fonts/" #endif -SkTypeface::Style find_name_and_attributes(SkStream* stream, SkString* name, - bool* isFixedWidth); +bool find_name_and_attributes(SkStream* stream, SkString* name, + SkTypeface::Style* style, bool* isFixedWidth); static void GetFullPathForSysFonts(SkString* full, const char name[]) { full->set(getenv("ANDROID_ROOT")); @@ -108,7 +108,7 @@ static SkTypeface* find_best_face(const FamilyRec* family, } } // should never get here, since the faces list should not be empty - SkASSERT(!"faces list is empty"); + SkDEBUGFAIL("faces list is empty"); return NULL; } @@ -373,14 +373,12 @@ static bool get_name_and_style(const char path[], SkString* name, SkMMAPStream stream(fullpath.c_str()); if (stream.getLength() > 0) { - *style = find_name_and_attributes(&stream, name, isFixedWidth); - return true; + return find_name_and_attributes(&stream, name, style, isFixedWidth); } else { SkFILEStream stream(fullpath.c_str()); if (stream.getLength() > 0) { - *style = find_name_and_attributes(&stream, name, isFixedWidth); - return true; + return find_name_and_attributes(&stream, name, style, isFixedWidth); } } @@ -749,10 +747,9 @@ SkTypeface* SkFontHost::CreateTypefaceFromStream(SkStream* stream) { } bool isFixedWidth; - SkString name; - SkTypeface::Style style = find_name_and_attributes(stream, &name, &isFixedWidth); + SkTypeface::Style style; - if (!name.isEmpty()) { + if (find_name_and_attributes(stream, NULL, &style, &isFixedWidth)) { return SkNEW_ARGS(StreamTypeface, (style, false, NULL, stream, isFixedWidth)); } else { return NULL; diff --git a/src/ports/SkFontHost_linux.cpp b/src/ports/SkFontHost_linux.cpp index c87b036..14684ed 100644 --- a/src/ports/SkFontHost_linux.cpp +++ b/src/ports/SkFontHost_linux.cpp @@ -22,8 +22,8 @@ #define SK_FONT_FILE_PREFIX "/usr/share/fonts/truetype/msttcorefonts/" #endif -SkTypeface::Style find_name_and_attributes(SkStream* stream, SkString* name, - bool* isFixedWidth); +bool find_name_and_attributes(SkStream* stream, SkString* name, + SkTypeface::Style* style, bool* isFixedWidth); static void GetFullPathForSysFonts(SkString* full, const char name[]) { @@ -358,14 +358,12 @@ static bool get_name_and_style(const char path[], SkString* name, SkTypeface::Style* style, bool* isFixedWidth) { SkMMAPStream stream(path); if (stream.getLength() > 0) { - *style = find_name_and_attributes(&stream, name, isFixedWidth); - return true; + return find_name_and_attributes(&stream, name, style, isFixedWidth); } else { SkFILEStream stream(path); if (stream.getLength() > 0) { - *style = find_name_and_attributes(&stream, name, isFixedWidth); - return true; + return find_name_and_attributes(&stream, name, style, isFixedWidth); } } @@ -581,10 +579,12 @@ SkTypeface* SkFontHost::CreateTypefaceFromStream(SkStream* stream) { } bool isFixedWidth; - SkString name; - SkTypeface::Style style = find_name_and_attributes(stream, &name, &isFixedWidth); - - return SkNEW_ARGS(StreamTypeface, (style, false, NULL, stream, isFixedWidth)); + SkTypeface::Style style; + if (find_name_and_attributes(stream, NULL, &style, &isFixedWidth)) { + return SkNEW_ARGS(StreamTypeface, (style, false, NULL, stream, isFixedWidth)); + } else { + return NULL; + } } SkTypeface* SkFontHost::CreateTypefaceFromFile(const char path[]) { diff --git a/src/ports/SkFontHost_simple.cpp b/src/ports/SkFontHost_simple.cpp index 0624d35..c0674ca 100644 --- a/src/ports/SkFontHost_simple.cpp +++ b/src/ports/SkFontHost_simple.cpp @@ -23,8 +23,8 @@ #define SK_FONT_FILE_PREFIX "/skimages/" #endif -SkTypeface::Style find_name_and_attributes(SkStream* stream, SkString* name, - bool* isFixedWidth); +bool find_name_and_attributes(SkStream* stream, SkString* name, + SkTypeface::Style* style, bool* isFixedWidth); static void GetFullPathForSysFonts(SkString* full, const char name[]) { full->set(SK_FONT_FILE_PREFIX); @@ -350,20 +350,17 @@ private: static bool get_name_and_style(const char path[], SkString* name, SkTypeface::Style* style, bool isExpected) { - bool isFixedWidth; SkString fullpath; GetFullPathForSysFonts(&fullpath, path); SkMMAPStream stream(fullpath.c_str()); if (stream.getLength() > 0) { - *style = find_name_and_attributes(&stream, name, &isFixedWidth); - return true; + return find_name_and_attributes(&stream, name, style, NULL); } else { SkFILEStream stream(fullpath.c_str()); if (stream.getLength() > 0) { - *style = find_name_and_attributes(&stream, name, &isFixedWidth); - return true; + return find_name_and_attributes(&stream, name, style, NULL); } } @@ -635,12 +632,12 @@ SkTypeface* SkFontHost::CreateTypefaceFromStream(SkStream* stream) { return NULL; } - bool isFixedWidth; - SkString name; - SkTypeface::Style style = find_name_and_attributes(stream, &name, - &isFixedWidth); - - return SkNEW_ARGS(StreamTypeface, (style, false, NULL, stream)); + SkTypeface::Style style; + if (find_name_and_attributes(stream, NULL, &style, NULL)) { + return SkNEW_ARGS(StreamTypeface, (style, false, NULL, stream)); + } else { + return NULL; + } } SkTypeface* SkFontHost::CreateTypefaceFromFile(const char path[]) { |