Fixed use of symbol characters in table cells

Fixed use of the hanging indent in procedure steps
This commit is contained in:
John Jenko 2015-07-24 18:55:31 +00:00
parent 33a1dba227
commit 1408a43fa8
2 changed files with 19 additions and 6 deletions

View File

@ -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);

View File

@ -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
{