public static void Setup() { if (s_isInit) { return; } s_isInit = true; //1. text breaker Typography.TextBreak.CustomBreakerBuilder.Setup( new Typography.TextBreak.IcuSimpleTextFileDictionaryProvider() { DataDir = "../../../../../Typography.TextBreak/icu62/brkitr" }); //1. create font collection s_installedTypefaceCollection = new InstalledTypefaceCollection(); //2. set some essential handler s_installedTypefaceCollection.SetFontNameDuplicatedHandler((f1, f2) => FontNameDuplicatedDecision.Skip); s_installedTypefaceCollection.LoadFontsFromFolder("../../../TestFonts_Err"); s_installedTypefaceCollection.LoadFontsFromFolder("../../../TestFonts"); s_installedTypefaceCollection.UpdateUnicodeRanges(); s_textServices = new OpenFontTextService(s_installedTypefaceCollection); //SKIP Woff,Woff2 //Svg builder }
public static void CreateConvasControlOnExistingControl( Control landingControl, int xpos, int ypos, int w, int h, InnerViewportKind internalViewportKind, out LayoutFarm.UI.UISurfaceViewportControl canvasViewport) { //1. init InitWinform(); IFontLoader fontLoader = s_fontstore; //2. PixelFarm.Drawing.ITextService ifont = null; switch (internalViewportKind) { default: ifont = PixelFarm.Drawing.WinGdi.WinGdiPlusPlatform.GetIFonts(); //ifont = new OpenFontTextService(); break; case InnerViewportKind.GL: ifont = new OpenFontTextService(); break; } PixelFarm.Drawing.WinGdi.WinGdiPlusPlatform.SetFontLoader(fontLoader); // //--------------------------------------------------------------------------- MyRootGraphic myRootGfx = new MyRootGraphic( w, h, ifont ); //--------------------------------------------------------------------------- var innerViewport = canvasViewport = new LayoutFarm.UI.UISurfaceViewportControl(); Rectangle screenClientAreaRect = Conv.ToRect(Screen.PrimaryScreen.WorkingArea); canvasViewport.InitRootGraphics(myRootGfx, myRootGfx.TopWinEventPortal, internalViewportKind); canvasViewport.Bounds = new System.Drawing.Rectangle(xpos, ypos, screenClientAreaRect.Width, screenClientAreaRect.Height); landingControl.Controls.Add(canvasViewport); // Form ownerForm = landingControl.FindForm(); if (ownerForm != null) { ownerForm.FormClosing += (s, e) => { innerViewport.Close(); }; } }
public FontAtlasTextPrinter(AggPainter painter) { _painter = painter; this.PositionTechnique = PositionTechnique.OpenFont; _textServices = new OpenFontTextService(); //2. _bmpFontMx = new BitmapFontManager <MemBitmap>( _textServices, atlas => atlas.MainBitmap ); //3. ChangeFont(painter.CurrentFont); SetupMaskPixelBlender(painter.Width, painter.Height); }
public override void Init() { //steps : detail ... //1. create a text service (or get it from a singleton class) _textServices = new OpenFontTextService(); _txtClient = _textServices.CreateNewServiceClient(); //2. create manager _bmpFontMx = new BitmapFontManager <MemBitmap>( _textServices, atlas => MemBitmap.CreateFromCopy(atlas.MainBitmap) ); //3. _font = new RequestFont("tahoma", 16); _fontAtlas = _bmpFontMx.GetFontAtlas(_textServices.ResolveFont(_font), _font.StartCodePoint, _font.EndCodePoint, out _fontBmp); }
public CpuBlit.AggPainter GetAggPainter() { if (_painter == null) { CpuBlit.AggPainter aggPainter = CpuBlit.AggPainter.Create(_memBmp); aggPainter.CurrentFont = this.CurrentFont; if (_openFontTextServices == null) { _openFontTextServices = new OpenFontTextService(); } //optional if we want to print text on agg surface //aggPainter.TextPrinter = new PixelFarm.Drawing.Fonts.VxsTextPrinter(aggPainter, _openFontTextServices); //1. //aggPainter.TextPrinter = new PixelFarm.Drawing.Fonts.FontAtlasTextPrinter(aggPainter);//2. aggPainter.TextPrinter = new GdiPlusTextPrinter(this); // _painter = aggPainter; _painter.SetOrigin(this.OriginX, this.OriginY); } return(_painter); }
public FormMsdfTest2() { InitializeComponent(); // _textServices = new OpenFontTextService(); }
/// <summary> /// use vertex buffer object /// </summary> public GLBitmapGlyphTextPrinter(GLPainter painter, OpenFontTextService textServices) { //create text printer for use with canvas painter _painter = painter; _pcx = painter.Core; _txtClient = textServices.CreateNewServiceClient(); //_currentTextureKind = TextureKind.Msdf; //_currentTextureKind = TextureKind.StencilGreyScale; _myGLBitmapFontMx = new MySimpleGLBitmapFontManager(textServices); //-------- //load preview of pre-built texture font //temp fix, TODO: review this again string[] maybeTextureInfoFiles = Directory.GetFiles(Directory.GetCurrentDirectory(), "*.tx_info"); if (maybeTextureInfoFiles.Length > 0) { for (int i = 0; i < maybeTextureInfoFiles.Length; ++i) { //try read using (FileStream fs = new FileStream(maybeTextureInfoFiles[i], FileMode.Open)) { try { _myGLBitmapFontMx.LoadBitmapAtlasPreview(fs); } catch (Exception ex) { } } } } //LoadFontAtlas("tahoma_set1.multisize_fontAtlas", "tahoma_set1.multisize_fontAtlas.png"); //test textures... //GlyphPosPixelSnapX = GlyphPosPixelSnapKind.Integer; //GlyphPosPixelSnapY = GlyphPosPixelSnapKind.Integer; //** //ChangeFont(painter.CurrentFont); // //TextDrawingTechnique = GlyphTexturePrinterDrawingTechnique.LcdSubPixelRendering; //default TextDrawingTechnique = GlyphTexturePrinterDrawingTechnique.Stencil; //default UseVBO = true; TextBaseline = PixelFarm.Drawing.TextBaseline.Top; //TextBaseline = TextBaseline.Alphabetic; //TextBaseline = TextBaseline.Bottom; //TODO: temp fix, //... var myAlternativeTypefaceSelector = new AlternativeTypefaceSelector(); { var preferTypefaces = new Typography.FontCollections.PreferredTypefaceList(); preferTypefaces.AddTypefaceName("Source Sans Pro"); preferTypefaces.AddTypefaceName("Sarabun"); myAlternativeTypefaceSelector.SetPreferredTypefaces( new[] { Typography.TextBreak.Unicode13RangeInfoList.C0_Controls_and_Basic_Latin, Typography.TextBreak.Unicode13RangeInfoList.C1_Controls_and_Latin_1_Supplement, Typography.TextBreak.Unicode13RangeInfoList.Latin_Extended_A, Typography.TextBreak.Unicode13RangeInfoList.Latin_Extended_B, }, preferTypefaces); } { var preferTypefaces = new Typography.FontCollections.PreferredTypefaceList(); preferTypefaces.AddTypefaceName("Twitter Color Emoji"); myAlternativeTypefaceSelector.SetPerferredEmoji(preferTypefaces); } AlternativeTypefaceSelector = myAlternativeTypefaceSelector; }
public static Form CreateNewFormCanvas( int w, int h, InnerViewportKind internalViewportKind, out LayoutFarm.UI.UISurfaceViewportControl canvasViewport) { //1. init InitWinform(); IFontLoader fontLoader = s_fontstore; //2. PixelFarm.Drawing.ITextService ifont = null; switch (internalViewportKind) { default: //ifont = PixelFarm.Drawing.WinGdi.WinGdiPlusPlatform.GetIFonts(); ifont = new OpenFontTextService(); break; case InnerViewportKind.GL: ifont = new OpenFontTextService(); break; } PixelFarm.Drawing.WinGdi.WinGdiPlusPlatform.SetFontLoader(fontLoader); // //--------------------------------------------------------------------------- MyRootGraphic myRootGfx = new MyRootGraphic( w, h, ifont ); //--------------------------------------------------------------------------- var innerViewport = canvasViewport = new LayoutFarm.UI.UISurfaceViewportControl(); Rectangle screenClientAreaRect = Conv.ToRect(Screen.PrimaryScreen.WorkingArea); canvasViewport.InitRootGraphics(myRootGfx, myRootGfx.TopWinEventPortal, internalViewportKind); canvasViewport.Bounds = new System.Drawing.Rectangle(10, 10, screenClientAreaRect.Width, screenClientAreaRect.Height); //---------------------- Form form1 = new Form(); //LayoutFarm.Dev.FormNoBorder form1 = new Dev.FormNoBorder(); form1.Controls.Add(canvasViewport); //---------------------- MakeFormCanvas(form1, canvasViewport); form1.SizeChanged += (s, e) => { if (form1.WindowState == FormWindowState.Maximized) { Screen currentScreen = GetScreenFromX(form1.Left); //make full screen ? if (innerViewport != null) { innerViewport.Size = currentScreen.WorkingArea.Size; } } }; //---------------------- return(form1); }
public BitmapFontManager(OpenFontTextService textServices) { _textServices = textServices; }
public BitmapFontManager(OpenFontTextService textServices, LoadNewBmpDelegate <SimpleBitmapAtlas, B> _createNewDel) : base(_createNewDel) { _textServices = textServices; }