Exemple #1
0
        /// <summary>
        ///     Adds all the system fonts to the FontInfo object.
        /// </summary>
        /// <remarks>
        ///     Adds metrics for basic fonts and useful family-style-weight
        ///     triplets for lookup.
        /// </remarks>
        /// <param name="fontType">Determines what type of font to instantiate.</param>
        private void AddSystemFonts(FontType fontType)
        {
            GdiFontEnumerator enumerator = new GdiFontEnumerator(new GdiDeviceContent());

            foreach (string familyName in enumerator.FamilyNames)
            {
                if (IsBase14FontName(familyName))
                {
                    FonetDriver.ActiveDriver.FireFonetWarning(
                        "Will ignore TrueType font '" + familyName + "' because a base 14 font with the same name already exists.");
                }
                else
                {
                    FontStyles styles = enumerator.GetStyles(familyName);

                    string name = GetNextAvailableName();
                    fontInfo.AddMetrics(name, new ProxyFont(new FontProperties(familyName, false, false), fontType));
                    fontInfo.AddFontProperties(name, familyName, "normal", "normal");

                    name = GetNextAvailableName();
                    fontInfo.AddMetrics(name, new ProxyFont(new FontProperties(familyName, true, false), fontType));
                    fontInfo.AddFontProperties(name, familyName, "normal", "bold");

                    name = GetNextAvailableName();
                    fontInfo.AddMetrics(name, new ProxyFont(new FontProperties(familyName, false, true), fontType));
                    fontInfo.AddFontProperties(name, familyName, "italic", "normal");

                    name = GetNextAvailableName();
                    fontInfo.AddMetrics(name, new ProxyFont(new FontProperties(familyName, true, true), fontType));
                    fontInfo.AddFontProperties(name, familyName, "italic", "bold");
                }
            }

            // Cursive - Monotype Corsiva
            fontInfo.AddMetrics("F15", new ProxyFont(new FontProperties("Monotype Corsiva", false, false), fontType));
            fontInfo.AddFontProperties("F15", "cursive", "normal", "normal");

            // Fantasy - Zapf Dingbats
            fontInfo.AddMetrics("F16", Base14Font.ZapfDingbats);
            fontInfo.AddFontProperties("F16", "fantasy", "normal", "normal");
        }