Пример #1
0
		/**
		 * 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;
			}
		}
Пример #2
0
    public FontInstance(IFormattingContext context, string fontName, float pointSize, StretchyGlyphIndices[] glyphIndices)
		{
			cachedAreas = null;
			PointSize = pointSize;
			FontHandle = context.CreateFont(pointSize, false, 500, fontName);
			stretchyAttributes = new StretchyGlyphAttributes[glyphIndices.Length];
			for(int i = 0; i < stretchyAttributes.Length; i++)
			{
				stretchyAttributes[i] = new StretchyGlyphAttributes(
					context, FontHandle, ref glyphIndices[i]);
			}
		}
Пример #3
0
        /**
         * load one of the root xml nodes.
         */
        private void LoadXmlNode(XmlNode node)
        {
            // need child nodes in any case
            XmlNodeList nodes = node.ChildNodes;
            int         i     = 0;

            if (node.Name == "stretchy-glyphs")
            {
                stretchyGlyphIndices = new StretchyGlyphIndices[nodes.Count];
                foreach (XmlElement n in nodes)
                {
                    stretchyGlyphIndices[i++] = new StretchyGlyphIndices(n);
                }
            }
            else if (node.Name == "simple-glyphs")
            {
                simpleGlyphs = new SimpleGlyphAttributes[nodes.Count];
                foreach (XmlElement n in nodes)
                {
                    simpleGlyphs[i++] = new SimpleGlyphAttributes(
                        Char.Parse(n.GetAttribute("char")), UInt16.Parse(n.GetAttribute("index")));
                }
            }
            else if (node.Name == "simple-glyph-ranges")
            {
                simpleGlyphRanges = new SimpleGlyphRange[nodes.Count];
                foreach (XmlElement n in nodes)
                {
                    simpleGlyphRanges[i++] = new SimpleGlyphRange(n);
                }
            }
            else
            {
                throw new Exception("Error, \"" + node.Name + "\" is not a valid item in a font config file");
            }
        }
Пример #4
0
        /**
         * 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;
            }
        }