Ejemplo n.º 1
0
        /// <summary>
        /// Sets the default font size to match that of a normal editor buffer.
        /// </summary>
        private void SetDefaultFontSize(IComponentModel model, IWpfTextView textView)
        {
            var formatMapSvc      = model.GetService <IClassificationFormatMapService>();
            var fontsAndColorsSvc = model.GetService <IVsFontsAndColorsInformationService>();
            var fontCat           = new VisualStudio.Editor.FontsAndColorsCategory(
                _langSvcGuid,
                Microsoft.VisualStudio.Editor.DefGuidList.guidTextEditorFontCategory,
                Microsoft.VisualStudio.Editor.DefGuidList.guidTextEditorFontCategory
                );

            var fontInfo  = fontsAndColorsSvc.GetFontAndColorInformation(fontCat);
            var fontPrefs = fontInfo.GetFontAndColorPreferences();
            var font      = System.Drawing.Font.FromHfont(fontPrefs.hRegularViewFont);

            var classMap     = formatMapSvc.GetClassificationFormatMap(textView);
            var defaultProps = classMap.DefaultTextProperties;

            defaultProps = defaultProps.SetFontRenderingEmSize(font.Size);
            classMap.DefaultTextProperties = defaultProps;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Sets the default font size to match that of a normal editor buffer.
        /// </summary>
        private void SetDefaultFontSize(IComponentModel model, IWpfTextView textView)
        {
            var formatMapSvc = model.GetService<IClassificationFormatMapService>();
            var fontsAndColorsSvc = model.GetService<IVsFontsAndColorsInformationService>();
            var fontCat = new VisualStudio.Editor.FontsAndColorsCategory(
                    _langSvcGuid,
                    Microsoft.VisualStudio.Editor.DefGuidList.guidTextEditorFontCategory,
                    Microsoft.VisualStudio.Editor.DefGuidList.guidTextEditorFontCategory
                    );

            var fontInfo = fontsAndColorsSvc.GetFontAndColorInformation(fontCat);
            var fontPrefs = fontInfo.GetFontAndColorPreferences();
            var font = System.Drawing.Font.FromHfont(fontPrefs.hRegularViewFont);

            var classMap = formatMapSvc.GetClassificationFormatMap(textView);
            var defaultProps = classMap.DefaultTextProperties;
            defaultProps = defaultProps.SetFontRenderingEmSize(font.Size);
            classMap.DefaultTextProperties = defaultProps;
        }