예제 #1
0
        public IAssetPlugin AddFont(IBaseFont font, List <FontTag> fontTags)
        {
            if (!CanAddFont(font))
            {
                return(this);
            }

            //convert the filename so the platform would understand this
            ConvertFontFileNameForPlatform(ref font);
            Fonts.Add(font.Name, font);

            //for each tag, add a font
            if (fontTags != null && fontTags.Count > 0)
            {
                if (FontsTagged != null)
                {
                    if (!FontsTagged.ContainsKey(font.Name))
                    {
                        FontsTagged[font.Name] = new List <FontTag>();
                    }
                    FontsTagged[font.Name].AddRange(fontTags);
                }
            }
            return(this);
        }
예제 #2
0
        public IBaseFont GetFontByTagWithTag(string originalFontName, string tag, out FontTag originalTag)
        {
            List <FontTag> fontTag;
            string         fontName = string.Empty;

            originalTag = null;

            if (FontsTagged.TryGetValue(originalFontName, out fontTag))
            {
                originalTag = fontTag.FirstOrDefault(c => c.Tag.Equals(tag));
                if (originalTag != null)
                {
                    fontName = originalTag.OriginalFontName;
                }
            }

            if (string.IsNullOrEmpty(fontName))
            {
                return(null);
            }
            var font = GetFontByName(fontName);

            return(font);
        }