public void Dispose_MultipleTimes_Nop()
        {
            var fontCollection = new InstalledFontCollection();

            fontCollection.Dispose();
            fontCollection.Dispose();
        }
Example #2
0
        public page02_EnterText(MainForm mf)
        {
            InitializeComponent();

            MAIN = mf;

            pageImageIN   = null;
            pageImageNOW  = null;
            pageVectorIN  = new List <GroupPoint>();
            pageVectorNOW = new List <GroupPoint>();

            NextPage = 6;

            // Заполним списком шрифтов установленных в систему
            InstalledFontCollection installedFontCollection = new InstalledFontCollection();

            foreach (FontFamily fnt in installedFontCollection.Families)
            {
                comboBoxFont.Items.Add(fnt.Name);
            }

            installedFontCollection.Dispose();

            if (comboBoxFont.Items.Count > 0)
            {
                comboBoxFont.Text = comboBoxFont.Items[0].ToString();
            }

            rbUseSystemFont.Checked = true;
            rbFontToVector.Checked  = true;
        }
Example #3
0
 static public void UnInitializeFontCollection()
 {
     if (IsLoaded)
     {
         ifc.Dispose();
     }
 }
Example #4
0
        public Preferences()
        {
            foreach (SettingsProperty setting in Settings.Default.Properties)
            {
                _tempSettings[setting.Name] = Settings.Default[setting.Name];
            }

            InitializeComponent();
            InstalledFontCollection f = new InstalledFontCollection();

            foreach (FontFamily family in f.Families)
            {
                fontBox.Items.Add(family.Name);
                outFontBox.Items.Add(family.Name);
            }

            f.Dispose();
            foreach (int num in _fontSizes)
            {
                fontSizeBox.Items.Add(num);
                outFontSizeBox.Items.Add(num);
            }

            UpdateOptions();
        }
Example #5
0
 void Dispose(bool Disposing)
 {
     if (!this.disposed)
     {
         ifc.Dispose(); disposed = true;
     }
 }
        public void Families_GetWhenDisposed_ReturnsNonEmpty()
        {
            var fontCollection = new InstalledFontCollection();

            fontCollection.Dispose();

            Assert.NotEmpty(fontCollection.Families);
        }
Example #7
0
 public FontCollection()
 {
     IFC = new InstalledFontCollection(); foreach (FontFamily ff in IFC.Families)
     {
         Add(ff);
     }
     IFC.Dispose();
 }
        public void Dispose_Family()
        {
            InstalledFontCollection ifc = new InstalledFontCollection();
            int count = ifc.Families.Length;

            ifc.Dispose();
            Assert.AreEqual(count, ifc.Families.Length, "Families");
            // there is *no* exception here
        }
Example #9
0
        public bool IsFontInstalled()
        {
            InstalledFontCollection fontCollection = new InstalledFontCollection();


            // Add three font files to the private collection.
            for (int i = 0; i < fontCollection.Families.Length; i++)
            {
                if (fontCollection.Families[i].Name.Equals(this.NameForIphone))
                {
                    fontCollection.Dispose();
                    return(true);
                }
            }

            fontCollection.Dispose();
            return(false);
        }
Example #10
0
        /* 参考
         * https://www.cnblogs.com/arxive/p/7795232.html
         * https://docs.microsoft.com/en-us/windows/win32/gdi/font-installation-and-deletion
         */

        /// <summary>
        ///
        /// 经测试只能获取当前进程启动时的字体库 后续变更后获取不到变化后的字体库
        /// </summary>
        /// <param name="fontName"></param>
        /// <returns></returns>
        public static bool ExistFont(string fontName)
        {
            InstalledFontCollection collection = new InstalledFontCollection();
            var fonts = collection.Families;
            var ret   = false;

            for (int i = 0; i < fonts.Length; i++)
            {
                if (string.Equals(fontName, fonts[i].Name, StringComparison.InvariantCultureIgnoreCase))
                {
                    ret = true;
                    break;
                }
            }
            collection.Dispose();
            return(ret);
        }
Example #11
0
        private bool m_fNewRendering = false;           // the writing system rendering has changed.
        #endregion

        #region Constructor/destructor
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="T:DefaultFontsControl"/> class.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public DefaultFontsControl()
        {
            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();

            // Fill in the font selection combo boxes.
            InstalledFontCollection installedFontCollection = new InstalledFontCollection();

            FontFamily[] fontFamilies = installedFontCollection.Families;
            int          count        = fontFamilies.Length;

            for (int i = 0; i < count; ++i)
            {
                // The .NET framework is unforgiving of using a font that doesn't support the
                // "regular"  style.  So we won't allow the user to even see them...
                if (fontFamilies[i].IsStyleAvailable(FontStyle.Regular))
                {
                    string familyName = fontFamilies[i].Name;
                    cbDefaultNormalFont.Items.Add(familyName);
                    cbDefaultHeadingFont.Items.Add(familyName);
                    cbDefaultPubFont.Items.Add(familyName);
                    fontFamilies[i].Dispose();
                }
            }
            installedFontCollection.Dispose();

            // Add our event handlers.
            cbDefaultNormalFont.SelectedIndexChanged +=
                new EventHandler(cbDefaultNormalFont_SelectedIndexChanged);
            m_defaultFontFeaturesBtn.FontFeatureSelected +=
                new EventHandler(m_defaultFontFeatures_FontFeatureSelected);
            cbDefaultHeadingFont.SelectedIndexChanged +=
                new EventHandler(cbDefaultHeadingFont_SelectedIndexChanged);
            m_headingFontFeaturesBtn.FontFeatureSelected +=
                new EventHandler(m_headingFontFeatures_FontFeatureSelected);
            cbDefaultPubFont.SelectedIndexChanged +=
                new EventHandler(cbDefaultPubFont_SelectedIndexChanged);
            m_pubFontFeaturesBtn.FontFeatureSelected +=
                new EventHandler(m_bodyFontFeaturesBtn_FontFeatureSelected);
        }
        /// <summary>
        /// Create the list of fonts available on this system, populate the combo box on the settings toolstrip
        /// </summary>
        private void LoadFontList()
        {
            cboFontName.BeginUpdate();
            cboFontName.Items.Clear();

            FontData fData = null;

            InstalledFontCollection ifc = new InstalledFontCollection();

            for (int i = 0; i < ifc.Families.Length; i++)
            {
                fData = new FontData(ifc.Families[i]);
                _listboxUtil.Add(cboFontName, new CoreObjects.ListBoxControls.Item(fData.Name, fData.Name, fData));
            }

            cboFontName.EndUpdate();

            if (ifc != null)
            {
                ifc.Dispose();
                ifc = null;
            }
        }
Example #13
0
 /// <summary>
 /// Disposes off the object
 /// </summary>
 public void Dispose()
 {
     _privateFonts.Dispose();
     _ifc.Dispose();
 }