Пример #1
0
        Size CalculateDrawingStringSize(char[] buffer, int length)
        {
            RequestFont fontInfo = GetFont();

            return(FontService1.MeasureString(buffer, 0, length, fontInfo));
            //return this.Root.IFonts.MeasureString(buffer, 0,
            //     length, fontInfo);
        }
Пример #2
0
        public override void CustomDrawToThisCanvas(DrawBoard canvas, Rectangle updateArea)
        {
            int bWidth  = this.Width;
            int bHeight = this.Height;

            if (!this.HasStyle)
            {
                canvas.DrawText(this.mybuffer, new Rectangle(0, 0, bWidth, bHeight), 0);
            }
            else
            {
                TextSpanStyle style = this.SpanStyle;
                switch (EvaluateFontAndTextColor(canvas, style))
                {
                case DIFF_FONT_SAME_TEXT_COLOR:
                {
                    RequestFont prevFont = canvas.CurrentFont;
                    canvas.DrawText(this.mybuffer,
                                    new Rectangle(0, 0, bWidth, bHeight),
                                    style.ContentHAlign);
                }
                break;

                case DIFF_FONT_DIFF_TEXT_COLOR:
                {
                    RequestFont prevFont  = canvas.CurrentFont;
                    Color       prevColor = canvas.CurrentTextColor;
                    canvas.CurrentFont      = style.FontInfo;
                    canvas.CurrentTextColor = style.FontColor;
                    canvas.DrawText(this.mybuffer,
                                    new Rectangle(0, 0, bWidth, bHeight),
                                    style.ContentHAlign);
                    canvas.CurrentFont      = prevFont;
                    canvas.CurrentTextColor = prevColor;
                }
                break;

                case SAME_FONT_DIFF_TEXT_COLOR:
                {
                    Color prevColor = canvas.CurrentTextColor;
                    canvas.CurrentTextColor = style.FontColor;
                    canvas.DrawText(this.mybuffer,
                                    new Rectangle(0, 0, bWidth, bHeight),
                                    style.ContentHAlign);
                    canvas.CurrentTextColor = prevColor;
                }
                break;

                default:
                {
                    canvas.DrawText(this.mybuffer,
                                    new Rectangle(0, 0, bWidth, bHeight),
                                    style.ContentHAlign);
                }
                break;
                }
            }
        }
Пример #3
0
 public static Size MeasureString(char[] buffer, int start, int len, RequestFont r)
 {
     return(s_fontService.MeasureString(buffer, start, len, r));
 }
Пример #4
0
 public static void CalculateGlyphAdvancePos(char[] buffer, int start, int len, RequestFont font, int[] outputGlyphPos)
 {
     s_fontService.CalculateGlyphAdvancePos(buffer, start, len, font, outputGlyphPos);
 }