diff options
author | bungeman@google.com <bungeman@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-11-11 19:52:29 +0000 |
---|---|---|
committer | bungeman@google.com <bungeman@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-11-11 19:52:29 +0000 |
commit | 0cd74ad38ab7153144aa7866a3b476b716d4b4d6 (patch) | |
tree | 2a49d5d8b48171e358f5ea2c6085288b292be753 /src/fonts | |
parent | af356417622fac3b5b86fe3a3aa48eca7822c8f9 (diff) |
Make onCreateFromStream check that the stream looks like a font.
git-svn-id: http://skia.googlecode.com/svn/trunk@12224 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/fonts')
-rw-r--r-- | src/fonts/SkFontMgr_fontconfig.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/fonts/SkFontMgr_fontconfig.cpp b/src/fonts/SkFontMgr_fontconfig.cpp index 0b4accd254..a0ca7e4f33 100644 --- a/src/fonts/SkFontMgr_fontconfig.cpp +++ b/src/fonts/SkFontMgr_fontconfig.cpp @@ -18,6 +18,10 @@ #include <fontconfig/fontconfig.h> #include <unistd.h> +// Defined in SkFontHost_FreeType.cpp +bool find_name_and_attributes(SkStream* stream, SkString* name, + SkTypeface::Style* style, bool* isFixedWidth); + // borrow this global from SkFontHost_fontconfig. eventually that file should // go away, and be replaced with this one. extern SkFontConfigInterface* SkFontHost_fontconfig_ref_global(); @@ -274,7 +278,12 @@ protected: // TODO should the caller give us the style or should we get it from freetype? SkTypeface::Style style = SkTypeface::kNormal; - SkTypeface* face = SkNEW_ARGS(FontConfigTypeface, (style, false, stream)); + bool isFixedWidth = false; + if (!find_name_and_attributes(stream, NULL, &style, &isFixedWidth)) { + return NULL; + } + + SkTypeface* face = SkNEW_ARGS(FontConfigTypeface, (style, isFixedWidth, stream)); return face; } |