private void TurnOnCategory(FontCategory category, double zoomLevel)
        {
            Guid categoryId = category.Id;

            int hr = fontsAndColors.OpenCategory(
                ref categoryId,
                (uint)(__FCSTORAGEFLAGS.FCSF_PROPAGATECHANGES | __FCSTORAGEFLAGS.FCSF_LOADDEFAULTS)
                );

            if (ErrorHandler.Succeeded(hr))
            {
                LOGFONTW[] logfont  = new LOGFONTW[1];
                FontInfo[] fontInfo = new FontInfo[1];

                hr = fontsAndColors.GetFont(logfont, fontInfo);
                if (ErrorHandler.Succeeded(hr))
                {
                    category.FontInfo = fontInfo[0];
                    double size = fontInfo[0].wPointSize;
                    size = (size * zoomLevel) / 100;

                    fontInfo[0].bFaceNameValid  = 0;
                    fontInfo[0].bCharSetValid   = 0;
                    fontInfo[0].bPointSizeValid = 1;
                    fontInfo[0].wPointSize      = Convert.ToUInt16(size);
                    fontsAndColors.SetFont(fontInfo);
                }
                fontsAndColors.CloseCategory();
            }
        }
Ejemplo n.º 2
0
        private void TurnOffCategory(FontCategory category, bool notifyChanges)
        {
            EnsureFontsAndColors();
            Guid categoryId = category.Id;
            var  flags      = __FCSTORAGEFLAGS.FCSF_LOADDEFAULTS;

            if (notifyChanges)
            {
                flags |= __FCSTORAGEFLAGS.FCSF_PROPAGATECHANGES;
            }

            int hr = fontsAndColors.OpenCategory(ref categoryId, (uint)flags);

            if (ErrorHandler.Succeeded(hr))
            {
                FontInfo[] fontInfo = new FontInfo[] {
                    category.FontInfo
                };
                fontInfo[0].bFaceNameValid  = 0;
                fontInfo[0].bCharSetValid   = 0;
                fontInfo[0].bPointSizeValid = 1;
                fontsAndColors.SetFont(fontInfo);
                fontsAndColors.CloseCategory();
            }
        }
Ejemplo n.º 3
0
        public static Font LoadFont(FontCategory category, FontStyle style)
        {
            var fontCategory = "SansSerif";
            var fontStyle    = "Regular";
            var fontName     = "Roboto";

            if (category == FontCategory.Monospace)
            {
                fontCategory = "Monospace";
                fontName     = "RobotoMono";
            }

            if (style == FontStyle.Bold)
            {
                fontStyle = "Bold";
            }
            else if (style == FontStyle.BoldAndItalic)
            {
                fontStyle = "BoldItalic";
            }
            else if (style == FontStyle.Italic)
            {
                fontStyle = "Italic";
            }

            return(Resources.Load <Font>(string.Format("CommonUnityLibrary/{0}Font/{1}-{2}", fontCategory, fontName, fontStyle)));
        }
Ejemplo n.º 4
0
        public bool FindAsset(FontCategory fontCategory, out FontProfileAsset fontProfileAsset)
        {
            if ((int)fontCategory < assets.Length && assets[(int)fontCategory].IsSet)
            {
                fontProfileAsset = assets[(int)fontCategory];
                return(true);
            }

            fontProfileAsset = new FontProfileAsset();
            return(false);
        }
        private void TurnOffCategory(FontCategory category, bool notifyChanges)
        {
            Guid categoryId = category.Id;
              var flags = __FCSTORAGEFLAGS.FCSF_LOADDEFAULTS;
              if ( notifyChanges ) {
            flags |= __FCSTORAGEFLAGS.FCSF_PROPAGATECHANGES;
              }

              int hr = fontsAndColors.OpenCategory(ref categoryId, (uint)flags);

              if ( ErrorHandler.Succeeded(hr) ) {
            FontInfo[] fontInfo = new FontInfo[] {
              category.FontInfo
            };
            fontInfo[0].bFaceNameValid = 0;
            fontInfo[0].bCharSetValid = 0;
            fontInfo[0].bPointSizeValid = 1;
            fontsAndColors.SetFont(fontInfo);
            fontsAndColors.CloseCategory();
              }
        }
        private void TurnOnCategory(FontCategory category, double zoomLevel)
        {
            Guid categoryId = category.Id;

              int hr = fontsAndColors.OpenCategory(
            ref categoryId,
            (uint)(__FCSTORAGEFLAGS.FCSF_PROPAGATECHANGES | __FCSTORAGEFLAGS.FCSF_LOADDEFAULTS)
            );

              if ( ErrorHandler.Succeeded(hr) ) {
            LOGFONTW[] logfont = new LOGFONTW[1];
            FontInfo[] fontInfo = new FontInfo[1];

            hr = fontsAndColors.GetFont(logfont, fontInfo);
            if ( ErrorHandler.Succeeded(hr) ) {
              category.FontInfo = fontInfo[0];
              double size = fontInfo[0].wPointSize;
              size = (size * zoomLevel) / 100;

              fontInfo[0].bFaceNameValid = 0;
              fontInfo[0].bCharSetValid = 0;
              fontInfo[0].bPointSizeValid = 1;
              fontInfo[0].wPointSize = Convert.ToUInt16(size);
              fontsAndColors.SetFont(fontInfo);
            }
            fontsAndColors.CloseCategory();
              }
        }