public Font ParseFont(Stream stream, Font font = null) { var path = Serialization.GetCurrentSerializationPath(); this.textureSize = GetTextureSize(path); using (var reader = new StreamReader(stream)) { string text = reader.ReadToEnd(); lexer = new HotLexer("", text, true); } var type = lexer.ParseQuotedString(); if (type != "Hot::Font") { throw new Exception("Unknown type of object '{0}'", type); } if (font == null) { font = new Font(); } AddFontTextures(font, path); lexer.ParseToken('{'); while (lexer.PeekChar() != '}') { ParseFontProperty(font, lexer.ParseWord()); } lexer.ParseToken('}'); return(font); }
protected Marker ParseMarker() { string type = lexer.ParseQuotedString(); if (type != "Hot::Marker") { throw new Exception("Invalid marker type '{0}'", type); } var marker = new Marker(); lexer.ParseToken('{'); while (lexer.PeekChar() != '}') { ParseMarkerProperty(marker, lexer.ParseWord()); } lexer.ParseToken('}'); return(marker); }
FontChar ParseFontChar() { string type = lexer.ParseQuotedString(); if (type != "Hot::FontChar") { throw new Exception("Unknown type of object '{0}'", type); } var fontChar = new FontChar(); lexer.ParseToken('{'); while (lexer.PeekChar() != '}') { ParseFontCharProperty(ref fontChar, lexer.ParseWord()); } lexer.ParseToken('}'); return(fontChar); }
public Font ParseFont(string srcPath, string dstPath) { this.textureSize = GetTextureSize(srcPath); this.lexer = CreateLexer(srcPath); var type = lexer.ParseQuotedString(); if (type != "Hot::Font") { throw new Exception("Unknown type of object '{0}'", type); } var font = new Font(); AddFontTextures(font, srcPath, dstPath); lexer.ParseToken('{'); while (lexer.PeekChar() != '}') { ParseFontProperty(font, lexer.ParseWord()); } lexer.ParseToken('}'); return(font); }