69 lines
2 KiB
JavaScript
69 lines
2 KiB
JavaScript
/* 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.font = {
|
|
globalValue: function() {
|
|
return random.pick(["inherit", "initial", "unset"]);
|
|
},
|
|
style: function () {
|
|
return random.pick(["italic", "normal", "oblique", "inherit"]);
|
|
},
|
|
variant: function () {
|
|
return random.pick(["normal", "small-caps", "inherit"]);
|
|
},
|
|
weight: function () {
|
|
return random.pick([
|
|
/* standard */
|
|
["normal", "bold"],
|
|
/* Relative to the parent */
|
|
["bolder", "lighter"],
|
|
/* numeric values */
|
|
[100, 200, 300, 400, 500, 600, 700, 800, 900],
|
|
]);
|
|
},
|
|
size: function () {
|
|
return random.pick([
|
|
/* <absolute-size> values */
|
|
["xx-small", "x-small", "small", "medium", "large", "x-large", "xx-large"],
|
|
/* <relative-size> values */
|
|
["larger", "smaller"],
|
|
/* <length> values */
|
|
make.number.unsignedNumber() + make.unit.unit(),
|
|
/* <percentage> values */
|
|
make.unit.percent(),
|
|
]);
|
|
},
|
|
genericFamily: function () {
|
|
return random.pick(["serif", "sans-serif", "cursive", "fantasy", "monospace"]);
|
|
},
|
|
familyName: function () {
|
|
return random.pick(["Times New Roman", "Arial", "Courier", "Helvetica"]);
|
|
},
|
|
family: function () {
|
|
let s = random.pick(make.font.familyName);
|
|
if (random.chance(8)) {
|
|
s += ", " + random.pick(make.font.genericFamily);
|
|
}
|
|
return s;
|
|
},
|
|
font: function () {
|
|
let s = "";
|
|
if (random.chance(4)) {
|
|
s += random.pick(make.font.style) + " ";
|
|
}
|
|
if (random.chance(4)) {
|
|
s += random.pick(make.font.variant) + " ";
|
|
}
|
|
if (random.chance(4)) {
|
|
s += random.pick(make.font.weight) + " ";
|
|
}
|
|
if (random.chance(4)) {
|
|
s += make.number.any() + "/";
|
|
}
|
|
s += make.font.size();
|
|
s += " ";
|
|
s += make.font.family();
|
|
return "'" + s + "'";
|
|
}
|
|
};
|