• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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 Erwin Beckers; 11-07-2018, 04:13 AM.

    #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 ;-)

      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

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by ralett, Today, 11:44 AM
            1 response
            12 views
            0 likes
            Last Post NinjaTrader_Spencer  
            Started by DMDINAZ, Today, 11:03 AM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by sukhob, Today, 10:14 AM
            4 responses
            10 views
            0 likes
            Last Post sukhob
            by sukhob
             
            Started by beaacontreras, Today, 09:27 AM
            1 response
            20 views
            0 likes
            Last Post NinjaTrader_PatrickG  
            Started by fxSol, 03-17-2019, 04:17 AM
            5 responses
            28 views
            0 likes
            Last Post NinjaTrader_ChristopherS  
            Working...
            X