I ran this simple code on a FEZ Feather running TinyCLR 2.0.0 and I am getting an error calling the DrawString method.
Error:
An unhandled exception of type ‘System.ArgumentException’ occurred in GHIElectronics.TinyCLR.Drawing.dll
static void Main()
{
var controller = I2cController.FromName(SC20100.I2cBus.I2c1);
var i2cDevice = controller.GetDevice(SSD1306Controller.GetConnectionSettings());
SSD1306Controller ssd1306Controller = new SSD1306Controller(i2cDevice);
var screen = Graphics.FromImage(new Bitmap(128, 32));
var font = new Font("GHIMono8x5", 8);
var brush = new SolidBrush(System.Drawing.Color.White);
Graphics.OnFlushEvent += (s, d) => {
ssd1306Controller.DrawBuffer(d);
};
screen.FillRectangle(brush, 0, 0, 30, 32); //Works
screen.Flush();
screen.DrawEllipse(new System.Drawing.Pen(System.Drawing.Color.White), 32, 0, 30, 30); //Works
screen.Flush();
Thread.Sleep(1000);
screen.DrawString("Welcome", font, brush, 34, 0); //Throws an error
screen.Flush();
Thread.Sleep(Timeout.Infinite);
}
Doing some investigation, I noticed that the height property on the Font class is throwing an error.
Is this the proper way to instantiate the font class?
var font = new Font("GHIMono8x5", 8);