Skip to content

Refactor font addons to use identical code with config files #14

@andjc

Description

@andjc

DEPENDANT ON BUG #1

Refactor font addons, so they have identical code with different configuration files and/or font files.

Suggestion form AMO reviewers:

The easiest thing to do, I think, would be to have a JSON configuration file like the following:

{
    fonts: [
        "Tharlon-Regular.ttf"
    ]
}

And then load it with something like the following:

    const XMLHttpRequest = Components.Constructor("@mozilla.org/xmlextras/xmlhttprequest;1");

    var baseURI = Services.io.newURI(__SCRIPT_URI_SPEC__.replace(/boostrap\.js$/, ""), null, null)

    var xhr = XMLHttpRequest();
    xhr.open("GET", baseURI.spec + "config.json", false);
    xhr.send();

    var config = JSON.parse(XHR.responseText);

    for (let font of config.fonts) {
        let file = Services.io.newURI("defaults/" + font, null, baseURI)
                           .QueryInterface(Ci.nsIFileURL).file;
        file.copyTo(fontdir, file.leafName);
    }

And so forth.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions