Merge "Necessary changes to build FreeType on Android" into staging-master
diff --git a/Android.bp b/Android.bp
new file mode 100644
index 0000000..b0895f3
--- /dev/null
+++ b/Android.bp
@@ -0,0 +1,71 @@
+cc_library_shared {
+    name: "libft2",
+
+    // compile in ARM mode, since the glyph loader/renderer is a hotspot
+    // when loading complex pages in the browser
+    //
+    arch: {
+        arm: {
+            instruction_set: "arm",
+        },
+    },
+
+    srcs: [
+        "src/base/ftbbox.c",
+        "src/base/ftbitmap.c",
+        "src/base/ftfntfmt.c",
+        "src/base/ftfstype.c",
+        "src/base/ftglyph.c",
+        "src/base/ftlcdfil.c",
+        "src/base/ftstroke.c",
+        "src/base/fttype1.c",
+        "src/base/ftbase.c",
+        "src/base/ftsystem.c",
+        "src/base/ftinit.c",
+        "src/base/ftgasp.c",
+        "src/base/ftmm.c",
+        "src/gzip/ftgzip.c",
+        "src/raster/raster.c",
+        "src/sfnt/sfnt.c",
+        "src/smooth/smooth.c",
+        "src/autofit/autofit.c",
+        "src/truetype/truetype.c",
+        "src/cff/cff.c",
+        "src/psnames/psnames.c",
+        "src/pshinter/pshinter.c",
+    ],
+
+    export_include_dirs: ["include"],
+
+    cflags: [
+        "-W",
+        "-Wall",
+        "-Werror",
+
+        "-fPIC",
+        "-DPIC",
+
+        "-DDARWIN_NO_CARBON",
+        "-DFT2_BUILD_LIBRARY",
+
+        "-O2",
+
+        // Upstream ignores unused parameter warning
+        "-Wno-unused-parameter",
+        // the following is for testing only, and should not be used in final
+        // builds of the product
+        // "-DTT_CONFIG_OPTION_BYTECODE_INTERPRETER",
+    ],
+
+    shared_libs: [
+        "libpng",
+        "libz",
+    ],
+}
+
+llndk_library {
+    name: "libft2",
+    vendor_available: false,
+    symbol_file: "libft2.map.txt",
+    export_include_dirs: ["include"],
+}
diff --git a/CleanSpec.mk b/CleanSpec.mk
new file mode 100644
index 0000000..b9cafef
--- /dev/null
+++ b/CleanSpec.mk
@@ -0,0 +1,51 @@
+# Copyright (C) 2007 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# If you don't need to do a full clean build but would like to touch
+# a file or delete some intermediate files, add a clean step to the end
+# of the list.  These steps will only be run once, if they haven't been
+# run before.
+#
+# E.g.:
+#     $(call add-clean-step, touch -c external/sqlite/sqlite3.h)
+#     $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libz_intermediates)
+#
+# Always use "touch -c" and "rm -f" or "rm -rf" to gracefully deal with
+# files that are missing or have been moved.
+#
+# Use $(PRODUCT_OUT) to get to the "out/target/product/blah/" directory.
+# Use $(OUT_DIR) to refer to the "out" directory.
+#
+# If you need to re-do something that's already mentioned, just copy
+# the command and add it to the bottom of the list.  E.g., if a change
+# that you made last week required touching a file and a change you
+# made today requires touching the same file, just copy the old
+# touch step and add it to the end of the list.
+#
+# ************************************************
+# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
+# ************************************************
+
+# For example:
+#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/AndroidTests_intermediates)
+#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/core_intermediates)
+#$(call add-clean-step, find $(OUT_DIR) -type f -name "IGTalkSession*" -print0 | xargs -0 rm -f)
+#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*)
+
+# ************************************************
+# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
+# ************************************************
+
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libft2_*)
diff --git a/MODULE_LICENSE_BSD_LIKE b/MODULE_LICENSE_BSD_LIKE
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/MODULE_LICENSE_BSD_LIKE
diff --git a/README.android b/README.android
new file mode 100644
index 0000000..d97d32d
--- /dev/null
+++ b/README.android
@@ -0,0 +1,23 @@
+Freetype
+
+There are the following local modifications:
+
+The following modules are disabled in include/freetype/config/ftmodule.h:
+  t1
+  t1cid
+  pfr
+  t42
+  winfnt
+  pcf
+  psaux
+  bdf
+
+The following options are disabled in include/freetype/config/ftoption.h:
+
+  FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
+  FT_CONFIG_OPTION_INCREMENTAL
+  TT_CONFIG_OPTION_SUBPIXEL_HINTING
+
+The following option is enabled to support color fonts.
+
+  FT_CONFIG_OPTION_USE_PNG
\ No newline at end of file
diff --git a/README.version b/README.version
new file mode 100644
index 0000000..228b520
--- /dev/null
+++ b/README.version
@@ -0,0 +1,3 @@
+URL: http://git.savannah.gnu.org/cgit/freetype/freetype2.git/commit/?id=e432ebf
+Version: 447a0b62634802d8acdb56008cff5ff4e50be244
+BugComponent: 75970
diff --git a/include/freetype/config/ftmodule.h b/include/freetype/config/ftmodule.h
index 76d271a..cf0d2b6 100644
--- a/include/freetype/config/ftmodule.h
+++ b/include/freetype/config/ftmodule.h
@@ -9,17 +9,17 @@
  *  FreeType without GNU make.
  *
  */
-
+// ANDROID: commented out ones are not needed for android, previously they were deleted
 FT_USE_MODULE( FT_Module_Class, autofit_module_class )
 FT_USE_MODULE( FT_Driver_ClassRec, tt_driver_class )
-FT_USE_MODULE( FT_Driver_ClassRec, t1_driver_class )
+//FT_USE_MODULE( FT_Driver_ClassRec, t1_driver_class )
 FT_USE_MODULE( FT_Driver_ClassRec, cff_driver_class )
-FT_USE_MODULE( FT_Driver_ClassRec, t1cid_driver_class )
-FT_USE_MODULE( FT_Driver_ClassRec, pfr_driver_class )
-FT_USE_MODULE( FT_Driver_ClassRec, t42_driver_class )
-FT_USE_MODULE( FT_Driver_ClassRec, winfnt_driver_class )
-FT_USE_MODULE( FT_Driver_ClassRec, pcf_driver_class )
-FT_USE_MODULE( FT_Module_Class, psaux_module_class )
+//FT_USE_MODULE( FT_Driver_ClassRec, t1cid_driver_class )
+//FT_USE_MODULE( FT_Driver_ClassRec, pfr_driver_class )
+//FT_USE_MODULE( FT_Driver_ClassRec, t42_driver_class )
+//FT_USE_MODULE( FT_Driver_ClassRec, winfnt_driver_class )
+//FT_USE_MODULE( FT_Driver_ClassRec, pcf_driver_class )
+//FT_USE_MODULE( FT_Module_Class, psaux_module_class )
 FT_USE_MODULE( FT_Module_Class, psnames_module_class )
 FT_USE_MODULE( FT_Module_Class, pshinter_module_class )
 FT_USE_MODULE( FT_Renderer_Class, ft_raster1_renderer_class )
@@ -27,6 +27,6 @@
 FT_USE_MODULE( FT_Renderer_Class, ft_smooth_renderer_class )
 FT_USE_MODULE( FT_Renderer_Class, ft_smooth_lcd_renderer_class )
 FT_USE_MODULE( FT_Renderer_Class, ft_smooth_lcdv_renderer_class )
-FT_USE_MODULE( FT_Driver_ClassRec, bdf_driver_class )
+//FT_USE_MODULE( FT_Driver_ClassRec, bdf_driver_class )
 
 /* EOF */
diff --git a/include/freetype/config/ftoption.h b/include/freetype/config/ftoption.h
index 7e81fa4..a559bcd 100644
--- a/include/freetype/config/ftoption.h
+++ b/include/freetype/config/ftoption.h
@@ -102,7 +102,8 @@
   /*                       cff:no-stem-darkening=1 \                       */
   /*                       autofitter:warping=1                            */
   /*                                                                       */
-#define FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
+  /* ANDROID: disabled */
+  /* #define FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES                       */
 
 
   /*************************************************************************/
@@ -255,7 +256,8 @@
   /*                                                                       */
   /*   Define this macro if you want to enable this `feature'.             */
   /*                                                                       */
-/* #define FT_CONFIG_OPTION_USE_PNG */
+  /* ANDROID: enabled */
+#define FT_CONFIG_OPTION_USE_PNG
 
 
   /*************************************************************************/
@@ -400,7 +402,8 @@
   /* supply font data incrementally as the document is parsed, such        */
   /* as the Ghostscript interpreter for the PostScript language.           */
   /*                                                                       */
-#define FT_CONFIG_OPTION_INCREMENTAL
+  /* ANDROID: disabled */
+  /* #define FT_CONFIG_OPTION_INCREMENTAL                                  */
 
 
   /*************************************************************************/
@@ -684,7 +687,10 @@
   /* [1] http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx */
   /*                                                                       */
 /* #define TT_CONFIG_OPTION_SUBPIXEL_HINTING  1         */
-#define TT_CONFIG_OPTION_SUBPIXEL_HINTING  2
+
+/* ANDROID: disabled */
+/* #define TT_CONFIG_OPTION_SUBPIXEL_HINTING  2         */
+
 /* #define TT_CONFIG_OPTION_SUBPIXEL_HINTING  ( 1 | 2 ) */
 
 
diff --git a/libft2.map.txt b/libft2.map.txt
new file mode 100644
index 0000000..4671ad6
--- /dev/null
+++ b/libft2.map.txt
@@ -0,0 +1,13 @@
+LIBFT2 {
+  global:
+    FT_Done_Face; # vndk
+    FT_Done_FreeType; # vndk
+    FT_Get_Char_Index; # vndk
+    FT_Init_FreeType; # vndk
+    FT_Load_Glyph; # vndk
+    FT_New_Face; # vndk
+    FT_New_Memory_Face; # vndk
+    FT_Set_Char_Size; # vndk
+  local:
+    *;
+};