diff --git a/BizHawk.Client.EmuHawk/CustomControls/ControlRenderer/GdiPlusRenderer.cs b/BizHawk.Client.EmuHawk/CustomControls/ControlRenderer/GdiPlusRenderer.cs
index 2d158351a9..cba17f44b1 100644
--- a/BizHawk.Client.EmuHawk/CustomControls/ControlRenderer/GdiPlusRenderer.cs
+++ b/BizHawk.Client.EmuHawk/CustomControls/ControlRenderer/GdiPlusRenderer.cs
@@ -80,10 +80,9 @@ namespace BizHawk.Client.EmuHawk.CustomControls
return new GdiPlusGraphicsLock();
}
- public Size MeasureString(string str, Font font)
+ public SizeF MeasureString(string str, Font font)
{
- var size = _graphics.MeasureString(str, font);
- return new Size((int)(size.Width + 0.5), (int)(size.Height + 0.5));
+ return _graphics.MeasureString(str, font);
}
public void PrepDrawString(Font font, Color color, bool rotate = false)
diff --git a/BizHawk.Client.EmuHawk/CustomControls/ControlRenderer/IControlRenderer.cs b/BizHawk.Client.EmuHawk/CustomControls/ControlRenderer/IControlRenderer.cs
index 9a5475cd9e..9003f934e7 100644
--- a/BizHawk.Client.EmuHawk/CustomControls/ControlRenderer/IControlRenderer.cs
+++ b/BizHawk.Client.EmuHawk/CustomControls/ControlRenderer/IControlRenderer.cs
@@ -14,7 +14,7 @@ namespace BizHawk.Client.EmuHawk.CustomControls
/// Measure the width and height of string when drawn
/// using the given font
///
- Size MeasureString(string str, Font font);
+ SizeF MeasureString(string str, Font font);
void SetBrush(Color color);
void SetSolidPen(Color color);
diff --git a/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.Drawing.cs b/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.Drawing.cs
index 19b6988c27..9c16c4bb15 100644
--- a/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.Drawing.cs
+++ b/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.Drawing.cs
@@ -51,7 +51,7 @@ namespace BizHawk.Client.EmuHawk
if (width.HasValue)
{
- var max = (width.Value - CellWidthPadding) / _charSize.Width;
+ var max = (int)((width.Value - CellWidthPadding) / _charSize.Width + 0.5);
if (text.Length >= max)
{
text = text.Substring(0, max);
@@ -94,7 +94,7 @@ namespace BizHawk.Client.EmuHawk
int strOffsetX = 0;
int strOffsetY = 0;
QueryItemText(startRow, col, out text, ref strOffsetX, ref strOffsetY);
- int textWidth = _renderer.MeasureString(text, Font).Width;
+ int textWidth = (int)_renderer.MeasureString(text, Font).Width;
height = Math.Max(height, textWidth + (CellWidthPadding * 2));
}
_horizontalColumnHeights[j] = height;
@@ -122,7 +122,7 @@ namespace BizHawk.Client.EmuHawk
int textOffsetY = CellHeightPadding;
if (HorizontalOrientation)
{
- int textHeight = _renderer.MeasureString(_columnDown.Text, Font).Height;
+ int textHeight = (int)_renderer.MeasureString(_columnDown.Text, Font).Height;
textOffsetY = (columnHeight - textHeight) / 2;
}
@@ -176,7 +176,7 @@ namespace BizHawk.Client.EmuHawk
{
var column = visibleColumns[j];
var columnHeight = GetHColHeight(j);
- var textHeight = _renderer.MeasureString(column.Text, Font).Height;
+ var textHeight = (int)_renderer.MeasureString(column.Text, Font).Height;
var point = new Point(CellWidthPadding, y + ((columnHeight - textHeight) / 2));
if (IsHoveringOnColumnCell && column == CurrentCell.Column)
@@ -264,7 +264,7 @@ namespace BizHawk.Client.EmuHawk
int strOffsetY = 0;
QueryItemText(f + startRow, col, out var text, ref strOffsetX, ref strOffsetY);
- int textWidth = _renderer.MeasureString(text, Font).Width;
+ int textWidth = (int)_renderer.MeasureString(text, Font).Width;
if (col.Rotatable)
{
// Center Text
diff --git a/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.cs b/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.cs
index 82972a4d98..391324a64b 100644
--- a/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.cs
+++ b/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.cs
@@ -34,7 +34,7 @@ namespace BizHawk.Client.EmuHawk
private int _maxCharactersInHorizontal = 1;
private int _rowCount;
- private Size _charSize;
+ private SizeF _charSize;
// Updated on paint
private int[] _horizontalColumnHeights;
@@ -151,7 +151,7 @@ namespace BizHawk.Client.EmuHawk
}
var newWidth = (maxLength * _charSize.Width) + (CellWidthPadding * 2);
- CurrentCell.Column.Width = newWidth;
+ CurrentCell.Column.Width = (int)newWidth;
_columns.ColumnsChanged();
Refresh();
}
@@ -1936,11 +1936,13 @@ namespace BizHawk.Client.EmuHawk
// Measure width change to ignore extra padding at start/end
var size1 = _renderer.MeasureString("A", Font);
var size2 = _renderer.MeasureString("AA", Font);
- _charSize = new Size(size2.Width - size1.Width, size1.Height); // TODO make this a property so changing it updates other values.
+ _charSize = new SizeF(size2.Width - size1.Width, size1.Height); // TODO make this a property so changing it updates other values.
}
- CellHeight = _charSize.Height + (CellHeightPadding * 2);
- CellWidth = (_charSize.Width * MaxCharactersInHorizontal) + (CellWidthPadding * 4); // Double the padding for horizontal because it looks better
+ // TODO: Should we round instead of truncate?
+ CellHeight = (int)_charSize.Height + (CellHeightPadding * 2);
+ CellWidth = (int)(_charSize.Width * MaxCharactersInHorizontal) + (CellWidthPadding * 4); // Double the padding for horizontal because it looks better
+
ColumnWidth = CellWidth;
ColumnHeight = CellHeight + 2;
}