| |
| |
| |
| |
| |
| |
| |
|
|
| |
| |
| |
| |
| class Style implements StyleInterface { |
| id: number; |
| size: number; |
| cramped: boolean; |
|
|
| constructor(id: number, size: number, cramped: boolean) { |
| this.id = id; |
| this.size = size; |
| this.cramped = cramped; |
| } |
|
|
| |
| |
| |
| sup(): Style { |
| return styles[sup[this.id]]; |
| } |
|
|
| |
| |
| |
| sub(): Style { |
| return styles[sub[this.id]]; |
| } |
|
|
| |
| |
| |
| |
| fracNum(): Style { |
| return styles[fracNum[this.id]]; |
| } |
|
|
| |
| |
| |
| |
| fracDen(): Style { |
| return styles[fracDen[this.id]]; |
| } |
|
|
| |
| |
| |
| |
| cramp(): Style { |
| return styles[cramp[this.id]]; |
| } |
|
|
| |
| |
| |
| text(): Style { |
| return styles[text[this.id]]; |
| } |
|
|
| |
| |
| |
| isTight(): boolean { |
| return this.size >= 2; |
| } |
| } |
|
|
| |
| |
| export interface StyleInterface { |
| id: number; |
| size: number; |
| cramped: boolean; |
|
|
| sup(): StyleInterface; |
| sub(): StyleInterface; |
| fracNum(): StyleInterface; |
| fracDen(): StyleInterface; |
| cramp(): StyleInterface; |
| text(): StyleInterface; |
| isTight(): boolean; |
| } |
|
|
| |
| const D = 0; |
| const Dc = 1; |
| const T = 2; |
| const Tc = 3; |
| const S = 4; |
| const Sc = 5; |
| const SS = 6; |
| const SSc = 7; |
|
|
| |
| const styles = [ |
| new Style(D, 0, false), |
| new Style(Dc, 0, true), |
| new Style(T, 1, false), |
| new Style(Tc, 1, true), |
| new Style(S, 2, false), |
| new Style(Sc, 2, true), |
| new Style(SS, 3, false), |
| new Style(SSc, 3, true), |
| ]; |
|
|
| |
| const sup = [S, Sc, S, Sc, SS, SSc, SS, SSc]; |
| const sub = [Sc, Sc, Sc, Sc, SSc, SSc, SSc, SSc]; |
| const fracNum = [T, Tc, S, Sc, SS, SSc, SS, SSc]; |
| const fracDen = [Tc, Tc, Sc, Sc, SSc, SSc, SSc, SSc]; |
| const cramp = [Dc, Dc, Tc, Tc, Sc, Sc, SSc, SSc]; |
| const text = [D, Dc, T, Tc, T, Tc, T, Tc]; |
|
|
| |
| export default { |
| DISPLAY: (styles[D] as Style), |
| TEXT: (styles[T] as Style), |
| SCRIPT: (styles[S] as Style), |
| SCRIPTSCRIPT: (styles[SS] as Style), |
| }; |
|
|