static bool get_name_and_style(const char path[], SkString* name, SkTypeface::Style* style, bool* isFixedWidth) { SkMMAPStream stream(path); if (stream.getLength() > 0) { return find_name_and_attributes(&stream, name, style, isFixedWidth); } else { SkFILEStream stream(path); if (stream.getLength() > 0) { return find_name_and_attributes(&stream, name, style, isFixedWidth); } } SkDebugf("---- failed to open <%s> as a font\n", path); return false; }
SkTypeface* SkFontHost::CreateTypefaceFromStream(SkStream* stream) { if (NULL == stream || stream->getLength() <= 0) { SkDELETE(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, isFixedWidth)); }
SkTypeface* SkFontHost::CreateTypefaceFromStream(SkStream* stream) { if (NULL == stream || stream->getLength() <= 0) { return NULL; } SkTypeface::Style style; if (find_name_and_attributes(stream, NULL, &style, NULL)) { return SkNEW_ARGS(StreamTypeface, (style, false, NULL, stream)); } else { return NULL; } }
static bool get_name_and_style(const char path[], SkString* name, SkTypeface::Style* style, bool isExpected) { SkString fullpath; GetFullPathForSysFonts(&fullpath, path); SkMMAPStream stream(fullpath.c_str()); if (stream.getLength() > 0) { return find_name_and_attributes(&stream, name, style, NULL); } else { SkFILEStream stream(fullpath.c_str()); if (stream.getLength() > 0) { return find_name_and_attributes(&stream, name, style, NULL); } } if (isExpected) { SkDebugf("---- failed to open <%s> as a font\n", fullpath.c_str()); } return false; }
SkTypeface* SkFontHost::CreateTypefaceFromStream(SkStream* stream) { if (NULL == stream || stream->getLength() <= 0) { return NULL; } bool isFixedWidth; SkTypeface::Style style; if (find_name_and_attributes(stream, NULL, &style, &isFixedWidth)) { SkAutoMutexAcquire ac(gFamilyHeadAndNameListMutex); // Make sure system fonts are loaded to comply with the assumption of // unique id offset by one in find_uniqueID. load_system_fonts(); return SkNEW_ARGS(StreamTypeface, (style, false, NULL, stream, isFixedWidth)); } else { return NULL; } }