octo-deno/lib/make/fonts.js

54 lines
1.6 KiB
JavaScript
Raw Normal View History

2017-04-22 22:49:49 +00:00
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
make.fonts = {
fontStyles: function () {
return ["italic", "normal", "oblique", "inherit"];
},
fontVariants: function () {
return ["normal", "small-caps", "inherit"];
},
fontWeights: function () {
return ["normal", "bold", "bolder", "lighter"];
},
fontSizeAbsolute: function () {
return ["xx-small", "x-small", "small", "medium", "large", "x-large", "xx-large"];
},
fontFamiliesGeneric: function () {
return ["serif", "sans-serif", "cursive", "fantasy", "monospace"];
},
fontFamilies: function () {
return ["'Times New Roman'", "Arial", "Courier", "Helvetica"];
},
fontFamily: function () {
let s = random.pick(make.fonts.fontFamilies);
if (random.chance(8)) {
s += ", " + random.pick(make.fonts.fontFamiliesGeneric);
}
return s;
},
fontSize: function () {
return make.numbers.unsignedNumber() + make.fonts.lengthUnit();
},
font: function () {
let s = "";
if (random.chance(4)) {
s += random.pick(make.fonts.fontStyles) + " ";
}
if (random.chance(4)) {
s += random.pick(make.fonts.fontVariants) + " ";
}
if (random.chance(4)) {
s += random.pick(make.fonts.fontWeights) + " ";
}
if (random.chance(4)) {
s += make.numbers.number() + "/";
}
s += make.fonts.fontSize();
s += " ";
2017-04-24 15:14:58 +00:00
s += make.fonts.fontFamily();
2017-04-22 22:49:49 +00:00
return "'" + s + "'";
}
};