Beispiel #1
0
        /// <inheritdoc/>
        public override FontFace GetFontFace()
        {
            if (!File.Exists(Source))
            {
                // Font does not exist
                throw new FontNotFoundException(Source);
            }

            var factory = new Factory();

            using (var fontFile = new FontFile(factory, Source))
            {
                FontSimulations fontSimulations;
                switch (Style)
                {
                    case Xenko.Graphics.Font.FontStyle.Regular:
                        fontSimulations = FontSimulations.None;
                        break;
                    case Xenko.Graphics.Font.FontStyle.Bold:
                        fontSimulations = FontSimulations.Bold;
                        break;
                    case Xenko.Graphics.Font.FontStyle.Italic:
                        fontSimulations = FontSimulations.Oblique;
                        break;
                    default:
                        throw new ArgumentOutOfRangeException();
                }

                RawBool isSupported;
                FontFileType fontType;
                FontFaceType faceType;
                int numberFaces;

                fontFile.Analyze(out isSupported, out fontType, out faceType, out numberFaces);

                return new FontFace(factory, faceType, new[] { fontFile }, 0, fontSimulations);
            }
        }
Beispiel #2
0
        private FontFace GetFontFaceFromSource(Factory factory, SpriteFontAsset options)
        {
            if (!File.Exists(options.Source))
            {
                // Font does not exist
                throw new FontNotFoundException(options.Source);
            }

            using (var fontFile = new FontFile(factory, options.Source))
            {
                FontSimulations fontSimulations;
                switch (options.Style)
                {
                    case Paradox.Graphics.Font.FontStyle.Regular:
                        fontSimulations = FontSimulations.None;
                        break;
                    case Paradox.Graphics.Font.FontStyle.Bold:
                        fontSimulations = FontSimulations.Bold;
                        break;
                    case Paradox.Graphics.Font.FontStyle.Italic:
                        fontSimulations = FontSimulations.Oblique;
                        break;
                    default:
                        throw new ArgumentOutOfRangeException();
                }

                RawBool isSupported;
                FontFileType fontType;
                FontFaceType faceType;
                int numberFaces;

                fontFile.Analyze(out isSupported, out fontType, out faceType, out numberFaces);

                return new FontFace(factory, faceType, new[] { fontFile }, 0, fontSimulations);
            }
        }