dnm-font-manager
Advanced tools
Comparing version 0.4.2 to 0.4.3
102
dist/main.js
@@ -262,41 +262,87 @@ 'use strict'; | ||
this.searchFonts = function (fonts, search) { | ||
this.searchFonts = function (fonts, search_request) { | ||
var search = []; | ||
search_request.forEach(function (new_search) { | ||
var family = new_search.family, | ||
style = new_search.style; | ||
if (style && (typeof style === 'undefined' ? 'undefined' : _typeof(style)) !== "object") style = [style]; | ||
var is_sorted = false; | ||
var _loop = function _loop(i) { | ||
if (search[i].family === family) { | ||
is_sorted = true; | ||
if (!style) search[i] = new_search;else if (search[i].style) { | ||
style.forEach(function (new_style) { | ||
if (search[i].style.indexOf(new_style) === -1) { | ||
search[i].style.push(new_style); | ||
} | ||
}); | ||
} | ||
return 'break'; | ||
} | ||
}; | ||
for (var i = 0; i < search.length; i++) { | ||
var _ret = _loop(i); | ||
if (_ret === 'break') break; | ||
} | ||
if (!is_sorted) { | ||
var _new_search = { family: family }; | ||
if (style) _new_search.style = style; | ||
search.push(_new_search); | ||
} | ||
}); | ||
var found = []; | ||
var missing = []; | ||
for (var n = 0; n < search.length; n++) { | ||
search.forEach(function (new_search) { | ||
var found_font = false; | ||
var family = search[n].family; | ||
var family = new_search.family, | ||
style = new_search.style; | ||
for (var i = 0; i < fonts.length; i++) { | ||
if (family === fonts[i].family) { | ||
found_font = true; | ||
var style = search[n].style; | ||
var files = fonts[i].files; | ||
var _ret2 = function () { | ||
found_font = true; | ||
var files = fonts[i].files; | ||
if (style) { | ||
if ((typeof style === 'undefined' ? 'undefined' : _typeof(style)) !== "object") style = [style]; | ||
for (var s = 0; s < style.length; s++) { | ||
var return_font = { | ||
family: family, | ||
style: style[s] | ||
}; | ||
if (files[style[s]]) { | ||
return_font.file = files[style[s]]; | ||
found.push(return_font); | ||
} else missing.push(return_font); | ||
} | ||
} else { | ||
for (var key in files) { | ||
found.push({ | ||
family: family, | ||
style: key, | ||
file: files[key] | ||
if (style) { | ||
style.forEach(function (new_style) { | ||
var return_font = { | ||
family: family, | ||
style: new_style | ||
}; | ||
if (files[new_style]) { | ||
return_font.file = files[new_style]; | ||
found.push(return_font); | ||
} else missing.push(return_font); | ||
}); | ||
} else { | ||
for (var key in files) { | ||
found.push({ | ||
family: family, | ||
style: key, | ||
file: files[key] | ||
}); | ||
} | ||
} | ||
} | ||
break; | ||
return 'break'; | ||
}(); | ||
if (_ret2 === 'break') break; | ||
} | ||
} | ||
if (!found_font) missing.push({ family: family }); | ||
} | ||
if (!found_font) { | ||
if (style) { | ||
style.forEach(function (fontStyle) { | ||
missing.push({ | ||
family: family, | ||
style: fontStyle | ||
}); | ||
}); | ||
} else missing.push({ family: family }); | ||
} | ||
}); | ||
return { found: found, missing: missing }; | ||
@@ -303,0 +349,0 @@ }; |
{ | ||
"name": "dnm-font-manager", | ||
"version": "0.4.2", | ||
"version": "0.4.3", | ||
"description": "Search system fonts with family and style using pure JavaScript, forked from rBurgett/system-font-families", | ||
@@ -5,0 +5,0 @@ "main": "dist/main.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
102826
308