diff --git a/PROMS/Volian.Print.Library/Grid2Pdf.cs b/PROMS/Volian.Print.Library/Grid2Pdf.cs index 3a19cfae..6c9fe28f 100644 --- a/PROMS/Volian.Print.Library/Grid2Pdf.cs +++ b/PROMS/Volian.Print.Library/Grid2Pdf.cs @@ -400,6 +400,11 @@ namespace Volian.Print.Library str = System.Text.RegularExpressions.Regex.Replace(str, @"\\cf[0-9]\\", @"\"); str = System.Text.RegularExpressions.Regex.Replace(str, @"\\cf[0-9] ", @""); } + // the FreeMono font is used for the editor, but VESymbFix is used for printing + // The font spefication is embeded in the table text so we need to change the font reference from + // FreeMono to VESymbFix before we print the table + if (str.ToUpper().Contains("FREEMONO")) + str = str.Replace("FreeMono", "VESymbFix"); DisplayText dt = new DisplayText(MyFlexGrid.GetMyItemInfo(), str, false); str = dt.StartText; str = PreProcessRTF(w, str); diff --git a/PROMS/Volian.Print.Library/Rtf2iTextSharp.cs b/PROMS/Volian.Print.Library/Rtf2iTextSharp.cs index 98d81668..391f71d6 100644 --- a/PROMS/Volian.Print.Library/Rtf2iTextSharp.cs +++ b/PROMS/Volian.Print.Library/Rtf2iTextSharp.cs @@ -223,6 +223,12 @@ namespace Volian.Print.Library break; } } + private bool ContainsSymbols(string p) + { + foreach (char c in p) + if (c <= '\x7F') return false; + return true; + } protected override void DoVisitText(IRtfVisualText visualText) { int profileDepth = ProfileTimer.Push(">>>> DoVisitText"); @@ -240,19 +246,21 @@ namespace Volian.Print.Library // and the 16bit conversion to be pdf may be off. //if (font.Familyname.StartsWith("Arial") && font.Size == 11 && DoingComparison) font.Size = 11.15f; iTextSharp.text.pdf.FontSelector fs = new FontSelector(); - if (visualText.Format.Font.Name == "VESymbFix") + if (visualText.Format.Font.Name == "VESymbFix" && ContainsSymbols(visualText.Text)) { - fs.AddFont(FontFactory.GetFont("VESymbFix", BaseFont.IDENTITY_H, BaseFont.EMBEDDED, visualText.Format.FontSize / 2, - (visualText.Format.IsBold ? iTextSharp.text.Font.BOLD : 0) + - (visualText.Format.IsItalic ? iTextSharp.text.Font.ITALIC : 0), font.Color)); + fs.AddFont(font); // if the symbol character cannot be found in VESymbFix then check/use the Consolas font - fs.AddFont(FontFactory.GetFont("Consolas", BaseFont.IDENTITY_H, BaseFont.EMBEDDED, (visualText.Format.FontSize*1.1F) / 2, + // We are using the VESymbFix font first because not all of the symbols that we use are in the Consolas font + // The Consolas font will give us other symbols that we don't have in VESymbFix (ex the Omega) + fs.AddFont(FontFactory.GetFont("Consolas", BaseFont.IDENTITY_H, BaseFont.EMBEDDED, (visualText.Format.FontSize * 1.1F) / 2, (visualText.Format.IsBold ? iTextSharp.text.Font.BOLD : 0) + (visualText.Format.IsItalic ? iTextSharp.text.Font.ITALIC : 0), font.Color)); Phrase ph = fs.Process(visualText.Text); foreach (Chunk chk in ph.Chunks) + { AdjustChunk(visualText, font, chk); - _MyParagraph.Add(ph); + _MyParagraph.Add(chk); + } } else {