fp 字体

 

 

var l = ["monospace", "sans-serif", "serif"];

var u = ["Andale Mono", "Arial", "Arial Black", "Arial Hebrew", "Arial MT", "Arial Narrow", "Arial Rounded MT Bold", "Arial Unicode MS", "Bitstream Vera Sans Mono", "Book Antiqua", "Bookman Old Style", "Calibri", "Cambria", "Cambria Math", "Century", "Century Gothic", "Century Schoolbook", "Comic Sans", "Comic Sans MS", "Consolas", "Courier", "Courier New", "Garamond", "Geneva", "Georgia", "Helvetica", "Helvetica Neue", "Impact", "Lucida Bright", "Lucida Calligraphy", "Lucida Console", "Lucida Fax", "LUCIDA GRANDE", "Lucida Handwriting", "Lucida Sans", "Lucida Sans Typewriter", "Lucida Sans Unicode", "Microsoft Sans Serif", "Monaco", "Monotype Corsiva", "MS Gothic", "MS Outlook", "MS PGothic", "MS Reference Sans Serif", "MS Sans Serif", "MS Serif", "MYRIAD", "MYRIAD PRO", "Palatino", "Palatino Linotype", "Segoe Print", "Segoe Script", "Segoe UI", "Segoe UI Light", "Segoe UI Semibold", "Segoe UI Symbol", "Tahoma", "Times", "Times New Roman", "Times New Roman PS", "Trebuchet MS", "Verdana", "Wingdings", "Wingdings 2", "Wingdings 3"];

var e = document.getElementsByTagName('body')[0];

var o = document.createElement('div');
var p = document.createElement('div');

var r = {}
  , i = {};

function h() {
    var e = document.createElement('span');
    e.style.position = 'absolute';
    e.style.left = '-9999px';
    e.style.fontSize = '72px';
    e.innerHTML = 'mmmmmmmmmmlli';
    return e;
}

var n = function() {

    for (var e = [], t = 0, n = l.length; t < n; t++) {
        var r = h();
        r.style.fontFamily = l[t],
        o.appendChild(r),
        e.push(r);
    }
    return e;

}();

e.appendChild(o);

for (var s = 0, a = l.length; s < a; s++)
    r[l[s]] = n[s]['offsetWidth'],
    i[l[s]] = n[s]['offsetHeight'];

function t(e) {
    for (var t = !1, n = 0; n < l['length']; n++)
        if (t = e[n]['offsetWidth'] !== r[l[n]] || e[n]['offsetHeight'] !== i[l[n]])
            return t;
    return t;
}
;
var c = function() {

    for (var e, t, n, r = {}, o = 0, i = u['length']; o < i; o++) {
        for (var s = [], a = 0, c = l['length']; a < c; a++) {
            var _ = (e = u[o],
            t = l[a],
            n = void 0,
            (n = h())['style']['fontFamily'] = "'" + e + "'," + t,
            n);
            p['appendChild'](_),
            s['push'](_);
        }
        r[u[o]] = s;
    }
    return r;
}();
e['appendChild'](p);

for (var _ = [], f = 0, g = u['length']; f < g; f++)
    t(c[u[f]]) && _['push'](u[f]['replace'](/\s/g, ''));
var d = _['join'](',');

console.log(d);

 

posted @ 2022-11-26 13:52  AngDH  阅读(62)  评论(0编辑  收藏  举报