Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Does NT8 SimpleFont support underline or strikethrough?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Does NT8 SimpleFont support underline or strikethrough?

    Hi there,

    In NT8's help guide reference for SimpleFont, it references bold, italics, etc. But not underline or strikethrough. I'm looking at this page:



    How would I designate a SimpleFont with an underline?
    Thanks in advance!

    #2
    Hello Spiderbird,

    I'm not aware that SimpleFont has these properties.

    I am happy to submit a feature request on your behalf for the NinjaTrader Development to consider this for a future version of NinjaTrader if you would like.

    In the meantime, you could achieve this with custom rendering.

    Below is a public link to an example of custom rendering text.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea,

      Thanks for the quick response! I believe there's an existing request from the Beta stage for underline text support for SimpleFont, so no need to send it through as a feature request again.

      For the example you posted, I'm looking at the following code:
      // create a new TextFormat object using information from the chart labels
      SharpDX.DirectWrite.TextFormat textFormat = new SharpDX.DirectWrite.TextFormat(Core.Globals.Direct WriteFactory, chartTextFormat.FontFamilyName, chartTextFormat.FontWeight, chartTextFormat.FontStyle, fontSize);

      // calculate the which will be rendered at each plot using it the plot name and its price
      string textToRender = "Some text to render";

      // calculate the layout of the text to be drawn
      SharpDX.DirectWrite.TextLayout textLayout = new SharpDX.DirectWrite.TextLayout(Core.Globals.Direct WriteFactory,
      textToRender, textFormat, 300, textFormat.FontSize);
      Is this what I should be considering when attempting to underline chart text?

      Comment


        #4
        Hello Spiderbird,

        Use the .SetUnderline from a TextLayout object and use a TextRange object created with the TextLayout.Metrics.Width.

        Below is a public link to a 3rd party website that has an example.
        C# (CSharp) SharpDX.DirectWrite TextLayout.SetUnderline - 4 examples found. These are the top rated real world C# (CSharp) examples of SharpDX.DirectWrite.TextLayout.SetUnderline extracted from open source projects. You can rate examples to help us improve the quality of examples.


        As well as public links to the documentation. (Unfortunately the SharpDX wiki is not well maintained and looks pretty bad)



        Code:
        SharpDX.DirectWrite.TextFormat textFormat = font.ToDirectWriteTextFormat();
        SharpDX.DirectWrite.TextLayout textLayout =
        new SharpDX.DirectWrite.TextLayout(NinjaTrader.Core.Globals.DirectWriteFactory,
        text, textFormat, chartPanel.X + chartPanel.W,
        textFormat.FontSize);
        SharpDX.Vector2 TextPlotPoint = new System.Windows.Point(pointX, pointY-textLayout.Metrics.Height/2).ToVector2();
        
        float newW = textLayout.Metrics.Width; 
                float newH = textLayout.Metrics.Height;
                SharpDX.RectangleF PLBoundRect = new SharpDX.RectangleF((float)pointX+2, (float)pointY-textLayout.Metrics.Height/2, newW+5, newH+2);
                renderTarget.FillRectangle(PLBoundRect, areaBrush);
        
        SharpDX.DirectWrite.TextRange textRange = new SharpDX.DirectWrite.TextRange(0, (int)textLayout.Metrics.Width);
        
        textLayout.SetUnderline(true, textRange);
        
        renderTarget.DrawTextLayout(TextPlotPoint, textLayout, brush, SharpDX.Direct2D1.DrawTextOptions.NoSnap);
        textLayout.Dispose();
        textFormat.Dispose();
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Wonderful! Thanks for your help Chelsea. I’ll give that a shot.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by DJ888, 04-16-2024, 06:09 PM
          4 responses
          12 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Started by terofs, Today, 04:18 PM
          0 responses
          8 views
          0 likes
          Last Post terofs
          by terofs
           
          Started by nandhumca, Today, 03:41 PM
          0 responses
          6 views
          0 likes
          Last Post nandhumca  
          Started by The_Sec, Today, 03:37 PM
          0 responses
          3 views
          0 likes
          Last Post The_Sec
          by The_Sec
           
          Started by GwFutures1988, Today, 02:48 PM
          1 response
          9 views
          0 likes
          Last Post NinjaTrader_Clayton  
          Working...
          X