diff options
author | 2012-02-15 21:03:45 +0000 | |
---|---|---|
committer | 2012-02-15 21:03:45 +0000 | |
commit | 4dc686d75353235260c716242f4ed596b70beb95 (patch) | |
tree | 799d194465140f1424b336115c42cc95404da648 /src | |
parent | 48b481bc22da6cd1481ec3bcb7f2ec8b00a53785 (diff) |
Fix regression where we disable fonts with no specified name
Review URL: https://codereview.appspot.com/5675061
git-svn-id: http://skia.googlecode.com/svn/trunk@3202 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r-- | src/ports/SkFontHost_FreeType.cpp | 27 | ||||
-rw-r--r-- | src/ports/SkFontHost_android.cpp | 15 | ||||
-rw-r--r-- | src/ports/SkFontHost_linux.cpp | 20 | ||||
-rw-r--r-- | src/ports/SkFontHost_simple.cpp | 23 |
4 files changed, 41 insertions, 44 deletions
diff --git a/src/ports/SkFontHost_FreeType.cpp b/src/ports/SkFontHost_FreeType.cpp index caca577ac7..1ef0b3df4f 100644 --- a/src/ports/SkFontHost_FreeType.cpp +++ b/src/ports/SkFontHost_FreeType.cpp @@ -1477,12 +1477,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 +1508,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 +1531,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 9a6d633182..906643e28b 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")); @@ -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 fa1d2eca66..9195224119 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 7a06b10d65..f94226e71a 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[]) { |