Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Xml Parser Exception

$
0
0

Hi: Can anyone suggest a solution? Everything else works and this code should work but I am having another parser problem with the following XML code:

public static XElement DrawingTextXml(string userText, int userThickness, SolidColorBrush userColor)
        {
            //string for color
            String strColor = userColor.ToString();
            //font URI
            String fontURI = @"C:\WINDOWS\Fonts\TIMES.TTF"; 
            //convert user text to unicode numbers
            String convertedIndices = ConvertTextToIndices(fontURI, userText);
            //glyph indices
            //String indices = "43 72 79 79 82 3 58 82 85 79 71";
            //base line origin
            String baseLine = "0,12.29";
            // font rendering EM size
            String emSize = "13.333333333333334";
            //device font name
            String dfName = "{x:Null}";
            //advanced widths
            //String advancedWidths = "9.62666666666667 7.41333333333333 2.96 2.96 7.41333333333333 3.70666666666667 12.5866666666667 7.41333333333333 4.44 2.96 7.41333333333333";
            String advancedWidths = "9.62666666666667 9.5";
            //BidiLevel
            String bidiLevel = "0";

             XElement myXml = new XElement(rootNS + "GlyphRunDrawing",
                                                        new XAttribute("ForegroundBrush", strColor),
                                                        new XElement(rootNS + "GlyphRunDrawing.GlyphRun",
                                                            new XAttribute("CaretStops", "{x:Null}" ),
                                                            new XAttribute("ClusterMap", "{x:Null}" ),
                                                            new XAttribute("IsSideways", "False"),
                                                            new XAttribute("GlyphOffsets", "{x:Null}" ),
                                                            new XAttribute("GlyphIndices", convertedIndices),
                                                            new XAttribute("BaselineOrigin", baseLine),
                                                            new XAttribute("FontRenderingEmSize", emSize),
                                                            new XAttribute("DeviceFontName", dfName),
                                                            new XAttribute("AdvanceWidths", advancedWidths),
                                                            new XAttribute("BidiLevel", bidiLevel),
                                                            new XElement(rootNS + "GlyphRun.GlyphTypeface",
                                                            new XElement(rootNS + "GlyphTypeface",
                                                            new XAttribute("FontUri", fontURI)))));
           /*
             * XElement myXml = new XElement(rootNS + "GlyphRunDrawing",
                                                        new XAttribute("ForegroundBrush", strColor),
                                                        new XElement(rootNS + "GlyphRunDrawing.GlyphRun",
                                                            new XElement(rootNS + "GlyphRun",
                                                                new XAttribute("CaretStops", "{x:Null}"),
                                                                new XAttribute("ClusterMap", "{x:Null}"),
                                                                new XAttribute("IsSideways", "False"),
                                                                new XAttribute("GlyphOffsets", "{x:Null}"),
                                                                new XAttribute("GlyphIndices", convertedIndices),
                                                                new XAttribute("BaselineOrigin", baseLine),
                                                                new XAttribute("FontRenderingEmSize", emSize),
                                                                new XAttribute("DeviceFontName", dfName),
                                                                new XAttribute("AdvanceWidths", advancedWidths),
                                                                new XAttribute("BidiLevel", bidiLevel),
                                                                new XElement(rootNS + "GlyphRun.GlyphTypeface",
                                                                    new XElement(rootNS + "GlyphTypeface",
                                                                        new XAttribute("FontUri", fontURI))))));
             */


            return myXml;


        }

The result when viewed from the debugger is:

The error message is:


Mike Gallinger C.Tech. Cutting Edge Computing Software Developer


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>