diff options
author | agl@chromium.org <agl@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2010-04-20 22:06:40 +0000 |
---|---|---|
committer | agl@chromium.org <agl@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2010-04-20 22:06:40 +0000 |
commit | 5f6a0762f14f73859e60f0e8339ca133d10e4d3c (patch) | |
tree | ea04605d6b956e3f1b591c754a74148ef1c68294 /src | |
parent | 756f6dd82da298375547cb36955be9ac8574d2dc (diff) |
Add a SkTypeface::CreateForChars() function.
This allows us to do font fallback for strange scripts.
Added empty stubs to the implementations on all platforms.
Patch-by: Evan Martin
Signed-off-by: Adam Langley
http://codereview.appspot.com/950041
git-svn-id: http://skia.googlecode.com/svn/trunk@557 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkTypeface.cpp | 14 | ||||
-rw-r--r-- | src/ports/SkFontHost_FONTPATH.cpp | 1 | ||||
-rw-r--r-- | src/ports/SkFontHost_android.cpp | 3 | ||||
-rw-r--r-- | src/ports/SkFontHost_fontconfig.cpp | 1 | ||||
-rw-r--r-- | src/ports/SkFontHost_linux.cpp | 5 | ||||
-rwxr-xr-x | src/ports/SkFontHost_mac.cpp | 4 | ||||
-rw-r--r-- | src/ports/SkFontHost_none.cpp | 1 | ||||
-rw-r--r-- | src/ports/SkFontHost_simple.cpp | 3 | ||||
-rw-r--r-- | src/ports/SkFontHost_win.cpp | 1 |
9 files changed, 24 insertions, 9 deletions
diff --git a/src/core/SkTypeface.cpp b/src/core/SkTypeface.cpp index 65052c1cec..44337610c8 100644 --- a/src/core/SkTypeface.cpp +++ b/src/core/SkTypeface.cpp @@ -12,8 +12,9 @@ uint32_t SkTypeface::UniqueID(const SkTypeface* face) { static uint32_t gDefaultFontID; if (0 == gDefaultFontID) { - SkTypeface* defaultFace = SkFontHost::CreateTypeface(NULL, NULL, - SkTypeface::kNormal); + SkTypeface* defaultFace = + SkFontHost::CreateTypeface(NULL, NULL, NULL, 0, + SkTypeface::kNormal); SkASSERT(defaultFace); gDefaultFontID = defaultFace->uniqueID(); defaultFace->unref(); @@ -28,11 +29,16 @@ bool SkTypeface::Equal(const SkTypeface* facea, const SkTypeface* faceb) { /////////////////////////////////////////////////////////////////////////////// SkTypeface* SkTypeface::CreateFromName(const char name[], Style style) { - return SkFontHost::CreateTypeface(NULL, name, style); + return SkFontHost::CreateTypeface(NULL, name, NULL, 0, style); +} + +SkTypeface* SkTypeface::CreateForChars(const void* data, size_t bytelength, + Style s) { + return SkFontHost::CreateTypeface(NULL, NULL, data, bytelength, s); } SkTypeface* SkTypeface::CreateFromTypeface(const SkTypeface* family, Style s) { - return SkFontHost::CreateTypeface(family, NULL, s); + return SkFontHost::CreateTypeface(family, NULL, NULL, NULL, s); } SkTypeface* SkTypeface::CreateFromStream(SkStream* stream) { diff --git a/src/ports/SkFontHost_FONTPATH.cpp b/src/ports/SkFontHost_FONTPATH.cpp index 211ed90f66..308adf8070 100644 --- a/src/ports/SkFontHost_FONTPATH.cpp +++ b/src/ports/SkFontHost_FONTPATH.cpp @@ -241,6 +241,7 @@ static uint32_t ptr2uint32(const void* p) SkTypeface* SkFontHost::CreateTypeface(const SkTypeface* familyFace, const char familyName[], + const void* data, size_t bytelength, SkTypeface::Style style) { const FontFamilyRec* family; diff --git a/src/ports/SkFontHost_android.cpp b/src/ports/SkFontHost_android.cpp index f50e35952c..3eb755d468 100644 --- a/src/ports/SkFontHost_android.cpp +++ b/src/ports/SkFontHost_android.cpp @@ -542,7 +542,7 @@ SkTypeface* SkFontHost::Deserialize(SkStream* stream) { for (int j = i; j >= 0; --j) { if (rec[j].fNames != NULL) { return SkFontHost::CreateTypeface(NULL, - rec[j].fNames[0], (SkTypeface::Style)style); + rec[j].fNames[0], NULL, 0, (SkTypeface::Style)style); } } } @@ -555,6 +555,7 @@ SkTypeface* SkFontHost::Deserialize(SkStream* stream) { SkTypeface* SkFontHost::CreateTypeface(const SkTypeface* familyFace, const char familyName[], + const void* data, size_t bytelength, SkTypeface::Style style) { load_system_fonts(); diff --git a/src/ports/SkFontHost_fontconfig.cpp b/src/ports/SkFontHost_fontconfig.cpp index 83a75ce74d..d1da8d1589 100644 --- a/src/ports/SkFontHost_fontconfig.cpp +++ b/src/ports/SkFontHost_fontconfig.cpp @@ -219,6 +219,7 @@ static unsigned FileIdFromFilename(const char* filename) // static SkTypeface* SkFontHost::CreateTypeface(const SkTypeface* familyFace, const char familyName[], + const void* data, size_t bytelength, SkTypeface::Style style) { const char* resolved_family_name = NULL; diff --git a/src/ports/SkFontHost_linux.cpp b/src/ports/SkFontHost_linux.cpp index c838d8ca85..ebebd08bda 100644 --- a/src/ports/SkFontHost_linux.cpp +++ b/src/ports/SkFontHost_linux.cpp @@ -509,14 +509,14 @@ SkTypeface* SkFontHost::Deserialize(SkStream* stream) { // backup until we hit the fNames for (int j = i; j >= 0; --j) { if (rec[j].fNames != NULL) { - return SkFontHost::CreateTypeface(NULL, rec[j].fNames[0], + return SkFontHost::CreateTypeface(NULL, rec[j].fNames[0], NULL, 0, (SkTypeface::Style)style); } } } } } - return SkFontHost::CreateTypeface(NULL, NULL, (SkTypeface::Style)style); + return SkFontHost::CreateTypeface(NULL, NULL, NULL, 0, (SkTypeface::Style)style); #endif sk_throw(); return NULL; @@ -526,6 +526,7 @@ SkTypeface* SkFontHost::Deserialize(SkStream* stream) { SkTypeface* SkFontHost::CreateTypeface(const SkTypeface* familyFace, const char familyName[], + const void* data, size_t bytelength, SkTypeface::Style style) { load_system_fonts(); diff --git a/src/ports/SkFontHost_mac.cpp b/src/ports/SkFontHost_mac.cpp index a652d9d3d1..a0239e224c 100755 --- a/src/ports/SkFontHost_mac.cpp +++ b/src/ports/SkFontHost_mac.cpp @@ -492,7 +492,9 @@ uint32_t SkFontHost::NextLogicalFont(uint32_t fontID) { } SkTypeface* SkFontHost::CreateTypeface(const SkTypeface* familyFace, - const char familyName[], SkTypeface::Style style) { + const char familyName[], + const void* data, size_t bytelength, + SkTypeface::Style style) { // todo: we don't know how to respect style bits if (NULL == familyName && NULL != familyFace) { familyFace->ref(); diff --git a/src/ports/SkFontHost_none.cpp b/src/ports/SkFontHost_none.cpp index 9132c74e61..ae56ae4e14 100644 --- a/src/ports/SkFontHost_none.cpp +++ b/src/ports/SkFontHost_none.cpp @@ -17,6 +17,7 @@ SkTypeface* SkFontHost::CreateTypeface(const SkTypeface* familyFace, const char famillyName[], + const void* data, size_t bytelength, SkTypeface::Style style) { SkASSERT(!"SkFontHost::FindTypeface unimplemented"); return NULL; diff --git a/src/ports/SkFontHost_simple.cpp b/src/ports/SkFontHost_simple.cpp index deda04d090..9e126bccf8 100644 --- a/src/ports/SkFontHost_simple.cpp +++ b/src/ports/SkFontHost_simple.cpp @@ -507,7 +507,7 @@ SkTypeface* SkFontHost::Deserialize(SkStream* stream) { for (int j = i; j >= 0; --j) { if (rec[j].fNames != NULL) { return SkFontHost::CreateTypeface(NULL, - rec[j].fNames[0], (SkTypeface::Style)style); + rec[j].fNames[0], NULL, 0, (SkTypeface::Style)style); } } } @@ -520,6 +520,7 @@ SkTypeface* SkFontHost::Deserialize(SkStream* stream) { SkTypeface* SkFontHost::CreateTypeface(const SkTypeface* familyFace, const char familyName[], + const void* data, size_t bytelength, SkTypeface::Style style) { load_system_fonts(); diff --git a/src/ports/SkFontHost_win.cpp b/src/ports/SkFontHost_win.cpp index 4533d3c0e4..f9ed7ad67c 100644 --- a/src/ports/SkFontHost_win.cpp +++ b/src/ports/SkFontHost_win.cpp @@ -540,6 +540,7 @@ SkScalerContext* SkFontHost::CreateScalerContext(const SkDescriptor* desc) { SkTypeface* SkFontHost::CreateTypeface(const SkTypeface* familyFace,
const char familyName[],
+ const void* data, size_t bytelength,
SkTypeface::Style style) {
SkAutoMutexAcquire ac(gFTMutex);
|