/// <summary>
    /// Read the unicode font data from fontdata.xml.
    /// </summary>
    /// <param name="ft">The fonttype of the output string.</param>
    /// <param name="unicodeDicts">The unicode dicts.</param>
    /// <param name="unicodeTable">The unicode table.</param>
    private static void readUnicodeData(string ft, Dictionary <int, Hashtable> unicodeDicts, Hashtable unicodeTable)
    {
        FontData FontData = new FontData();

        if (FontData.parents[ft] != null)
        {
            readUnicodeData(FontData.parents[ft].ToString(), unicodeDicts, unicodeTable);
        }


        XmlDocument DataSource = new XmlDocument();

        DataSource.Load(@"XML\fontdata.xml");
        XmlNodeList fonts;

        fonts = DataSource.GetElementsByTagName("font");

        if (unicodeTable.Count < 126)
        {
            for (int i = 0; i < 127; i++)
            {
                unicodeTable.Add(i, string.Empty);
            }
        }

        if (fonts.Count > 0)
        {
            foreach (XmlNode font in fonts)
            {
                if (font.Attributes["type"].Value.ToLower() == ft)
                {
                    foreach (XmlNode map in font.SelectSingleNode("maps").SelectSingleNode("global").SelectNodes("map"))
                    {
                        string uni = map.Attributes["unicode"].Value;
                        string leg = FontData.Covert2String(map.Attributes["legacy"].Value);
                        int    l   = uni.Length;
                        if (l == 1)
                        {
                            int i = (Int16)uni[0] - Convert.ToInt16("0x1780", 16);
                            if ((i >= 0 & i < 127))
                            {
                                if (unicodeTable[i].ToString() == string.Empty)
                                {
                                    unicodeTable[i] = leg;
                                }

                                //Modified By Dara:  Fixed Error Character
                                if (i == 74)// ៊
                                {
                                    unicodeTable[i] = "‘";
                                }
                                else if (i == 76) // ៌
                                {
                                    unicodeTable[i] = "_";
                                }
                                //End Fixed
                            }
                            else
                            {
                                addToGeneric(uni, leg, unicodeDicts);
                            }
                        }
                        else
                        {
                            addToGeneric(uni, leg, unicodeDicts);
                        }
                    }

                    if ((font.SelectSingleNode("maps").ChildNodes.Count > 0))
                    {
                        for (int i = 0; i <= font.SelectSingleNode("maps").ChildNodes.Count - 1; i++)
                        {
                            string ab = font.SelectSingleNode("maps").ChildNodes[i].Name.ToLower();
                            if ((ab == "fromunicode"))
                            {
                                foreach (
                                    XmlNode map in
                                    font.SelectSingleNode("maps").SelectSingleNode("fromunicode").SelectNodes("map")
                                    )
                                {
                                    string uni = map.Attributes["unicode"].Value;
                                    string leg = FontData.Covert2String(map.Attributes["legacy"].Value);
                                    int    l   = uni.Length;
                                    if ((l > 0 & l < 256))
                                    {
                                        addToGeneric(uni, leg, unicodeDicts);
                                    }
                                }
                                break;
                            }
                        }
                    }
                }
            }
        }
    }
Exemple #2
0
    /// <summary>
    /// Read the legacy font data from fontdata.xml.
    /// </summary>
    /// <param name="ft">The font type of legacy font.</param>
    /// <param name="unicodeDicts">The unicode dicts.</param>
    /// <param name="legacyTable">The legacy table.</param>
    private static void readLegacyData(string ft, Hashtable unicodeDicts, ArrayList legacyTable)
    {
        FontData FontData = new FontData();

        if (FontData.parents[ft] != null)
        {
            readLegacyData(FontData.parents[ft].ToString(), unicodeDicts, legacyTable);
        }


        XmlDocument DataSource = new XmlDocument();

        DataSource.Load(@"XML\fontdata.xml");
        XmlNodeList fonts;

        fonts = DataSource.GetElementsByTagName("font");


        for (int i = 0; i < 256; i++)
        {
            legacyTable.Add(((char)i).ToString());
        }

        if (fonts.Count > 0)
        {
            foreach (XmlNode font in fonts)
            {
                if (font.Attributes["type"].Value.ToLower() == ft)
                {
                    foreach (XmlNode map in font.SelectSingleNode("maps").SelectSingleNode("global").SelectNodes("map"))
                    {
                        string uni = map.Attributes["unicode"].Value;
                        string leg = FontData.Covert2String(map.Attributes["legacy"].Value);
                        int    l   = leg.Length;
                        if (l == 1)
                        {
                            int i = (Int16)leg[0];
                            if ((i >= 0 & i < 256))
                            {
                                if (legacyTable[i].ToString() == ((char)i).ToString())
                                {
                                    legacyTable[i] = uni;
                                }
                            }
                            else
                            {
                                addToHashtable(leg, uni, unicodeDicts);
                            }
                        }
                        else
                        {
                            addToHashtable(leg, uni, unicodeDicts);
                        }
                    }

                    if ((font.SelectSingleNode("maps").ChildNodes.Count > 0))
                    {
                        for (int i = 0; i <= font.SelectSingleNode("maps").ChildNodes.Count - 1; i++)
                        {
                            string ab = font.SelectSingleNode("maps").ChildNodes[i].Name.ToLower();
                            if ((ab == "tounicode"))
                            {
                                foreach (
                                    XmlNode map in
                                    font.SelectSingleNode("maps").SelectSingleNode("tounicode").SelectNodes("map")
                                    )
                                {
                                    string uni = map.Attributes["unicode"].Value;
                                    string leg = FontData.Covert2String(map.Attributes["legacy"].Value);
                                    int    l   = leg.Length;
                                    if ((l > 0 & l < 10))
                                    {
                                        addToHashtable(leg, uni, unicodeDicts);
                                    }
                                }
                                break;
                            }
                        }
                    }
                }
            }
        }
    }