public Form1() { InitializeComponent(); _devVxsTextPrinter = new DevVxsTextPrinter(); _devGdiTextPrinter = new DevGdiTextPrinter(); this.sampleTextBox1.Visible = false; selectedTextPrinter = _devVxsTextPrinter; //default //set script lang, //test with Thai for 'complex script' _devGdiTextPrinter.ScriptLang = _devVxsTextPrinter.ScriptLang = Typography.OpenFont.ScriptLangs.Thai; _devGdiTextPrinter.PositionTechnique = _devVxsTextPrinter.PositionTechnique = PositionTechnique.OpenFont; this.Load += new EventHandler(Form1_Load); this.txtGridSize.KeyDown += TxtGridSize_KeyDown; //---------- txtInputChar.TextChanged += (s, e) => UpdateRenderOutput(); //---------- cmbRenderChoices.Items.Add(RenderChoice.RenderWithMiniAgg_SingleGlyph); cmbRenderChoices.Items.Add(RenderChoice.RenderWithGdiPlusPath); cmbRenderChoices.Items.Add(RenderChoice.RenderWithTextPrinterAndMiniAgg); cmbRenderChoices.Items.Add(RenderChoice.RenderWithMsdfGen); cmbRenderChoices.SelectedIndex = 2; 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(); //---------- //---------- //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.TextPrinter = _devGdiTextPrinter; _controllerForGdi.BindHostGraphics(gx); //---------- _controllerForPixelFarm.TextPrinter = _devVxsTextPrinter; _controllerForPixelFarm.BindHostGraphics(gx); //---------- 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(); chkDrawBone.CheckedChanged += (s, e) => UpdateRenderOutput(); chkGsubEnableLigature.CheckedChanged += (s, e) => UpdateRenderOutput(); chkShowTess.CheckedChanged += (s, e) => 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 _fontSizeInPts = (int)lstFontSizes.SelectedItem; UpdateRenderOutput(); }; //---------- //simple load test fonts from local test dir //and send it into test list int selectedFileIndex = -1; //string selectedFontFileName = "pala.ttf"; string selectedFontFileName = "tahoma.ttf"; //string selectedFontFileName="cambriaz.ttf"; //string selectedFontFileName="CompositeMS2.ttf"; int fileIndexCount = 0; foreach (string file in Directory.GetFiles("..\\..\\..\\TestFonts", "*.ttf")) { var tmpLocalFile = new TempLocalFontFile(file); lstFontList.Items.Add(tmpLocalFile); if (selectedFileIndex < 0 && tmpLocalFile.OnlyFileName == selectedFontFileName) { selectedFileIndex = fileIndexCount; _selectedFontFilename = file; } fileIndexCount++; } if (selectedFileIndex < 0) { selectedFileIndex = 0; } lstFontList.SelectedIndex = selectedFileIndex; lstFontList.SelectedIndexChanged += (s, e) => { _selectedFontFilename = ((TempLocalFontFile)lstFontList.SelectedItem).actualFileName; UpdateRenderOutput(); }; //---------------- //string inputstr = "ก้า"; string inputstr = "น้ำน้ำ"; //string inputstr = "fi"; //string inputstr = "ก่นกิ่น"; //string inputstr = "ญญู"; //string inputstr = "ป่า"; //for gpos test //string inputstr = "快速上手"; //---------------- this.txtInputChar.Text = inputstr; this.chkFillBackground.Checked = true; }
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; }