Add font type to AAPT2

Test: make libaapt2_tests AaptTestAppOne
Change-Id: I8fbf01675a218cc3c0b59598b6b1ec173851e946
diff --git a/api/current.txt b/api/current.txt
index b39fcf8..961fd07 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -577,8 +577,11 @@
     field public static final int focusable = 16842970; // 0x10100da
     field public static final int focusableInTouchMode = 16842971; // 0x10100db
     field public static final deprecated int focusedMonthDateColor = 16843587; // 0x1010343
+    field public static final int font = 16844082; // 0x1010532
     field public static final int fontFamily = 16843692; // 0x10103ac
     field public static final int fontFeatureSettings = 16843959; // 0x10104b7
+    field public static final int fontStyle = 16844081; // 0x1010531
+    field public static final int fontWeight = 16844083; // 0x1010533
     field public static final int footerDividersEnabled = 16843311; // 0x101022f
     field public static final int forceHasOverlappingRendering = 16844065; // 0x1010521
     field public static final int foreground = 16843017; // 0x1010109
diff --git a/api/system-current.txt b/api/system-current.txt
index d73dbe9..1577b7c 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -683,8 +683,11 @@
     field public static final int focusable = 16842970; // 0x10100da
     field public static final int focusableInTouchMode = 16842971; // 0x10100db
     field public static final deprecated int focusedMonthDateColor = 16843587; // 0x1010343
+    field public static final int font = 16844082; // 0x1010532
     field public static final int fontFamily = 16843692; // 0x10103ac
     field public static final int fontFeatureSettings = 16843959; // 0x10104b7
+    field public static final int fontStyle = 16844081; // 0x1010531
+    field public static final int fontWeight = 16844083; // 0x1010533
     field public static final int footerDividersEnabled = 16843311; // 0x101022f
     field public static final int forceHasOverlappingRendering = 16844065; // 0x1010521
     field public static final int foreground = 16843017; // 0x1010109
diff --git a/api/test-current.txt b/api/test-current.txt
index fbd13153..22c08a2 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -577,8 +577,11 @@
     field public static final int focusable = 16842970; // 0x10100da
     field public static final int focusableInTouchMode = 16842971; // 0x10100db
     field public static final deprecated int focusedMonthDateColor = 16843587; // 0x1010343
+    field public static final int font = 16844082; // 0x1010532
     field public static final int fontFamily = 16843692; // 0x10103ac
     field public static final int fontFeatureSettings = 16843959; // 0x10104b7
+    field public static final int fontStyle = 16844081; // 0x1010531
+    field public static final int fontWeight = 16844083; // 0x1010533
     field public static final int footerDividersEnabled = 16843311; // 0x101022f
     field public static final int forceHasOverlappingRendering = 16844065; // 0x1010521
     field public static final int foreground = 16843017; // 0x1010109
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index c3967e4..2d61e6e 100644
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -8335,4 +8335,15 @@
     <declare-styleable name="ShortcutCategories">
         <attr name="name" />
     </declare-styleable>
+
+    <!-- Attributes that are read when parsing a <font> tag, which is a child of
+         <font-family>. -->
+    <declare-styleable name="FontFamilyFont">
+        <attr name="fontStyle">
+            <enum name="normal" value="0" />
+            <enum name="italic" value="1" />
+        </attr>
+        <attr name="font" format="reference" />
+        <attr name="fontWeight" format="integer" />
+    </declare-styleable>
 </resources>
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index 7999e7e..6668347 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -2756,6 +2756,9 @@
     <eat-comment />
 
     <public-group type="attr" first-id="0x01010531">
+        <public name="fontStyle" />
+        <public name="font" />
+        <public name="fontWeight" />
     </public-group>
 
     <public-group type="style" first-id="0x010302e0">
diff --git a/tools/aapt2/Main.cpp b/tools/aapt2/Main.cpp
index 8dd176d..a3404e5 100644
--- a/tools/aapt2/Main.cpp
+++ b/tools/aapt2/Main.cpp
@@ -25,7 +25,7 @@
 static const char* sMajorVersion = "2";
 
 // Update minor version whenever a feature or flag is added.
-static const char* sMinorVersion = "2";
+static const char* sMinorVersion = "3";
 
 int PrintVersion() {
   std::cerr << "Android Asset Packaging Tool (aapt) " << sMajorVersion << "."
diff --git a/tools/aapt2/Resource.cpp b/tools/aapt2/Resource.cpp
index 1d414743..3eef7aa7 100644
--- a/tools/aapt2/Resource.cpp
+++ b/tools/aapt2/Resource.cpp
@@ -41,6 +41,8 @@
       return "dimen";
     case ResourceType::kDrawable:
       return "drawable";
+    case ResourceType::kFont:
+      return "font";
     case ResourceType::kFraction:
       return "fraction";
     case ResourceType::kId:
@@ -83,6 +85,7 @@
     {"color", ResourceType::kColor},
     {"dimen", ResourceType::kDimen},
     {"drawable", ResourceType::kDrawable},
+    {"font", ResourceType::kFont},
     {"fraction", ResourceType::kFraction},
     {"id", ResourceType::kId},
     {"integer", ResourceType::kInteger},
diff --git a/tools/aapt2/Resource.h b/tools/aapt2/Resource.h
index 78acb70..13330b5 100644
--- a/tools/aapt2/Resource.h
+++ b/tools/aapt2/Resource.h
@@ -46,6 +46,7 @@
   kColor,
   kDimen,
   kDrawable,
+  kFont,
   kFraction,
   kId,
   kInteger,
diff --git a/tools/aapt2/Resource_test.cpp b/tools/aapt2/Resource_test.cpp
index 720ab91..6acb4d3 100644
--- a/tools/aapt2/Resource_test.cpp
+++ b/tools/aapt2/Resource_test.cpp
@@ -57,6 +57,10 @@
   ASSERT_NE(type, nullptr);
   EXPECT_EQ(*type, ResourceType::kDrawable);
 
+  type = ParseResourceType("font");
+  ASSERT_NE(type, nullptr);
+  EXPECT_EQ(*type, ResourceType::kFont);
+
   type = ParseResourceType("fraction");
   ASSERT_NE(type, nullptr);
   EXPECT_EQ(*type, ResourceType::kFraction);
diff --git a/tools/aapt2/integration-tests/AppOne/res/font/myfont-italic.ttf b/tools/aapt2/integration-tests/AppOne/res/font/myfont-italic.ttf
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tools/aapt2/integration-tests/AppOne/res/font/myfont-italic.ttf
diff --git a/tools/aapt2/integration-tests/AppOne/res/font/myfont-normal.ttf b/tools/aapt2/integration-tests/AppOne/res/font/myfont-normal.ttf
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tools/aapt2/integration-tests/AppOne/res/font/myfont-normal.ttf
diff --git a/tools/aapt2/integration-tests/AppOne/res/font/myfont.xml b/tools/aapt2/integration-tests/AppOne/res/font/myfont.xml
new file mode 100644
index 0000000..1fb6791
--- /dev/null
+++ b/tools/aapt2/integration-tests/AppOne/res/font/myfont.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<font-family xmlns:android="http://schemas.android.com/apk/res/android">
+    <font android:fontStyle="normal" android:fontWeight="400" android:font="@font/myfont-normal" />
+    <font android:fontStyle="italic" android:fontWeight="400" android:font="@font/myfont-italic" />
+</font-family>
diff --git a/tools/aapt2/readme.md b/tools/aapt2/readme.md
index 93c790d..ac411b1 100644
--- a/tools/aapt2/readme.md
+++ b/tools/aapt2/readme.md
@@ -1,5 +1,9 @@
 # Android Asset Packaging Tool 2.0 (AAPT2) release notes
 
+## Version 2.3
+### `aapt2`
+- Support new `font` resource type.
+
 ## Version 2.2
 ### `aapt2 compile ...`
 - Added support for inline complex XML resources. See