| 368 | * whether it has CSS classes, styles, or needs italic correction. |
| 369 | */ |
| 370 | export class SymbolNode implements HtmlDomNode { |
| 371 | text: string; |
| 372 | height: number; |
| 373 | depth: number; |
| 374 | italic: number; |
| 375 | skew: number; |
| 376 | width: number; |
| 377 | maxFontSize: number; |
| 378 | classes: string[]; |
| 379 | style: CssStyle; |
| 380 | |
| 381 | constructor( |
| 382 | text: string, |
| 383 | height?: number, |
| 384 | depth?: number, |
| 385 | italic?: number, |
| 386 | skew?: number, |
| 387 | width?: number, |
| 388 | classes?: string[], |
| 389 | style?: CssStyle, |
| 390 | ) { |
| 391 | this.text = text; |
| 392 | this.height = height || 0; |
| 393 | this.depth = depth || 0; |
| 394 | this.italic = italic || 0; |
| 395 | this.skew = skew || 0; |
| 396 | this.width = width || 0; |
| 397 | this.classes = classes || []; |
| 398 | this.style = style || {}; |
| 399 | this.maxFontSize = 0; |
| 400 | |
| 401 | // Mark text from non-Latin scripts with specific classes so that we |
| 402 | // can specify which fonts to use. This allows us to render these |
| 403 | // characters with a serif font in situations where the browser would |
| 404 | // either default to a sans serif or render a placeholder character. |
| 405 | // We use CSS class names like cjk_fallback, hangul_fallback and |
| 406 | // brahmic_fallback. See ./unicodeScripts.js for the set of possible |
| 407 | // script names |
| 408 | const script = scriptFromCodepoint(this.text.charCodeAt(0)); |
| 409 | if (script) { |
| 410 | this.classes.push(script + "_fallback"); |
| 411 | } |
| 412 | |
| 413 | if (/[îïíì]/.test(this.text)) { // add ī when we add Extended Latin |
| 414 | this.text = iCombinations[this.text]; |
| 415 | } |
| 416 | } |
| 417 | |
| 418 | hasClass(className: string): boolean { |
| 419 | return this.classes.includes(className); |
| 420 | } |
| 421 | |
| 422 | /** |
| 423 | * Creates a text node or span from a symbol node. Note that a span is only |
| 424 | * created if it is needed. |
| 425 | */ |
| 426 | toNode(): Node { |
| 427 | const node = document.createTextNode(this.text); |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…