Пример #1
0
 public OpenFontIFonts()
 {
     typefaceStore = new TypefaceStore();
     typefaceStore.FontCollection = InstalledFontCollection.GetSharedFontCollection(null);
     glyphLayout            = new GlyphLayout(); //create glyph layout with default value
     userGlyphPlanList      = new GlyphPlanList();
     userCharToGlyphMapList = new List <UserCharToGlyphIndexMap>();
 }
Пример #2
0
        public OpenFontIFonts(IFontLoader fontloader)
        {
            this._fontloader             = fontloader;
            typefaceStore                = new TypefaceStore();
            typefaceStore.FontCollection = InstalledFontCollection.GetSharedFontCollection(null);
            glyphLayout = new GlyphLayout();

            glyphLayout.ScriptLang        = Typography.OpenFont.ScriptLangs.Thai;//test conplex script
            glyphLayout.PositionTechnique = PositionTechnique.OpenFont;
            //assign fitting engine


            //
            userGlyphPlanList      = new List <GlyphPlan>();
            userCharToGlyphMapList = new List <UserCharToGlyphIndexMap>();
        }
Пример #3
0
        public void LoadFontList()
        {
            _openFontStore = new OpenFontStore();
            _typefaceStore = new TypefaceStore();
            //
            _installedFontCollection      = new InstalledFontCollection();
            _typefaceStore.FontCollection = _installedFontCollection;

            //----------
            //1. create font collection
            //2. set some essential handler
            _installedFontCollection.SetFontNameDuplicatedHandler((f1, f2) => FontNameDuplicatedDecision.Skip);
            foreach (string file in Directory.GetFiles("../../../TestFonts", "*.ttf"))
            {
                //eg. this is our custom font folder
                _installedFontCollection.AddFont(new FontFileStreamProvider(file));
            }
            PositionTech = PositionTechnique.OpenFont;
        }
Пример #4
0
        public Form2()
        {
            InitializeComponent();

            //choose Thai script for 'complex script' testing.
            //you can change this to test other script.
            _currentTextPrinter.ScriptLang = Typography.OpenFont.ScriptLangs.Latin;
            //----------
            button1.Click += (s, e) => UpdateRenderOutput();
            //simple load test fonts from local test dir
            //and send it into test list
            chkFillBackground.Checked         = true;
            chkBorder.CheckedChanged         += (s, e) => UpdateRenderOutput();
            chkFillBackground.CheckedChanged += (s, e) => UpdateRenderOutput();
            //----------
            cmbPositionTech.Items.Add(PositionTechnique.OpenFont);
            cmbPositionTech.Items.Add(PositionTechnique.Kerning);
            cmbPositionTech.Items.Add(PositionTechnique.None);
            cmbPositionTech.SelectedIndex         = 0;
            cmbPositionTech.SelectedIndexChanged += (s, e) => UpdateRenderOutput();
            //----------
            lstHintList.Items.Add(HintTechnique.None);
            lstHintList.Items.Add(HintTechnique.TrueTypeInstruction);
            lstHintList.Items.Add(HintTechnique.TrueTypeInstruction_VerticalOnly);
            lstHintList.Items.Add(HintTechnique.CustomAutoFit);
            lstHintList.SelectedIndex         = 0;
            lstHintList.SelectedIndexChanged += (s, e) => UpdateRenderOutput();

            //----------
            //share text printer to our sample textbox
            //but you can create another text printer that specific to text textbox control
            _textBoxControllerForGdi.TextPrinter = _currentTextPrinter;
            _textBoxControllerForGdi.BindHostGraphics(this.sampleTextBox1.CreateGraphics());

            this.sampleTextBox1.SetController(_textBoxControllerForGdi);

            //----------
            txtInputChar.TextChanged += (s, e) => UpdateRenderOutput();
            //1. create font collection
            installedFontCollection = new InstalledFontCollection();
            //set some essential handler
            installedFontCollection.SetFontNameDuplicatedHandler((f1, f2) => FontNameDuplicatedDecision.Skip);
            foreach (string file in Directory.GetFiles("../../../TestFonts", "*.ttf"))
            {
                //eg. this is our custom font folder
                installedFontCollection.AddFont(new FontFileStreamProvider(file));
            }
            //
            _typefaceStore = new TypefaceStore();
            _typefaceStore.FontCollection = installedFontCollection;

            //----------
            //show result
            InstalledFont selectedFF     = null;
            int           selected_index = 0;
            int           ffcount        = 0;
            bool          found          = false;

            foreach (InstalledFont ff in installedFontCollection.GetInstalledFontIter())
            {
                if (!found && ff.FontName == "Source Sans Pro")
                {
                    selectedFF     = ff;
                    selected_index = ffcount;
                    found          = true;
                }
                lstFontList.Items.Add(ff);
                ffcount++;
            }
            //set default font for current text printer
            _currentTextPrinter.Typeface = _typefaceStore.GetTypeface(selectedFF.FontName, selectedFF.FontSubFamily);
            //----------

            if (selected_index < 0)
            {
                selected_index = 0;
            }
            lstFontList.SelectedIndex         = selected_index;
            lstFontList.SelectedIndexChanged += (s, e) =>
            {
                InstalledFont ff = lstFontList.SelectedItem as InstalledFont;
                if (ff != null)
                {
                    //direct set
                    _currentTextPrinter.Typeface = _typefaceStore.GetTypeface(ff);
                    //sample text box
                    UpdateRenderOutput();
                }
            };
            lstFontSizes.Items.AddRange(
                new object[] {
                8, 9,
                10, 11,
                12,
                14,
                16,
                18, 20, 22, 24, 26, 28, 36, 48, 72, 240, 300, 360
            });
            lstFontSizes.SelectedIndexChanged += (s, e) =>
            {
                //new font size
                _currentTextPrinter.FontSizeInPoints = (int)lstFontSizes.SelectedItem;
                UpdateRenderOutput();
            };
            lstFontSizes.SelectedIndex = 0;
            this.Text = "Gdi+ Sample";
            //------
        }
Пример #5
0
 public TextServiceHub()
 {
     _openFontStore  = new OpenFontStore();
     _typefaceStore  = new TypefaceStore();
     _shapingService = new TextShapingService(this);
 }
Пример #6
0
        public Form1()
        {
            InitializeComponent();

            //choose Thai script for 'complex script' testing.
            //you can change this to test other script.
            _currentTextPrinter.ScriptLang = Typography.OpenFont.ScriptLangs.Thai;
            //----------
            button1.Click += (s, e) => UpdateRenderOutput();
            //simple load test fonts from local test dir
            //and send it into test list
            chkFillBackground.Checked         = true;
            chkBorder.CheckedChanged         += (s, e) => UpdateRenderOutput();
            chkFillBackground.CheckedChanged += (s, e) => UpdateRenderOutput();
            //----------
            cmbPositionTech.Items.Add(PositionTechnique.OpenFont);
            cmbPositionTech.Items.Add(PositionTechnique.Kerning);
            cmbPositionTech.Items.Add(PositionTechnique.None);
            cmbPositionTech.SelectedIndex         = 0;
            cmbPositionTech.SelectedIndexChanged += (s, e) => UpdateRenderOutput();
            //----------
            lstHintList.Items.Add(HintTechnique.None);
            lstHintList.Items.Add(HintTechnique.TrueTypeInstruction);
            lstHintList.Items.Add(HintTechnique.TrueTypeInstruction_VerticalOnly);
            //lstHintList.Items.Add(HintTechnique.CustomAutoFit);
            lstHintList.SelectedIndex         = 0;
            lstHintList.SelectedIndexChanged += (s, e) => UpdateRenderOutput();
            //----------
            txtInputChar.TextChanged += (s, e) => UpdateRenderOutput();
            //

            //1. create font collection
            installedFontCollection = new InstalledFontCollection();
            //2. set some essential handler
            installedFontCollection.SetFontNameDuplicatedHandler((f1, f2) => FontNameDuplicatedDecision.Skip);

            installedFontCollection.LoadFontsFromFolder("../../../TestFonts_Err");
            installedFontCollection.LoadFontsFromFolder("../../../TestFonts");
            //installedFontCollection.LoadSystemFonts();

            //----------
            //show result
            InstalledFont selectedFF     = null;
            int           selected_index = 0;
            int           ffcount        = 0;
            bool          found          = false;

            foreach (InstalledFont ff in installedFontCollection.GetInstalledFontIter())
            {
                if (!found && ff.FontName == "Tahoma")
                {
                    selectedFF     = ff;
                    selected_index = ffcount;
                    found          = true;
                }
                lstFontList.Items.Add(ff);
                ffcount++;
            }
            //set default font for current text printer
            //
            _typefaceStore = new TypefaceStore();
            _typefaceStore.FontCollection = installedFontCollection;
            //set default font for current text printer
            _currentTextPrinter.Typeface = _typefaceStore.GetTypeface(selectedFF);
            //----------


            if (selected_index < 0)
            {
                selected_index = 0;
            }
            lstFontList.SelectedIndex         = selected_index;
            lstFontList.SelectedIndexChanged += (s, e) =>
            {
                InstalledFont ff = lstFontList.SelectedItem as InstalledFont;
                if (ff != null)
                {
                    _currentTextPrinter.Typeface = _typefaceStore.GetTypeface(ff);
                    //sample text box
                    UpdateRenderOutput();
                }
            };
            //----------
            lstFontSizes.Items.AddRange(
                new object[] {
                8, 9,
                10, 11,
                12,
                14,
                16,
                18, 20, 22, 24, 26, 28, 36, 48, 72, 240, 300, 360
            });
            lstFontSizes.SelectedIndexChanged += (s, e) =>
            {
                //new font size
                _currentTextPrinter.FontSizeInPoints = (int)lstFontSizes.SelectedItem;
                UpdateRenderOutput();
            };
            lstFontSizes.SelectedIndex = 0;
            this.Text = "Gdi+ Sample";
            //------
        }
Пример #7
0
        public Form1()
        {
            InitializeComponent();



            _devGdiTextPrinter          = new DevGdiTextPrinter();
            this.sampleTextBox1.Visible = false;
            _openFontStore = new OpenFontStore();

            //default
            //set script lang,
            //test with Thai for 'complex script'
            _current_script = Typography.OpenFont.ScriptLangs.Latin;
            _devGdiTextPrinter.ScriptLang        = _current_script;
            _devGdiTextPrinter.PositionTechnique = PositionTechnique.OpenFont;


            this.Load += new EventHandler(Form1_Load);

            this.txtGridSize.KeyDown += TxtGridSize_KeyDown;
            //----------
            txtInputChar.TextChanged += (s, e) => UpdateRenderOutput();
            //----------
            cmbRenderChoices.Items.Add(RenderChoice.RenderWithTextPrinterAndMiniAgg);
            cmbRenderChoices.Items.Add(RenderChoice.RenderWithMiniAgg_SingleGlyph);
            cmbRenderChoices.Items.Add(RenderChoice.RenderWithGdiPlusPath);
            cmbRenderChoices.Items.Add(RenderChoice.RenderWithMsdfGen);
            cmbRenderChoices.SelectedIndex         = 0;
            cmbRenderChoices.SelectedIndexChanged += (s, e) => UpdateRenderOutput();
            //----------
            cmbPositionTech.Items.Add(PositionTechnique.OpenFont);
            cmbPositionTech.Items.Add(PositionTechnique.Kerning);
            cmbPositionTech.Items.Add(PositionTechnique.None);
            cmbPositionTech.SelectedIndex         = 0;
            cmbPositionTech.SelectedIndexChanged += (s, e) => UpdateRenderOutput();
            //----------
            lstHintList.Items.Add(HintTechnique.None);
            lstHintList.Items.Add(HintTechnique.TrueTypeInstruction);
            lstHintList.Items.Add(HintTechnique.TrueTypeInstruction_VerticalOnly);
            lstHintList.Items.Add(HintTechnique.CustomAutoFit);
            lstHintList.SelectedIndex         = 0;
            lstHintList.SelectedIndexChanged += (s, e) => UpdateRenderOutput();
            //edge offset
            lstEdgeOffset.Items.Add(0f);
            lstEdgeOffset.Items.Add(-10f);
            lstEdgeOffset.Items.Add(-8f);
            lstEdgeOffset.Items.Add(-6f);
            lstEdgeOffset.Items.Add(-4f);
            lstEdgeOffset.Items.Add(4f);
            lstEdgeOffset.Items.Add(6f);
            lstEdgeOffset.Items.Add(8f);
            lstEdgeOffset.Items.Add(10f);
            lstEdgeOffset.SelectedIndex         = 0;
            lstEdgeOffset.SelectedIndexChanged += (s, e) => UpdateRenderOutput();

            //share text printer to our sample textbox
            //but you can create another text printer that specific to text textbox control
            Graphics gx = this.sampleTextBox1.CreateGraphics();

            _controllerForGdi.BindHostGraphics(gx);
            _controllerForGdi.TextPrinter = _devGdiTextPrinter;
            //----------
            _controllerForPixelFarm.BindHostGraphics(gx);
            _controllerForPixelFarm.TextPrinter = _devVxsTextPrinter;

            //----------
            this.sampleTextBox1.SetController(_controllerForPixelFarm);


            button1.Click += (s, e) => UpdateRenderOutput();
            chkShowGrid.CheckedChanged           += (s, e) => UpdateRenderOutput();
            chkShowTess.CheckedChanged           += (s, e) => UpdateRenderOutput();
            chkXGridFitting.CheckedChanged       += (s, e) => UpdateRenderOutput();
            chkYGridFitting.CheckedChanged       += (s, e) => UpdateRenderOutput();
            chkFillBackground.CheckedChanged     += (s, e) => UpdateRenderOutput();
            chkLcdTechnique.CheckedChanged       += (s, e) => UpdateRenderOutput();
            chkGsubEnableLigature.CheckedChanged += (s, e) => UpdateRenderOutput();
            //----------
            chkShowTess.CheckedChanged                     += (s, e) => UpdateRenderOutput();
            chkDrawCentroidBone.CheckedChanged             += (s, e) => UpdateRenderOutput();
            chkDrawGlyphBone.CheckedChanged                += (s, e) => UpdateRenderOutput();
            chkDynamicOutline.CheckedChanged               += (s, e) => UpdateRenderOutput();
            chkSetPrinterLayoutForLcdSubPix.CheckedChanged += (s, e) => UpdateRenderOutput();
            chkDrawTriangles.CheckedChanged                += (s, e) => UpdateRenderOutput();
            chkDrawRegenerateOutline.CheckedChanged        += (s, e) => UpdateRenderOutput();
            chkBorder.CheckedChanged                  += (s, e) => UpdateRenderOutput();
            chkDrawLineHubConn.CheckedChanged         += (s, e) => UpdateRenderOutput();
            chkDrawPerpendicularLine.CheckedChanged   += (s, e) => UpdateRenderOutput();
            chkDrawGlyphPoint.CheckedChanged          += (s, e) => UpdateRenderOutput();
            chkTestGridFit.CheckedChanged             += (s, e) => UpdateRenderOutput();
            chkUseHorizontalFitAlign.CheckedChanged   += (s, e) => UpdateRenderOutput();
            chkWriteFitOutputToConsole.CheckedChanged += (s, e) => UpdateRenderOutput();

            //----------
            //1. create font collection
            installedFontCollection = new InstalledFontCollection();
            //2. set some essential handler
            installedFontCollection.SetFontNameDuplicatedHandler((f1, f2) => FontNameDuplicatedDecision.Skip);
            foreach (string file in Directory.GetFiles(Path.Combine("..", "..", "..", "TestFonts"), "*.ttf"))
            {
                //eg. this is our custom font folder
                installedFontCollection.AddFont(new FontFileStreamProvider(file));
            }
            //3.
            //installedFontCollection.LoadSystemFonts();
            //----------
            //show result
            InstalledFont selectedFF     = null;
            int           selected_index = 0;
            int           ffcount        = 0;
            bool          found          = false;

            string defaultFont = "Tahoma";

            //string defaultFont = "Alef"; //test hebrew
            //string defaultFont = "Century";
            foreach (InstalledFont ff in installedFontCollection.GetInstalledFontIter())
            {
                if (!found && ff.FontName == defaultFont)
                {
                    selectedFF           = ff;
                    selected_index       = ffcount;
                    _selectedInstallFont = ff;
                    found = true;
                }
                lstFontList.Items.Add(ff);
                ffcount++;
            }
            //set default font for current text printer
            //
            _typefaceStore = new TypefaceStore();
            _typefaceStore.FontCollection = installedFontCollection;


            if (selected_index < 0)
            {
                selected_index = 0;
            }
            lstFontList.SelectedIndex         = selected_index;
            lstFontList.SelectedIndexChanged += (s, e) =>
            {
                InstalledFont ff = lstFontList.SelectedItem as InstalledFont;
                if (ff != null)
                {
                    _selectedInstallFont         = ff;
                    selectedTextPrinter.Typeface = _typefaceStore.GetTypeface(ff);
                    //sample text box
                    UpdateRenderOutput();
                }
            };
            //----------

            lstFontSizes.Items.AddRange(
                new object[] {
                8, 9,
                10, 11,
                12,
                14,
                16,
                18, 20, 22, 24, 26, 28, 36, 48, 72,
                240, 280, 300, 360, 400, 420, 460,
                620, 720, 860, 920, 1024
            });
            lstFontSizes.SelectedIndexChanged += (s, e) =>
            {
                //new font size
                _fontSizeInPts = (int)lstFontSizes.SelectedItem;
                UpdateRenderOutput();
            };

            //----------------
            //string inputstr = "ก้า";
            //string inputstr = "น้ำน้ำ";
            //string inputstr = "example";
            //string inputstr = "lllll";
            //string inputstr = "e";
            //string inputstr = "T";
            //string inputstr = "u";
            //string inputstr = "t";
            //string inputstr = "2";
            //string inputstr = "3";
            //string inputstr = "o";
            //string inputstr = "l";
            //string inputstr = "k";
            //string inputstr = "8";
            //string inputstr = "#";
            //string inputstr = "a";
            //string inputstr = "e";
            //string inputstr = "l";
            //string inputstr = "t";
            //string inputstr = "i";
            string inputstr = "ma";

            //string inputstr = "po";
            //string inputstr = "Å";
            //string inputstr = "fi";
            //string inputstr = "ก่นกิ่น";
            //string inputstr = "ญญู";
            //string inputstr = "ป่า"; //for gpos test
            //string inputstr = "快速上手";
            //string inputstr = "啊";

            //----------------
            this.txtInputChar.Text         = inputstr;
            this.chkFillBackground.Checked = true;
            _readyToRender = true;
        }