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/. */
|
|
|
|
|
2018-03-19 03:23:05 +00:00
|
|
|
const make = require('../make')
|
|
|
|
const random = require('../random')
|
|
|
|
|
|
|
|
class font extends make {
|
|
|
|
static globalValue () {
|
2017-04-25 22:21:31 +00:00
|
|
|
return random.pick(['inherit', 'initial', 'unset'])
|
2018-03-19 03:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static style () {
|
2017-04-25 22:21:31 +00:00
|
|
|
return random.pick(['italic', 'normal', 'oblique', 'inherit'])
|
2018-03-19 03:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static variant () {
|
2017-04-25 22:21:31 +00:00
|
|
|
return random.pick(['normal', 'small-caps', 'inherit'])
|
2018-03-19 03:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static weight () {
|
2017-04-25 15:00:01 +00:00
|
|
|
return random.pick([
|
|
|
|
/* standard */
|
2017-04-25 22:21:31 +00:00
|
|
|
['normal', 'bold'],
|
2017-04-25 15:00:01 +00:00
|
|
|
/* Relative to the parent */
|
2017-04-25 22:21:31 +00:00
|
|
|
['bolder', 'lighter'],
|
2017-04-25 15:00:01 +00:00
|
|
|
/* numeric values */
|
2017-04-25 22:21:31 +00:00
|
|
|
[100, 200, 300, 400, 500, 600, 700, 800, 900]
|
|
|
|
])
|
2018-03-19 03:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static size () {
|
2017-04-25 15:00:01 +00:00
|
|
|
return random.pick([
|
|
|
|
/* <absolute-size> values */
|
2017-04-25 22:21:31 +00:00
|
|
|
['xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large'],
|
2017-04-25 15:00:01 +00:00
|
|
|
/* <relative-size> values */
|
2017-04-25 22:21:31 +00:00
|
|
|
['larger', 'smaller'],
|
2017-04-25 15:00:01 +00:00
|
|
|
/* <length> values */
|
2017-06-10 05:40:29 +00:00
|
|
|
make.number.unsigned() + make.unit.unit(),
|
2017-04-25 15:00:01 +00:00
|
|
|
/* <percentage> values */
|
2017-04-25 22:21:31 +00:00
|
|
|
make.unit.percent()
|
|
|
|
])
|
2018-03-19 03:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static relativeSize () {
|
2017-06-28 19:01:34 +00:00
|
|
|
let value = random.number(8)
|
|
|
|
return random.item(['', '+', '-']) + value
|
2018-03-19 03:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static genericFamily () {
|
2017-04-25 22:21:31 +00:00
|
|
|
return random.pick(['serif', 'sans-serif', 'cursive', 'fantasy', 'monospace'])
|
2018-03-19 03:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static familyName () {
|
2017-04-25 22:21:31 +00:00
|
|
|
return random.pick(['Times New Roman', 'Arial', 'Courier', 'Helvetica'])
|
2018-03-19 03:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static family () {
|
|
|
|
let s = random.pick(this.familyName)
|
2017-04-22 22:49:49 +00:00
|
|
|
if (random.chance(8)) {
|
2018-03-19 03:23:05 +00:00
|
|
|
s += ', ' + random.pick(this.genericFamily)
|
2017-04-22 22:49:49 +00:00
|
|
|
}
|
2017-04-25 22:21:31 +00:00
|
|
|
return s
|
2018-03-19 03:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static registeredFontFeatures () {
|
2017-05-31 19:24:43 +00:00
|
|
|
return random.pick([
|
|
|
|
'aalt', 'abvf', 'abvm', 'abvs', 'afrc', 'akhn', 'blwf', 'blwm', 'blws',
|
|
|
|
'calt', 'case', 'ccmp', 'cfar', 'cjct', 'clig', 'cpct', 'cpsp', 'cswh',
|
|
|
|
'curs', 'cv01-cv99', 'c2pc', 'c2sc', 'dist', 'dlig', 'dnom', 'expt',
|
|
|
|
'falt', 'fin2', 'fin3', 'fina', 'frac', 'fwid', 'half', 'haln', 'halt',
|
|
|
|
'hist', 'hkna', 'hlig', 'hngl', 'hojo', 'hwid', 'init', 'isol', 'ital',
|
|
|
|
'jalt', 'jp78', 'jp83', 'jp90', 'jp04', 'kern', 'lfbd', 'liga', 'ljmo',
|
|
|
|
'lnum', 'locl', 'ltra', 'ltrm', 'mark', 'med2', 'medi', 'mgrk', 'mkmk',
|
|
|
|
'mset', 'nalt', 'nlck', 'nukt', 'numr', 'onum', 'opbd', 'ordn', 'ornm',
|
|
|
|
'palt', 'pcap', 'pkna', 'pnum', 'pref', 'pres', 'pstf', 'psts', 'pwid',
|
|
|
|
'qwid', 'rand', 'rkrf', 'rlig', 'rphf', 'rtbd', 'rtla', 'rtlm', 'ruby',
|
|
|
|
'salt', 'sinf', 'size', 'smcp', 'smpl', 'ss01', 'ss02', 'ss03', 'ss04',
|
|
|
|
'ss05', 'ss06', 'ss07', 'ss08', 'ss09', 'ss10', 'ss11', 'ss12', 'ss13',
|
|
|
|
'ss14', 'ss15', 'ss16', 'ss17', 'ss18', 'ss19', 'ss20', 'subs', 'sups',
|
|
|
|
'swsh', 'titl', 'tjmo', 'tnam', 'tnum', 'trad', 'twid', 'unic', 'valt',
|
|
|
|
'vatu', 'vert', 'vhal', 'vjmo', 'vkna', 'vkrn', 'vpal', 'vrt2', 'zero'
|
|
|
|
])
|
2018-03-19 03:23:05 +00:00
|
|
|
}
|
|
|
|
|
2018-03-19 04:54:40 +00:00
|
|
|
static font () {
|
2017-04-25 22:21:31 +00:00
|
|
|
let s = ''
|
2017-04-22 22:49:49 +00:00
|
|
|
if (random.chance(4)) {
|
2018-03-19 03:23:05 +00:00
|
|
|
s += random.pick(this.style) + ' '
|
2017-04-22 22:49:49 +00:00
|
|
|
}
|
|
|
|
if (random.chance(4)) {
|
2018-03-19 03:23:05 +00:00
|
|
|
s += random.pick(this.variant) + ' '
|
2017-04-22 22:49:49 +00:00
|
|
|
}
|
|
|
|
if (random.chance(4)) {
|
2018-03-19 03:23:05 +00:00
|
|
|
s += random.pick(this.weight) + ' '
|
2017-04-22 22:49:49 +00:00
|
|
|
}
|
|
|
|
if (random.chance(4)) {
|
2017-04-25 22:21:31 +00:00
|
|
|
s += make.number.any() + '/'
|
2017-04-22 22:49:49 +00:00
|
|
|
}
|
2018-03-19 03:23:05 +00:00
|
|
|
s += this.size()
|
2017-04-25 22:21:31 +00:00
|
|
|
s += ' '
|
2018-03-19 03:23:05 +00:00
|
|
|
s += this.family()
|
2017-09-19 20:02:37 +00:00
|
|
|
return s
|
2017-04-22 22:49:49 +00:00
|
|
|
}
|
2017-04-25 22:21:31 +00:00
|
|
|
}
|
2018-03-19 03:23:05 +00:00
|
|
|
|
2018-03-19 04:54:40 +00:00
|
|
|
module.exports = font
|