Exemple #1
0
 public void ParseFamilyList(EntityInfo item, string sFontFamilyList)
 {
     try
     {
         if ((item == null) || (sFontFamilyList.Length <= 0))
         {
             return;
         }
         item.FontTables = null;
         string[] strings = sFontFamilyList.Split(new char[] { ';' }, 10);
         if (strings.Length <= 0)
         {
             return;
         }
         bool hasFf = false;
         for (int i = 0; i < strings.Length; i++)
         {
             try
             {
                 FontTable table = (FontTable)this.fontTablesHash_[strings[i]];
                 if (table != null)
                 {
                     if (this.HasFontFamily(strings[i]) && !hasFf)
                     {
                         Symbol symbol;
                         hasFf           = true;
                         item.FontFamily = table.FontFamily;
                         if (item.CodeAlias.Length > 0)
                         {
                             symbol = table.ByCode(item.CodeAlias);
                             if (symbol != null)
                             {
                                 item.CharPos = symbol.CharPos;
                             }
                         }
                         else
                         {
                             symbol = table.ByCode(item.Code);
                             if (symbol != null)
                             {
                                 item.CharPos = symbol.CharPos;
                             }
                         }
                     }
                 }
             }
             catch
             {
             }
         }
     }
     catch
     {
     }
 }
Exemple #2
0
 public void Add(FontTable fontTable)
 {
     try
     {
         if ((this.fontTables == null) || (this.fontTables.Count == 0))
         {
             this.fontTables = new ArrayList(1);
             this.fontTables.Add(fontTable);
         }
         else
         {
             this.fontTables.Add(fontTable);
         }
     }
     catch
     {
     }
 }
        public void ParseFontTables(string path, string fileName)
        {
            try
            {
                XmlDocument doc = new XmlDocument();

                Stream stream = ResourceLoader.GetStream(path, fileName);
                if (stream == null)
                {
                    return;
                }
                doc.Load(stream);
                stream.Close();
                
                XmlNode node = doc.DocumentElement;
                if (!node.HasChildNodes)
                {
                    return;
                }
                for (int i = 0; i < node.ChildNodes.Count; i++)
                {
                    if (node.ChildNodes[i].Name == "FontTables")
                    {
                        node = node.ChildNodes[i];
                        for (int j = 0; j < node.ChildNodes.Count; j++)
                        {
                            try
                            {
                                XmlNode child = node.ChildNodes[j];
                                if (child != null)
                                {
                                    XmlNode filenode = child.Attributes.GetNamedItem("file");
                                    string name = filenode.Value;
                                    try
                                    {
                                        if (name != this.mapFilename)
                                        {
                                            FontTable fontTable = new FontTable(path, name);
                                            if (fontTable != null)
                                            {
                                                
                                                    if (this.HasFontFamily(fontTable.FontFamily))
                                                    {
                                                        this.fontTables_.Add(fontTable);
                                                        this.fontTablesHash_.Add(fontTable.FontFamily, fontTable);
                                                    }
                                                
                                            }
                                        }
                                    }
                                    catch
                                    {
                                    }
                                }
                            }
                            catch
                            {
                            }
                        }
                    }
                }
            }
            catch
            {
            }
        }
Exemple #4
0
        public void ParseFontTables(string path, string fileName)
        {
            try
            {
                XmlDocument doc = new XmlDocument();

                Stream stream = ResourceLoader.GetStream(path, fileName);
                if (stream == null)
                {
                    return;
                }
                doc.Load(stream);
                stream.Close();

                XmlNode node = doc.DocumentElement;
                if (!node.HasChildNodes)
                {
                    return;
                }
                for (int i = 0; i < node.ChildNodes.Count; i++)
                {
                    if (node.ChildNodes[i].Name == "FontTables")
                    {
                        node = node.ChildNodes[i];
                        for (int j = 0; j < node.ChildNodes.Count; j++)
                        {
                            try
                            {
                                XmlNode child = node.ChildNodes[j];
                                if (child != null)
                                {
                                    XmlNode filenode = child.Attributes.GetNamedItem("file");
                                    string  name     = filenode.Value;
                                    try
                                    {
                                        if (name != this.mapFilename)
                                        {
                                            FontTable fontTable = new FontTable(path, name);
                                            if (fontTable != null)
                                            {
                                                if (this.HasFontFamily(fontTable.FontFamily))
                                                {
                                                    this.fontTables_.Add(fontTable);
                                                    this.fontTablesHash_.Add(fontTable.FontFamily, fontTable);
                                                }
                                            }
                                        }
                                    }
                                    catch
                                    {
                                    }
                                }
                            }
                            catch
                            {
                            }
                        }
                    }
                }
            }
            catch
            {
            }
        }
Exemple #5
0
        public EntityManager(FontCollection FontCollection)
        {
            this.fonts_ = null;

            this.fonts_           = FontCollection;
            this.mapper_          = new Entity2FontMapper(this.fonts_, true);
            this.list_            = new ArrayList(5);
            this.fontFamilyInfos_ = new Hashtable(5, 0.5f);
            for (int i = 0; i < this.mapper_.FontTable_Count; i++)
            {
                FontFamilyInfo fontFamilyInfo = new FontFamilyInfo();
                FontTable      fontTable      = this.mapper_.GetFontTable(i);
                fontFamilyInfo.FontFamily = fontTable.FontFamily;
                fontFamilyInfo.Name       = fontTable.Name;
                fontFamilyInfo.CorrectB   = fontTable.CorrectB;
                fontFamilyInfo.CorrectH   = fontTable.CorrectH;
                fontFamilyInfo.CorrectW   = fontTable.CorrectW;
                fontFamilyInfo.CorrectY   = fontTable.CorrectY;
                fontFamilyInfo.CorrectX   = fontTable.CorrectX;
                this.list_.Add(fontFamilyInfo);
                this.fontFamilyInfos_.Add(fontFamilyInfo.FontFamily, fontFamilyInfo);
            }
            this.mapper_.ClearFontTables();
            this.ids_ = new MapItems();
            this.ops_ = new MapItems();
            try
            {
                for (int i = 0; i < this.mapper_.uniCats_.Count; i++)
                {
                    bool            isActive        = false;
                    UnicodeCategory unicodeCategory = this.mapper_.uniCats_.Indexer(i);
                    isActive = false;
                    switch (unicodeCategory.ID)
                    {
                    case 1:
                    case 3:
                    case 4:
                    case 7:
                    case 9:
                    case 11:
                    case 12:
                    case 14:
                    case 0x16:
                    case 0x1d:
                    case 0x1f:
                    case 0x20:
                        isActive = true;
                        break;
                    }
                    this.ids_.Put(unicodeCategory.ID, unicodeCategory.Name, isActive);

                    isActive = false;
                    switch (unicodeCategory.ID)
                    {
                    case 1:
                    case 11:
                    case 12:
                    case 0x10:
                    case 0x11:
                    case 0x12:
                    case 0x18:
                    case 0x19:
                    case 0x1d:
                    case 0x20:
                        isActive = true;
                        break;
                    }
                    this.ops_.Put(unicodeCategory.ID, unicodeCategory.Name, isActive);
                }
                for (int g = 0; g < this.Count; g++)
                {
                    Glyph glyph = this.Get(g);
                    if ((glyph != null) && glyph.IsVisible)
                    {
                        this.ops_.Ref(glyph.Category.ID, true);
                        this.ids_.Ref(glyph.Category.ID, true);
                        if (glyph.FontFamily.Length > 0)
                        {
                            this.ops_.Ref(glyph.Category.ID, false);
                            this.ids_.Ref(glyph.Category.ID, false);
                        }
                    }
                }
            }
            catch
            {
            }
        }