Example #1
0
        public object SetStyle(object handle, FontStyle style)
        {
            NSFont f = (NSFont)handle;
            NSFontSymbolicTraits traits = f.FontDescriptor.SymbolicTraits;

            if (style == FontStyle.Italic || style == FontStyle.Oblique)
            {
                traits |= NSFontSymbolicTraits.ItalicTrait;
            }
            else
            {
                traits &= ~NSFontSymbolicTraits.ItalicTrait;
            }

            return(NSFont.FromDescription(f.FontDescriptor.FontDescriptorWithSymbolicTraits(traits), f.FontDescriptor.Matrix));
        }
Example #2
0
        public object SetWeight(object handle, FontWeight weight)
        {
            NSFont f = (NSFont)handle;
            NSFontSymbolicTraits traits = f.FontDescriptor.SymbolicTraits;

            if (weight > FontWeight.Normal)
            {
                traits |= NSFontSymbolicTraits.BoldTrait;
            }
            else
            {
                traits &= ~NSFontSymbolicTraits.BoldTrait;
            }

            return(NSFont.FromDescription(f.FontDescriptor.FontDescriptorWithSymbolicTraits(traits), f.FontDescriptor.Matrix));
        }
Example #3
0
        public object SetStretch(object handle, FontStretch stretch)
        {
            NSFont f = (NSFont)handle;
            NSFontSymbolicTraits traits = f.FontDescriptor.SymbolicTraits;

            if (stretch < FontStretch.Normal)
            {
                traits |= NSFontSymbolicTraits.CondensedTrait;
                traits &= ~NSFontSymbolicTraits.ExpandedTrait;
            }
            else if (stretch > FontStretch.Normal)
            {
                traits |= NSFontSymbolicTraits.ExpandedTrait;
                traits &= ~NSFontSymbolicTraits.CondensedTrait;
            }
            else
            {
                traits &= ~NSFontSymbolicTraits.ExpandedTrait;
                traits &= ~NSFontSymbolicTraits.CondensedTrait;
            }

            return(NSFont.FromDescription(f.FontDescriptor.FontDescriptorWithSymbolicTraits(traits), f.FontDescriptor.Matrix));
        }