public void SetPreferredTypefaces(UnicodeRangeInfo[] unicodeRangeInfos, PreferredTypefaceList typefaceNames)
 {
     for (int i = 0; i < unicodeRangeInfos.Length; ++i)
     {
         _dics[unicodeRangeInfos[i].Name] = typefaceNames;
     }
 }
Ejemplo n.º 2
0
        public Form1()
        {
            InitializeComponent();

            //choose Thai script for 'complex script' testing.
            //you can change this to test other script.


            _txtServiceClient              = OurOpenFontSystem.CreateTextServiceClient();
            _currentTextPrinter            = new DevGdiTextSpanPrinter(_txtServiceClient);
            _currentTextPrinter.ScriptLang = new ScriptLang(ScriptTagDefs.Latin.Tag);


            //----------
            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();
            //
            //----------
            //show result
            InstalledTypeface selectedFF = null;
            int  selected_index          = 0;
            int  ffcount = 0;
            bool found   = false;

            foreach (InstalledTypeface ff in OurOpenFontSystem.GetInstalledTypefaceIter())
            {
                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
            //

            //set default font for current text printer
            _currentTextPrinter.Typeface = OurOpenFontSystem.ResolveTypeface(selectedFF);


            //Alternative Typeface Selector
            {
                AlternativeTypefaceSelector alternativeTypefaceSelector = new AlternativeTypefaceSelector();
                PreferredTypefaceList       preferredTypefaces          = new PreferredTypefaceList();
                preferredTypefaces.AddTypefaceName("Segoe UI Emoji");
                alternativeTypefaceSelector.SetPerferredEmoji(preferredTypefaces);

                //set alternative typeface selector to printer
                _currentTextPrinter.AlternativeTypefaceSelector = alternativeTypefaceSelector;
            }

            //----------
#if DEBUG
            //test get font from typeface store
            //InstalledTypeface instFont = OurOpenFontSystem.GetFontCollection().GetFontByPostScriptName("SourceSansPro-Regular");
#endif

            if (selected_index < 0)
            {
                selected_index = 0;
            }
            lstFontList.SelectedIndex         = selected_index;
            lstFontList.SelectedIndexChanged += (s, e) =>
            {
                if (lstFontList.SelectedItem is InstalledTypeface ff)
                {
                    _currentTextPrinter.Typeface = OurOpenFontSystem.ResolveTypeface(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";
            //------
        }
 public void SetPerferredEmoji(PreferredTypefaceList typefaceNames)
 {
     _emojiPreferList = typefaceNames;
 }
 public void SetPreferredTypefaces(UnicodeRangeInfo unicodeRangeInfo, PreferredTypefaceList typefaceNames)
 {
     _dics[unicodeRangeInfo.Name] = typefaceNames;
 }