Esempio n. 1
0
        public static SizeF DrawString(this IGUIContext ctx, string text, IGUIFont font, Brush brush, float x, float y, FontFormat format)
        {
            if (ctx == null)
            {
                return(SizeF.Empty);
            }

            SizeF contentSize = font.Measure(text);

            switch (format.HAlign)
            {
            case Alignment.Near:
                break;

            case Alignment.Center:
                x -= contentSize.Width / 2f;
                break;

            case Alignment.Far:
                x -= contentSize.Width;
                break;
            }

            // ToDo: Was soll das hier noch ?
            switch (format.VAlign)
            {
            case Alignment.Near:
                y -= contentSize.Height / 2f;
                break;

            case Alignment.Center:
                y += contentSize.Height / 2f;
                break;

            case Alignment.Far:
            case Alignment.Baseline:
                y += contentSize.Height / 2;
                break;
            }

            SizeF retVal;

            font.Begin(ctx);
            Color c = Color.Empty;

            if (brush != null)
            {
                c = brush.Color;
            }
            retVal = font.Print(text, new RectangleF(x, y, contentSize.Width, contentSize.Height), format, c);
            font.End();
            return(retVal);
        }
Esempio n. 2
0
        public SizeF Print(IGUIContext ctx, string fontTag, string text, RectangleF bounds, FontFormat format, Color color = default(Color))
        {
            IGUIFont font = FontByTag(fontTag);

            if (font == null)
            {
                return(SizeF.Empty);
            }

            font.Begin(ctx);
            try {
                return(font.Print(text, bounds, format, color));
            } catch (Exception ex) {
                ex.LogError();
                return(SizeF.Empty);
            }
            finally {
                font.End();
            }
        }
Esempio n. 3
0
        public static SizeF DrawString(this IGUIContext ctx, string text, IGUIFont font, Brush brush, RectangleF rect, FontFormat format)
        {
            if (ctx == null || text == null)
            {
                return(SizeF.Empty);
            }

            SizeF retVal;

            Color c = Color.Empty;

            if (brush != null)
            {
                c = brush.Color;
            }

            font.Begin(ctx);
            retVal = font.Print(text, rect, format, c);
            font.End();
            return(retVal);
        }