Beispiel #1
0
        public static WinGdiFont GetWinGdiFont(RequestFont f)
        {
            if (f == null)
            {
                throw new NotSupportedException();
            }
            if (f == latestFont)
            {
                return(latestWinFont);
            }
            WinGdiFont actualFontInside = WinGdiFont.GetCacheFontAsWinGdiFont(f);

            if (actualFontInside != null)
            {
                return(actualFontInside);
            }
            //-----
            //need to create a new one
            //get register font or create the new one
            FontKey    key = f.FontKey;
            WinGdiFont found;

            if (!registerFonts.TryGetValue(key, out found))
            {
                //create the new one and register
                //create fontface
                FontFaceKey    fontfaceKey = new FontFaceKey(key);
                WinGdiFontFace fontface;
                if (!winGdiFonFaces.TryGetValue(fontfaceKey, out fontface))
                {
                    //create new
                    fontface = new WinGdiFontFace(f.Name);
                    winGdiFonFaces.Add(fontfaceKey, fontface);
                }

                var winGdiFont = new WinGdiFont(fontface, f.SizeInPoints, FontStyle.Regular);
                found = winGdiFont;
                registerFonts.Add(key, found);//cache here
            }
            latestFont = f;
            RequestFontImpl reqFont = (RequestFontImpl)f;

            if (reqFont._platformFont == null)
            {
                reqFont._platformFont = found;
            }

            //found.AssignToRequestFont(f);
            return(latestWinFont = found);
        }
Beispiel #2
0
        //public override FontGlyph GetGlyphByIndex(uint glyphIndex)
        //{
        //    throw new NotImplementedException();
        //}
        //public override FontGlyph GetGlyph(char c)
        //{
        //    //convert c to glyph index
        //    //temp fix
        //    throw new NotImplementedException();
        //}
        //public override FontFace FontFace
        //{
        //    get
        //    {
        //        throw new NotImplementedException();
        //    }
        //}
        //public override float AscentInPixels
        //{
        //    get
        //    {
        //        return ascendInPixels;
        //    }
        //}
        //public override float LineGapInPixels
        //{
        //    get { return linegapInPixels; }
        //}
        //public override float RecommendedLineSpacingInPixels
        //{
        //    get { return AscentInPixels - DescentInPixels + LineGapInPixels; }
        //}
        //public override float DescentInPixels
        //{
        //    get
        //    {
        //        return descentInPixels;
        //    }
        //}
        //public void AssignToRequestFont(RequestFont r)
        //{
        //    SetCacheActualFont(r, this);
        //}
        public static WinGdiFont GetCacheFontAsWinGdiFont(RequestFont r)
        {
            RequestFontImpl requestFontImpl = (RequestFontImpl)r;

            return(requestFontImpl._platformFont);
        }