private Atom ConvertCharacter(TexFormula formula, string value, ref int position, char character) { position++; var font = TexUtility.RenderFont == -2 ? TexUtility.RawRenderFont : TexUtility.RenderFont; if (font == -1 && IsSymbol(character)) { // Character is symbol (and math). var charIdx = TEXPreference.main.charMapData[character, -1]; if (charIdx >= 0) { return(SymbolAtom.Get(TEXPreference.main.GetChar(charIdx), character)); } return(UnicodeAtom.Get(TEXConfiguration.main.Typeface_Unicode, character)); } else { // Character is alpha-numeric. if (font >= 0 && !TEXPreference.main.IsCharAvailable(font, character)) { return(UnicodeAtom.Get(font, character)); } return(CharAtom.Get(character)); } }
private Atom ConvertCharacter(string value, ref int position, char character) { position++; var font = TexContext.Font.value; if (font == -1) { // Character is symbol (and math). var charIdx = TEXPreference.main.charmaps[character, -1]; if (charIdx >= 0) { return(SymbolAtom.Get(TEXPreference.main.GetChar(charIdx), character)); } else { return(CharAtom.Get(character, -1)); } } else { return(CharAtom.Get(character, font)); } }
private void ProcessEscapeSequence(TexFormula formula, string value, ref int position) { position++; var command = LookForAWord(value, ref position); // Check if there's no command if (command.Length == 0) { if (position < value.Length) { var nextChar = value[position]; if (IsParserReserved(nextChar)) { formula.Add(ConvertCharacter(value, ref position, nextChar)); } } return; } //Check if the command registered in Commands if (isCommandRegistered(command)) { formula.Add(AttachScripts(formula, value, ref position, ProcessCommand(formula, value, ref position, command))); return; } //Check if the command registered in FontID var fontID = TEXPreference.main.GetFontIndexByID(command); if (fontID != -1) { SkipWhiteSpace(value, ref position); formula.Add(ParseFontStyle(value, ref position, fontID, ParseFontStyle(ReadInsideBracket(value, ref position)))); return; } SymbolAtom symbolAtom = SymbolAtom.GetAtom(command); //Check if the command registered in Symbol database if (symbolAtom != null) { // Symbol was found. if (symbolAtom.RightType == CharType.Accent && formula.RootAtom != null) { //Accent is Found Atom baseAtom = formula.RootAtom; if (baseAtom is RowAtom) { var row = (RowAtom)baseAtom; baseAtom = MatrixAtom.Last(row.Elements); row.Elements.RemoveAt(row.Elements.Count - 1); } else { formula.RootAtom = null; } formula.Add(AttachScripts(formula, value, ref position, AccentedAtom.Get(baseAtom, symbolAtom))); } else { formula.Add(AttachScripts(formula, value, ref position, symbolAtom)); } return; } //No lucks, now ... { // Command aren't defined, use it as command text style RowAtom row = RowAtom.Get(); for (int i = 0; i < command.Length; i++) { var charAtom = CharAtom.Get(command[i], TEXConfiguration.main.Typeface_Commands); row.Add(charAtom); } formula.Add(AttachScripts(formula, value, ref position, row)); } }