Ejemplo n.º 1
0
        public void SetCurrentFont(string fontname, InstalledFontStyle fontStyle, float fontSizeInPts, ScriptLang scLang = null)
        {
            InstalledFont installedFont = _hub._openFontStore.GetFont(fontname, fontStyle);

            if (installedFont == null)
            {
                return;                       //not found request font
            }
            if (scLang != null)
            {
                _glyphLayout.ScriptLang = scLang;
            }

            var key = new TextShapingContextKey(installedFont, _glyphLayout.ScriptLang);

            if (!_registerShapingContexts.TryGetValue(key, out _currentShapingContext))
            {
                //not found
                //the create the new one
                Typeface typeface;
                using (var fs = new System.IO.FileStream(installedFont.FontPath, System.IO.FileMode.Open, System.IO.FileAccess.Read))
                {
                    var reader = new OpenFontReader();
                    typeface = reader.Read(fs);
                }
                var shapingContext = new TextShapingContext(typeface, _glyphLayout.ScriptLang);
                //shaping context setup ...
                _registerShapingContexts.Add(key, shapingContext);
                _currentShapingContext = shapingContext;
            }
            _fontSizeInPts = fontSizeInPts;
        }
Ejemplo n.º 2
0
        public InstalledFont GetFont(string fontName, InstalledFontStyle style)
        {
            //request font from installed font
            InstalledFont found;

            switch (style)
            {
            case (InstalledFontStyle.Bold | InstalledFontStyle.Italic):
            {
                //check if we have bold & italic
                //version of this font ?
                if (!boldItalic_Fonts.TryGetValue(fontName.ToUpper(), out found))
                {
                    //if not found then goto italic
                    goto case InstalledFontStyle.Italic;
                }
                return(found);
            }

            case InstalledFontStyle.Bold:
            {
                if (!bold_Fonts.TryGetValue(fontName.ToUpper(), out found))
                {
                    //goto regular
                    goto default;
                }
                return(found);
            }

            case InstalledFontStyle.Italic:
            {
                //if not found then choose regular
                if (!italic_Fonts.TryGetValue(fontName.ToUpper(), out found))
                {
                    goto default;
                }
                return(found);
            }

            default:
            {
                //we skip gras style ?
                if (!regular_Fonts.TryGetValue(fontName.ToUpper(), out found))
                {
                    if (fontNotFoundHandler != null)
                    {
                        return(fontNotFoundHandler(
                                   this,
                                   fontName,
                                   style));
                    }
                    return(null);
                }
                return(found);
            }
            }
        }
Ejemplo n.º 3
0
        public InstalledFont GetFont(string fontName, InstalledFontStyle wellknownSubFam)
        {
            //not auto resolve
            FontGroup     selectedFontGroup;
            InstalledFont _found;

            switch (wellknownSubFam)
            {
            default: return(null);

            case InstalledFontStyle.Normal: selectedFontGroup = _normal; break;

            case InstalledFontStyle.Bold: selectedFontGroup = _bold; break;

            case InstalledFontStyle.Italic: selectedFontGroup = _italic; break;

            case (InstalledFontStyle.Bold | InstalledFontStyle.Italic): selectedFontGroup = _bold_italic; break;
            }
            if (selectedFontGroup.TryGetValue(fontName.ToUpper(), out _found))
            {
                return(_found);
            }
            //-------------------------------------------

            //retry ....
            if (wellknownSubFam == InstalledFontStyle.Bold)
            {
                //try get from Gras?
                //eg. tahoma
                if (_subFamToFontGroup.TryGetValue("GRAS", out selectedFontGroup))
                {
                    if (selectedFontGroup.TryGetValue(fontName.ToUpper(), out _found))
                    {
                        return(_found);
                    }
                }
            }
            else if (wellknownSubFam == InstalledFontStyle.Italic)
            {
                //TODO: simulate oblique (italic) font???
                selectedFontGroup = _normal;

                if (selectedFontGroup.TryGetValue(fontName.ToUpper(), out _found))
                {
                    return(_found);
                }
            }



            return(_found);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// get typeface from wellknown style
        /// </summary>
        /// <param name="fontname"></param>
        /// <param name="style"></param>
        /// <returns></returns>
        public Typeface GetTypeface(string fontname, InstalledFontStyle style)
        {
            InstalledFont installedFont = FontCollection.GetFont(fontname, style);

            if (installedFont == null && _fontNotFoundHandler != null)
            {
                installedFont = _fontNotFoundHandler(this.FontCollection, fontname, null, style);
            }
            if (installedFont == null)
            {
                return(null);
            }
            return(GetTypefaceOrCreateNew(installedFont));
        }
Ejemplo n.º 5
0
        FontGroup CreateNewFontGroup(InstalledFontStyle installedFontStyle, params string[] names)
        {
            //create font group
            var fontGroup = new FontGroup();

            //single dic may be called by many names
            foreach (string name in names)
            {
                string upperCaseName = name.ToUpper();
                //register name
                //should not duplicate
                _subFamToFontGroup.Add(upperCaseName, fontGroup);
            }
            _allFontGroups.Add(fontGroup);
            return(fontGroup);
        }
Ejemplo n.º 6
0
        public InstalledFont GetFont(string fontName, InstalledFontStyle style)
        {
            InstalledFont found = installFontCollection.GetFont(fontName, style);

            if (found == null)
            {
                //not found
                if (fontNotFoundHandler != null)
                {
                    return(fontNotFoundHandler(installFontCollection, fontName, null, style));
                }
                else
                {
                    return(_defaultFontNotFoundHandler(installFontCollection, fontName, null, style));
                }
            }
            return(found);
        }
Ejemplo n.º 7
0
        public InstalledFont GetFont(string fontName, InstalledFontStyle wellknownSubFam)
        {
            //not auto resolve
            FontGroup selectedFontGroup;

            switch (wellknownSubFam)
            {
            default: return(null);

            case InstalledFontStyle.Normal: selectedFontGroup = _normal; break;

            case InstalledFontStyle.Bold: selectedFontGroup = _bold; break;

            case InstalledFontStyle.Italic: selectedFontGroup = _italic; break;

            case (InstalledFontStyle.Bold | InstalledFontStyle.Italic): selectedFontGroup = _bold_italic; break;
            }
            selectedFontGroup.TryGetValue(fontName.ToUpper(), out InstalledFont _found);
            return(_found);
        }
Ejemplo n.º 8
0
        public static InstalledFontStyle ConvToInstalledFontStyle(this FontStyle style)
        {
            InstalledFontStyle installedStyle = InstalledFontStyle.Normal;//regular

            switch (style)
            {
            default: break;

            case FontStyle.Bold:
                installedStyle = InstalledFontStyle.Bold;
                break;

            case FontStyle.Italic:
                installedStyle = InstalledFontStyle.Italic;
                break;

            case FontStyle.Bold | FontStyle.Italic:
                installedStyle = InstalledFontStyle.Italic;
                break;
            }
            return(installedStyle);
        }
Ejemplo n.º 9
0
 public static InstalledFont GetInstalledFont(string fontName, InstalledFontStyle style)
 {
     return installFonts.GetFont(fontName, style);
 }
Ejemplo n.º 10
0
 public static InstalledFont GetInstalledFont(string fontName, InstalledFontStyle style)
 {
     return(s_fontLoader.GetFont(fontName, style));
 }
Ejemplo n.º 11
0
 public Typeface GetTypeface(string name, InstalledFontStyle installedFontStyle)
 {
     return(typefaceStore.GetTypeface(name, installedFontStyle));
 }
Ejemplo n.º 12
0
 public InstalledFont GetFont(string fontName, InstalledFontStyle style)
 {
     return(installFontCollection.GetFont(fontName, style));
 }
Ejemplo n.º 13
0
 public static InstalledFont GetInstalledFont(string fontName, InstalledFontStyle style)
 {
     return(GLES2PlatformFontMx.GetInstalledFont(fontName, style));
 }
        public InstalledFont GetFont(string fontName, InstalledFontStyle style)
        {
            //request font from installed font
            InstalledFont found;
            switch (style)
            {
                case (InstalledFontStyle.Bold | InstalledFontStyle.Italic):
                    {
                        //check if we have bold & italic 
                        //version of this font ?  
                        if (!boldItalic_Fonts.TryGetValue(fontName.ToUpper(), out found))
                        {
                            //if not found then goto italic 
                            goto case InstalledFontStyle.Italic;
                        }
                        return found;
                    }
                case InstalledFontStyle.Bold:
                    {

                        if (!bold_Fonts.TryGetValue(fontName.ToUpper(), out found))
                        {
                            //goto regular
                            goto default;
                        }
                        return found;
                    }
                case InstalledFontStyle.Italic:
                    {
                        //if not found then choose regular
                        if (!italic_Fonts.TryGetValue(fontName.ToUpper(), out found))
                        {
                            goto default;
                        }
                        return found;
                    }
                default:
                    {
                        //we skip gras style ?
                        if (!regular_Fonts.TryGetValue(fontName.ToUpper(), out found))
                        {

                            if (fontNotFoundHandler != null)
                            {
                                return fontNotFoundHandler(
                                    this,
                                    fontName,
                                    style);
                            }
                            return null;
                        }
                        return found;
                    }
            }
        }