summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Adam Lesinski <adamlesinski@google.com> 2016-10-19 18:37:53 -0700
committer Adam Lesinski <adamlesinski@google.com> 2016-10-27 18:09:00 -0700
commitc0c366394c658e3787b12e65833b520c9a9a34d9 (patch)
tree0f8edb0b05d1d2899100fd114053ba1b8baa39a0
parent9212fc742ff4fc92561c8055388d119d8ef195ae (diff)
Add font type to AAPT2
Test: make libaapt2_tests AaptTestAppOne Change-Id: I8fbf01675a218cc3c0b59598b6b1ec173851e946
-rw-r--r--api/current.txt3
-rw-r--r--api/system-current.txt3
-rw-r--r--api/test-current.txt3
-rw-r--r--core/res/res/values/attrs.xml11
-rw-r--r--core/res/res/values/public.xml3
-rw-r--r--tools/aapt2/Main.cpp2
-rw-r--r--tools/aapt2/Resource.cpp3
-rw-r--r--tools/aapt2/Resource.h1
-rw-r--r--tools/aapt2/Resource_test.cpp4
-rw-r--r--tools/aapt2/integration-tests/AppOne/res/font/myfont-italic.ttf0
-rw-r--r--tools/aapt2/integration-tests/AppOne/res/font/myfont-normal.ttf0
-rw-r--r--tools/aapt2/integration-tests/AppOne/res/font/myfont.xml5
-rw-r--r--tools/aapt2/readme.md4
13 files changed, 41 insertions, 1 deletions
diff --git a/api/current.txt b/api/current.txt
index b39fcf8254a3..961fd07de8ce 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -577,8 +577,11 @@ package android {
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 d73dbe9f7731..1577b7c97838 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -683,8 +683,11 @@ package android {
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 fbd1315397e3..22c08a277dde 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -577,8 +577,11 @@ package android {
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 c3967e46c3e9..2d61e6ec3bc5 100644
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -8335,4 +8335,15 @@ i
<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 7999e7e48365..66683471f43f 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 8dd176d27345..a3404e5db21c 100644
--- a/tools/aapt2/Main.cpp
+++ b/tools/aapt2/Main.cpp
@@ -25,7 +25,7 @@ namespace aapt {
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 1d414743de71..3eef7aa71a92 100644
--- a/tools/aapt2/Resource.cpp
+++ b/tools/aapt2/Resource.cpp
@@ -41,6 +41,8 @@ StringPiece ToString(ResourceType type) {
return "dimen";
case ResourceType::kDrawable:
return "drawable";
+ case ResourceType::kFont:
+ return "font";
case ResourceType::kFraction:
return "fraction";
case ResourceType::kId:
@@ -83,6 +85,7 @@ static const std::map<StringPiece, ResourceType> sResourceTypeMap{
{"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 78acb700c7c0..13330b548d2c 100644
--- a/tools/aapt2/Resource.h
+++ b/tools/aapt2/Resource.h
@@ -46,6 +46,7 @@ enum class ResourceType {
kColor,
kDimen,
kDrawable,
+ kFont,
kFraction,
kId,
kInteger,
diff --git a/tools/aapt2/Resource_test.cpp b/tools/aapt2/Resource_test.cpp
index 720ab91c5740..6acb4d3eb850 100644
--- a/tools/aapt2/Resource_test.cpp
+++ b/tools/aapt2/Resource_test.cpp
@@ -57,6 +57,10 @@ TEST(ResourceTypeTest, ParseResourceTypes) {
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 000000000000..e69de29bb2d1
--- /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 000000000000..e69de29bb2d1
--- /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 000000000000..1fb67914894e
--- /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 93c790d80c4c..ac411b15ae83 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