Example #1
0
        public WindowsFontLoader()
        {
            //iterate
            var installFontsWin32 = new InstallFontsProviderWin32();

            installFontCollection.LoadInstalledFont(installFontsWin32.GetInstalledFontIter());
        }
Example #2
0
        public WindowsFontLoader()
        {
            //iterate
            var installFontsWin32 = new InstallFontsProviderWin32();

            installFontCollection.LoadInstalledFont(installFontsWin32.GetInstalledFontIter());
            SetFontNotFoundHandler(
                (fontCollection, fontName, style) =>
            {
                //TODO: implement font not found mapping here
                //_fontsMapping["monospace"] = "Courier New";
                //_fontsMapping["Helvetica"] = "Arial";
                fontName = fontName.ToUpper();
                switch (fontName)
                {
                case "MONOSPACE":
                    return(fontCollection.GetFont("Courier New", style));

                case "HELVETICA":
                    return(fontCollection.GetFont("Arial", style));

                case "TAHOMA":
                    //default font must found
                    //if not throw err
                    //this prevent infinit loop
                    throw new System.NotSupportedException();

                default:
                    return(fontCollection.GetFont("tahoma", style));
                }
            });
        }
Example #3
0
        //  PixelFarm.Drawing.Fonts.SvgFontStore svgFontStore = new PixelFarm.Drawing.Fonts.SvgFontStore();
        protected override void OnInitGLProgram(object sender, EventArgs args)
        {
            //temp***
            int max = Math.Max(this.Width, this.Height);

            canvas2d = PixelFarm.Drawing.GLES2.GLES2Platform.CreateCanvasGL2d(max, max);
            painter  = new GLCanvasPainter(canvas2d, max, max);

            //----------------------
            var win32InstallFontProvider       = new PixelFarm.Drawing.InstallFontsProviderWin32();
            InstalledFontCollection collection = new InstalledFontCollection();

            collection.LoadInstalledFont(win32InstallFontProvider.GetInstalledFontIter());
            InstalledFont tahomaFont = collection.GetFont("tahoma", InstalledFontStyle.Regular);
            FontFace      tahomaFace = OpenFontLoader.LoadFont(tahomaFont.FontPath, ScriptLangs.Latin);
            ActualFont    actualFont = tahomaFace.GetFontAtPointsSize(72);
            FontGlyph     glyph      = actualFont.GetGlyph('K');

            //var svgFont = svgFontStore.LoadFont("svg-LiberationSansFont", 300);
            ////PathWriter p01 = new PathWriter();
            ////p01.MoveTo(0, 0);
            ////p01.LineTo(50, 100);
            ////p01.LineTo(100, 0);
            //////-
            ////p01.MoveTo(220, 10);
            ////p01.LineTo(50, 75);
            ////p01.LineTo(25, 15);
            ////p01.CloseFigure();
            ////p01.Stop();
            ////m_pathVxs = p01.Vxs;

            //var m_pathVxs = svgFont.GetGlyph('K').originalVxs;// typeFaceForLargeA.GetGlyphForCharacter('a');
            ////m_pathVxs = MergeFontSubFigures(m_pathVxs);

            //Affine shape_mtx = Affine.NewMatix(AffinePlan.Translate(150, 100));
            //m_pathVxs = shape_mtx.TransformToVxs(m_pathVxs);
            //var curveFlattener = new CurveFlattener();
            //var m_pathVxs2 = curveFlattener.MakeVxs(m_pathVxs);

            glyph_vx = painter.CreateRenderVx(tempSnap1 = new PixelFarm.Agg.VertexStoreSnap(glyph.flattenVxs));

            linearGrBrush2 = new LinearGradientBrush(
                new PointF(0, 0), Color.Red,
                new PointF(100, 100), Color.Black);
            //----------------------
        }