merge in jb-release history after reset to jb-dev
diff --git a/include/core/SkPaint.h b/include/core/SkPaint.h
index 7be5ad2..30ff663 100644
--- a/include/core/SkPaint.h
+++ b/include/core/SkPaint.h
@@ -870,6 +870,9 @@
     /** Returns the base glyph count for the strike associated with this paint
     */
     unsigned getBaseGlyphCount(SkUnichar text) const;
+    
+    int utfToGlyphs(const void* text, TextEncoding encoding,
+            size_t byteLength, uint16_t glyphs[]) const;
 #endif
 
     // returns true if the paint's settings (e.g. xfermode + alpha) resolve to
diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp
index 82a1f57..07fe9b0 100644
--- a/src/core/SkPaint.cpp
+++ b/src/core/SkPaint.cpp
@@ -440,6 +440,37 @@
     SkGlyphCache::AttachCache(cache);
     return image;
 }
+
+int SkPaint::utfToGlyphs(const void* textData, TextEncoding encoding,
+                         size_t byteLength, uint16_t glyphs[]) const {
+
+    SkAutoGlyphCache autoCache(*this, NULL);
+    SkGlyphCache* cache = autoCache.getCache();
+    
+    const char* text = (const char*) textData;
+    const char* stop = text + byteLength;
+    uint16_t* gptr = glyphs;
+    
+    switch (encoding) {
+        case SkPaint::kUTF8_TextEncoding:
+            while (text < stop) {
+                *gptr++ = cache->unicharToGlyph(SkUTF8_NextUnichar(&text));
+            }
+            break;
+        case SkPaint::kUTF16_TextEncoding: {
+            const uint16_t* text16 = (const uint16_t*)text;
+            const uint16_t* stop16 = (const uint16_t*)stop;
+            while (text16 < stop16) {
+                *gptr++ = cache->unicharToGlyph(SkUTF16_NextUnichar(&text16));
+            }
+            break;
+        }
+        default:
+            SkDEBUGFAIL("unknown text encoding");
+    }
+    return gptr - glyphs;
+}
+
 #endif
 
 int SkPaint::textToGlyphs(const void* textData, size_t byteLength,