Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

GraphicsUnit parameter needed for SimpleFont

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

    GraphicsUnit parameter needed for SimpleFont

    On NT7 as DrawText() was the only native draw method that had an offset parameter ("yPixelOffset"), and the other DrawObjects were fixed size and non-scalable, the only way to draw many objects with precision and control was to draw them as text. So we drew text rectangles, triangles etc, so that we could control size and positioning with some precision. To do that we needed to specify the GraphicsUnit.Pixel on the Font used.

    NT8 still has no ability natively to precisely position (via offset) anything other than Text, so the same workaround is still required. That means that on SimpleFont(), we need to have, and be able to specify, the GraphicsUnit, unless, of course, it is natively locked to GraphicsUnit.Pixel.

    This offset capability for precision positioning on all DrawObjects has been a long-standing request. I have to presume that it is not of importance to many folks, so making it is low priority matter for NTDevelopment, which is understandable, but can we at least be able to draw with the same precision as we could in NT7.
    Last edited by koganam; 01-30-2016, 10:44 AM. Reason: Corrected spelling.

    #2
    The DirectWrite API coordinates are in device independent pixels (DIPs)

    In the case of writing on the chart, when you're using your SimpleFont myFont, you must convert myFont.ToDirectWriteTextFormat().

    This method will take the Size property you specified when constructing the SimpleFont and convert it to pixels. Same concept applies to using the Draw.Text()

    So if you specify 10 as your SimpleFont Size, or through the Draw.Text(), what is rendered will be 10 pixels

    If you're seeing a loss of precision, it could just be due to the leading space in the font family, which will vary for the block of geometric unicode shapes.

    For example the attached was drawn using Draw.Text() with Unicode Character 'Black up-pointing triangle △' (U+25B2), all using a Size of 10, and displaced a YPixelOffset of 10, but with various font families.

    To illustrate, I manually drew a 10 pixel block around each one and zoomed in, and you can see that the amount of lead around each character varies from font family, but what is rendered is technically 10 pixels...



    If there is something else preventing you drawing as you wish which prompted this request, please let me know and I'll be glad to look into for you, or do the research on what needs to be done in the future to help out.

    With that said, I hear you that the drawing objects could all use some sort of offset and we'll definitely look into enhancing these objects when that time comes
    Attached Files
    MatthewNinjaTrader Product Management

    Comment


      #3
      Wouldn't it be better to have scalable draw objects with offsets, instead of continuing to use Draw.Text as a kludge?

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by ghoul, Today, 06:02 PM
      3 responses
      14 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by jeronymite, 04-12-2024, 04:26 PM
      3 responses
      44 views
      0 likes
      Last Post jeronymite  
      Started by Barry Milan, Yesterday, 10:35 PM
      7 responses
      20 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by AttiM, 02-14-2024, 05:20 PM
      10 responses
      180 views
      0 likes
      Last Post jeronymite  
      Started by DanielSanMartin, Yesterday, 02:37 PM
      2 responses
      13 views
      0 likes
      Last Post DanielSanMartin  
      Working...
      X