Ejemplo n.º 1
0
        public FontAtlasTextPrinter(AggPainter painter)
        {
            _painter = painter;

            this.PositionTechnique = PositionTechnique.OpenFont;
            _textServices          = new Typography.Text.OpenFontTextService();
            _txtClient             = _textServices.CreateNewServiceClient();
            //2.
            _bmpFontMx = new BitmapFontManager <MemBitmap>(
                _textServices,
                atlas => atlas.MainBitmap
                );

            //3.
            ChangeFont(painter.CurrentFont);
            SetupMaskPixelBlender(painter.Width, painter.Height);
        }
Ejemplo n.º 2
0
        void InitGraphics()
        {
            //INIT ONCE
            if (_g != null)
            {
                return;
            }
            //

            _destImg = new MemBitmap(800, 600);
            _painter = AggPainter.Create(_destImg);
            _winBmp  = new Bitmap(_destImg.Width, _destImg.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            _g       = this.CreateGraphics();

            _defaultReqFont      = new PixelFarm.Drawing.RequestFont("Source Sans Pro", 10);
            _painter.CurrentFont = _defaultReqFont;


            _textService = new Typography.Text.OpenFontTextService();
            _textService.LoadFontsFromFolder("../../../TestFonts");
            _textService.UpdateUnicodeRanges();

            _devVxsTextPrinter = new PixelFarm.Drawing.VxsTextSpanPrinter(_painter, _textService.CreateNewServiceClient());
            _devVxsTextPrinter.SetSvgBmpBuilderFunc(PaintLab.SvgBuilderHelper.ParseAndRenderSvg);

            _devVxsTextPrinter.ScriptLang        = new ScriptLang(ScriptTagDefs.Latin.Tag);
            _devVxsTextPrinter.PositionTechnique = Typography.TextLayout.PositionTechnique.OpenFont;

            //Alternative Typeface selector..
            _myAlternativeTypefaceSelector = new Typography.Text.AlternativeTypefaceSelector();
            {
                //------------
                //TODO: review this again
                //load from config?
                //------------

                //arabic
                //1. create prefer typeface list for arabic script
                var preferTypefaces = new Typography.FontCollections.PreferredTypefaceList();
                preferTypefaces.AddTypefaceName("Noto Sans Arabic UI");

                //2. set unicode ranges and prefered typeface list.
                _myAlternativeTypefaceSelector.SetPreferredTypefaces(
                    new[] { Typography.TextBreak.Unicode13RangeInfoList.Arabic,
                            Typography.TextBreak.Unicode13RangeInfoList.Arabic_Supplement,
                            Typography.TextBreak.Unicode13RangeInfoList.Arabic_Extended_A },
                    preferTypefaces);
            }
            {
                //latin

                var preferTypefaces = new Typography.FontCollections.PreferredTypefaceList();
                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);
            }

            _devVxsTextPrinter.AlternativeTypefaceSelector = _myAlternativeTypefaceSelector;
        }
Ejemplo n.º 3
0
 public FormMsdfTest2()
 {
     InitializeComponent();
     //
     _textServices = new Typography.Text.OpenFontTextService();
 }
Ejemplo n.º 4
0
 internal TextServiceClient(OpenFontTextService openFontTextService)
 {
     _openFontTextService = openFontTextService;
     _p = new VirtualTextSpanPrinter();
     _p.BuiltInAlternativeTypefaceSelector = (int codepoint, AltTypefaceSelectorBase userSelector, out Typeface typeface) => _openFontTextService.TryGetAlternativeTypefaceFromCodepoint(codepoint, userSelector, out typeface);
 }