Exemplo n.º 1
0
        public override object Create(string fontName, double size, FontStyle style, FontWeight weight, FontStretch stretch)
        {
            var t = GetStretchTrait(stretch) | GetStyleTrait(style);

            var    names = fontName.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            NSFont f     = null;

            foreach (var name in names)
            {
                f = NSFontManager.SharedFontManager.FontWithFamily(name.Trim(), t, GetWeightValue(weight), (float)size);
                if (f != null)
                {
                    break;
                }
            }
            if (f == null)
            {
                return(null);
            }

            var fd = FontData.FromFont(NSFontManager.SharedFontManager.ConvertFont(f, t));

            fd.Style   = style;
            fd.Weight  = weight;
            fd.Stretch = stretch;
            return(fd);
        }
Exemplo n.º 2
0
        public bool Run(IWindowFrameBackend parent)
        {
            fontPanel.Delegate = new FontPanelDelegate();

            if (parent != null)
            {
                var macParent = parent as NSWindow ?? context.Toolkit.GetNativeWindow(parent) as NSWindow ?? NSApplication.SharedApplication.KeyWindow;
                if (macParent != null && fontPanel.EffectiveAppearance.Name != macParent.EffectiveAppearance.Name)
                {
                    fontPanel.Appearance = macParent.EffectiveAppearance;
                }
            }

            if (SelectedFont != null)
            {
                NSFontManager.SharedFontManager.SetSelectedFont(((FontData)Toolkit.GetBackend(SelectedFont)).Font, false);
            }

            NSApplication.SharedApplication.RunModalForWindow(fontPanel);

            var font = NSFontPanel.SharedFontPanel.PanelConvertFont(NSFont.SystemFontOfSize(0));

            SelectedFont = Font.FromName(FontData.FromFont(font).ToString());

            return(true);
        }
Exemplo n.º 3
0
        public override object Create(string fontName, double size, FontStyle style, FontWeight weight, FontStretch stretch)
        {
            var t  = GetStretchTrait(stretch) | GetStyleTrait(style);
            var f  = NSFontManager.SharedFontManager.FontWithFamily(fontName, t, GetWeightValue(weight), (float)size);
            var fd = FontData.FromFont(NSFontManager.SharedFontManager.ConvertFont(f, t));

            fd.Style   = style;
            fd.Weight  = weight;
            fd.Stretch = stretch;
            return(fd);
        }
        public bool Run(IWindowFrameBackend parent)
        {
            fontPanel.Delegate = new FontPanelDelegate();

            if (SelectedFont != null)
            {
                NSFontManager.SharedFontManager.SetSelectedFont(((FontData)Toolkit.GetBackend(SelectedFont)).Font, false);
            }

            NSApplication.SharedApplication.RunModalForWindow(fontPanel);

            var font = NSFontPanel.SharedFontPanel.PanelConvertFont(NSFont.SystemFontOfSize(0));

            SelectedFont = Font.FromName(FontData.FromFont(font).ToString());

            return(true);
        }
Exemplo n.º 5
0
 public override object GetSystemDefaultFont()
 {
     return(FontData.FromFont(NSFont.SystemFontOfSize(0)));
 }