Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(836)

Unified Diff: src/ports/SkFontConfigInterface_android.cpp

Issue 24364008: Update PDF backend to support fallback fonts on Android. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: testing more fallbacks Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/pdf/SkPDFDevice.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ports/SkFontConfigInterface_android.cpp
diff --git a/src/ports/SkFontConfigInterface_android.cpp b/src/ports/SkFontConfigInterface_android.cpp
index 7382d00b4546ab0cc8317db1b9bd137d52916739..9c188d90c63efa803810fc7b30d7bce1c06df49a 100644
--- a/src/ports/SkFontConfigInterface_android.cpp
+++ b/src/ports/SkFontConfigInterface_android.cpp
@@ -104,6 +104,9 @@ public:
SkPaintOptionsAndroid::FontVariant fontVariant);
SkTypeface* nextLogicalTypeface(SkFontID currFontID, SkFontID origFontID,
const SkPaintOptionsAndroid& options);
+ SkTypeface* getTypefaceForGlyphID(uint16_t glyphID, const SkTypeface* origTypeface,
+ const SkPaintOptionsAndroid& options,
+ int* lowerBounds, int* upperBounds);
private:
void addFallbackFamily(FamilyRecID fontRecID);
@@ -672,6 +675,61 @@ SkTypeface* SkFontConfigInterfaceAndroid::nextLogicalTypeface(SkFontID currFontI
return SkSafeRef(nextLogicalTypeface);
}
+SkTypeface* SkFontConfigInterfaceAndroid::getTypefaceForGlyphID(uint16_t glyphID,
+ const SkTypeface* origTypeface,
+ const SkPaintOptionsAndroid& opts,
+ int* lBounds, int* uBounds) {
+ // If we aren't using fallbacks then we shouldn't be calling this
+ SkASSERT(opts.isUsingFontFallbacks());
+ SkASSERT(origTypeface);
+
+ SkTypeface* currentTypeface = NULL;
+ int lowerBounds = 0; //inclusive
+ int upperBounds = origTypeface->countGlyphs(); //exclusive
+
+ // check to see if the glyph is in the bounds of the origTypeface
+ if (glyphID < upperBounds) {
+ currentTypeface = const_cast<SkTypeface*>(origTypeface);
+ } else {
+ FallbackFontList* currentFallbackList = findFallbackFontList(opts.getLanguage());
+ SkASSERT(currentFallbackList);
+
+ // If an object is set to prefer "kDefault_Variant" it means they have no preference
+ // In this case, we set the value to "kCompact_Variant"
+ SkPaintOptionsAndroid::FontVariant variant = opts.getFontVariant();
+ if (variant == SkPaintOptionsAndroid::kDefault_Variant) {
+ variant = SkPaintOptionsAndroid::kCompact_Variant;
+ }
+
+ int32_t acceptedVariants = SkPaintOptionsAndroid::kDefault_Variant | variant;
+ SkTypeface::Style origStyle = origTypeface->style();
+
+ for (int x = 0; x < currentFallbackList->count(); ++x) {
+ const FamilyRecID familyRecID = currentFallbackList->getAt(x);
+ const SkPaintOptionsAndroid& familyOptions = fFontFamilies[familyRecID].fPaintOptions;
+ if ((familyOptions.getFontVariant() & acceptedVariants) != 0) {
+ FontRecID matchedFont = find_best_style(fFontFamilies[familyRecID], origStyle);
+ currentTypeface = this->getTypefaceForFontRec(matchedFont);
+ lowerBounds = upperBounds;
+ upperBounds += currentTypeface->countGlyphs();
+ if (glyphID < upperBounds) {
+ break;
+ }
+ }
+ }
+ }
+
+ if (NULL != currentTypeface) {
+ if (lBounds) {
+ *lBounds = lowerBounds;
+ }
+ if (uBounds) {
+ *uBounds = upperBounds;
+ }
+ }
+ return currentTypeface;
+}
+
///////////////////////////////////////////////////////////////////////////////
bool SkGetFallbackFamilyNameForChar(SkUnichar uni, SkString* name) {
@@ -704,6 +762,14 @@ SkTypeface* SkAndroidNextLogicalTypeface(SkFontID currFontID, SkFontID origFontI
}
+SkTypeface* SkGetTypefaceForGlyphID(uint16_t glyphID, const SkTypeface* origTypeface,
+ const SkPaintOptionsAndroid& options,
+ int* lowerBounds, int* upperBounds) {
+ SkFontConfigInterfaceAndroid* fontConfig = getSingletonInterface();
+ return fontConfig->getTypefaceForGlyphID(glyphID, origTypeface, options,
+ lowerBounds, upperBounds);
+}
+
///////////////////////////////////////////////////////////////////////////////
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
« no previous file with comments | « src/pdf/SkPDFDevice.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698