Describes how a font was loaded so that it can be reloaded
Exemple #1
0
        private void LoadQFontFromQFontFile(FontLoadDescription loadDescription)
        {
            var loaderConfig     = loadDescription.LoaderConfig;
            var filePath         = loadDescription.Path;
            var downSampleFactor = loadDescription.DownSampleFactor;


            if (loaderConfig == null)
            {
                loaderConfig = new QFontLoaderConfiguration();
            }

            TransformViewport?transToVp = null;
            float             fontScale = 1f;

            if (loaderConfig.TransformToCurrentOrthogProjection)
            {
                transToVp = OrthogonalTransform(out fontScale);
            }

            fontData = Builder.LoadQFontDataFromFile(filePath, downSampleFactor * fontScale, loaderConfig);
            fontData.scaleDueToTransformToViewport = fontScale;

            if (loaderConfig.ShadowConfig != null)
            {
                Options.DropShadowActive = true;
            }
            if (transToVp != null)
            {
                Options.TransformToViewport = transToVp;
            }
        }
Exemple #2
0
        private void LoadQFontFromFontFile(FontLoadDescription loadDescription)
        {
            var config   = loadDescription.BuilderConfig;
            var fileName = loadDescription.Path;
            var size     = loadDescription.Size;
            var style    = loadDescription.Style;

            if (config == null)
            {
                config = new QFontBuilderConfiguration();
            }

            TransformViewport?transToVp = null;
            float             fontScale = 1f;

            if (config.TransformToCurrentOrthogProjection)
            {
                transToVp = OrthogonalTransform(out fontScale);
            }

            //dont move this into a separate method - it needs to stay in scope!
            PrivateFontCollection pfc = new PrivateFontCollection();

            pfc.AddFontFile(fileName);
            var fontFamily = pfc.Families[0];

            if (!fontFamily.IsStyleAvailable(style))
            {
                throw new ArgumentException("Font file: " + fileName + " does not support style: " + style);
            }


            var font = new Font(fontFamily, size * fontScale * config.SuperSampleLevels, style);

            //var font = ObtainFont(fileName, size * fontScale * config.SuperSampleLevels, style)
            fontData = BuildFont(font, config, null);
            fontData.scaleDueToTransformToViewport = fontScale;
            font.Dispose();



            if (config.ShadowConfig != null)
            {
                Options.DropShadowActive = true;
            }
            if (transToVp != null)
            {
                Options.TransformToViewport = transToVp;
            }
        }
Exemple #3
0
        private void LoadQFontFromFontFile(FontLoadDescription loadDescription)
        {
            var config = loadDescription.BuilderConfig;
            var fileName = loadDescription.Path;
            var size = loadDescription.Size;
            var style = loadDescription.Style;

            if (config == null)
                config = new QFontBuilderConfiguration();

            TransformViewport? transToVp = null;
            float fontScale = 1f;
            if (config.TransformToCurrentOrthogProjection)
                transToVp = OrthogonalTransform(out fontScale);

            //dont move this into a separate method - it needs to stay in scope!
            PrivateFontCollection pfc = new PrivateFontCollection();
            pfc.AddFontFile(fileName);
            var fontFamily = pfc.Families[0];

            if (!fontFamily.IsStyleAvailable(style))
                throw new ArgumentException("Font file: " + fileName + " does not support style: " + style);


            var font = new Font(fontFamily, size * fontScale * config.SuperSampleLevels, style);
            //var font = ObtainFont(fileName, size * fontScale * config.SuperSampleLevels, style)
            fontData = BuildFont(font, config, null);
            fontData.scaleDueToTransformToViewport = fontScale;
            font.Dispose();



            if (config.ShadowConfig != null)
                Options.DropShadowActive = true;
            if (transToVp != null)
                Options.TransformToViewport = transToVp;
        }
Exemple #4
0
 public QFont(string fileName, float size, FontStyle style, QFontBuilderConfiguration config)
 {
     fontLoadDescription = new FontLoadDescription(fileName, size, style, config);
     LoadQFontFromFontFile(fontLoadDescription);
 }
Exemple #5
0
        private void LoadQFontFromQFontFile(FontLoadDescription loadDescription)
        {
            var loaderConfig = loadDescription.LoaderConfig;
            var filePath = loadDescription.Path;
            var downSampleFactor = loadDescription.DownSampleFactor;


            if (loaderConfig == null)
                loaderConfig = new QFontLoaderConfiguration();

            TransformViewport? transToVp = null;
            float fontScale = 1f;
            if (loaderConfig.TransformToCurrentOrthogProjection)
                transToVp = OrthogonalTransform(out fontScale);

            fontData = Builder.LoadQFontDataFromFile(filePath, downSampleFactor * fontScale, loaderConfig);
            fontData.scaleDueToTransformToViewport = fontScale;

            if (loaderConfig.ShadowConfig != null)
                Options.DropShadowActive = true;
            if (transToVp != null)
                Options.TransformToViewport = transToVp;
        }
Exemple #6
0
 public QFont(string fileName, float size, FontStyle style, QFontBuilderConfiguration config)
 {
     fontLoadDescription = new FontLoadDescription(fileName, size, style, config);
     LoadQFontFromFontFile(fontLoadDescription);
 }
Exemple #7
0
        private void LoadQFontFromQFontFile(FontLoadDescription loadDescription)
        {
            var loaderConfig = loadDescription.LoaderConfig;
            var filePath = loadDescription.Path;
            var downSampleFactor = loadDescription.DownSampleFactor;

            if (loaderConfig == null)
                loaderConfig = new QFontLoaderConfiguration();

            fontData = Builder.LoadQFontDataFromFile(filePath, downSampleFactor, loaderConfig);
            LoadTextures(fontData);
            fontData.scaleDueToTransformToViewport = 1f;

            if (loaderConfig.ShadowConfig != null)
                Options.DropShadowActive = true;
        }
Exemple #8
0
 public QFont(IFontRenderer renderer, string fileName, float size, FontStyle style = FontStyle.Regular, QFontBuilderConfiguration config = null)
 {
     this.renderer = renderer;
     fontLoadDescription = new FontLoadDescription(fileName, size, style, config);
     LoadQFontFromFontFile(fontLoadDescription);
 }
Exemple #9
0
        private void LoadQFontFromFontFile(FontLoadDescription loadDescription)
        {
            var config   = loadDescription.BuilderConfig;
            var fileName = loadDescription.Path;
            var size     = loadDescription.Size;
            var style    = loadDescription.Style;

            if (config == null)
            {
                config = new QFontBuilderConfiguration();
            }

            TransformViewport?transToVp = null;

            float dpiX, dpiY;
            float fontScale = 1.0f;

            using (Graphics graphics = Graphics.FromHwnd(IntPtr.Zero))
            {
                dpiX = graphics.DpiX;
                dpiY = graphics.DpiY;
            }

            float distancefrom120 = 120 - dpiX;
            float percent         = (120 - distancefrom120) / 120;

            if (dpiX != 120f)
            {
                if (percent > 1)
                {
                    fontScale = 1 - Math.Abs(percent - 1);
                }
                else
                {
                    fontScale = 1f + (1 - percent);
                }
            }

            fontScale = Math.Abs(fontScale);

            if (config.TransformToCurrentOrthogProjection)
            {
                transToVp = OrthogonalTransform(out fontScale);
            }

            //dont move this into a separate method - it needs to stay in scope!
            PrivateFontCollection pfc = new PrivateFontCollection();

            pfc.AddFontFile(fileName);
            var fontFamily = pfc.Families[0];

            if (!fontFamily.IsStyleAvailable(style))
            {
                throw new ArgumentException("Font file: " + fileName + " does not support style: " + style);
            }


            var font = new Font(fontFamily, size * fontScale * config.SuperSampleLevels, style);

            //var font = ObtainFont(fileName, size * fontScale * config.SuperSampleLevels, style)
            fontData = BuildFont(font, config, null);
            fontData.scaleDueToTransformToViewport = fontScale;
            font.Dispose();

            if (config.ShadowConfig != null)
            {
                Options.DropShadowActive = true;
            }
            if (transToVp != null)
            {
                Options.TransformToViewport = transToVp;
            }
        }
Exemple #10
0
        private void LoadQFontFromFontFile(FontLoadDescription loadDescription)
        {
            var config = loadDescription.BuilderConfig;
            var fileName = loadDescription.Path;
            var size = loadDescription.Size;
            var style = loadDescription.Style;

            if (config == null)
                config = new QFontBuilderConfiguration();

            TransformViewport? transToVp = null;

            float dpiX, dpiY;
            float fontScale = 1.0f;
            using (Graphics graphics = Graphics.FromHwnd(IntPtr.Zero))
            {
                dpiX = graphics.DpiX;
                dpiY = graphics.DpiY;
            }

            float distancefrom120 = 120 - dpiX;
            float percent = (120 - distancefrom120) / 120;

            if (dpiX != 120f)
                if (percent > 1)
                    fontScale = 1 - Math.Abs(percent - 1);
                else
                    fontScale = 1f + (1 - percent);

            fontScale = Math.Abs(fontScale);

            if (config.TransformToCurrentOrthogProjection)
                transToVp = OrthogonalTransform(out fontScale);

            //dont move this into a separate method - it needs to stay in scope!
            PrivateFontCollection pfc = new PrivateFontCollection();
            pfc.AddFontFile(fileName);
            var fontFamily = pfc.Families[0];

            if (!fontFamily.IsStyleAvailable(style))
                throw new ArgumentException("Font file: " + fileName + " does not support style: " + style);


            var font = new Font(fontFamily, size * fontScale * config.SuperSampleLevels, style);
            //var font = ObtainFont(fileName, size * fontScale * config.SuperSampleLevels, style)
            fontData = BuildFont(font, config, null);
            fontData.scaleDueToTransformToViewport = fontScale;
            font.Dispose();

            if (config.ShadowConfig != null)
                Options.DropShadowActive = true;
            if (transToVp != null)
                Options.TransformToViewport = transToVp;
        }