Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

SharpDX.DirectWrite.TextLayout

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

    SharpDX.DirectWrite.TextLayout

    Hello,

    Perhaps I am doing something incorrect but Textlayout seems to be having issues with handling white spaces. I am creating labels and when I specify the label as "MyLabel", everything works fine. When, however, I specify the label as "My Label", only "My La" is displayed.

    I am using

    Code:
    TextLayout textLayout0 = new TextLayout(Globals.DirectWriteFactory, label0, textFormat, 999, textFormat.FontSize);
    and

    Code:
    RenderTarget.DrawTextLayout(labelAnchor0.ToVector2(), textLayout0, myBrush);
    As an aside, can you offer any suggestion on creating knock-out (reverse color) text?
    Any suggestion would be appreciated. Thank you.

    #2
    Hello Zeos6,

    Thanks for your inquiry.

    I haven't had issues with spaces using TextLayouts.

    I've attached an indicator I worked on previously that uses TextLayouts and adding spaces works fine. You may add spaces to the strings created in the DrawString() methods on lines 182-193 to test on your end.

    You may need to check your implementation or print out the string passed to the TextLayout to be sure that the correct string was passed.

    As for knock out colors, I can't think of an easier way to do this outside of creating a new brush based off of the RGB values of the original brush, using additional math on these RGB values to find the RGB values of the opposite color.

    I've linked a Stack Overflow page on inverting colors to get some ideas: https://stackoverflow.com/questions/...a-colour-color

    If you need any reference for creating brushes, it can be found in the Working with Brushes section of our help guide: https://ninjatrader.com/support/help...th_brushes.htm

    If there is anything else I can do to help out, please let me know.
    Attached Files
    JimNinjaTrader Customer Service

    Comment


      #3
      Thank you very much Jim.

      I will look at the references regarding the knock-out colors. As to the TextLayout issue, I actually have printed the string that is supposed to be going to TextLayout and it is fine; it does include the white spaces. The only difference I see in the sample you provided is that you use DrawString. I use DrawTextLayout. is there any way to verify the actual string inside TextLayout? Also, the issue might be with the DrawTextLayout. This is simply baffling me.

      Comment


        #4
        Hello Zeos6,

        My DrawString() is simply a wrapper used as boiler-plate port code to convert NT7 indicators that use GDI graphics. The DrawString() method is defined at line 274 where the TextLayout is created and DrawTextLayout is used.

        I am not aware of a property that will return the string entered into a TextLayout. If you have confirmed that the string going in is valid, I would then suggest to check the implementation. You could use what I have in the attached indicator for reference or you may wish to reference the Text Drawing Tools as an additional reference for comparison.

        I look forward to being of any further assistance.
        JimNinjaTrader Customer Service

        Comment


          #5
          Thanks Jim. Will check out the implementation.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by inanazsocial, Today, 01:15 AM
          1 response
          6 views
          0 likes
          Last Post NinjaTrader_Jason  
          Started by rocketman7, Today, 02:12 AM
          0 responses
          10 views
          0 likes
          Last Post rocketman7  
          Started by dustydbayer, Today, 01:59 AM
          0 responses
          2 views
          0 likes
          Last Post dustydbayer  
          Started by trilliantrader, 04-18-2024, 08:16 AM
          5 responses
          23 views
          0 likes
          Last Post trilliantrader  
          Started by Davidtowleii, Today, 12:15 AM
          0 responses
          3 views
          0 likes
          Last Post Davidtowleii  
          Working...
          X