|
23 | 23 | */ |
24 | 24 |
|
25 | 25 |
|
26 | | -import {CharacterMap, CommandMap} from '../SymbolMap.js'; |
27 | | -import {Symbol} from '../Symbol.js'; |
| 26 | +import {CommandMap} from '../SymbolMap.js'; |
28 | 27 | import {TexConstant} from '../TexConstants.js'; |
29 | 28 | import {TextMacrosMethods} from '../textmacros/TextMacrosMethods.js'; |
30 | 29 | import TexParser from '../TexParser.js'; |
@@ -159,56 +158,34 @@ new CommandMap('textcomp-macros', { |
159 | 158 | 'textdied': ['Insert', '\u2020'], |
160 | 159 | 'textdivorced': ['Insert', '\u26AE'], |
161 | 160 | // 'textleaf' |
162 | | - 'textmarried': ['Insert', '\u26AD'] |
163 | | -}, { |
164 | | - Insert: function(parser: TexParser, name: string, c: string) { |
165 | | - if (parser instanceof TextParser) { |
166 | | - TextMacrosMethods.Insert(parser, name, c); |
167 | | - } else { |
168 | | - parser.Push(ParseUtil.internalText(parser, c, {})); |
169 | | - } |
170 | | - } |
171 | | -}); |
172 | | - |
173 | | - |
174 | | -/** |
175 | | - * Handle old style characters. |
176 | | - * @param {TextParser} parser The current tex parser. |
177 | | - * @param {Symbol} mchar The parsed symbol. |
178 | | - */ |
179 | | -function oldstyleText(parser: TexParser, mchar: Symbol) { |
180 | | - if (!(parser instanceof TextParser)) { |
181 | | - parser.Push(ParseUtil.internalText( |
182 | | - parser, mchar.char, {mathvariant: TexConstant.Variant.OLDSTYLE})); |
183 | | - return; |
184 | | - } |
185 | | - if (parser.stack.env.mathvariant = TexConstant.Variant.OLDSTYLE) { |
186 | | - parser.text += mchar.char; |
187 | | - return; |
188 | | - } |
189 | | - TextMacrosMethods.SetFont(parser, mchar.symbol, TexConstant.Variant.OLDSTYLE); |
190 | | - parser.text = mchar.char; |
191 | | -} |
192 | | - |
193 | | -/** |
194 | | - * Identifiers from the Textcomp package. |
195 | | - */ |
196 | | -new CharacterMap('textcomp-oldstyle', oldstyleText, { |
| 161 | + 'textmarried': ['Insert', '\u26AD'], |
197 | 162 |
|
198 | 163 | // This is not the correct glyph |
199 | | - 'textcentoldstyle': '\u00A2', |
| 164 | + 'textcentoldstyle': ['Insert', '\u00A2', TexConstant.Variant.OLDSTYLE], |
200 | 165 | // This is not the correct glyph |
201 | | - 'textdollaroldstyle': '\u0024', |
| 166 | + 'textdollaroldstyle': ['Insert', '\u0024', TexConstant.Variant.OLDSTYLE], |
202 | 167 |
|
203 | 168 | // Table 16: textcomp Old-Style Numerals |
204 | | - 'textzerooldstyle': '0', |
205 | | - 'textoneoldstyle': '1', |
206 | | - 'texttwooldstyle': '2', |
207 | | - 'textthreeoldstyle': '3', |
208 | | - 'textfouroldstyle': '4', |
209 | | - 'textfiveoldstyle': '5', |
210 | | - 'textsixoldstyle': '6', |
211 | | - 'textsevenoldstyle': '7', |
212 | | - 'texteightoldstyle': '8', |
213 | | - 'textnineoldstyle': '9' |
| 169 | + 'textzerooldstyle': ['Insert', '0', TexConstant.Variant.OLDSTYLE], |
| 170 | + 'textoneoldstyle': ['Insert', '1', TexConstant.Variant.OLDSTYLE], |
| 171 | + 'texttwooldstyle': ['Insert', '2', TexConstant.Variant.OLDSTYLE], |
| 172 | + 'textthreeoldstyle': ['Insert', '3', TexConstant.Variant.OLDSTYLE], |
| 173 | + 'textfouroldstyle': ['Insert', '4', TexConstant.Variant.OLDSTYLE], |
| 174 | + 'textfiveoldstyle': ['Insert', '5', TexConstant.Variant.OLDSTYLE], |
| 175 | + 'textsixoldstyle': ['Insert', '6', TexConstant.Variant.OLDSTYLE], |
| 176 | + 'textsevenoldstyle': ['Insert', '7', TexConstant.Variant.OLDSTYLE], |
| 177 | + 'texteightoldstyle': ['Insert', '8', TexConstant.Variant.OLDSTYLE], |
| 178 | + 'textnineoldstyle': ['Insert', '9', TexConstant.Variant.OLDSTYLE] |
| 179 | +}, { |
| 180 | + Insert: function(parser: TexParser, name: string, c: string, font: string) { |
| 181 | + if (parser instanceof TextParser) { |
| 182 | + if (!font) { |
| 183 | + TextMacrosMethods.Insert(parser, name, c); |
| 184 | + return; |
| 185 | + } |
| 186 | + parser.saveText(); |
| 187 | + } |
| 188 | + parser.Push(ParseUtil.internalText( |
| 189 | + parser, c, font ? {mathvariant: font} : {})); |
| 190 | + } |
214 | 191 | }); |
0 commit comments