/// <summary> /// Reads GlyphEntry from reader. /// </summary> /// <param name="reader">Reader from which to read GlyphEntry.</param> /// <param name="glyphBits">Bits count used for reading glyph index.</param> /// <param name="advanceBits">Bits count used for reading advance value.</param> /// <returns></returns> public static GlyphEntry ReadGlyphEntry(this ISwfStreamReader reader, uint glyphBits, uint advanceBits) { var entry = new GlyphEntry { GlyphIndex = reader.ReadUnsignedBits(glyphBits), GlyphAdvance = reader.ReadSignedBits(advanceBits) }; return entry; }
/// <summary> /// Reads GlyphEntry from reader. /// </summary> /// <param name="reader">Reader from which to read GlyphEntry.</param> /// <param name="glyphBits">Bits count used for reading glyph index.</param> /// <param name="advanceBits">Bits count used for reading advance value.</param> /// <returns></returns> public static GlyphEntry ReadGlyphEntry(this ISwfStreamReader reader, uint glyphBits, uint advanceBits) { var entry = new GlyphEntry { GlyphIndex = reader.ReadUnsignedBits(glyphBits), GlyphAdvance = reader.ReadSignedBits(advanceBits) }; return(entry); }
public static XElement FormatGlyphEntry(GlyphEntry entry) { return new XElement(XName.Get("TextEntry"), new XAttribute(XName.Get("glyph"), entry.GlyphIndex), new XAttribute(XName.Get("advance"), entry.GlyphAdvance)); }
public static GlyphEntry ParseGlyphEntry(XElement element) { var result = new GlyphEntry(); foreach (var attribute in element.Attributes()) { switch (attribute.Name.LocalName) { case "glyph": result.GlyphIndex = uint.Parse(attribute.Value); break; case "advance": result.GlyphAdvance = int.Parse(attribute.Value); break; default: throw new NotSupportedException(); } } foreach (var elem in element.Elements()) { switch (elem.Name.LocalName) { default: throw new NotSupportedException(); } } return result; }
/// <summary> /// Writes GlyphEntry to writer. /// </summary> /// <param name="writer">Writer to which to write GlyphEntry.</param> /// <param name="glyph">Glyph to be written.</param> /// <param name="glyphBits">Bits count used for writing glyph index.</param> /// <param name="advanceBits">Bits count used for writing advance value.</param> public static void WriteGlyphEntry(this ISwfStreamWriter writer, GlyphEntry glyph, uint glyphBits, uint advanceBits) { writer.WriteUnsignedBits(glyph.GlyphIndex, glyphBits); writer.WriteSignedBits(glyph.GlyphAdvance, advanceBits); }