cordova-plugin-fonts maintenance release 0.6.0
The Adapt It Mobile team members maintain a general purpose plugin for the Apache Cordova framework called cordova-plugin-fonts. This plugin allows Adapt It Mobile to enumerate the fonts installed on the mobile device, so that they can be used for adaptation.
The cordova-plugin-fonts release 0.6.0 adds a new method, getDefaultFont:
GetDefaultFont
Parameters:
- successCallback: Callback that returns the string name of the default font on the device.
- errorCallback: Callback that executes if an error occurs during the call.
Android quirks
Android currently returns a hard-coded string for the default font, “Roboto Regular”.
Firefox OS quirks
Firefox OS does not provide an API to access the fonts on the device. The Fonts plugin currently returns a hard-coded string for the default font “Fira Sans Regular”. See https://www.mozilla.org/en-US/styleguide/products/firefox-os/typeface/ for more information.
Example
if (navigator.Fonts) {
console.log("Fonts object in navigator");
navigator.Fonts.getDefaultFont(
function (defaultFont) {
if (defaultFont) {
console.log("Default Font: " + defaultFont);
}
},
function (error) {
console.log("DefaultFont error: " + error);
}
);
} else {
console.log("Plugin error: Fonts plugin not found (is it installed?)");
}
For more information about cordova-plugin-fonts, including installation instructions for Apache Cordova-based mobile apps, please visit the cordova-plugin-fonts repository page.