* This is the main options class. It contains the current style, size, color, * and font. * * Options objects should not be modified. To create a new Options with * different properties, call a `.having*` method.
| 4803 | * different properties, call a `.having*` method. |
| 4804 | */ |
| 4805 | class Options { |
| 4806 | // A font family applies to a group of fonts (i.e. SansSerif), while a font |
| 4807 | // represents a specific font (i.e. SansSerif Bold). |
| 4808 | // See: https://tex.stackexchange.com/questions/22350/difference-between-textrm-and-mathrm |
| 4809 | |
| 4810 | /** |
| 4811 | * The base size index. |
| 4812 | */ |
| 4813 | constructor(data) { |
| 4814 | this.style = void 0; |
| 4815 | this.color = void 0; |
| 4816 | this.size = void 0; |
| 4817 | this.textSize = void 0; |
| 4818 | this.phantom = void 0; |
| 4819 | this.font = void 0; |
| 4820 | this.fontFamily = void 0; |
| 4821 | this.fontWeight = void 0; |
| 4822 | this.fontShape = void 0; |
| 4823 | this.sizeMultiplier = void 0; |
| 4824 | this.maxSize = void 0; |
| 4825 | this._fontMetrics = void 0; |
| 4826 | this.style = data.style; |
| 4827 | this.color = data.color; |
| 4828 | this.size = data.size || Options.BASESIZE; |
| 4829 | this.textSize = data.textSize || this.size; |
| 4830 | this.phantom = !!data.phantom; |
| 4831 | this.font = data.font || ""; |
| 4832 | this.fontFamily = data.fontFamily || ""; |
| 4833 | this.fontWeight = data.fontWeight || ''; |
| 4834 | this.fontShape = data.fontShape || ''; |
| 4835 | this.sizeMultiplier = sizeMultipliers[this.size - 1]; |
| 4836 | this.maxSize = data.maxSize; |
| 4837 | this._fontMetrics = undefined; |
| 4838 | } |
| 4839 | /** |
| 4840 | * Returns a new options object with the same properties as "this". Properties |
| 4841 | * from "extension" will be copied to the new options object. |
| 4842 | */ |
| 4843 | |
| 4844 | |
| 4845 | extend(extension) { |
| 4846 | const data = { |
| 4847 | style: this.style, |
| 4848 | size: this.size, |
| 4849 | textSize: this.textSize, |
| 4850 | color: this.color, |
| 4851 | phantom: this.phantom, |
| 4852 | font: this.font, |
| 4853 | fontFamily: this.fontFamily, |
| 4854 | fontWeight: this.fontWeight, |
| 4855 | fontShape: this.fontShape, |
| 4856 | maxSize: this.maxSize |
| 4857 | }; |
| 4858 | |
| 4859 | for (const key in extension) { |
| 4860 | if (extension.hasOwnProperty(key)) { |
| 4861 | data[key] = extension[key]; |
| 4862 | } |
nothing calls this directly
no outgoing calls
no test coverage detected