From 64429dcef0650723193e9533305e7849a18b854e Mon Sep 17 00:00:00 2001 From: John Date: Thu, 13 Oct 2011 18:49:14 +0000 Subject: [PATCH] pass the symbol font name to vlnTab use the current symbol font (determined by Step RTB) to find the real width of a tab containing a symbol character --- PROMS/Volian.Print.Library/vlnParagraph.cs | 2 +- PROMS/Volian.Print.Library/vlnTab.cs | 25 +++++++++++++++++----- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/PROMS/Volian.Print.Library/vlnParagraph.cs b/PROMS/Volian.Print.Library/vlnParagraph.cs index 4e3ef0a5..7ba13030 100644 --- a/PROMS/Volian.Print.Library/vlnParagraph.cs +++ b/PROMS/Volian.Print.Library/vlnParagraph.cs @@ -889,7 +889,7 @@ namespace Volian.Print.Library } if (!itemInfo.IsSection || doSectTab) { - mytab = new vlnTab(cb, this, itemInfo.MyTab.Text, itemInfo.MyTab.CleanText, localXOffset, yoff, itemInfo.MyTab.MyFont, doSectTab); + mytab = new vlnTab(cb, this, itemInfo.MyTab.Text, itemInfo.MyTab.CleanText, localXOffset, yoff, itemInfo.MyTab.MyFont, doSectTab, StepRTB.MySymbolFontName); PartsLeft.Add(mytab); if (mytab.MyMacro != null) PartsLeft.Add(mytab.MyMacro); } diff --git a/PROMS/Volian.Print.Library/vlnTab.cs b/PROMS/Volian.Print.Library/vlnTab.cs index 94ae8cae..7bc1c039 100644 --- a/PROMS/Volian.Print.Library/vlnTab.cs +++ b/PROMS/Volian.Print.Library/vlnTab.cs @@ -58,21 +58,36 @@ namespace Volian.Print.Library set { _MyMacro = value; } } - private float GetTextWidth(VE_Font vefont, string txt) + private string symblsStr = "\u25CF"; // string of possible symbol character in a tab + // add symbol characters as needed + // "\u25CF" - solid bullet + + private float GetTextWidth(VE_Font vefont, string txt, string symblFontName) { System.Drawing.Font font = new System.Drawing.Font(vefont.Family, (float)vefont.Size); + System.Drawing.Font symbFont = new System.Drawing.Font(symblFontName, (float)vefont.Size); iTextSharp.text.Font iFont = Volian.Svg.Library.VolianPdf.GetFont(font); - float w = iFont.BaseFont.GetWidthPointKerned(Text.Replace("\u25CF","@"), (float)vefont.Size); + iTextSharp.text.Font iSymblFont = Volian.Svg.Library.VolianPdf.GetFont(symbFont); + float w = 0; + foreach (char c in Text) + { + int idx = symblsStr.IndexOf(c); + if (idx >= 0) // symbol character - use symbol font to find its width + w += iSymblFont.BaseFont.GetWidthPointKerned(symblsStr[idx].ToString(), (float)vefont.Size); + else + w += iFont.BaseFont.GetWidthPointKerned(c.ToString(), (float)vefont.Size); + } + //float w = iFont.BaseFont.GetWidthPointKerned(Text.Replace("\u25CF","@"), (float)vefont.Size); return w; } - public vlnTab(PdfContentByte cb, vlnParagraph myparent, string origTab, string cleanTab, float xoffset, float yoffset, VE_Font vFont, bool doSectTab) + public vlnTab(PdfContentByte cb, vlnParagraph myparent, string origTab, string cleanTab, float xoffset, float yoffset, VE_Font vFont, bool doSectTab, string symblFontName) { MyContentByte = cb; MyParent = myparent; YOffset = yoffset; Text = cleanTab; MyFont = vFont; - Width = GetTextWidth(MyFont, (Text != null ? Text : origTab));//MyFont.CharsToTwips * (Text != null ? Text.Length : origTab.Length); + Width = GetTextWidth(MyFont, (Text != null ? Text : origTab), symblFontName);//MyFont.CharsToTwips * (Text != null ? Text.Length : origTab.Length); if (origTab.Contains(@"{!")) { int mindx = origTab.IndexOf(@"{!"); @@ -84,7 +99,7 @@ namespace Volian.Print.Library origTab = origTab.Replace(macro,""); origTab = origTab + " "; cleanTab = origTab; - Width = GetTextWidth(MyFont, (cleanTab != null ? cleanTab : origTab));//MyFont.CharsToTwips * (cleanTab != null ? cleanTab.Length : origTab.Length); + Width = GetTextWidth(MyFont, (cleanTab != null ? cleanTab : origTab), symblFontName);//MyFont.CharsToTwips * (cleanTab != null ? cleanTab.Length : origTab.Length); } Rtf = GetRtf(origTab, vFont); Rtf = Rtf.Replace("\u25CF", @"\f1\u9679?\f0"); // bullet 25CF // jsj- add space after \f0