コード例 #1
0
        bool LoadFont()
        {
            // Load font
            string filename = font.ToString() + ".FNT";

            if (!fntFile.Load(Path.Combine(DaggerfallUI.Instance.FontsFolder, filename), FileUsage.UseMemory, true))
            {
                throw new Exception("DaggerfallFont failed to load font " + filename);
            }

            // Start new glyph dictionary
            // Daggerfall fonts start at ASCII 33 '!' so we must create our own space glyph for ASCII 32
            ClearGlyphs();
            AddGlyph(SpaceCode, CreateSpaceGlyph());

            // Add remaining glyphs
            int ascii = asciiStart;

            for (int i = 0; i < FntFile.MaxGlyphCount; i++)
            {
                AddGlyph(ascii++, CreateGlyph(i));
            }

            GlyphHeight = fntFile.FixedHeight;

            // Create font atlas
            ImageProcessing.CreateFontAtlas(fntFile, Color.clear, Color.white, out atlasTexture, out atlasRects);
            atlasTexture.filterMode = FilterMode;

            // Load an SDF font variant if one is available
            LoadSDFFontAsset(string.Format("Fonts/{0}-SDF", font.ToString()));

            return(true);
        }
コード例 #2
0
 public void SaveSettings()
 {
     try
     {
         RegistryKey viewerkey = Registry.CurrentUser;
         viewerkey = viewerkey.OpenSubKey(@"SOFTWARE\MCEBuddyViewer", true);
         viewerkey.SetValue("Language", Language.CurrentLanguage);
         viewerkey.SetValue("Font", FontName.ToString());
     }
     catch
     {
     }
 }
コード例 #3
0
ファイル: Stamping.cs プロジェクト: zsy960/PDFCreator
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("Color=" + Color.ToString());
            sb.AppendLine("Enabled=" + Enabled.ToString());
            sb.AppendLine("FontAsOutline=" + FontAsOutline.ToString());
            sb.AppendLine("FontName=" + FontName.ToString());
            sb.AppendLine("FontOutlineWidth=" + FontOutlineWidth.ToString());
            sb.AppendLine("FontSize=" + FontSize.ToString());
            sb.AppendLine("PostScriptFontName=" + PostScriptFontName.ToString());
            sb.AppendLine("StampText=" + StampText.ToString());

            return(sb.ToString());
        }
コード例 #4
0
ファイル: FontSet.cs プロジェクト: yangl5619/OfdSharp
        /// <summary>
        /// 通过文件名获取字体
        /// </summary>
        /// <param name="fontName"></param>
        /// <returns></returns>
        public static Font Get(FontName fontName)
        {
            String fileName = fontName.ToString();

            FileInfo path = null;

            if (fileName != null)
            {
                // 从jar包中加载字体
                path = LoadAndCacheFont(fileName);
            }

            switch (fontName)
            {
            case FontName.NotoSerif:
                return(new Font {
                    Name = "Noto Serif CJK SC", FontFile = path, PrintableAsciiWidthMap = NOTO_PRINTABLE_ASCII_WIDTH_MAP
                });

            case FontName.NotoSerifBold:
                return(new Font {
                    Name = "Noto Serif CJK SC Bold", FamilyName = "Bold", FontFile = path, PrintableAsciiWidthMap = NOTO_PRINTABLE_ASCII_WIDTH_MAP
                });

            case FontName.NotoSans:
                return(new Font {
                    Name = "Noto Sans Mono CJK SC Regular", FontFile = path, PrintableAsciiWidthMap = NOTO_PRINTABLE_ASCII_WIDTH_MAP
                });

            case FontName.NotoSansBold:
                return(new Font {
                    Name = "Noto Sans Mono CJK SC Bold", FamilyName = "Bold", FontFile = path, PrintableAsciiWidthMap = NOTO_PRINTABLE_ASCII_WIDTH_MAP
                });

            case FontName.SimSun:
                return(new Font {
                    Name = "宋体", FamilyName = "宋体"
                });

            case FontName.SimHei:
                return(new Font {
                    Name = "黑体", FamilyName = "黑体"
                });

            case FontName.KaiTi:
                return(new Font {
                    Name = "楷体", FamilyName = "楷体"
                });

            case FontName.MSYahei:
                return(new Font {
                    Name = "微软雅黑", FamilyName = "微软雅黑"
                });

            case FontName.FangSong:
                return(new Font {
                    Name = "仿宋", FamilyName = "仿宋"
                });

            case FontName.TimesNewRoman:
                return(new Font {
                    Name = "Times New Roman", FamilyName = "Times New Roman", PrintableAsciiWidthMap = TIMES_NEW_ROMAN_PRINTABLE_ASCII_MAP
                });
            }
            throw new NotSupportedException("不支持字体:" + fontName);
        }