Describes how a font was loaded so that it can be reloaded
예제 #1
0
파일: QFont.cs 프로젝트: demelev/neovim.cs
        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;
            }
        }
예제 #2
0
파일: QFont.cs 프로젝트: demelev/neovim.cs
        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;
            }
        }
예제 #3
0
파일: QFont.cs 프로젝트: Pireax/neovim.cs
        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;
        }
예제 #4
0
파일: QFont.cs 프로젝트: Pireax/neovim.cs
 public QFont(string fileName, float size, FontStyle style, QFontBuilderConfiguration config)
 {
     fontLoadDescription = new FontLoadDescription(fileName, size, style, config);
     LoadQFontFromFontFile(fontLoadDescription);
 }
예제 #5
0
파일: QFont.cs 프로젝트: Pireax/neovim.cs
        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;
        }
예제 #6
0
파일: QFont.cs 프로젝트: demelev/neovim.cs
 public QFont(string fileName, float size, FontStyle style, QFontBuilderConfiguration config)
 {
     fontLoadDescription = new FontLoadDescription(fileName, size, style, config);
     LoadQFontFromFontFile(fontLoadDescription);
 }
예제 #7
0
파일: QFont.cs 프로젝트: rumkex/QuickFont
        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;
        }
예제 #8
0
파일: QFont.cs 프로젝트: rumkex/QuickFont
 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);
 }
예제 #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;
            }
        }
예제 #10
0
파일: QFont.cs 프로젝트: law4x/stonevox3d
        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;
        }