Add font type to AAPT2

Test: make libaapt2_tests AaptTestAppOne
Change-Id: I8fbf01675a218cc3c0b59598b6b1ec173851e946
This commit is contained in:
Adam Lesinski
2016-10-19 18:37:53 -07:00
parent 9212fc742f
commit c0c366394c
13 changed files with 41 additions and 1 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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>

View File

@@ -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">

View File

@@ -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 << "."

View File

@@ -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},

View File

@@ -46,6 +46,7 @@ enum class ResourceType {
kColor,
kDimen,
kDrawable,
kFont,
kFraction,
kId,
kInteger,

View File

@@ -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);

View File

@@ -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>

View File

@@ -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