Ejemplo n.º 1
0
        private void CreateFont(string familyName, float emSize, FontStyle style, GraphicsUnit unit, byte charSet, bool isVertical)
        {
#if ONLY_1_1
            if (familyName == null)
            {
                throw new ArgumentNullException("familyName");
            }
#endif
#if NET_2_0
            originalFontName = familyName;
#endif
            FontFamily family;
            // NOTE: If family name is null, empty or invalid,
            // MS creates Microsoft Sans Serif font.
            try
            {
                family = new FontFamily(familyName);
            }
            catch (Exception)
            {
                family = FontFamily.GenericSansSerif;
            }

            setProperties(family, emSize, style, unit, charSet, isVertical);
            Status status = GDIPlus.GdipCreateFont(family.NativeObject, emSize, style, unit, out fontObject);

            if (status == Status.FontStyleNotFound)
            {
                throw new ArgumentException(Locale.GetText("Style {0} isn't supported by font {1}.", style.ToString(), familyName));
            }

            GDIPlus.CheckStatus(status);
        }
Ejemplo n.º 2
0
        public Font(Font prototype, FontStyle newStyle)
        {
            // no null checks, MS throws a NullReferenceException if original is null
            setProperties(prototype.FontFamily, prototype.Size, newStyle, prototype.Unit, prototype.GdiCharSet, prototype.GdiVerticalFont);

            Status status = GDIPlus.GdipCreateFont(_fontFamily.NativeObject, Size, Style, Unit, out fontObject);

            GDIPlus.CheckStatus(status);
        }
Ejemplo n.º 3
0
        public Font(FontFamily family, float emSize, FontStyle style,
                    GraphicsUnit unit, byte gdiCharSet, bool gdiVerticalFont)
        {
            if (family == null)
            {
                throw new ArgumentNullException("family");
            }

            Status status;

            setProperties(family, emSize, style, unit, gdiCharSet, gdiVerticalFont);
            status = GDIPlus.GdipCreateFont(family.NativeObject, emSize, style, unit, out fontObject);
            GDIPlus.CheckStatus(status);
        }