Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Ninja's icon font

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

    Ninja's icon font

    How can i draw icons on the chart ?
    Atm.. im trying todo the following
    However the IconsFamily font used by NT8 to draw icons is an embedded resource. It seems that SimpleFont does not work with embedded resources.
    Is there some other way to get this to work ?

    Code:
            private void DrawTextLabel(ChartControl chartControl, ChartScale chartScale, string txt, float x, float y, float w)
            {
                var family = System.Windows.Application.Current.TryFindResource("IconsFamily") as System.Windows.Media.FontFamily;
                var wpfFont = new SimpleFont(family.ToString(), 32);
                var textFormat = wpfFont.ToDirectWriteTextFormat();
    
                textFormat.TextAlignment = SharpDX.DirectWrite.TextAlignment.Center;
                textFormat.WordWrapping = WordWrapping.NoWrap;
    
                var textLayout = new TextLayout(Globals.DirectWriteFactory, txt, textFormat, w, textFormat.FontSize);
                var textBrush = Brushes.Black.ToDxBrush(RenderTarget);
                RenderTarget.DrawTextLayout(new Vector2(x, y), textLayout, textBrush, DrawTextOptions.NoSnap);
    
                textBrush.Dispose();
                textFormat.Dispose();
                textLayout.Dispose();
            }
    Last edited by EB Worx; 11-07-2018, 04:13 AM.
    EB Worx
    NinjaTrader Ecosystem Vendor - EB Worx

    #2
    Hello Erwin Beckers,

    So with the right font family the icons can be rendered in sharpdx.

    Below is a link to a forum post on how to the get icon font family with an automation id.
    https://ninjatrader.com/support/foru...270#post803270

    For example:
    Code:
    protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
    {
        base.OnRender(chartControl, chartScale);
    
        // calculate the x and y values for the line to start and end
        SharpDX.Vector2 startPoint = new SharpDX.Vector2(100, 70);
    
        // get the IconsFamily font family and supply to textformat
        FontFamily btnFontFamily = Application.Current.TryFindResource("IconsFamily") as FontFamily;
        SharpDX.DirectWrite.TextFormat chartTextFormat = new SimpleFont(btnFontFamily.FamilyNames.First().Value, 40).ToDirectWriteTextFormat();
    
        // create a new TextFormat object using information from the chart labels
        SharpDX.DirectWrite.TextFormat textFormat = new SharpDX.DirectWrite.TextFormat(Core.Globals.DirectWriteFactory, chartTextFormat.FontFamilyName, chartTextFormat.FontWeight, chartTextFormat.FontStyle, chartTextFormat.FontSize);
    
        string textToRender = NinjaTrader.Gui.Tools.Icons.CcTools;
    
        // calculate the layout of the text to be drawn
        SharpDX.DirectWrite.TextLayout textLayout = new SharpDX.DirectWrite.TextLayout(Core.Globals.DirectWriteFactory,
            textToRender, textFormat, 300, textFormat.FontSize);
    
        RenderTarget.DrawTextLayout(startPoint, textLayout, Brushes.LightBlue.ToDxBrush(RenderTarget) );
    }
    I'm noticing that for this to display, the nt8_iconfont.ttf font file needs to be installed in windows and it appears that the later versions of NinjaTrader 8's installer is not installing this. I'm checking with our development to see if there is a different method for accessing this.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Yes for fonts installed in windows it works fine, but for fonts embedded as a resource it doesn't ;-)
      EB Worx
      NinjaTrader Ecosystem Vendor - EB Worx

      Comment


        #4
        Hello Erwin Beckers,

        Our development is letting me know the font file is no longer distributed with NinjaTrader 8.

        I'm attaching to this post if you want to use it.

        I'm also submitting a feature request for a native supported way of using the font with NinjaScripts. Once I have a tracking ID for this request I will forward this to you for future reference.
        Attached Files
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hello Erwin Beckers,

          I've received tracking ID #SFT-2023 for this request for a supported way of accessing NinjaTrader's icons.

          Please note it is up to the NinjaTrader Development to decide if or when any request will be implemented.

          We appreciate your feedback on this.
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            Thx.. for now i decided to use custom gfx icons instead of the Ninatrader font
            EB Worx
            NinjaTrader Ecosystem Vendor - EB Worx

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by sightcareclickhere, Today, 01:55 PM
            0 responses
            0 views
            0 likes
            Last Post sightcareclickhere  
            Started by Mindset, 05-06-2023, 09:03 PM
            9 responses
            258 views
            0 likes
            Last Post ender_wiggum  
            Started by Mizzouman1, Today, 07:35 AM
            4 responses
            18 views
            0 likes
            Last Post Mizzouman1  
            Started by philmg, Today, 01:17 PM
            1 response
            6 views
            0 likes
            Last Post NinjaTrader_ChristopherJ  
            Started by cre8able, Today, 01:01 PM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Working...
            X