Fix possible symbol font discrepancy in tables

Allow options for handling foldout page if first page.
This commit is contained in:
2013-09-10 12:46:23 +00:00
parent e47df68f83
commit 89965f1278
5 changed files with 78 additions and 19 deletions

View File

@@ -796,17 +796,45 @@ namespace Volian.Controls.Library
private static Regex _ReplaceVESymbFix = new Regex(@"({\\f[0-9]+[^ ]* )(VESymbFix)(;})");
private static Regex _ReplaceArialUnicodeMS = new Regex(@"({\\f[0-9]+[^ ]* )(Arial Unicode MS)(;})");
private static Regex _ReplaceTextFont = new Regex(@"({\\f[0-9]+[^ ]* )(?((?!VESymbFix)(?!Arial Unicode MS))([^;]*)|(!!!!))(;})");
private bool FontIsFixed(Font myFont)
{
Graphics grph = Graphics.FromHwnd(this.Handle);
SizeF sfW = grph.MeasureString("W", myFont);
SizeF sfE = grph.MeasureString("!", myFont);
if (sfW.Width == sfE.Width) return true;
return false;
}
public void LoadGrid(ItemInfo itemInfo)
{
_MyItemInfo = itemInfo;
string str = itemInfo.MyContent.MyGrid.Data;
VE_Font vefont = _MyItemInfo.GetItemFont();
FontFamily ff = StepRTB.MyFontFamily ?? vefont.WindowsFont.FontFamily; // TODO: Does not change fixed font.
if (StepRTB.MySymbolFontName != "VESymbFix")
str = _ReplaceVESymbFix.Replace(str, "$1" + StepRTB.MySymbolFontName + "$3");
if (StepRTB.MySymbolFontName != "Arial Unicode MS")
str = _ReplaceArialUnicodeMS.Replace(str, "$1" + StepRTB.MySymbolFontName + "$3");
str = _ReplaceTextFont.Replace(str, "$1" + ff.Name + "$4");
// the following code is used to be sure that the font used for symbols is the correct font
// based on whether the font for non-symbol text is fixed or proportional. Each steprtb has
// a font for the non-symbol AND the symbol text, and these must be the correct association, i.e.
// for fixed fonts, the symbol font is 'VESymbFix', for proportional fonts, the symbol font is
// 'Arial Unicode MS'. The underlying flexgrid stores the fonts, and if the table font was
// reset for some reason (for example from the drop-down font selection in the user interface),
// this code 'cleans' up if there is a mismatch.
if (StepRTB.MyFontFamily != null)
{
FontFamily ff = StepRTB.MyFontFamily;
if (StepRTB.MySymbolFontName != "VESymbFix")
str = _ReplaceVESymbFix.Replace(str, "$1" + StepRTB.MySymbolFontName + "$3");
if (StepRTB.MySymbolFontName != "Arial Unicode MS")
str = _ReplaceArialUnicodeMS.Replace(str, "$1" + StepRTB.MySymbolFontName + "$3");
str = _ReplaceTextFont.Replace(str, "$1" + ff.Name + "$4");
}
else
{
FontFamily ff = vefont.WindowsFont.FontFamily;
if (FontIsFixed(vefont.WindowsFont))
str = _ReplaceArialUnicodeMS.Replace(str, "$1" + "VESymbFix" + "$3");
else
str = _ReplaceVESymbFix.Replace(str, "$1" + "Arial Unicode MS" + "$3");
str = _ReplaceTextFont.Replace(str, "$1" + ff.Name + "$4");
}
// To prevent scroll bars from being flashed on/off
// - save an image of the current grid
// - set Visible to false