C2019-022 When pre-processing table cells before we print a table, we now replace any Arial Unicode font reference with FreeSerif.
85 lines
4.7 KiB
C#
85 lines
4.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Drawing;
|
|
using System.Drawing.Text;
|
|
using System.Windows.Forms;
|
|
|
|
namespace Volian.Base.Library
|
|
{
|
|
public static class vlnFont
|
|
{
|
|
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
|
private static InstalledFontCollection _MyFontCollection = new InstalledFontCollection();
|
|
private static string _ProportionalSymbolFont = null;
|
|
// C2017-036 Look for suitable proportional font that will support the symbol characters used in PROMS
|
|
// Microsoft removed Arial Unicode MS starting with Word16 (office 365 containing that version of Word)
|
|
public static string ProportionalSymbolFont
|
|
{
|
|
get {
|
|
if (_ProportionalSymbolFont == null)
|
|
{
|
|
// C2019-022 Microsoft no longer supplies the Arial Unicode font. New computers more than likely do not have this font
|
|
// Since this font is no longer supported, we will now use FreeSerif or FreeMono for symbol characters
|
|
// when using a proportional font.
|
|
// We removed even checking if Arial Unicode was installed because we had a case (at Volian) where the font
|
|
// existed (was installed on a Windows 10 computer) but so some reason (unknown at time of writing) Windows say it was bad.
|
|
// PROMS would will try to use it when printing resulting in very slow print speed and often an un-readable PDF file.
|
|
if (FindFontFamily("FreeSerif"))
|
|
_ProportionalSymbolFont = "FreeSerif"; // volian supplied font but regular chars look like Times Roman
|
|
else if (FindFontFamily("FreeMono"))
|
|
_ProportionalSymbolFont = "FreeMono"; // volian suppllied font but regular chars are fixed spaced and look like Courier
|
|
else
|
|
{
|
|
MessageBox.Show("A suitable font for symbol characters could not be found.\n\n"
|
|
+"Please install Arial Unicode MS and/or the Volian supplied fonts", "Symbol Font");
|
|
_MyLog.Error("Could Not File a Proportional Symbol Font to use.");
|
|
_ProportionalSymbolFont = "Arial"; // if volian fonts not installed, default to plain Arial (which does not have all of the symbols that we use)
|
|
}
|
|
}
|
|
return _ProportionalSymbolFont;
|
|
}
|
|
}
|
|
|
|
|
|
// C2017-036 Look for suitable proportional font that will support the symbol characters used in PROMS
|
|
// Microsoft removed Arial Unicode MS starting with Word16 (office 365 containing that version of Word)
|
|
// This font (below) is used only for the Reports - trying to find a font similar to Arial Unicode MS
|
|
private static string _ReportsFont = null;
|
|
|
|
public static string ReportsFont
|
|
{
|
|
get {
|
|
if (_ReportsFont == null)
|
|
{
|
|
// C2019-022 Microsoft no longer supplies the Arial Unicode font. New computers more than likely do not have this font
|
|
// Since this font is no longer supported, we will now use FreeSerif or FreeMono for symbol characters
|
|
// when using a proportional font.
|
|
// Also the Meiryo font will not be used as it cannot be used along with the Arial font.
|
|
if (FindFontFamily("FreeSerif")) // volian supplied font but regular chars look like Times Roman
|
|
_ReportsFont = "FreeSerif";
|
|
else if (FindFontFamily("FreeMono")) // volian suppllied font but regular chars are fixed spaced and look like Courier
|
|
_ReportsFont = "FreeMono";
|
|
else
|
|
{
|
|
MessageBox.Show("A suitable font to use to generate Reports could not be found.\n\n"
|
|
+"Please install Arial Unicode MS and/or the Volian supplied fonts", "Report Font");
|
|
_MyLog.Error("Could Not File a font to use for Report generation.");
|
|
_ReportsFont = "Arial";
|
|
}
|
|
}
|
|
return _ReportsFont;
|
|
}
|
|
}
|
|
|
|
// see if the given font exists on the computer running PROMS
|
|
private static bool FindFontFamily(string name)
|
|
{
|
|
foreach (FontFamily ff in _MyFontCollection.Families)
|
|
if (ff.Name == name) return true;
|
|
return false;
|
|
}
|
|
}
|
|
}
|