diff --git a/libse/SsaStyle.cs b/libse/SsaStyle.cs index 9217686e5..a1d386917 100644 --- a/libse/SsaStyle.cs +++ b/libse/SsaStyle.cs @@ -1,6 +1,7 @@ using Nikse.SubtitleEdit.Core.SubtitleFormats; using System; using System.Drawing; +using System.Globalization; using System.Text; namespace Nikse.SubtitleEdit.Core @@ -9,7 +10,7 @@ namespace Nikse.SubtitleEdit.Core { public string Name { get; set; } public string FontName { get; set; } - public int FontSize { get; set; } + public float FontSize { get; set; } public bool Italic { get; set; } public bool Bold { get; set; } public bool Underline { get; set; } @@ -31,7 +32,7 @@ namespace Nikse.SubtitleEdit.Core public SsaStyle() { FontName = Configuration.Settings.SubtitleSettings.SsaFontName; - FontSize = (int)Configuration.Settings.SubtitleSettings.SsaFontSize; + FontSize = (float)Configuration.Settings.SubtitleSettings.SsaFontSize; Primary = Color.FromArgb(Configuration.Settings.SubtitleSettings.SsaFontColorArgb); Secondary = Color.Yellow; Outline = Color.Black; @@ -99,7 +100,7 @@ namespace Nikse.SubtitleEdit.Core } else if (f == "fontsize") { - sb.Append(FontSize); + sb.Append(FontSize.ToString(CultureInfo.InvariantCulture)); } else if (f == "primarycolour") { @@ -206,7 +207,7 @@ namespace Nikse.SubtitleEdit.Core } else if (f == "fontsize") { - sb.Append(FontSize); + sb.Append(FontSize.ToString(CultureInfo.InvariantCulture)); } else if (f == "primarycolour") { diff --git a/libse/SubtitleFormats/AdvancedSubStationAlpha.cs b/libse/SubtitleFormats/AdvancedSubStationAlpha.cs index 343f8131d..72adc1546 100644 --- a/libse/SubtitleFormats/AdvancedSubStationAlpha.cs +++ b/libse/SubtitleFormats/AdvancedSubStationAlpha.cs @@ -30,7 +30,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats var ssa = Configuration.Settings.SubtitleSettings; return "Style: Default," + ssa.SsaFontName + "," + - (int)ssa.SsaFontSize + "," + + ssa.SsaFontSize.ToString(CultureInfo.InvariantCulture) + "," + GetSsaColorString(Color.FromArgb(ssa.SsaFontColorArgb)) + "," + "&H0300FFFF,&H00000000,&H02000000," + boldStyle + ",0,0,0,100,100,0,0," + borderStyle + "," + ssa.SsaOutline.ToString(CultureInfo.InvariantCulture) + "," + Configuration.Settings.SubtitleSettings.SsaShadow.ToString(CultureInfo.InvariantCulture) + ",2," + ssa.SsaMarginLeft + "," + ssa.SsaMarginRight + "," + ssa.SsaMarginTopBottom + ",1"; @@ -403,8 +403,7 @@ Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text" fontSize = node.Attributes["tts:fontSize"].Value.Replace("px", string.Empty).Replace("em", string.Empty); } - int fSize; - if (!int.TryParse(fontSize, out fSize)) + if (!float.TryParse(fontSize, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var fSize)) { fSize = 20; } @@ -551,7 +550,7 @@ Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text" fontSize = node.Attributes["tts:fontSize"].Value.Replace("px", string.Empty).Replace("em", string.Empty); } - if (!int.TryParse(fontSize, out var fSize)) + if (!float.TryParse(fontSize, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var fSize)) { fSize = 20; } @@ -824,7 +823,7 @@ Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text" string fontSize = text.Substring(start + 4, end - (start + 4)); string extraTags = string.Empty; CheckAndAddSubTags(ref fontSize, ref extraTags, out var unknownTags, out italic); - if (Utilities.IsInteger(fontSize)) + if (float.TryParse(fontSize, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out _)) { text = text.Remove(start, end - start + 1); if (italic) @@ -1747,7 +1746,7 @@ Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text" } else if (i == fontsizeIndex) { - if (!int.TryParse(f, out _) || f.StartsWith('-')) + if (!float.TryParse(f, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture , out _) || f.StartsWith('-')) { sb.AppendLine("'Fontsize' incorrect: " + rawLine); sb.AppendLine(); @@ -2048,9 +2047,9 @@ Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text" } else if (i == fontsizeIndex) { - if (int.TryParse(f, out var number)) + if (float.TryParse(f, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var fOut)) { - style.FontSize = number; + style.FontSize = fOut; } } else if (i == primaryColourIndex) diff --git a/src/Forms/Styles/SubStationAlphaStyles.Designer.cs b/src/Forms/Styles/SubStationAlphaStyles.Designer.cs index 2c9220cc2..6b8abb2d9 100644 --- a/src/Forms/Styles/SubStationAlphaStyles.Designer.cs +++ b/src/Forms/Styles/SubStationAlphaStyles.Designer.cs @@ -765,6 +765,7 @@ // // numericUpDownFontSize // + this.numericUpDownFontSize.DecimalPlaces = 1; this.numericUpDownFontSize.Location = new System.Drawing.Point(100, 44); this.numericUpDownFontSize.Maximum = new decimal(new int[] { 200, diff --git a/src/Forms/Styles/SubStationAlphaStyles.cs b/src/Forms/Styles/SubStationAlphaStyles.cs index 3b9d502f1..c8a7725c0 100644 --- a/src/Forms/Styles/SubStationAlphaStyles.cs +++ b/src/Forms/Styles/SubStationAlphaStyles.cs @@ -324,7 +324,7 @@ namespace Nikse.SubtitleEdit.Forms.Styles var subItem = new ListViewItem.ListViewSubItem(item, ssaStyle.FontName); item.SubItems.Add(subItem); - subItem = new ListViewItem.ListViewSubItem(item, ssaStyle.FontSize.ToString()); + subItem = new ListViewItem.ListViewSubItem(item, ssaStyle.FontSize.ToString(CultureInfo.InvariantCulture)); item.SubItems.Add(subItem); int count = 0; @@ -548,9 +548,9 @@ namespace Nikse.SubtitleEdit.Forms.Styles checkBoxFontBold.Checked = style.Bold; checkBoxFontUnderline.Checked = style.Underline; - if (style.FontSize > 0 && style.FontSize <= numericUpDownFontSize.Maximum) + if (style.FontSize > 0 && style.FontSize <= (float)numericUpDownFontSize.Maximum) { - numericUpDownFontSize.Value = style.FontSize; + numericUpDownFontSize.Value = (decimal)style.FontSize; } else { diff --git a/src/Forms/Styles/SubStationAlphaStylesBatchConvert.Designer.cs b/src/Forms/Styles/SubStationAlphaStylesBatchConvert.Designer.cs index bc05bd238..47328b723 100644 --- a/src/Forms/Styles/SubStationAlphaStylesBatchConvert.Designer.cs +++ b/src/Forms/Styles/SubStationAlphaStylesBatchConvert.Designer.cs @@ -677,6 +677,7 @@ // // numericUpDownFontSize // + this.numericUpDownFontSize.DecimalPlaces = 1; this.numericUpDownFontSize.Location = new System.Drawing.Point(100, 44); this.numericUpDownFontSize.Maximum = new decimal(new int[] { 200, diff --git a/src/Forms/Styles/SubStationAlphaStylesBatchConvert.cs b/src/Forms/Styles/SubStationAlphaStylesBatchConvert.cs index 16b892932..edd43ac1e 100644 --- a/src/Forms/Styles/SubStationAlphaStylesBatchConvert.cs +++ b/src/Forms/Styles/SubStationAlphaStylesBatchConvert.cs @@ -886,9 +886,9 @@ namespace Nikse.SubtitleEdit.Forms.Styles checkBoxFontBold.Checked = style.Bold; checkBoxFontUnderline.Checked = style.Underline; - if (style.FontSize > 0 && style.FontSize <= numericUpDownFontSize.Maximum) + if (style.FontSize > 0 && style.FontSize <= (float) numericUpDownFontSize.Maximum) { - numericUpDownFontSize.Value = style.FontSize; + numericUpDownFontSize.Value = (decimal) style.FontSize; } else {