F2021-066 Additional work Barakah. Limit font shrinking to font size of 8 and if can’t shrink to that size put out message
This commit is contained in:
parent
5aeac983d3
commit
d8983d41d6
@ -169,6 +169,14 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return (LazyLoad(ref _FontShrinkAftLen, "@FontShrinkAftLen"));
|
return (LazyLoad(ref _FontShrinkAftLen, "@FontShrinkAftLen"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private LazyLoad<string> _FontTooSmallMsg; // F2021-066 message if can't shrink enough
|
||||||
|
public string FontTooSmallMsg
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return LazyLoad(ref _FontTooSmallMsg, "@FontTooSmallMsg");
|
||||||
|
}
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region Override ToString
|
#region Override ToString
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
|
@ -2687,8 +2687,10 @@ i = 0;
|
|||||||
}
|
}
|
||||||
svgText.Font = pageItem.Font.WindowsFont;
|
svgText.Font = pageItem.Font.WindowsFont;
|
||||||
// F2021-070 & 066 - shrink font size of page list items if format has amount
|
// F2021-070 & 066 - shrink font size of page list items if format has amount
|
||||||
|
string tmpText = text;
|
||||||
if (pageItem.FontShrinkAftLen != null && pageItem.FontShrinkAftLen > 0)
|
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;
|
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);
|
if ((justify & VEPROMS.CSLA.Library.E_Justify.PSTop) == VEPROMS.CSLA.Library.E_Justify.PSTop) row -= ((72 / 6) / 2);
|
||||||
float lcol = pageItem.Col ?? 0;
|
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
|
// 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.
|
// 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 image = new System.Drawing.Bitmap(1, 1))
|
||||||
{
|
{
|
||||||
using (var g = System.Drawing.Graphics.FromImage(image))
|
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
|
// 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
|
// and decrement until it is less than format value
|
||||||
System.Drawing.SizeF mySize = g.MeasureString(text, svgText.Font);
|
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;
|
tmpi = tmpi - 1;
|
||||||
svgText.FontSize = tmpi.ToString() + "PT";
|
svgText.FontSize = tmpi.ToString() + "PT";
|
||||||
mySize = g.MeasureString(text, svgText.Font);
|
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.
|
catch // don't reset if error occurred.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user