diff --git a/PROMS/VEPROMS.CSLA.Library/Format/PageStyles.cs b/PROMS/VEPROMS.CSLA.Library/Format/PageStyles.cs index 873cb6f0..f35b54e0 100644 --- a/PROMS/VEPROMS.CSLA.Library/Format/PageStyles.cs +++ b/PROMS/VEPROMS.CSLA.Library/Format/PageStyles.cs @@ -169,6 +169,14 @@ namespace VEPROMS.CSLA.Library return (LazyLoad(ref _FontShrinkAftLen, "@FontShrinkAftLen")); } } + private LazyLoad _FontTooSmallMsg; // F2021-066 message if can't shrink enough + public string FontTooSmallMsg + { + get + { + return LazyLoad(ref _FontTooSmallMsg, "@FontTooSmallMsg"); + } + } #endregion #region Override ToString public override string ToString() diff --git a/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs b/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs index d1b67595..c609f151 100644 --- a/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs +++ b/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs @@ -2687,8 +2687,10 @@ i = 0; } svgText.Font = pageItem.Font.WindowsFont; // F2021-070 & 066 - shrink font size of page list items if format has amount + string tmpText = text; if (pageItem.FontShrinkAftLen != null && pageItem.FontShrinkAftLen > 0) - svgText.FontSize = ShrinkIt(text, svgText, (float)pageItem.FontShrinkAftLen); + svgText.FontSize = ShrinkIt(ref tmpText, svgText, (float)pageItem.FontShrinkAftLen, pageItem.FontTooSmallMsg); + if (tmpText != text) svgText.Text = tmpText; float row = (float)pageItem.Row < 0 ? -(float)pageItem.Row : (float)pageItem.Row; if ((justify & VEPROMS.CSLA.Library.E_Justify.PSTop) == VEPROMS.CSLA.Library.E_Justify.PSTop) row -= ((72 / 6) / 2); float lcol = pageItem.Col ?? 0; @@ -2710,9 +2712,12 @@ i = 0; } // F2021-070 & 066 - shrink font size of page list items if format has amount. ShrinkIt compares size (width) of text with input font and // will decrement font size by one until the text size is less than value from format file. - private static string ShrinkIt(string text, SvgText svgText, float fontShrinkAftLen) + // Additional work has been done for F2021-066 to allow for only shrinking to font size greater/equal to 8 and if it goes smaller than that + // to put out a message. + private static string ShrinkIt(ref string text, SvgText svgText, float fontShrinkAftLen, string reptext) { - int tmpi = 0; + int tmpi = Convert.ToInt32(svgText.FontSize.Substring(0, svgText.FontSize.IndexOf("PT"))); + string origFontSize = svgText.FontSize; using (var image = new System.Drawing.Bitmap(1, 1)) { using (var g = System.Drawing.Graphics.FromImage(image)) @@ -2722,12 +2727,25 @@ i = 0; // pageitem's font size did not have a 'set'. svgtext's fontsize is in format of 12PT, so get font size from that // and decrement until it is less than format value System.Drawing.SizeF mySize = g.MeasureString(text, svgText.Font); - while (mySize.Width > fontShrinkAftLen) + while (mySize.Width > fontShrinkAftLen && tmpi > 8) { - tmpi = Convert.ToInt32(svgText.FontSize.Substring(0, svgText.FontSize.IndexOf("PT"))); tmpi = tmpi - 1; svgText.FontSize = tmpi.ToString() + "PT"; mySize = g.MeasureString(text, svgText.Font); + + } + // Additional work for F2021-066: if font size goes less than or equal to 6, use original font size & if + // there is a message in format file to use instead of text, then use it. + if (tmpi == 8 && mySize.Width > fontShrinkAftLen) + { + if (reptext != null && reptext != "") + text = reptext; + else // As per PAL (11/15/21) have default message and highlight by italics (text was already bolded) + { + text = "Text Too Long To Fit"; + svgText.SVGFontStyle = "italic"; + } + svgText.FontSize = origFontSize; } } catch // don't reset if error occurred.