48 lines
2.2 KiB
HTML
48 lines
2.2 KiB
HTML
<!doctype html>
|
|
<output id="result"></output>
|
|
<script>
|
|
const fonts = {
|
|
windows: [
|
|
'Arial Black', 'Bahnschrift', 'Cambria', 'Candara', 'Cascadia Code',
|
|
'Comic Sans MS', 'Consolas', 'Constantia', 'Corbel', 'Ebrima',
|
|
'Franklin Gothic Medium', 'Gabriola', 'Gadugi', 'Georgia', 'Impact',
|
|
'Ink Free', 'Javanese Text', 'Lucida Console', 'Malgun Gothic',
|
|
'Microsoft YaHei', 'Palatino Linotype', 'Segoe UI', 'SimSun', 'Tahoma',
|
|
'Trebuchet MS', 'Verdana', 'Webdings', 'Wingdings', 'Yu Gothic'
|
|
],
|
|
macos: [
|
|
'Academy Engraved LET', 'American Typewriter', 'Andale Mono',
|
|
'Apple Chancery', 'Apple Color Emoji', 'Apple Symbols', 'Avenir',
|
|
'Avenir Next', 'Baskerville', 'Big Caslon', 'Bradley Hand', 'Chalkboard',
|
|
'Chalkduster', 'Charter', 'Cochin', 'Copperplate', 'Didot', 'Futura',
|
|
'Geneva', 'Gill Sans', 'Helvetica Neue', 'Herculanum', 'Hoefler Text',
|
|
'Lucida Grande', 'Marker Felt', 'Menlo', 'Monaco', 'Optima', 'Papyrus',
|
|
'PingFang SC', 'Rockwell', 'SF Pro Display', 'Skia', 'Snell Roundhand',
|
|
'Songti SC', 'Times', 'Trattatello', 'Zapfino'
|
|
],
|
|
linux: [
|
|
'Arimo', 'Caladea', 'Carlito', 'Cousine', 'DejaVu Math TeX Gyre',
|
|
'DejaVu Sans', 'DejaVu Sans Mono', 'DejaVu Serif', 'FreeMono', 'FreeSans',
|
|
'FreeSerif', 'Liberation Mono', 'Liberation Sans', 'Liberation Sans Narrow',
|
|
'Liberation Serif', 'Nimbus Mono PS', 'Nimbus Roman', 'Nimbus Sans',
|
|
'Nimbus Sans Narrow', 'Noto Color Emoji', 'Noto Sans', 'Noto Sans CJK JP',
|
|
'Noto Sans CJK SC', 'Noto Serif', 'Noto Serif CJK JP', 'Noto Serif CJK SC',
|
|
'Tinos', 'Ubuntu', 'Ubuntu Mono'
|
|
]
|
|
};
|
|
const platform = location.hash.slice(1);
|
|
const sample = 'mmmmmmmmmmlli';
|
|
const bases = ['monospace', 'sans-serif', 'serif'];
|
|
const context = document.createElement('canvas').getContext('2d');
|
|
const widths = bases.map(base => {
|
|
context.font = `72px ${base}`;
|
|
return context.measureText(sample).width;
|
|
});
|
|
const detected = fonts[platform].filter(font => bases.some((base, index) => {
|
|
context.font = `72px "${font}",${base}`;
|
|
return context.measureText(sample).width !== widths[index];
|
|
}));
|
|
result.dataset.count = detected.length;
|
|
result.textContent = `${platform}:${detected.join('|')}`;
|
|
</script>
|