Remove ALL font fallback logic from Skia.

R=reed@google.com, bungeman@google.com, caryclark@google.com

Author: djsollen@google.com

Review URL: https://codereview.chromium.org/434623002
diff --git a/gm/androidfallback.cpp b/gm/androidfallback.cpp
deleted file mode 100644
index e0f36aa..0000000
--- a/gm/androidfallback.cpp
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright 2013 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "gm.h"
-
-namespace skiagm {
-
-class AndroidFallbackGM : public GM {
-public:
-    AndroidFallbackGM() {
-        this->setBGColor(0xFFCCCCCC);
-    }
-
-protected:
-    virtual uint32_t onGetFlags() const SK_OVERRIDE {
-        // TODO(scroggo): Undo this if we decide to fix skia:1763.
-        return GM::kSkipPipe_Flag;
-    }
-
-    virtual SkString onShortName() SK_OVERRIDE {
-        return SkString("android_paint");
-    }
-
-    virtual SkISize onISize() SK_OVERRIDE {
-        return SkISize::Make(500, 500);
-    }
-
-    virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
-
-        SkPaint paint;
-        paint.setTextEncoding(SkPaint::kUTF16_TextEncoding);
-        paint.setTextSize(24);
-
-        SkPaintOptionsAndroid options = paint.getPaintOptionsAndroid();
-        options.setUseFontFallbacks(true);
-        paint.setPaintOptionsAndroid(options);
-
-        // "ื foo ๅ…่ˆŒ bar เค•"
-        const uint16_t unicodeStr[] = {0x05D0, 0x0020, 0x0066, 0x006F, 0x006F, 0x0020, 0x514D,
-                                       0x820c, 0x0020, 0x0062, 0x0061, 0x0072, 0x0020, 0x0915};
-        const int strLength = sizeof(unicodeStr) / sizeof(uint16_t);
-        const int strByteLength = sizeof(unicodeStr);
-
-        SkScalar posX[strLength];
-        SkPoint posXY[strLength];
-
-        for (int i = 0; i < strLength; ++i) {
-            posX[i] = SkIntToScalar(i * 24);
-            posXY[i].fX = posX[i];
-            posXY[i].fY = SkIntToScalar(24 + i);
-        }
-
-        canvas->translate(SkIntToScalar(10), SkIntToScalar(25));
-        // This currently causes the PDF backend to assert
-        // canvas->drawText(unicodeStr, strByteLength, 0, 0, paint);
-
-        canvas->translate(0, SkIntToScalar(75));
-        canvas->drawPosTextH(unicodeStr, strByteLength, posX, 0, paint);
-
-        options.setLanguage("ja");
-        paint.setPaintOptionsAndroid(options);
-
-        canvas->translate(0, SkIntToScalar(75));
-        canvas->drawPosText(unicodeStr, strByteLength, posXY, paint);
-
-        SkPath path;
-        path.moveTo(0, 0);
-        path.quadTo(50.0f, 100.0f, 250.0f, 150.0f);
-
-        canvas->translate(0, SkIntToScalar(75));
-        canvas->drawTextOnPath(unicodeStr, strByteLength, path, NULL, paint);
-    }
-
-private:
-    typedef GM INHERITED;
-};
-
-//////////////////////////////////////////////////////////////////////////////
-
-DEF_GM( return SkNEW(AndroidFallbackGM); )
-
-}
diff --git a/gyp/gmslides.gypi b/gyp/gmslides.gypi
index 1ccccff..5a3c39b 100644
--- a/gyp/gmslides.gypi
+++ b/gyp/gmslides.gypi
@@ -228,10 +228,6 @@
         # fulfilling. See http://skbug.com/1978
         '../gm/verylargebitmap.cpp',
       ],
-
-      'sources': [
-        '../gm/androidfallback.cpp',
-      ],
     }],
   ],
 }
diff --git a/include/core/SkPaint.h b/include/core/SkPaint.h
index 3874d98..58cb160 100644
--- a/include/core/SkPaint.h
+++ b/include/core/SkPaint.h
@@ -942,10 +942,6 @@
     uint32_t getGenerationID() const;
     void setGenerationID(uint32_t generationID);
 
-    /** Returns the base glyph count for the strike associated with this paint
-    */
-    unsigned getBaseGlyphCount(SkUnichar text) const;
-
     const SkPaintOptionsAndroid& getPaintOptionsAndroid() const {
         return fPaintOptionsAndroid;
     }
diff --git a/include/core/SkPaintOptionsAndroid.h b/include/core/SkPaintOptionsAndroid.h
index ab84ec0..4d0bae3 100644
--- a/include/core/SkPaintOptionsAndroid.h
+++ b/include/core/SkPaintOptionsAndroid.h
@@ -60,13 +60,11 @@
 public:
     SkPaintOptionsAndroid() {
         fFontVariant = kDefault_Variant;
-        fUseFontFallbacks = false;
     }
 
     SkPaintOptionsAndroid& operator=(const SkPaintOptionsAndroid& b) {
         fLanguage = b.fLanguage;
         fFontVariant = b.fFontVariant;
-        fUseFontFallbacks = b.fUseFontFallbacks;
         return *this;
     }
 
@@ -76,8 +74,7 @@
 
     bool operator!=(const SkPaintOptionsAndroid& b) const {
         return fLanguage != b.fLanguage ||
-               fFontVariant != b.fFontVariant ||
-               fUseFontFallbacks != b.fUseFontFallbacks;
+               fFontVariant != b.fFontVariant;
     }
 
     void flatten(SkWriteBuffer&) const;
@@ -115,16 +112,9 @@
         fFontVariant = fontVariant;
     }
 
-    bool isUsingFontFallbacks() const { return fUseFontFallbacks; }
-
-    void setUseFontFallbacks(bool useFontFallbacks) {
-        fUseFontFallbacks = useFontFallbacks;
-    }
-
 private:
     SkLanguage fLanguage;
     FontVariant fFontVariant;
-    bool fUseFontFallbacks;
 };
 
 #endif // #ifndef SkPaintOptionsAndroid_DEFINED
diff --git a/include/ports/SkTypeface_android.h b/include/ports/SkTypeface_android.h
index e46c8f8..c199bee 100644
--- a/include/ports/SkTypeface_android.h
+++ b/include/ports/SkTypeface_android.h
@@ -39,39 +39,5 @@
 SK_API void SkUseTestFontConfigFile(const char* mainconf, const char* fallbackconf,
                                     const char* fontsdir);
 
-/**
- *  Given a "current" fontID, return a ref to the next logical typeface
- *  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 NULL.
- *
- *  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.
- */
-SkTypeface* SkAndroidNextLogicalTypeface(SkFontID currFontID, SkFontID origFontID,
-                                         const SkPaintOptionsAndroid& options);
-
-/**
- * Given a glyphID (built using fallback font chaining) and its origin typeface
- * return the actual typeface within the fallback chain that this glyphID
- * resolves to. If no suitable typeface is found then NULL is returned. However,
- * if returned typeface is not NULL it is assumed to be globally cached so the
- * caller need not ref it.
- *
- * Optionally, if lower/upper bound params are provided and the returned
- * typeface is not NULL, then these params are populated with the range of
- * glyphIDs that this typeface is capable of resolving. The lower bound is
- * inclusive while the upper bound is exclusive.
- */
-SkTypeface* SkGetTypefaceForGlyphID(uint16_t glyphID, const SkTypeface* origTypeface,
-                                    const SkPaintOptionsAndroid& options,
-                                    int* lowerBounds = NULL, int* upperBounds = NULL);
-
 #endif // #ifdef SK_BUILD_FOR_ANDROID
 #endif // #ifndef SkTypeface_android_DEFINED
diff --git a/src/core/SkGlyph.h b/src/core/SkGlyph.h
index 73afb13..5e0ac7e 100644
--- a/src/core/SkGlyph.h
+++ b/src/core/SkGlyph.h
@@ -76,12 +76,6 @@
         return ID2Code(fID);
     }
 
-    unsigned getGlyphID(unsigned baseGlyphCount) const {
-        unsigned code = ID2Code(fID);
-        SkASSERT(code >= baseGlyphCount);
-        return code - baseGlyphCount;
-    }
-
     unsigned getSubX() const {
         return ID2SubX(fID);
     }
diff --git a/src/core/SkGlyphCache.h b/src/core/SkGlyphCache.h
index 4daf6b0..2939eaa 100644
--- a/src/core/SkGlyphCache.h
+++ b/src/core/SkGlyphCache.h
@@ -76,14 +76,6 @@
     */
     unsigned getGlyphCount();
 
-#ifdef SK_BUILD_FOR_ANDROID
-    /** Returns the base glyph count for this strike.
-    */
-    unsigned getBaseGlyphCount(SkUnichar charCode) const {
-        return fScalerContext->getBaseGlyphCount(charCode);
-    }
-#endif
-
     /** Return the image associated with the glyph. If it has not been generated
         this will trigger that.
     */
diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp
index 8fc7c19..9e53d19 100644
--- a/src/core/SkPaint.cpp
+++ b/src/core/SkPaint.cpp
@@ -242,12 +242,6 @@
     fGenerationID = generationID;
 }
 
-unsigned SkPaint::getBaseGlyphCount(SkUnichar text) const {
-    SkAutoGlyphCache autoCache(*this, NULL, NULL);
-    SkGlyphCache* cache = autoCache.getCache();
-    return cache->getBaseGlyphCount(text);
-}
-
 void SkPaint::setPaintOptionsAndroid(const SkPaintOptionsAndroid& options) {
     if (options != fPaintOptionsAndroid) {
         fPaintOptionsAndroid = options;
diff --git a/src/core/SkPaintOptionsAndroid.cpp b/src/core/SkPaintOptionsAndroid.cpp
index 56f1bd1..df71ca8 100644
--- a/src/core/SkPaintOptionsAndroid.cpp
+++ b/src/core/SkPaintOptionsAndroid.cpp
@@ -29,7 +29,8 @@
 void SkPaintOptionsAndroid::flatten(SkWriteBuffer& buffer) const {
     buffer.writeUInt(fFontVariant);
     buffer.writeString(fLanguage.getTag().c_str());
-    buffer.writeBool(fUseFontFallbacks);
+    // to maintain picture compatibility for the old fUseFontFallbacks variable
+    buffer.writeBool(false);
 }
 
 void SkPaintOptionsAndroid::unflatten(SkReadBuffer& buffer) {
@@ -37,5 +38,6 @@
     SkString tag;
     buffer.readString(&tag);
     fLanguage = SkLanguage(tag);
-    fUseFontFallbacks = buffer.readBool();
+    // to maintain picture compatibility for the old fUseFontFallbacks variable
+    buffer.readBool();
 }
diff --git a/src/core/SkScalerContext.cpp b/src/core/SkScalerContext.cpp
index b18dc1a..11208fe 100644
--- a/src/core/SkScalerContext.cpp
+++ b/src/core/SkScalerContext.cpp
@@ -83,7 +83,6 @@
 SkScalerContext::SkScalerContext(SkTypeface* typeface, const SkDescriptor* desc)
     : fRec(*static_cast<const Rec*>(desc->findEntry(kRec_SkDescriptorTag, NULL)))
 
-    , fBaseGlyphCount(0)
     , fTypeface(SkRef(typeface))
     , fPathEffect(static_cast<SkPathEffect*>(load_flattenable(desc, kPathEffect_SkDescriptorTag,
                                              SkFlattenable::kSkPathEffect_Type)))
@@ -94,8 +93,6 @@
       // Initialize based on our settings. Subclasses can also force this.
     , fGenerateImageFromPath(fRec.fFrameWidth > 0 || fPathEffect != NULL || fRasterizer != NULL)
 
-    , fNextContext(NULL)
-
     , fPreBlend(fMaskFilter ? SkMaskGamma::PreBlend() : SkScalerContext::GetMaskPreBlend(fRec))
     , fPreBlendForFilter(fMaskFilter ? SkScalerContext::GetMaskPreBlend(fRec)
                                      : SkMaskGamma::PreBlend())
@@ -126,180 +123,22 @@
 }
 
 SkScalerContext::~SkScalerContext() {
-    SkDELETE(fNextContext);
-
     SkSafeUnref(fPathEffect);
     SkSafeUnref(fMaskFilter);
     SkSafeUnref(fRasterizer);
 }
 
-// Return the context associated with the next logical typeface, or NULL if
-// there are no more entries in the fallback chain.
-SkScalerContext* SkScalerContext::allocNextContext() const {
-#ifdef SK_BUILD_FOR_ANDROID
-    SkTypeface* newFace = SkAndroidNextLogicalTypeface(fRec.fFontID,
-                                                       fRec.fOrigFontID,
-                                                       fPaintOptionsAndroid);
-    if (0 == newFace) {
-        return NULL;
-    }
-
-    SkAutoTUnref<SkTypeface> aur(newFace);
-    uint32_t newFontID = newFace->uniqueID();
-
-    SkWriteBuffer androidBuffer;
-    fPaintOptionsAndroid.flatten(androidBuffer);
-
-    SkAutoDescriptor    ad(sizeof(fRec) + androidBuffer.bytesWritten()
-                           + SkDescriptor::ComputeOverhead(2));
-    SkDescriptor*       desc = ad.getDesc();
-
-    desc->init();
-    SkScalerContext::Rec* newRec =
-    (SkScalerContext::Rec*)desc->addEntry(kRec_SkDescriptorTag,
-                                          sizeof(fRec), &fRec);
-    androidBuffer.writeToMemory(desc->addEntry(kAndroidOpts_SkDescriptorTag,
-                                               androidBuffer.bytesWritten(), NULL));
-
-    newRec->fFontID = newFontID;
-    desc->computeChecksum();
-
-    return newFace->createScalerContext(desc);
-#else
-    return NULL;
-#endif
-}
-
-/*  Return the next context, creating it if its not already created, but return
-    NULL if the fonthost says there are no more fonts to fallback to.
- */
-SkScalerContext* SkScalerContext::getNextContext() {
-    SkScalerContext* next = fNextContext;
-    // if next is null, then either it isn't cached yet, or we're at the
-    // end of our possible chain
-    if (NULL == next) {
-        next = this->allocNextContext();
-        if (NULL == next) {
-            return NULL;
-        }
-        // next's base is our base + our local count
-        next->setBaseGlyphCount(fBaseGlyphCount + this->getGlyphCount());
-        // cache the answer
-        fNextContext = next;
-    }
-    return next;
-}
-
-SkScalerContext* SkScalerContext::getGlyphContext(const SkGlyph& glyph) {
-    unsigned glyphID = glyph.getGlyphID();
-    SkScalerContext* ctx = this;
-    for (;;) {
-        unsigned count = ctx->getGlyphCount();
-        if (glyphID < count) {
-            break;
-        }
-        glyphID -= count;
-        ctx = ctx->getNextContext();
-        if (NULL == ctx) {
-//            SkDebugf("--- no context for glyph %x\n", glyph.getGlyphID());
-            // just return the original context (this)
-            return this;
-        }
-    }
-    return ctx;
-}
-
-SkScalerContext* SkScalerContext::getContextFromChar(SkUnichar uni,
-                                                     uint16_t* glyphID) {
-    SkScalerContext* ctx = this;
-    for (;;) {
-        const uint16_t glyph = ctx->generateCharToGlyph(uni);
-        if (glyph) {
-            if (NULL != glyphID) {
-                *glyphID = glyph;
-            }
-            break;  // found it
-        }
-        ctx = ctx->getNextContext();
-        if (NULL == ctx) {
-            return NULL;
-        }
-    }
-    return ctx;
-}
-
-#ifdef SK_BUILD_FOR_ANDROID
-SkFontID SkScalerContext::findTypefaceIdForChar(SkUnichar uni) {
-    SkScalerContext* ctx = this->getContextFromChar(uni, NULL);
-    if (NULL != ctx) {
-        return ctx->fRec.fFontID;
-    } else {
-        return 0;
-    }
-}
-
-/*  This loops through all available fallback contexts (if needed) until it
-    finds some context that can handle the unichar and return it.
-
-    As this is somewhat expensive operation, it should only be done on the first
-    char of a run.
- */
-unsigned SkScalerContext::getBaseGlyphCount(SkUnichar uni) {
-    SkScalerContext* ctx = this->getContextFromChar(uni, NULL);
-    if (NULL != ctx) {
-        return ctx->fBaseGlyphCount;
-    } else {
-        SkDEBUGF(("--- no context for char %x\n", uni));
-        return this->fBaseGlyphCount;
-    }
-}
-#endif
-
-/*  This loops through all available fallback contexts (if needed) until it
-    finds some context that can handle the unichar. If all fail, returns 0
- */
-uint16_t SkScalerContext::charToGlyphID(SkUnichar uni) {
-
-    uint16_t tempID;
-    SkScalerContext* ctx = this->getContextFromChar(uni, &tempID);
-    if (NULL == ctx) {
-        return 0; // no more contexts, return missing glyph
-    }
-    // add the ctx's base, making glyphID unique for chain of contexts
-    unsigned glyphID = tempID + ctx->fBaseGlyphCount;
-    // check for overflow of 16bits, since our glyphID cannot exceed that
-    if (glyphID > 0xFFFF) {
-        glyphID = 0;
-    }
-    return SkToU16(glyphID);
-}
-
-SkUnichar SkScalerContext::glyphIDToChar(uint16_t glyphID) {
-    SkScalerContext* ctx = this;
-    unsigned rangeEnd = 0;
-    do {
-        unsigned rangeStart = rangeEnd;
-
-        rangeEnd += ctx->getGlyphCount();
-        if (rangeStart <= glyphID && glyphID < rangeEnd) {
-            return ctx->generateGlyphToChar(glyphID - rangeStart);
-        }
-        ctx = ctx->getNextContext();
-    } while (NULL != ctx);
-    return 0;
-}
-
 void SkScalerContext::getAdvance(SkGlyph* glyph) {
     // mark us as just having a valid advance
     glyph->fMaskFormat = MASK_FORMAT_JUST_ADVANCE;
     // we mark the format before making the call, in case the impl
     // internally ends up calling its generateMetrics, which is OK
     // albeit slower than strictly necessary
-    this->getGlyphContext(*glyph)->generateAdvance(glyph);
+    generateAdvance(glyph);
 }
 
 void SkScalerContext::getMetrics(SkGlyph* glyph) {
-    this->getGlyphContext(*glyph)->generateMetrics(glyph);
+    generateMetrics(glyph);
 
     // for now we have separate cache entries for devkerning on and off
     // in the future we might share caches, but make our measure/draw
@@ -737,7 +576,7 @@
             generateMask(mask, devPath, fPreBlend);
         }
     } else {
-        this->getGlyphContext(*glyph)->generateImage(*glyph);
+        generateImage(*glyph);
     }
 
     if (fMaskFilter) {
@@ -811,8 +650,7 @@
 void SkScalerContext::internalGetPath(const SkGlyph& glyph, SkPath* fillPath,
                                   SkPath* devPath, SkMatrix* fillToDevMatrix) {
     SkPath  path;
-
-    this->getGlyphContext(glyph)->generatePath(glyph, &path);
+    generatePath(glyph, &path);
 
     if (fRec.fFlags & SkScalerContext::kSubpixelPositioning_Flag) {
         SkFixed dx = glyph.getSubXFixed();
diff --git a/src/core/SkScalerContext.h b/src/core/SkScalerContext.h
index be5d3b5..43b5ebf 100644
--- a/src/core/SkScalerContext.h
+++ b/src/core/SkScalerContext.h
@@ -164,22 +164,21 @@
         return SkToBool(fRec.fFlags & kVertical_Flag);
     }
 
-    // remember our glyph offset/base
-    void setBaseGlyphCount(unsigned baseGlyphCount) {
-        fBaseGlyphCount = baseGlyphCount;
-    }
-
     /** Return the corresponding glyph for the specified unichar. Since contexts
         may be chained (under the hood), the glyphID that is returned may in
         fact correspond to a different font/context. In that case, we use the
         base-glyph-count to know how to translate back into local glyph space.
      */
-    uint16_t charToGlyphID(SkUnichar uni);
+    uint16_t charToGlyphID(SkUnichar uni) {
+        return generateCharToGlyph(uni);
+    }
 
     /** Map the glyphID to its glyph index, and then to its char code. Unmapped
         glyphs return zero.
     */
-    SkUnichar glyphIDToChar(uint16_t glyphID);
+    SkUnichar glyphIDToChar(uint16_t glyphID) {
+        return (glyphID < getGlyphCount()) ? generateGlyphToChar(glyphID) : 0;
+    }
 
     unsigned    getGlyphCount() { return this->generateGlyphCount(); }
     void        getAdvance(SkGlyph*);
@@ -199,14 +198,6 @@
     static void   GetGammaLUTData(SkScalar contrast, SkScalar paintGamma, SkScalar deviceGamma,
                                   void* data);
 
-#ifdef SK_BUILD_FOR_ANDROID
-    unsigned getBaseGlyphCount(SkUnichar charCode);
-
-    // This function must be public for SkTypeface_android.h, but should not be
-    // called by other callers
-    SkFontID findTypefaceIdForChar(SkUnichar uni);
-#endif
-
     static void MakeRec(const SkPaint&, const SkDeviceProperties* deviceProperties,
                         const SkMatrix*, Rec* rec);
     static inline void PostMakeRec(const SkPaint&, Rec*);
@@ -215,7 +206,6 @@
 
 protected:
     Rec         fRec;
-    unsigned    fBaseGlyphCount;
 
     /** Generates the contents of glyph.fAdvanceX and glyph.fAdvanceY.
      *  May call getMetrics if that would be just as fast.
@@ -288,25 +278,11 @@
     void internalGetPath(const SkGlyph& glyph, SkPath* fillPath,
                          SkPath* devPath, SkMatrix* fillToDevMatrix);
 
-    // Return the context associated with the next logical typeface, or NULL if
-    // there are no more entries in the fallback chain.
-    SkScalerContext* allocNextContext() const;
-
-    // return the next context, treating fNextContext as a cache of the answer
-    SkScalerContext* getNextContext();
-
-    // returns the right context from our link-list for this glyph. If no match
-    // is found, just returns the original context (this)
-    SkScalerContext* getGlyphContext(const SkGlyph& glyph);
-
     // returns the right context from our link-list for this char. If no match
     // is found it returns NULL. If a match is found then the glyphID param is
     // set to the glyphID that maps to the provided char.
     SkScalerContext* getContextFromChar(SkUnichar uni, uint16_t* glyphID);
 
-    // link-list of context, to handle missing chars. null-terminated.
-    SkScalerContext* fNextContext;
-
     // SkMaskGamma::PreBlend converts linear masks to gamma correcting masks.
 protected:
     // Visible to subclasses so that generateImage can apply the pre-blend directly.
diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp
index e571477..5946b9a 100644
--- a/src/pdf/SkPDFDevice.cpp
+++ b/src/pdf/SkPDFDevice.cpp
@@ -35,22 +35,6 @@
 #include "SkTypefacePriv.h"
 #include "SkTSet.h"
 
-#ifdef SK_BUILD_FOR_ANDROID
-#include "SkTypeface_android.h"
-
-struct TypefaceFallbackData {
-    SkTypeface* typeface;
-    int lowerBounds;
-    int upperBounds;
-
-    bool operator==(const TypefaceFallbackData& b) const {
-        return typeface == b.typeface &&
-               lowerBounds == b.lowerBounds &&
-               upperBounds == b.upperBounds;
-    }
-};
-#endif
-
 #define DPI_FOR_RASTER_SCALE_ONE 72
 
 // Utility functions
@@ -1175,116 +1159,6 @@
         return;
     }
 
-#ifdef SK_BUILD_FOR_ANDROID
-    /*
-     * In the case that we have enabled fallback fonts on Android we need to
-     * take the following steps to ensure that the PDF draws all characters,
-     * regardless of their underlying font file, correctly.
-     *
-     * 1. Convert input into GlyphID encoding if it currently is not
-     * 2. Iterate over the glyphIDs and identify the actual typeface that each
-     *    glyph resolves to
-     * 3. Iterate over those typefaces and recursively call this function with
-     *    only the glyphs (and their positions) that the typeface is capable of
-     *    resolving.
-     */
-    if (paint.getPaintOptionsAndroid().isUsingFontFallbacks()) {
-        uint16_t* glyphIDs = NULL;
-        SkGlyphStorage tmpStorage(0);
-        size_t numGlyphs = 0;
-
-        // convert to glyphIDs
-        if (paint.getTextEncoding() == SkPaint::kGlyphID_TextEncoding) {
-            numGlyphs = len / 2;
-            glyphIDs = reinterpret_cast<uint16_t*>(const_cast<void*>(text));
-        } else {
-            numGlyphs = paint.textToGlyphs(text, len, NULL);
-            tmpStorage.reset(numGlyphs);
-            paint.textToGlyphs(text, len, tmpStorage.get());
-            glyphIDs = tmpStorage.get();
-        }
-
-        // if no typeface is provided in the paint get the default
-        SkAutoTUnref<SkTypeface> origFace(SkSafeRef(paint.getTypeface()));
-        if (NULL == origFace.get()) {
-            origFace.reset(SkTypeface::RefDefault());
-        }
-        const uint16_t origGlyphCount = origFace->countGlyphs();
-
-        // keep a list of the already visited typefaces and some data about them
-        SkTDArray<TypefaceFallbackData> visitedTypefaces;
-
-        // find all the typefaces needed to resolve this run of text
-        bool usesOriginalTypeface = false;
-        for (uint16_t x = 0; x < numGlyphs; ++x) {
-            // optimization that checks to see if original typeface can resolve
-            // the glyph
-            if (glyphIDs[x] < origGlyphCount) {
-                usesOriginalTypeface = true;
-                continue;
-            }
-
-            // find the fallback typeface that supports this glyph
-            TypefaceFallbackData data;
-            data.typeface =
-                    SkGetTypefaceForGlyphID(glyphIDs[x], origFace.get(),
-                                            paint.getPaintOptionsAndroid(),
-                                            &data.lowerBounds,
-                                            &data.upperBounds);
-            // add the typeface and its data if we don't have it
-            if (data.typeface && !visitedTypefaces.contains(data)) {
-                visitedTypefaces.push(data);
-            }
-        }
-
-        // if the original font was used then add it to the list as well
-        if (usesOriginalTypeface) {
-            TypefaceFallbackData* data = visitedTypefaces.push();
-            data->typeface = origFace.get();
-            data->lowerBounds = 0;
-            data->upperBounds = origGlyphCount;
-        }
-
-        // keep a scratch glyph and pos storage
-        SkAutoTMalloc<SkScalar> posStorage(len * scalarsPerPos);
-        SkScalar* tmpPos = posStorage.get();
-        SkGlyphStorage glyphStorage(numGlyphs);
-        uint16_t* tmpGlyphIDs = glyphStorage.get();
-
-        // loop through all the valid typefaces, trim the glyphs to only those
-        // resolved by the typeface, and then draw that run of glyphs
-        for (int x = 0; x < visitedTypefaces.count(); ++x) {
-            const TypefaceFallbackData& data = visitedTypefaces[x];
-
-            int tmpGlyphCount = 0;
-            for (uint16_t y = 0; y < numGlyphs; ++y) {
-                if (glyphIDs[y] >= data.lowerBounds &&
-                        glyphIDs[y] < data.upperBounds) {
-                    tmpGlyphIDs[tmpGlyphCount] = glyphIDs[y] - data.lowerBounds;
-                    memcpy(&(tmpPos[tmpGlyphCount * scalarsPerPos]),
-                           &(pos[y * scalarsPerPos]),
-                           scalarsPerPos * sizeof(SkScalar));
-                    tmpGlyphCount++;
-                }
-            }
-
-            // recursively call this function with the right typeface
-            SkPaint tmpPaint = paint;
-            tmpPaint.setTypeface(data.typeface);
-            tmpPaint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
-
-            // turn off fallback chaining
-            SkPaintOptionsAndroid paintOpts = tmpPaint.getPaintOptionsAndroid();
-            paintOpts.setUseFontFallbacks(false);
-            tmpPaint.setPaintOptionsAndroid(paintOpts);
-
-            this->drawPosText(d, tmpGlyphIDs, tmpGlyphCount * 2, tmpPos, constY,
-                              scalarsPerPos, tmpPaint);
-        }
-        return;
-    }
-#endif
-
     SkGlyphStorage storage(0);
     uint16_t* glyphIDs = NULL;
     size_t numGlyphs = force_glyph_encoding(paint, text, len, &storage,
diff --git a/src/ports/SkFontConfigInterface_android.cpp b/src/ports/SkFontConfigInterface_android.cpp
index bdc3d50..1bdcf4c 100644
--- a/src/ports/SkFontConfigInterface_android.cpp
+++ b/src/ports/SkFontConfigInterface_android.cpp
@@ -98,14 +98,6 @@
      *  contains the specified chararacter. if no font is found, returns false.
      */
     bool getFallbackFamilyNameForChar(SkUnichar uni, const char* lang, SkString* name);
-    /**
-     *
-     */
-    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);
@@ -579,135 +571,6 @@
     return fallbackFontList;
 }
 
-SkTypeface* SkFontConfigInterfaceAndroid::nextLogicalTypeface(SkFontID currFontID,
-                                                              SkFontID origFontID,
-                                                              const SkPaintOptionsAndroid& opts) {
-    // Skia does not support font fallback by default. This enables clients such
-    // as WebKit to customize their font selection. In any case, clients can use
-    // GetFallbackFamilyNameForChar() to get the fallback font for individual
-    // characters.
-    if (!opts.isUsingFontFallbacks()) {
-        return NULL;
-    }
-
-    FallbackFontList* currentFallbackList = findFallbackFontList(opts.getLanguage());
-    SkASSERT(currentFallbackList);
-
-    SkTypeface::Style origStyle = SkTypeface::kNormal;
-    const SkTypeface* origTypeface = SkTypefaceCache::FindByID(origFontID);
-    if (NULL != origTypeface) {
-        origStyle = origTypeface->style();
-    }
-
-    // we must convert currTypeface into a FontRecID
-    FontRecID currFontRecID = INVALID_FONT_REC_ID;
-    const SkTypeface* currTypeface = SkTypefaceCache::FindByID(currFontID);
-    // non-system fonts are not in the font cache so if we are asked to fallback
-    // for a non-system font we will start at the front of the chain.
-    if (NULL != currTypeface) {
-        currFontRecID = ((FontConfigTypeface*)currTypeface)->getIdentity().fID;
-        SkASSERT(INVALID_FONT_REC_ID != currFontRecID);
-    }
-
-    FamilyRecID currFamilyRecID = INVALID_FAMILY_REC_ID;
-    if (INVALID_FONT_REC_ID != currFontRecID) {
-        currFamilyRecID = fFonts[currFontRecID].fFamilyRecID;
-    }
-
-    // lookup the index next font in the chain
-    int currFallbackFontIndex = currentFallbackList->find(currFamilyRecID);
-    // We add 1 to the returned index for 2 reasons: (1) if find succeeds it moves
-    // our index to the next entry in the list; (2) if find() fails it returns
-    // -1 and incrementing it will set our starting index to 0 (the head of the list)
-    int nextFallbackFontIndex = currFallbackFontIndex + 1;
-
-    if(nextFallbackFontIndex >= currentFallbackList->count()) {
-        return NULL;
-    }
-
-    // If a rec 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* nextLogicalTypeface = 0;
-    while (nextFallbackFontIndex < currentFallbackList->count()) {
-        FamilyRecID familyRecID = currentFallbackList->getAt(nextFallbackFontIndex);
-        if ((fFontFamilies[familyRecID].fPaintOptions.getFontVariant() & acceptedVariants) != 0) {
-            FontRecID matchedFont = find_best_style(fFontFamilies[familyRecID], origStyle);
-            nextLogicalTypeface = this->getTypefaceForFontRec(matchedFont);
-            break;
-        }
-        nextFallbackFontIndex++;
-    }
-
-    DEBUG_FONT(("---- nextLogicalFont: currFontID=%d, origFontID=%d, currRecID=%d, "
-                "lang=%s, variant=%d, nextFallbackIndex[%d,%d] => nextLogicalTypeface=%d",
-                currFontID, origFontID, currFontRecID, opts.getLanguage().getTag().c_str(),
-                variant, nextFallbackFontIndex, currentFallbackList->getAt(nextFallbackFontIndex),
-                (nextLogicalTypeface) ? nextLogicalTypeface->uniqueID() : 0));
-    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, const char* lang, SkString* name) {
@@ -726,18 +589,3 @@
     SkDEBUGF(("Use Test Config File Main %s, Fallback %s, Font Dir %s",
               gTestMainConfigFile, gTestFallbackConfigFile, gTestFontFilePrefix));
 }
-
-SkTypeface* SkAndroidNextLogicalTypeface(SkFontID currFontID, SkFontID origFontID,
-                                         const SkPaintOptionsAndroid& options) {
-    SkFontConfigInterfaceAndroid* fontConfig = getSingletonInterface();
-    return fontConfig->nextLogicalTypeface(currFontID, origFontID, options);
-
-}
-
-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);
-}
diff --git a/src/ports/SkFontHost_FreeType.cpp b/src/ports/SkFontHost_FreeType.cpp
index e2b0fe9..ef943aa 100644
--- a/src/ports/SkFontHost_FreeType.cpp
+++ b/src/ports/SkFontHost_FreeType.cpp
@@ -1115,7 +1115,7 @@
         FT_Error    error;
         FT_Fixed    advance;
 
-        error = FT_Get_Advance( fFace, glyph->getGlyphID(fBaseGlyphCount),
+        error = FT_Get_Advance( fFace, glyph->getGlyphID(),
                                 fLoadGlyphFlags | FT_ADVANCE_FLAG_FAST_ONLY,
                                 &advance );
         if (0 == error) {
@@ -1217,11 +1217,11 @@
         goto ERROR;
     }
 
-    err = FT_Load_Glyph( fFace, glyph->getGlyphID(fBaseGlyphCount), fLoadGlyphFlags );
+    err = FT_Load_Glyph( fFace, glyph->getGlyphID(), fLoadGlyphFlags );
     if (err != 0) {
 #if 0
         SkDEBUGF(("SkScalerContext_FreeType::generateMetrics(%x): FT_Load_Glyph(glyph:%d flags:%x) returned 0x%x\n",
-                    fFaceRec->fFontID, glyph->getGlyphID(fBaseGlyphCount), fLoadGlyphFlags, err));
+                    fFaceRec->fFontID, glyph->getGlyphID(), fLoadGlyphFlags, err));
 #endif
     ERROR:
         glyph->zeroMetrics();
@@ -1305,7 +1305,7 @@
 
 #ifdef ENABLE_GLYPH_SPEW
     SkDEBUGF(("FT_Set_Char_Size(this:%p sx:%x sy:%x ", this, fScaleX, fScaleY));
-    SkDEBUGF(("Metrics(glyph:%d flags:0x%x) w:%d\n", glyph->getGlyphID(fBaseGlyphCount), fLoadGlyphFlags, glyph->fWidth));
+    SkDEBUGF(("Metrics(glyph:%d flags:0x%x) w:%d\n", glyph->getGlyphID(), fLoadGlyphFlags, glyph->fWidth));
 #endif
 }
 
@@ -1319,10 +1319,10 @@
         goto ERROR;
     }
 
-    err = FT_Load_Glyph( fFace, glyph.getGlyphID(fBaseGlyphCount), fLoadGlyphFlags);
+    err = FT_Load_Glyph( fFace, glyph.getGlyphID(), fLoadGlyphFlags);
     if (err != 0) {
         SkDEBUGF(("SkScalerContext_FreeType::generateImage: FT_Load_Glyph(glyph:%d width:%d height:%d rb:%d flags:%d) returned 0x%x\n",
-                    glyph.getGlyphID(fBaseGlyphCount), glyph.fWidth, glyph.fHeight, glyph.rowBytes(), fLoadGlyphFlags, err));
+                    glyph.getGlyphID(), glyph.fWidth, glyph.fHeight, glyph.rowBytes(), fLoadGlyphFlags, err));
     ERROR:
         memset(glyph.fImage, 0, glyph.rowBytes() * glyph.fHeight);
         return;
@@ -1348,11 +1348,11 @@
     flags |= FT_LOAD_NO_BITMAP; // ignore embedded bitmaps so we're sure to get the outline
     flags &= ~FT_LOAD_RENDER;   // don't scan convert (we just want the outline)
 
-    FT_Error err = FT_Load_Glyph( fFace, glyph.getGlyphID(fBaseGlyphCount), flags);
+    FT_Error err = FT_Load_Glyph( fFace, glyph.getGlyphID(), flags);
 
     if (err != 0) {
         SkDEBUGF(("SkScalerContext_FreeType::generatePath: FT_Load_Glyph(glyph:%d flags:%d) returned 0x%x\n",
-                    glyph.getGlyphID(fBaseGlyphCount), flags, err));
+                    glyph.getGlyphID(), flags, err));
         path->reset();
         return;
     }
diff --git a/src/ports/SkFontHost_mac.cpp b/src/ports/SkFontHost_mac.cpp
index 2d985f9..72a3274 100755
--- a/src/ports/SkFontHost_mac.cpp
+++ b/src/ports/SkFontHost_mac.cpp
@@ -958,7 +958,7 @@
 }
 
 void SkScalerContext_Mac::generateMetrics(SkGlyph* glyph) {
-    const CGGlyph cgGlyph = (CGGlyph) glyph->getGlyphID(fBaseGlyphCount);
+    const CGGlyph cgGlyph = (CGGlyph) glyph->getGlyphID();
     glyph->zeroMetrics();
 
     // The following block produces cgAdvance in CG units (pixels, y up).
@@ -1203,7 +1203,7 @@
 }
 
 void SkScalerContext_Mac::generateImage(const SkGlyph& glyph) {
-    CGGlyph cgGlyph = (CGGlyph) glyph.getGlyphID(fBaseGlyphCount);
+    CGGlyph cgGlyph = (CGGlyph) glyph.getGlyphID();
 
     // FIXME: lcd smoothed un-hinted rasterization unsupported.
     bool generateA8FromLCD = fRec.getHinting() != SkPaint::kNo_Hinting;
@@ -1342,7 +1342,7 @@
         font = CTFontCreateCopyWithAttributes(fCTFont, 1, &xform, NULL);
     }
 
-    CGGlyph cgGlyph = (CGGlyph)glyph.getGlyphID(fBaseGlyphCount);
+    CGGlyph cgGlyph = (CGGlyph)glyph.getGlyphID();
     AutoCFRelease<CGPathRef> cgPath(CTFontCreatePathForGlyph(font, cgGlyph, NULL));
 
     path->reset();
diff --git a/src/ports/SkFontHost_win.cpp b/src/ports/SkFontHost_win.cpp
index e4aab81..6f8669e 100755
--- a/src/ports/SkFontHost_win.cpp
+++ b/src/ports/SkFontHost_win.cpp
@@ -873,7 +873,7 @@
 
     if (fType == SkScalerContext_GDI::kBitmap_Type || fType == SkScalerContext_GDI::kLine_Type) {
         SIZE size;
-        WORD glyphs = glyph->getGlyphID(0);
+        WORD glyphs = glyph->getGlyphID();
         if (0 == GetTextExtentPointI(fDDC, &glyphs, 1, &size)) {
             glyph->fWidth = SkToS16(fTM.tmMaxCharWidth);
         } else {
@@ -911,7 +911,7 @@
         return;
     }
 
-    UINT glyphId = glyph->getGlyphID(0);
+    UINT glyphId = glyph->getGlyphID();
 
     GLYPHMETRICS gm;
     sk_bzero(&gm, sizeof(gm));
diff --git a/tests/AndroidPaintTest.cpp b/tests/AndroidPaintTest.cpp
index 0fc2f9b..f5cf84f 100644
--- a/tests/AndroidPaintTest.cpp
+++ b/tests/AndroidPaintTest.cpp
@@ -27,7 +27,6 @@
     SkPaintOptionsAndroid options;
     options.setLanguage("ja-JP");
     options.setFontVariant(SkPaintOptionsAndroid::kElegant_Variant);
-    options.setUseFontFallbacks(true);
 
     SkPaint paint;
     paint.setPaintOptionsAndroid(options);
@@ -46,7 +45,6 @@
     SkPaintOptionsAndroid options;
     options.setLanguage("ja-JP");
     options.setFontVariant(SkPaintOptionsAndroid::kElegant_Variant);
-    options.setUseFontFallbacks(true);
     SkPaint nonDefaultOptions;
     nonDefaultOptions.setPaintOptionsAndroid(options);
 
@@ -64,7 +62,7 @@
     SkPaint defaultOptions;
 
     SkPaintOptionsAndroid options;
-    options.setUseFontFallbacks(true);
+    options.setLanguage("ja-JP");
     SkPaint nonDefaultOptions;
     nonDefaultOptions.setPaintOptionsAndroid(options);