public GLBitmapGlyphTextPrinter(GLPainter painter, LayoutFarm.OpenFontTextService textServices) { //create text printer for use with canvas painter this.painter = painter; this._glsx = painter.Canvas; this._textServices = textServices; //_currentTextureKind = TextureKind.Msdf; //_currentTextureKind = TextureKind.StencilGreyScale; _myGLBitmapFontMx = new MySimpleGLBitmapFontManager(TextureKind.StencilLcdEffect, textServices); //change this to fit yours. _myGLBitmapFontMx.SetCurrentScriptLangs( new ScriptLang[] { ScriptLangs.Latin, ScriptLangs.Thai //eg. Thai, for test with complex script, you can change to your own }); //test textures... //GlyphPosPixelSnapX = GlyphPosPixelSnapKind.Integer; //GlyphPosPixelSnapY = GlyphPosPixelSnapKind.Integer; ChangeFont(painter.CurrentFont); }
/// <summary> /// use vertex buffer object /// </summary> public GLBitmapGlyphTextPrinter(GLPainter painter, LayoutFarm.OpenFontTextService textServices) { //create text printer for use with canvas painter _painter = painter; _pcx = painter.PainterContext; _textServices = textServices; //_currentTextureKind = TextureKind.Msdf; //_currentTextureKind = TextureKind.StencilGreyScale; _myGLBitmapFontMx = new MySimpleGLBitmapFontManager(textServices); LoadFontAtlas("tahoma_set1.multisize_fontAtlas", "tahoma_set1.multisize_fontAtlas.png"); //test textures... //GlyphPosPixelSnapX = GlyphPosPixelSnapKind.Integer; //GlyphPosPixelSnapY = GlyphPosPixelSnapKind.Integer; //** ChangeFont(painter.CurrentFont); // DrawingTechnique = GlyphTexturePrinterDrawingTechnique.LcdSubPixelRendering; //default UseVBO = true; }
public void Dispose() { _myGLBitmapFontMx.Clear(); _myGLBitmapFontMx = null; if (_glBmp != null) { _glBmp.Dispose(); _glBmp = null; } }
/// <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; }