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 rocketman7, Today, 09:41 AM
          3 responses
          7 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by traderqz, Today, 09:44 AM
          2 responses
          4 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by stafe, 04-15-2024, 08:34 PM
          8 responses
          40 views
          0 likes
          Last Post stafe
          by stafe
           
          Started by rocketman7, Today, 02:12 AM
          7 responses
          31 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by guillembm, Yesterday, 11:25 AM
          3 responses
          16 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Working...
          X