Exemplo n.º 1
0
        public static Glyphs Parse(Page page, XElement xmlNode, VisualElement parent)
        {
            var glyphs = new Glyphs(page, xmlNode, parent);

            glyphs.Init();
            return(glyphs);
        }
Exemplo n.º 2
0
 internal TextSpan(Glyphs glyphs, Matrix transformMatrix, bool isSideways, int bidiLevel, int markupDir)
 {
     Glyphs          = glyphs;
     TransformMatrix = transformMatrix;
     IsSideways      = isSideways;
     BidiLevel       = bidiLevel;
     MarkupDir       = markupDir;
 }
Exemplo n.º 3
0
        protected override void ParseMetadata()
        {
            Opacity = double.Parse(XmlNode.Attribute("Opacity")?.Value ?? "1.0");
            var transformString = XmlNode.Attribute("RenderTransform")?.Value;

            //var clipString = XmlNode.Attribute("Clip")?.Value;
            //var opacityMaskString = XmlNode.Attribute("OpacityMask")?.Value;
            foreach (var xElement in XmlNode.Elements())
            {
                switch (xElement.Name.LocalName)
                {
                case "Canvas.Resources":
                case "Canvas.Clip":
                case "Canvas.OpacityMask":
                    break;

                case "Canvas.RenderTransform":
                    transformString = xElement.Elements().FirstOrDefault()?.Attribute("Matrix")?.Value;
                    break;
                }
            }

            RenderTransform = transformString == null ? Matrix.Identity : Matrix.Parse(transformString);
            foreach (var xElement in XmlNode.Elements())
            {
                switch (xElement.Name.LocalName)
                {
                case "Path":
                    break;

                case "Glyphs":
                    var glyphs = Glyphs.Parse(Page, xElement, this);
                    var span   = glyphs.GetContent();
                    if (span != null)
                    {
                        _spans.Add(span);
                    }
                    break;

                case "Canvas":
                    var canvas = Canvas.Parse(Page, xElement, this);
                    _spans.AddRange(canvas.GetContent());
                    break;
                }
            }
        }
Exemplo n.º 4
0
        protected void ParseMetadata()
        {
            foreach (var element in XmlNode.Elements())
            {
                switch (element.Name.LocalName)
                {
                case "Canvas":
                    var canvas = Canvas.Parse(this, element, null);
                    _spans.AddRange(canvas.GetContent());
                    break;

                case "Glyphs":
                    var glyphs = Glyphs.Parse(this, element, null);
                    var span   = glyphs.GetContent();
                    if (span != null)
                    {
                        _spans.Add(span);
                    }
                    break;
                }
            }
        }
Exemplo n.º 5
0
        public Rect BoundGlyph(Matrix transformMatrix, Glyphs glyphs)
        {
            var  font = Span.Glyphs.Font;
            Rect rect;

            if (font.BBoxTable != null && GlyphIndex < font.GlyphCount)
            {
                font.BBoxTable[GlyphIndex] = font.BoundGlyph(GlyphIndex, glyphs.Style);
                rect = font.BBoxTable[GlyphIndex];
                if (rect.IsEmpty)
                {
                    rect = font.BBox;
                }
            }
            else
            {
                rect = font.BBox;
            }

            rect.Transform(transformMatrix);
            GlyphBox = new Rect(rect.Location, new Size(font.BBoxTable != null && GlyphIndex < font.GlyphCount ? rect.Width : rect.Width * AbsoluteWidth / 100, rect.Height));

            return(GlyphBox);
        }