summaryrefslogtreecommitdiff
path: root/tools/aapt/Resource.cpp
diff options
context:
space:
mode:
authorAdam Lesinski <adamlesinski@google.com>2017-01-24 13:52:04 -0800
committerAdam Lesinski <adamlesinski@google.com>2017-01-24 13:52:45 -0800
commit9bbe787822502e8c09d9abe963e6539647bea346 (patch)
treee8490849a1ba6013ed2cd2a7a4d37cdbd06a0b4f /tools/aapt/Resource.cpp
parent04620c98a7470109700e93caaa84b44ff23dfb5e (diff)
Finish font support for AAPT
Test: make CtsContentTestCases in cts/tests/tests/content Change-Id: Ie1e08deeef56611de261bd12f25f53c88068950e
Diffstat (limited to 'tools/aapt/Resource.cpp')
-rw-r--r--tools/aapt/Resource.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/tools/aapt/Resource.cpp b/tools/aapt/Resource.cpp
index 045d68c3bbae..cf5badc82117 100644
--- a/tools/aapt/Resource.cpp
+++ b/tools/aapt/Resource.cpp
@@ -1223,6 +1223,7 @@ status_t buildResources(Bundle* bundle, const sp<AaptAssets>& assets, sp<ApkBuil
sp<ResourceTypeSet> colors;
sp<ResourceTypeSet> menus;
sp<ResourceTypeSet> mipmaps;
+ sp<ResourceTypeSet> fonts;
ASSIGN_IT(drawable);
ASSIGN_IT(layout);
@@ -1235,6 +1236,7 @@ status_t buildResources(Bundle* bundle, const sp<AaptAssets>& assets, sp<ApkBuil
ASSIGN_IT(color);
ASSIGN_IT(menu);
ASSIGN_IT(mipmap);
+ ASSIGN_IT(font);
assets->setResources(resources);
// now go through any resource overlays and collect their files
@@ -1257,6 +1259,7 @@ status_t buildResources(Bundle* bundle, const sp<AaptAssets>& assets, sp<ApkBuil
!applyFileOverlay(bundle, assets, &raws, "raw") ||
!applyFileOverlay(bundle, assets, &colors, "color") ||
!applyFileOverlay(bundle, assets, &menus, "menu") ||
+ !applyFileOverlay(bundle, assets, &fonts, "font") ||
!applyFileOverlay(bundle, assets, &mipmaps, "mipmap")) {
return UNKNOWN_ERROR;
}
@@ -1291,6 +1294,13 @@ status_t buildResources(Bundle* bundle, const sp<AaptAssets>& assets, sp<ApkBuil
}
}
+ if (fonts != NULL) {
+ err = makeFileResources(bundle, assets, &table, fonts, "font");
+ if (err != NO_ERROR) {
+ hasErrors = true;
+ }
+ }
+
if (layouts != NULL) {
err = makeFileResources(bundle, assets, &table, layouts, "layout");
if (err != NO_ERROR) {
@@ -1549,6 +1559,26 @@ status_t buildResources(Bundle* bundle, const sp<AaptAssets>& assets, sp<ApkBuil
err = NO_ERROR;
}
+ if (fonts != NULL) {
+ ResourceDirIterator it(fonts, String8("font"));
+ while ((err=it.next()) == NO_ERROR) {
+ // fonts can be resources other than xml.
+ if (it.getFile()->getPath().getPathExtension() == ".xml") {
+ String8 src = it.getFile()->getPrintableSource();
+ err = compileXmlFile(bundle, assets, String16(it.getBaseName()),
+ it.getFile(), &table, xmlFlags);
+ if (err != NO_ERROR) {
+ hasErrors = true;
+ }
+ }
+ }
+
+ if (err < NO_ERROR) {
+ hasErrors = true;
+ }
+ err = NO_ERROR;
+ }
+
// Now compile any generated resources.
std::queue<CompileResourceWorkItem>& workQueue = table.getWorkQueue();
while (!workQueue.empty()) {