| 480 | } |
| 481 | |
| 482 | public toCssString(scale: number = 1): string { |
| 483 | if (!this._css || !(Math.abs(scale - this._cssScale) < 0.01)) { |
| 484 | let buf: string = ''; |
| 485 | if (this.isBold) { |
| 486 | buf += 'bold '; |
| 487 | } |
| 488 | if (this.isItalic) { |
| 489 | buf += 'italic '; |
| 490 | } |
| 491 | buf += this.size * scale; |
| 492 | buf += 'px '; |
| 493 | buf += this.families.map(f => FontParser.quoteFont(f)).join(', '); |
| 494 | this._css = buf; |
| 495 | this._cssScale = scale; |
| 496 | } |
| 497 | return this._css; |
| 498 | } |
| 499 | |
| 500 | public static fromJson(v: unknown): Font | undefined { |
| 501 | if (v instanceof Font) { |