octo-deno/make/fonts.js

50 lines
1.4 KiB
JavaScript
Raw Normal View History

2017-04-12 18:43:30 +00:00
make.fonts = {
2017-04-22 20:07:29 +00:00
fontStyles: function () {
2017-04-12 18:43:30 +00:00
return ["italic", "normal", "oblique", "inherit"];
},
2017-04-22 20:07:29 +00:00
fontVariants: function () {
2017-04-12 18:43:30 +00:00
return ["normal", "small-caps", "inherit"];
},
2017-04-22 20:07:29 +00:00
fontWeights: function () {
2017-04-12 18:43:30 +00:00
return ["normal", "bold", "bolder", "lighter"];
},
2017-04-22 20:07:29 +00:00
fontSizeAbsolute: function () {
2017-04-12 18:43:30 +00:00
return ["xx-small", "x-small", "small", "medium", "large", "x-large", "xx-large"];
},
2017-04-22 20:07:29 +00:00
fontFamiliesGeneric: function () {
2017-04-12 18:43:30 +00:00
return ["serif", "sans-serif", "cursive", "fantasy", "monospace"];
},
2017-04-22 20:07:29 +00:00
fontFamilies: function () {
2017-04-22 19:02:38 +00:00
return ["'Times New Roman'", "Arial", "Courier", "Helvetica"];
2017-04-12 18:43:30 +00:00
},
fontFamily: function () {
2017-04-22 19:02:38 +00:00
let s = random.pick(make.fonts.fontFamilies);
2017-04-12 18:43:30 +00:00
if (random.chance(8)) {
2017-04-22 19:02:38 +00:00
s += ", " + random.pick(make.fonts.fontFamiliesGeneric);
2017-04-12 18:43:30 +00:00
}
return s;
},
fontSize: function () {
2017-04-22 19:02:38 +00:00
return make.numbers.unsignedNumber() + make.fonts.lengthUnit();
2017-04-12 18:43:30 +00:00
},
font: function () {
let s = "";
if (random.chance(4)) {
2017-04-22 19:02:38 +00:00
s += random.pick(make.fonts.fontStyles) + " ";
2017-04-12 18:43:30 +00:00
}
if (random.chance(4)) {
2017-04-22 19:02:38 +00:00
s += random.pick(make.fonts.fontVariants) + " ";
2017-04-12 18:43:30 +00:00
}
if (random.chance(4)) {
2017-04-22 19:02:38 +00:00
s += random.pick(make.fonts.fontWeights) + " ";
2017-04-12 18:43:30 +00:00
}
if (random.chance(4)) {
2017-04-22 19:02:38 +00:00
s += make.numbers.number() + "/";
2017-04-12 18:43:30 +00:00
}
2017-04-22 19:02:38 +00:00
s += make.fonts.fontSize();
2017-04-12 18:43:30 +00:00
s += " ";
2017-04-22 19:02:38 +00:00
s += Make.fonts.fontFamily();
2017-04-12 18:43:30 +00:00
return "'" + s + "'";
2017-04-13 02:14:02 +00:00
}
};