コード例 #1
0
ファイル: XenkoRenderer.cs プロジェクト: TeaCrab/UI_Engines
        /// <summary>
        /// Draws the text.
        /// </summary>
        /// <param name="font">The font.</param>
        /// <param name="text">The text.</param>
        /// <param name="position">The position.</param>
        /// <param name="renderSize">Size of the render.</param>
        /// <param name="color">The color.</param>
        /// <param name="scale">The scale.</param>
        /// <param name="depth">The depth.</param>
        public override void DrawText(FontBase font, string text, PointF position, Size renderSize, ColorW color, PointF scale, float depth)
        {
            if (isClipped)
            {
                testRectangle.X      = (int)position.X;
                testRectangle.Y      = (int)position.Y;
                testRectangle.Width  = (int)renderSize.Width;
                testRectangle.Height = (int)renderSize.Height;

                if (!currentScissorRectangle.Intersects(testRectangle))
                {
                    return;
                }
            }

            vecPosition.X = position.X;
            vecPosition.Y = position.Y;
            vecScale.X    = scale.X;
            vecScale.Y    = scale.Y;
            vecColor.A    = color.A;
            vecColor.R    = color.R;
            vecColor.G    = color.G;
            vecColor.B    = color.B;
            SpriteFont native = font.GetNativeFont() as SpriteFont;

            spriteBatch.DrawString(native, text, vecPosition, vecColor);
        }
コード例 #2
0
        public override void DrawText(FontBase font, string text, PointF position, Size renderSize, ColorW color, PointF scale, float depth)
        {
            var wcR2Font = (font.GetNativeFont() as IWcR2Font)?.BaseFont;

            if (wcR2Font != null)
            {
                if (wcR2Font is XnaFont)
                {
                    //snap pixels
                    position.X = (float)Math.Round(position.X);
                    position.Y = (float)Math.Round(position.Y);

                    Prepare(DrawState.Sprite);
                    spriteBatch.DrawStringEx((XnaFont)wcR2Font,
                                             text,
                                             new Vector2(position.X, position.Y),
                                             new Vector2(renderSize.Width, renderSize.Height),
                                             new Color(color.R, color.G, color.B, color.A));
                }
                else if (wcR2Font is D2DFont)
                {
                    Prepare(DrawState.D2D);
                    d2dRenderer.DrawString((D2DFont)wcR2Font,
                                           text,
                                           new Vector2(position.X, position.Y),
                                           new Vector2(renderSize.Width, renderSize.Height),
                                           new Color(color.R, color.G, color.B, color.A));
                }
            }
        }
コード例 #3
0
ファイル: FontBase.cs プロジェクト: jstefanelli/DiscordOVR
 public TextDrawInstance(int amount, FontBase f, Vector3 color)
 {
     Amount  = amount;
     Atlases = new int[amount];
     Chars   = new Matrix4[amount];
     Offsets = new Matrix4[amount];
     UVs     = new Matrix3[amount];
     Font    = f;
     Color   = color;
 }
コード例 #4
0
ファイル: WcR2Renderer.cs プロジェクト: ncrispi/WzComparerR2
        public override void DrawText(FontBase font, string text, PointF position, Size renderSize, ColorW color, PointF scale, float depth)
        {
            XnaFont nativeFont = font.GetNativeFont() as XnaFont;

            if (nativeFont != null)
            {
                spriteBatch.DrawStringEx(nativeFont,
                                         text,
                                         new Vector2(position.X, position.Y),
                                         new Color(color.R, color.G, color.B, color.A));
            }
        }
コード例 #5
0
 private static void GetDemoFonts(bool useOnlyStandardFonts, out FontBase boldItalicFont, out FontBase normalFont, out FontBase serifBoldItalic)
 {
     if (useOnlyStandardFonts)
     {
         boldItalicFont  = FontsRepository.CourierBoldOblique;
         normalFont      = FontsRepository.Courier;
         serifBoldItalic = FontsRepository.TimesBoldItalic;
     }
     else
     {
         FontsRepository.TryCreateFont(new FontFamily("Arial"), FontStyles.Italic, FontWeights.Bold, out boldItalicFont);
         FontsRepository.TryCreateFont(new FontFamily("Arial"), FontStyles.Normal, FontWeights.Normal, out normalFont);
         FontsRepository.TryCreateFont(new FontFamily("Jokerman"), FontStyles.Italic, FontWeights.Bold, out serifBoldItalic);
     }
 }
コード例 #6
0
        public static Size MeasureString(this FontBase font, string text, Size layoutSize)
        {
            var wcR2Font = (font.GetNativeFont() as IWcR2Font)?.BaseFont;

            if (wcR2Font != null)
            {
                if (wcR2Font is XnaFont)
                {
                    var xnaFont = (XnaFont)wcR2Font;
                    var size    = xnaFont.MeasureString(text, new Vector2(layoutSize.Width, layoutSize.Height));
                    return(new Size(size.X, size.Y));
                }
                else if (wcR2Font is D2DFont)
                {
                    var d2dFont = (D2DFont)wcR2Font;
                    var size    = d2dFont.MeasureString(text, new Vector2(layoutSize.Width, layoutSize.Height));
                    return(new Size(size.X, size.Y));
                }
            }
            return(font.MeasureString(text, 1, 1));
        }
コード例 #7
0
        private void DrawLabel(int x, int y, string text, FontBase font, Meadow.Foundation.Color?color)
        {
            FontBase oldFont = null;

            if (font != null)
            {
                oldFont = _graphicsLibrary.CurrentFont;
                _graphicsLibrary.CurrentFont = font;
            }
            if (color.HasValue)
            {
                _graphicsLibrary.DrawText(x, y, text, color.Value);
            }
            else
            {
                _graphicsLibrary.DrawText(x, y, text);
            }
            if (oldFont != null)
            {
                _graphicsLibrary.CurrentFont = oldFont;
            }
        }
コード例 #8
0
ファイル: Text.cs プロジェクト: RenatoCesarF/Mars
 public virtual void Draw()
 {
     FontBase.WriteText(this.position, this.scale, this.text, this.color);
 }
コード例 #9
0
        public static Table GetComplexTable(FontBase bigTextFont)
        {
            var table = new Table();

            table.Margin  = new Thickness(0, 10, 0, 0);
            table.Borders = new TableBorders(new Border(10, RgbColors.Black));
            Border defaultBorder = new Border(3, RgbColors.Black);

            table.DefaultCellProperties.Borders = new TableCellBorders(defaultBorder, defaultBorder, defaultBorder, defaultBorder);
            table.DefaultCellProperties.Padding = new Thickness(10);
            table.BorderSpacing  = 5;
            table.BorderCollapse = BorderCollapse.Separate;

            TableRow row = table.Rows.AddTableRow();

            TableCell cell = row.Cells.AddTableCell();

            cell.Background = new RgbColor(255, 230, 230);
            cell.RowSpan    = 2;
            cell.ColumnSpan = 2;
            Border redBorder = new Border(5, new RgbColor(255, 0, 0));

            cell.Borders = new TableCellBorders(redBorder, redBorder, redBorder, redBorder);
            Block block = cell.Blocks.AddBlock();

            block.InsertText("This is a ");
            using (block.SaveGraphicProperties())
            {
                block.GraphicProperties.FillColor = new RgbColor(0, 0, 255);
                block.InsertHyperlinkStart(new Uri("http://en.wikipedia.org/wiki/Golden_spiral"));
                block.InsertText("Golden spiral");
                block.InsertHyperlinkEnd();
            }
            block.InsertText(" approximation: ");

            PathGeometry spiralGeometry, rectanglesGeometry;

            using (block.SaveGraphicProperties())
            {
                block.GraphicProperties.IsFilled  = false;
                block.GraphicProperties.IsStroked = true;
                GetGoldenSpiralGeometry(10, out spiralGeometry, out rectanglesGeometry);
                block.GraphicProperties.StrokeColor     = new RgbColor(0, 0, 255);
                block.GraphicProperties.StrokeThickness = 1;
                rectanglesGeometry.Figures.Add(spiralGeometry.Figures[0]);
                block.InsertPath(rectanglesGeometry);
            }

            block.InsertText(GoldenSpiralApproximationText);

            using (Stream sampleImage = GetSampleImageStream())
            {
                cell = row.Cells.AddTableCell();
                cell.Blocks.AddBlock().InsertImage(sampleImage, new Size(200, 124));
            }

            table.Rows.AddTableRow().Cells.AddTableCell().Blocks.AddBlock().InsertText(GoldenSpiralApproximationText);

            row = table.Rows.AddTableRow();

            cell  = row.Cells.AddTableCell();
            block = cell.Blocks.AddBlock();
            block.TextProperties.FontSize = 30;
            block.TextProperties.Font     = bigTextFont;
            block.InsertText("Red Golden Spiral:");

            cell = row.Cells.AddTableCell();
            Border greenBorder = new Border(10, new RgbColor(0, 150, 0));

            cell.Borders    = new TableCellBorders(greenBorder, greenBorder, greenBorder, greenBorder);
            cell.Background = new RgbColor(230, 255, 230);
            cell.ColumnSpan = 2;
            block           = cell.Blocks.AddBlock();
            block.GraphicProperties.IsFilled        = false;
            block.GraphicProperties.IsStroked       = true;
            block.GraphicProperties.StrokeColor     = new RgbColor(255, 0, 0);
            block.GraphicProperties.StrokeThickness = 4;
            block.InsertPath(spiralGeometry);

            return(table);
        }
コード例 #10
0
 /// <summary>
 /// </summary>
 /// <param name="display"></param>
 public GraphicsLibrary(DisplayBase display)
 {
     _display    = display;
     CurrentFont = null;
 }
コード例 #11
0
 private void SetTextProperties(Block block, ColorBase color, double fontSize, FontBase font, bool isUnderlined = false)
 {
     block.GraphicProperties.FillColor     = color;
     block.HorizontalAlignment             = Telerik.Windows.Documents.Fixed.Model.Editing.Flow.HorizontalAlignment.Left;
     block.TextProperties.FontSize         = fontSize;
     block.TextProperties.Font             = font;
     block.TextProperties.UnderlinePattern = isUnderlined ? UnderlinePattern.Single : UnderlinePattern.None;
 }
コード例 #12
0
 /// <summary>
 /// Draws the text.
 /// </summary>
 /// <param name="font">The font.</param>
 /// <param name="text">The text.</param>
 /// <param name="position">The position.</param>
 /// <param name="renderSize">Size of the render.</param>
 /// <param name="color">The color.</param>
 /// <param name="scale">The scale.</param>
 /// <param name="depth">The depth.</param>
 public abstract void DrawText(FontBase font, string text, PointF position, Size renderSize, ColorW color, PointF scale, float depth);