Support for System.Drawing.Font

Created at 12 Nov 2024, 14:50
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
CT

ctid5996231

Joined 26.06.2024

Support for System.Drawing.Font
12 Nov 2024, 14:50


Hi all, 

I'm trying to use System.Drawing.Font to calculate the height in pixels of a font I am using in a TextBlock control. I am getting an error as follows:
 

Error | Crashed in OnStart with DllNotFoundException: Unable to load DLL 'gdiplus.dll' or one of its dependencies: 0x80070005 (E_ACCESSDENIED)

Here is a cBot to reproduce the problem:

using System.Runtime.Versioning;
using cAlgo.API;

namespace cAlgo.Robots {

	[Robot(AccessRights = AccessRights.None, AddIndicators = true)]
	[SupportedOSPlatform("windows")]
    public class FontTest : Robot
    {

        protected override void OnStart()
        {

			var fontFamily = new System.Drawing.FontFamily("Consolas");
			var font = new System.Drawing.Font(
			   fontFamily,
			   14,
			   System.Drawing.FontStyle.Regular,
			   System.Drawing.GraphicsUnit.Point
			);

			var lineSpacing = (double)font.GetHeight();
			Print("linespacing: {0}", lineSpacing.ToString());

		}

    }
}

 

Thanks in advance,

Mat

 


@ctid5996231
Replies

PanagiotisCharalampous
13 Nov 2024, 06:31

Hi there,

It looks like the dll is missing from your computer. Can you please advise the reference you use for the System.Drawing methods? The methods do not seem to be a part of the standard System.Drawing namespace

Best regards,

Panagiotis


@PanagiotisCharalampous