add GetFileName api to fonthost, to return (optionally) the file backing a given font
minor refresh on freetype and blitrow.h from skia/trunk
diff --git a/include/core/SkFontHost.h b/include/core/SkFontHost.h
index 5a49146..cb56772 100644
--- a/include/core/SkFontHost.h
+++ b/include/core/SkFontHost.h
@@ -87,7 +87,7 @@
         the caller is responsible for calling unref() when it is no longer used.
      */
     static SkTypeface* CreateTypefaceFromFile(const char path[]);
-    
+
     ///////////////////////////////////////////////////////////////////////////
     
     /** Returns true if the specified unique ID matches an existing font.
@@ -102,6 +102,35 @@
     */
     static SkStream* OpenStream(SkFontID uniqueID);
 
+    /** Some fonts are stored in files. If that is true for the fontID, then
+        this returns the byte length of the full file path. If path is not null,
+        then the full path is copied into path (allocated by the caller), up to
+        length bytes. If index is not null, then it is set to the truetype
+        collection index for this font, or 0 if the font is not in a collection.
+
+        Note: GetFileName does not assume that path is a null-terminated string,
+        so when it succeeds, it only copies the bytes of the file name and
+        nothing else (i.e. it copies exactly the number of bytes returned by the
+        function. If the caller wants to treat path[] as a C string, it must be
+        sure that it is allocated at least 1 byte larger than the returned size,
+        and it must copy in the terminating 0.
+
+        If the fontID does not correspond to a file, then the function returns
+        0, and the path and index parameters are ignored.
+
+        @param fontID   The font whose file name is being queried
+        @param path     Either NULL, or storage for receiving up to length bytes
+                        of the font's file name. Allocated by the caller.
+        @param length   The maximum space allocated in path (by the caller).
+                        Ignored if path is NULL.
+        @param index    Either NULL, or receives the TTC index for this font.
+                        If the font is not a TTC, then will be set to 0.
+        @return The byte length of th font's file name, or 0 if the font is not
+                baked by a file.
+     */
+    static size_t GetFileName(SkFontID fontID, char path[], size_t length,
+                              int32_t* index);
+
     ///////////////////////////////////////////////////////////////////////////
 
     /** Write a unique identifier to the stream, so that the same typeface can
diff --git a/src/core/SkBlitRow.h b/src/core/SkBlitRow.h
index 473c925..ec31ff5 100644
--- a/src/core/SkBlitRow.h
+++ b/src/core/SkBlitRow.h
@@ -33,7 +33,7 @@
     static Proc Factory(unsigned flags, SkBitmap::Config);
 
 private:
-    /** These global arrays are indexed using the flags parameterr to Factory,
+    /** These global arrays are indexed using the flags parameter to Factory,
         and contain either NULL, or a platform-specific function-ptr to be used
         in place of the system default.
      */
diff --git a/src/ports/SkFontHost_FreeType.cpp b/src/ports/SkFontHost_FreeType.cpp
index dbba1a2..77f4b23 100644
--- a/src/ports/SkFontHost_FreeType.cpp
+++ b/src/ports/SkFontHost_FreeType.cpp
@@ -73,6 +73,8 @@
 static int          gFTCount;
 static FT_Library   gFTLibrary;
 static SkFaceRec*   gFaceRecHead;
+static bool         gLCDSupportValid;  // true iff |gLCDSupport| has been set.
+static bool         gLCDSupport;  // true iff LCD is supported by the runtime.
 
 /////////////////////////////////////////////////////////////////////////
 
@@ -86,7 +88,9 @@
     // Setup LCD filtering. This reduces colour fringes for LCD rendered
     // glyphs.
     err = FT_Library_SetLcdFilter(gFTLibrary, FT_LCD_FILTER_DEFAULT);
+    gLCDSupport = err == 0;
 #endif
+    gLCDSupportValid = true;
 
     return true;
 }
@@ -263,6 +267,17 @@
 ///////////////////////////////////////////////////////////////////////////
 
 void SkFontHost::FilterRec(SkScalerContext::Rec* rec) {
+    if (!gLCDSupportValid) {
+      InitFreetype();
+      FT_Done_FreeType(gFTLibrary);
+    }
+
+    if (!gLCDSupport && rec->isLCD()) {
+      // If the runtime Freetype library doesn't support LCD mode, we disable
+      // it here.
+      rec->fMaskFormat = SkMask::kA8_Format;
+    }
+
     SkPaint::Hinting h = rec->getHinting();
     if (SkPaint::kFull_Hinting == h && !rec->isLCD()) {
         // collapse full->normaling hinting if we're not doing LCD
diff --git a/src/ports/SkFontHost_android.cpp b/src/ports/SkFontHost_android.cpp
index e6d134a..6aa7a0b 100644
--- a/src/ports/SkFontHost_android.cpp
+++ b/src/ports/SkFontHost_android.cpp
@@ -267,6 +267,7 @@
     
     virtual SkStream* openStream() = 0;
     virtual const char* getUniqueString() const = 0;
+    virtual const char* getFilePath() const = 0;
     
 private:
     bool    fIsSysFont;
@@ -297,6 +298,7 @@
         return fStream;
     }
     virtual const char* getUniqueString() const { return NULL; }
+    virtual const char* getFilePath() const { return NULL; }
 
 private:
     SkStream* fStream;
@@ -341,6 +343,9 @@
         }
         return str;
     }
+    virtual const char* getFilePath() const {
+        return fPath.c_str();
+    }
 
 private:
     SkString fPath;
@@ -592,6 +597,27 @@
     return stream;
 }
 
+size_t SkFontHost::GetFileName(SkFontID fontID, char path[], size_t length,
+                               int32_t* index) {
+    SkAutoMutexAcquire  ac(gFamilyMutex);
+
+    FamilyTypeface* tf = (FamilyTypeface*)find_from_uniqueID(fontID);
+    const char* src = tf ? tf->getFilePath() : NULL;
+
+    if (src) {
+        size_t size = strlen(src);
+        if (path) {
+            memcpy(path, src, SkMin32(size, length));
+        }
+        if (index) {
+            *index = 0; // we don't have collections (yet)
+        }
+        return size;
+    } else {
+        return 0;
+    }
+}
+
 uint32_t SkFontHost::NextLogicalFont(uint32_t fontID) {
     load_system_fonts();