Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9bbe7878 authored by Adam Lesinski's avatar Adam Lesinski
Browse files

Finish font support for AAPT

Test: make CtsContentTestCases in cts/tests/tests/content
Change-Id: Ie1e08deeef56611de261bd12f25f53c88068950e
parent 04620c98
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
@@ -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()) {