/** * create a set of attributes. * this calculates all of the glyph metrics from the graphic device. */ public StretchyGlyphAttributes(IFormattingContext context, IFontHandle fontHandle, ref StretchyGlyphIndices indices) { orientation = indices.Orientation; if(indices.SimpleIndices != null) { simpleGlyphs = new GlyphAttributes[indices.SimpleIndices.Length]; for(int i = 0; i < simpleGlyphs.Length; i++) { simpleGlyphs[i] = new GlyphAttributes(context, fontHandle, indices.SimpleIndices[i], GlyphAttributes.FudgeNone); } } else { simpleGlyphs = null; } if(indices.CompoundIndices != null) { compoundGlyphs = new GlyphAttributes[indices.CompoundIndices.Length]; for(int i = 0; i < compoundGlyphs.Length; i++) { // TODO deal with horizontal glyphs compoundGlyphs[i] = new GlyphAttributes(context, fontHandle, indices.CompoundIndices[i], i == StretchyGlyphIndices.Filler ? GlyphAttributes.FudgeHeight : GlyphAttributes.FudgeNone); } } else { compoundGlyphs = null; } }
/** * create a set of attributes. * this calculates all of the glyph metrics from the graphic device. */ public StretchyGlyphAttributes(IFormattingContext context, IFontHandle fontHandle, ref StretchyGlyphIndices indices) { orientation = indices.Orientation; if (indices.SimpleIndices != null) { simpleGlyphs = new GlyphAttributes[indices.SimpleIndices.Length]; for (int i = 0; i < simpleGlyphs.Length; i++) { simpleGlyphs[i] = new GlyphAttributes(context, fontHandle, indices.SimpleIndices[i], GlyphAttributes.FudgeNone); } } else { simpleGlyphs = null; } if (indices.CompoundIndices != null) { compoundGlyphs = new GlyphAttributes[indices.CompoundIndices.Length]; for (int i = 0; i < compoundGlyphs.Length; i++) { // TODO deal with horizontal glyphs compoundGlyphs[i] = new GlyphAttributes(context, fontHandle, indices.CompoundIndices[i], i == StretchyGlyphIndices.Filler ? GlyphAttributes.FudgeHeight : GlyphAttributes.FudgeNone); } } else { compoundGlyphs = null; } }
/** * load this set from an xml element. */ public StretchyGlyphIndices(XmlElement node) { XmlElement index = null; // make sure we have the right type of xml node if (node.Name != "stretchy") { throw new Exception( String.Format("the node name of \"{0}\" is not valid for a StretchyGlyphIndices", node.Name)); } // get the orientation Orientation = node.GetAttribute("orientation") == "vertical" ? StretchyOrientation.Vertical : StretchyOrientation.Horizontal; // get the char value, required value Char = Utility.ParseChar(node.GetAttribute("char")); // simple indices are not required if ((index = node.SelectSingleNode("simple") as XmlElement) != null) { SimpleIndices = Utility.ParseShortArray(index.GetAttribute("index")); } else { SimpleIndices = null; } // compound indices are not required if ((index = node.SelectSingleNode("compound") as XmlElement) != null) { CompoundIndices = Utility.ParseShortArray(index.GetAttribute("index")); if (CompoundIndices.Length != 4) { throw new Exception(String.Format( "Error, a compound index array was found with a length of {0}, it must have a length of 4", CompoundIndices.Length)); } } else { CompoundIndices = null; } }
/** * load this set from an xml element. */ public StretchyGlyphIndices(XmlElement node) { XmlElement index = null; // make sure we have the right type of xml node if(node.Name != "stretchy") throw new Exception( String.Format("the node name of \"{0}\" is not valid for a StretchyGlyphIndices", node.Name)); // get the orientation Orientation = node.GetAttribute("orientation") == "vertical" ? StretchyOrientation.Vertical : StretchyOrientation.Horizontal; // get the char value, required value Char = Utility.ParseChar(node.GetAttribute("char")); // simple indices are not required if((index = node.SelectSingleNode("simple") as XmlElement) != null) { SimpleIndices = Utility.ParseShortArray(index.GetAttribute("index")); } else { SimpleIndices = null; } // compound indices are not required if((index = node.SelectSingleNode("compound") as XmlElement) != null) { CompoundIndices = Utility.ParseShortArray(index.GetAttribute("index")); if(CompoundIndices.Length != 4) { throw new Exception(String.Format( "Error, a compound index array was found with a length of {0}, it must have a length of 4", CompoundIndices.Length)); } } else { CompoundIndices = null; } }