diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-06-13 13:01:10 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-06-13 13:01:10 +0000 |
commit | 7d26c590f6bc431a5ecf5c25619b64d058613a4d (patch) | |
tree | fc915a95e51cc6bc9a518d30b00a5f274ab835ad | |
parent | 80afbf08eb82a99f8a2eeeb1741eb7ca1ccf957d (diff) |
add 2nd parameter to SkFontHost::NextLogicalFont()
needed by android to map different styles of fallback fonts
git-svn-id: http://skia.googlecode.com/svn/trunk@1562 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | include/core/SkFontHost.h | 24 | ||||
-rw-r--r-- | include/core/SkScalerContext.h | 1 | ||||
-rw-r--r-- | src/core/SkPaint.cpp | 3 | ||||
-rw-r--r-- | src/core/SkScalerContext.cpp | 2 | ||||
-rw-r--r-- | src/ports/SkFontHost_android.cpp | 4 | ||||
-rw-r--r-- | src/ports/SkFontHost_fontconfig.cpp | 3 | ||||
-rw-r--r-- | src/ports/SkFontHost_linux.cpp | 2 | ||||
-rw-r--r-- | src/ports/SkFontHost_mac_atsui.cpp | 4 | ||||
-rw-r--r-- | src/ports/SkFontHost_mac_coretext.cpp | 4 | ||||
-rw-r--r-- | src/ports/SkFontHost_none.cpp | 2 | ||||
-rw-r--r-- | src/ports/SkFontHost_simple.cpp | 4 | ||||
-rwxr-xr-x | src/ports/SkFontHost_win.cpp | 2 |
12 files changed, 32 insertions, 23 deletions
diff --git a/include/core/SkFontHost.h b/include/core/SkFontHost.h index d0f7c650e0..e20ea05878 100644 --- a/include/core/SkFontHost.h +++ b/include/core/SkFontHost.h @@ -150,14 +150,22 @@ public: */ static SkScalerContext* CreateScalerContext(const SkDescriptor* desc); - /** Given a "current" fontID, return the next logical fontID to use - when searching fonts for a given unicode value. Typically the caller - will query a given font, and if a unicode value is not supported, they - will call this, and if 0 is not returned, will search that font, and so - on. This process must be finite, and when the fonthost sees a - font with no logical successor, it must return 0. - */ - static uint32_t NextLogicalFont(SkFontID fontID); + /** + * Given a "current" fontID, return the next logical fontID to use + * when searching fonts for a given unicode value. Typically the caller + * will query a given font, and if a unicode value is not supported, they + * will call this, and if 0 is not returned, will search that font, and so + * on. This process must be finite, and when the fonthost sees a + * font with no logical successor, it must return 0. + * + * The original fontID is also provided. This is the initial font that was + * stored in the typeface of the caller. It is provided as an aid to choose + * the best next logical font. e.g. If the original font was bold or serif, + * but the 2nd in the logical chain was plain, then a subsequent call to + * get the 3rd can still inspect the original, and try to match its + * stylistic attributes. + */ + static SkFontID NextLogicalFont(SkFontID currFontID, SkFontID origFontID); /////////////////////////////////////////////////////////////////////////// diff --git a/include/core/SkScalerContext.h b/include/core/SkScalerContext.h index 3f818a3112..cbbbdf0357 100644 --- a/include/core/SkScalerContext.h +++ b/include/core/SkScalerContext.h @@ -189,6 +189,7 @@ private: }; public: struct Rec { + uint32_t fOrigFontID; uint32_t fFontID; SkScalar fTextSize, fPreScaleX, fPreSkewX; SkScalar fPost2x2[2][2]; diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp index b7b6a34e1d..f9abe3f420 100644 --- a/src/core/SkPaint.cpp +++ b/src/core/SkPaint.cpp @@ -1234,7 +1234,8 @@ void SkScalerContext::MakeRec(const SkPaint& paint, const SkMatrix* deviceMatrix, Rec* rec) { SkASSERT(deviceMatrix == NULL || !deviceMatrix->hasPerspective()); - rec->fFontID = SkTypeface::UniqueID(paint.getTypeface()); + rec->fOrigFontID = SkTypeface::UniqueID(paint.getTypeface()); + rec->fFontID = rec->fOrigFontID; rec->fTextSize = paint.getTextSize(); rec->fPreScaleX = paint.getTextScaleX(); rec->fPreSkewX = paint.getTextSkewX(); diff --git a/src/core/SkScalerContext.cpp b/src/core/SkScalerContext.cpp index 6b5f663f85..05439f1f55 100644 --- a/src/core/SkScalerContext.cpp +++ b/src/core/SkScalerContext.cpp @@ -180,7 +180,7 @@ static SkScalerContext* allocNextContext(const SkScalerContext::Rec& rec) { // fonthost will determine the next possible font to search, based // on the current font in fRec. It will return NULL if ctx is our // last font that can be searched (i.e. ultimate fallback font) - uint32_t newFontID = SkFontHost::NextLogicalFont(rec.fFontID); + uint32_t newFontID = SkFontHost::NextLogicalFont(rec.fFontID, rec.fOrigFontID); if (0 == newFontID) { return NULL; } diff --git a/src/ports/SkFontHost_android.cpp b/src/ports/SkFontHost_android.cpp index d01577d695..e9b398688f 100644 --- a/src/ports/SkFontHost_android.cpp +++ b/src/ports/SkFontHost_android.cpp @@ -632,7 +632,7 @@ size_t SkFontHost::GetFileName(SkFontID fontID, char path[], size_t length, } } -uint32_t SkFontHost::NextLogicalFont(uint32_t fontID) { +SkFontID SkFontHost::NextLogicalFont(SkFontID currFontID, SkFontID origFontID) { load_system_fonts(); /* First see if fontID is already one of our fallbacks. If so, return @@ -642,7 +642,7 @@ uint32_t SkFontHost::NextLogicalFont(uint32_t fontID) { */ const uint32_t* list = gFallbackFonts; for (int i = 0; list[i] != 0; i++) { - if (list[i] == fontID) { + if (list[i] == currFontID) { return list[i+1]; } } diff --git a/src/ports/SkFontHost_fontconfig.cpp b/src/ports/SkFontHost_fontconfig.cpp index 21fc7739b3..332c911e10 100644 --- a/src/ports/SkFontHost_fontconfig.cpp +++ b/src/ports/SkFontHost_fontconfig.cpp @@ -364,8 +364,7 @@ SkTypeface* SkFontHost::Deserialize(SkStream* stream) { return NULL; } -// static -uint32_t SkFontHost::NextLogicalFont(SkFontID fontID) { +SkFontID SkFontHost::NextLogicalFont(SkFontID currFontID, SkFontID origFontID) { // We don't handle font fallback, WebKit does. return 0; } diff --git a/src/ports/SkFontHost_linux.cpp b/src/ports/SkFontHost_linux.cpp index 37c2c35eb2..9ede78c50b 100644 --- a/src/ports/SkFontHost_linux.cpp +++ b/src/ports/SkFontHost_linux.cpp @@ -578,7 +578,7 @@ size_t SkFontHost::GetFileName(SkFontID fontID, char path[], size_t length, return 0; } -uint32_t SkFontHost::NextLogicalFont(uint32_t fontID) { +SkFontID SkFontHost::NextLogicalFont(SkFontID currFontID, SkFontID origFontID) { return 0; } diff --git a/src/ports/SkFontHost_mac_atsui.cpp b/src/ports/SkFontHost_mac_atsui.cpp index 5bc438a4b6..fb61c6068a 100644 --- a/src/ports/SkFontHost_mac_atsui.cpp +++ b/src/ports/SkFontHost_mac_atsui.cpp @@ -491,9 +491,9 @@ SkScalerContext* SkFontHost::CreateScalerContext(const SkDescriptor* desc) { return new SkScalerContext_Mac(desc); } -uint32_t SkFontHost::NextLogicalFont(uint32_t fontID) { +SkFontID SkFontHost::NextLogicalFont(SkFontID currFontID, SkFontID origFontID) { uint32_t newFontID = find_default_fontID(); - if (newFontID == fontID) { + if (newFontID == currFontID) { newFontID = 0; } return newFontID; diff --git a/src/ports/SkFontHost_mac_coretext.cpp b/src/ports/SkFontHost_mac_coretext.cpp index ad57e16f91..f9eba95c7b 100644 --- a/src/ports/SkFontHost_mac_coretext.cpp +++ b/src/ports/SkFontHost_mac_coretext.cpp @@ -887,10 +887,10 @@ SkScalerContext* SkFontHost::CreateScalerContext(const SkDescriptor* desc) { return new SkScalerContext_Mac(desc); } -SkFontID SkFontHost::NextLogicalFont(SkFontID fontID) { +SkFontID SkFontHost::NextLogicalFont(SkFontID currFontID, SkFontID origFontID) { SkFontID nextFontID = 0; SkTypeface* face = GetDefaultFace(); - if (face->uniqueID() != fontID) { + if (face->uniqueID() != currFontID) { nextFontID = face->uniqueID(); } return nextFontID; diff --git a/src/ports/SkFontHost_none.cpp b/src/ports/SkFontHost_none.cpp index 91546f8043..0593dd5c4e 100644 --- a/src/ports/SkFontHost_none.cpp +++ b/src/ports/SkFontHost_none.cpp @@ -80,7 +80,7 @@ SkScalerContext* SkFontHost::CreateScalerContext(const SkDescriptor* desc) { return NULL; } -uint32_t SkFontHost::NextLogicalFont(uint32_t fontID) { +SkFontID SkFontHost::NextLogicalFont(SkFontID currFontID, SkFontID origFontID) { return 0; } diff --git a/src/ports/SkFontHost_simple.cpp b/src/ports/SkFontHost_simple.cpp index 54d326efb2..d63aec2076 100644 --- a/src/ports/SkFontHost_simple.cpp +++ b/src/ports/SkFontHost_simple.cpp @@ -620,7 +620,7 @@ size_t SkFontHost::GetFileName(SkFontID fontID, char path[], size_t length, } } -uint32_t SkFontHost::NextLogicalFont(uint32_t fontID) { +SkFontID SkFontHost::NextLogicalFont(SkFontID currFontID, SkFontID origFontID) { load_system_fonts(); /* First see if fontID is already one of our fallbacks. If so, return @@ -630,7 +630,7 @@ uint32_t SkFontHost::NextLogicalFont(uint32_t fontID) { */ const uint32_t* list = gFallbackFonts; for (int i = 0; list[i] != 0; i++) { - if (list[i] == fontID) { + if (list[i] == currFontID) { return list[i+1]; } } diff --git a/src/ports/SkFontHost_win.cpp b/src/ports/SkFontHost_win.cpp index f5d126ea6f..62b0a0c358 100755 --- a/src/ports/SkFontHost_win.cpp +++ b/src/ports/SkFontHost_win.cpp @@ -179,7 +179,7 @@ SkTypeface* SkCreateTypefaceFromLOGFONT(const LOGFONT& origLF) { return face; } -uint32_t SkFontHost::NextLogicalFont(uint32_t fontID) { +SkFontID SkFontHost::NextLogicalFont(SkFontID currFontID, SkFontID origFontID) { // Zero means that we don't have any fallback fonts for this fontID. // This function is implemented on Android, but doesn't have much // meaning here. |