Skip to content

Commit

Permalink
[#136] 着発番線の文字が小さくなりすぎる場合がある問題を修正
Browse files Browse the repository at this point in the history
- ` ` 等のエスケープの考慮漏れ
- 念のため `\r` も取り除くよう変更
  • Loading branch information
TetsuOtter committed Aug 19, 2024
1 parent 3ad5570 commit 67b6228
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion TRViS/DTAC/DTACElementStyles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -375,15 +375,18 @@ public static Style TimetableDefaultNumberLabelStyleResource
private static partial Regex HtmlTagRegex();
[GeneratedRegex("<br[^>]*/?>")]
private static partial Regex HtmlBrTagRegex();
[GeneratedRegex("&[^;]+;")]
private static partial Regex XmlEscapedStrRegex();
public static double GetTimetableTrackLabelFontSize(string trackName, double currentFontSize)
{
bool isTrackNameHtml = trackName.StartsWith('<');
if (isTrackNameHtml)
{
trackName = HtmlBrTagRegex().Replace(trackName, "\n");
trackName = HtmlTagRegex().Replace(trackName, "");
trackName = XmlEscapedStrRegex().Replace(trackName, "");
}
int maxLineLength = trackName.Split("\n", StringSplitOptions.RemoveEmptyEntries).Select(v => v.Length).Max();
int maxLineLength = trackName.Split(['\r', '\n'], StringSplitOptions.RemoveEmptyEntries).Select(v => v.Length).Max();
if (maxLineLength <= 2)
return currentFontSize;
else
Expand Down

0 comments on commit 67b6228

Please sign in to comment.