*/
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);
///////////////////////////////////////////////////////////////////////////
};
public:
struct Rec {
+ uint32_t fOrigFontID;
uint32_t fFontID;
SkScalar fTextSize, fPreScaleX, fPreSkewX;
SkScalar fPost2x2[2][2];
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();
// 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;
}
}
}
-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
*/
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];
}
}
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;
}
return 0;
}
-uint32_t SkFontHost::NextLogicalFont(uint32_t fontID) {
+SkFontID SkFontHost::NextLogicalFont(SkFontID currFontID, SkFontID origFontID) {
return 0;
}
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;
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;
return NULL;
}
-uint32_t SkFontHost::NextLogicalFont(uint32_t fontID) {
+SkFontID SkFontHost::NextLogicalFont(SkFontID currFontID, SkFontID origFontID) {
return 0;
}
}
}
-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
*/
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];
}
}
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.