Exemplo n.º 1
0
        public override object SetStretch(object handle, FontStretch stretch)
        {
            FontData f = (FontData)handle;

            f = f.Copy();

            NSFont font = f.Font;

            if (stretch < FontStretch.SemiCondensed)
            {
                font = NSFontManager.SharedFontManager.ConvertFont(font, NSFontTraitMask.Condensed);
                font = NSFontManager.SharedFontManager.ConvertFontToNotHaveTrait(font, NSFontTraitMask.Compressed | NSFontTraitMask.Expanded | NSFontTraitMask.Narrow);
            }
            if (stretch == FontStretch.SemiCondensed)
            {
                font = NSFontManager.SharedFontManager.ConvertFont(font, NSFontTraitMask.Narrow);
                font = NSFontManager.SharedFontManager.ConvertFontToNotHaveTrait(font, NSFontTraitMask.Compressed | NSFontTraitMask.Expanded | NSFontTraitMask.Condensed);
            }
            else if (stretch > FontStretch.Normal)
            {
                font = NSFontManager.SharedFontManager.ConvertFont(font, NSFontTraitMask.Expanded);
                font = NSFontManager.SharedFontManager.ConvertFontToNotHaveTrait(font, NSFontTraitMask.Compressed | NSFontTraitMask.Narrow | NSFontTraitMask.Condensed);
            }
            else
            {
                font = NSFontManager.SharedFontManager.ConvertFontToNotHaveTrait(font, NSFontTraitMask.Condensed | NSFontTraitMask.Expanded | NSFontTraitMask.Narrow | NSFontTraitMask.Compressed);
            }
            f.Font    = font;
            f.Stretch = stretch;
            return(f);
        }
Exemplo n.º 2
0
        public override object Copy(object handle)
        {
            FontData f = (FontData)handle;

            f      = f.Copy();
            f.Font = (NSFont)f.Font.Copy();
            return(f);
        }
Exemplo n.º 3
0
        public override object SetFamily(object handle, string family)
        {
            FontData f = (FontData)handle;

            f      = f.Copy();
            f.Font = NSFontManager.SharedFontManager.ConvertFontToFamily(f.Font, family);
            return(f);
        }
Exemplo n.º 4
0
        public override object SetSize(object handle, double size)
        {
            FontData f = (FontData)handle;

            f      = f.Copy();
            f.Font = NSFontManager.SharedFontManager.ConvertFont(f.Font, (float)size);
            return(f);
        }
Exemplo n.º 5
0
        public override object SetWeight(object handle, FontWeight weight)
        {
            FontData f = (FontData)handle;

            f        = f.Copy();
            f.Font   = f.Font.WithWeight(weight);
            f.Weight = weight;
            return(f);
        }
Exemplo n.º 6
0
        public override object SetWeight(object handle, FontWeight weight)
        {
            FontData f = (FontData)handle;

            f = f.Copy();
            int w = GetWeightValue(weight);

            f.Font   = NSFontManager.SharedFontManager.FontWithFamily(f.Font.FamilyName, NSFontManager.SharedFontManager.TraitsOfFont(f.Font), w, f.Font.PointSize);
            f.Weight = weight;
            return(f);
        }
Exemplo n.º 7
0
        public override object SetWeight(object handle, FontWeight weight)
        {
            FontData f = (FontData)handle;

            f = f.Copy();
            int w      = GetWeightValue(weight);
            var traits = NSFontManager.SharedFontManager.TraitsOfFont(f.Font);

            traits  |= weight >= FontWeight.Bold ? NSFontTraitMask.Bold : NSFontTraitMask.Unbold;
            traits  &= weight >= FontWeight.Bold ? ~NSFontTraitMask.Unbold : ~NSFontTraitMask.Bold;
            f.Font   = NSFontManager.SharedFontManager.FontWithFamily(f.Font.FamilyName, traits, w, f.Font.PointSize);
            f.Weight = weight;
            return(f);
        }
Exemplo n.º 8
0
        public override object SetStyle(object handle, FontStyle style)
        {
            FontData f = (FontData)handle;

            f = f.Copy();
            NSFontTraitMask mask;

            if (style == FontStyle.Italic || style == FontStyle.Oblique)
            {
                mask = NSFontTraitMask.Italic;
            }
            else
            {
                mask = NSFontTraitMask.Unitalic;
            }
            f.Font  = NSFontManager.SharedFontManager.ConvertFont(f.Font, mask);
            f.Style = style;
            return(f);
        }
Exemplo n.º 9
0
        public override object SetFamily(object handle, string family)
        {
            FontData f = (FontData)handle;

            f = f.Copy();

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

            foreach (var name in names)
            {
                font = NSFontManager.SharedFontManager.ConvertFontToFamily(f.Font, name.Trim());
                if (font != null)
                {
                    f.Font = font;
                    break;
                }
            }

            return(f);
        }