diff --git a/LanguageMaster.xml b/LanguageMaster.xml
index 547fc4731..283bb07b7 100644
--- a/LanguageMaster.xml
+++ b/LanguageMaster.xml
@@ -2270,6 +2270,13 @@ can edit in same subtitle file (collaboration)
None, ellipsis for pauses
Dash
Dash, but dots for pauses
+ Cps/line-length
+ Count all characters
+ Count all except space
+ CJK 1, latin 0.5
+ CJK 1, latin 0.5, space 0
+ Ignore Arabic diacritics
+ Ignore Arabic diacritics/space
Music symbol
Music symbols to replace (separate by comma)
Fix common OCR errors - also use hard-coded rules
diff --git a/src/Test/Core/StringExtensionsTest.cs b/src/Test/Core/StringExtensionsTest.cs
index ca7c9386d..adbb0510b 100644
--- a/src/Test/Core/StringExtensionsTest.cs
+++ b/src/Test/Core/StringExtensionsTest.cs
@@ -1,6 +1,7 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Nikse.SubtitleEdit.Core.Common;
using System;
+using Nikse.SubtitleEdit.Core.Common.TextLengthCalculator;
namespace Test.Core
{
@@ -219,58 +220,57 @@ namespace Test.Core
[TestMethod]
public void CountLetters1()
{
- string input = " Hallo world! ";
- var res = input.CountCharacters(false, false);
+ var input = " Hallo world! ";
+ var res = CalcFactory.MakeCalculator(nameof(CalcAll)).CountCharacters(input);
Assert.AreEqual(" Hallo world! ".Length, res);
}
[TestMethod]
public void CountLetters2()
{
- string input = " Hallo " + Environment.NewLine + " world! ";
- var res = input.CountCharacters(true, false);
+ var input = " Hallo " + Environment.NewLine + " world! ";
+ var res = CalcFactory.MakeCalculator(nameof(CalcNoSpace)).CountCharacters(input);
Assert.AreEqual("Halloworld!".Length, res);
}
[TestMethod]
public void CountLetters3()
{
- string input = " Hallo" + Environment.NewLine + "world!";
- var res = input.CountCharacters(false, false);
+ var input = " Hallo" + Environment.NewLine + "world!";
+ var res = CalcFactory.MakeCalculator(nameof(CalcAll)).CountCharacters(input);
Assert.AreEqual(" Halloworld!".Length, res);
}
[TestMethod]
public void CountLetters4Ssa()
{
- string input = "{\\an1}Hallo";
- var res = input.CountCharacters(true, false);
+ var input = "{\\an1}Hallo";
+ var res = CalcFactory.MakeCalculator(nameof(CalcAll)).CountCharacters(input);
Assert.AreEqual("Hallo".Length, res);
}
[TestMethod]
public void CountLetters4Html()
{
- string input = "Hallo";
- var res = input.CountCharacters(true, false);
+ var input = "Hallo";
+ var res = CalcFactory.MakeCalculator(nameof(CalcAll)).CountCharacters(input);
Assert.AreEqual("Hallo".Length, res);
}
[TestMethod]
public void CountLetters5HtmlFont()
{
- string input = "Hal lo";
- var res = input.CountCharacters(true, false);
+ var input = "Hal lo";
+ var res = CalcFactory.MakeCalculator(nameof(CalcNoSpace)).CountCharacters(input);
Assert.AreEqual("Hallo".Length, res);
}
[TestMethod]
public void CountLetters6HtmlFontMultiLine()
{
- string input = "Hal lo" + Environment.NewLine + "Bye!";
- var res = input.CountCharacters(true, false);
+ var input = "Hal lo" + Environment.NewLine + "Bye!";
+ var res = CalcFactory.MakeCalculator(nameof(CalcNoSpace)).CountCharacters(input);
Assert.AreEqual("HalloBye!".Length, res);
}
-
}
}
diff --git a/src/libse/Common/RulesProfile.cs b/src/libse/Common/RulesProfile.cs
index 1cda432e1..cefb966c6 100644
--- a/src/libse/Common/RulesProfile.cs
+++ b/src/libse/Common/RulesProfile.cs
@@ -18,7 +18,7 @@ namespace Nikse.SubtitleEdit.Core.Common
public int SubtitleMinimumDisplayMilliseconds { get; set; }
public int SubtitleMaximumDisplayMilliseconds { get; set; }
public int MinimumMillisecondsBetweenLines { get; set; }
- public bool CpsIncludesSpace { get; set; }
+ public string CpsLineLengthStrategy { get; set; }
public int MaxNumberOfLines { get; set; }
public int MergeLinesShorterThan { get; set; }
public DialogType DialogStyle { get; set; }
@@ -42,7 +42,7 @@ namespace Nikse.SubtitleEdit.Core.Common
SubtitleMinimumDisplayMilliseconds = profile.SubtitleMinimumDisplayMilliseconds;
SubtitleMaximumDisplayMilliseconds = profile.SubtitleMaximumDisplayMilliseconds;
MinimumMillisecondsBetweenLines = profile.MinimumMillisecondsBetweenLines;
- CpsIncludesSpace = profile.CpsIncludesSpace;
+ CpsLineLengthStrategy = profile.CpsLineLengthStrategy;
MaxNumberOfLines = profile.MaxNumberOfLines;
MergeLinesShorterThan = profile.MergeLinesShorterThan;
DialogStyle = profile.DialogStyle;
@@ -64,7 +64,7 @@ namespace Nikse.SubtitleEdit.Core.Common
}
sb.Append("{\"name\":\"" + Json.EncodeJsonText(p.Name) + "\", " +
"\"maxNumberOfLines\":\"" + p.MaxNumberOfLines.ToString(CultureInfo.InvariantCulture) + "\"," +
- "\"cpsIncludesSpace\":\"" + p.CpsIncludesSpace.ToString(CultureInfo.InvariantCulture) + "\"," +
+ "\"cpsLineLengthStrategy\":\"" + p.CpsLineLengthStrategy + "\"," +
"\"mergeLinesShorterThan\":\"" + p.MergeLinesShorterThan.ToString(CultureInfo.InvariantCulture) + "\"," +
"\"minimumMillisecondsBetweenLines\":\"" + p.MinimumMillisecondsBetweenLines.ToString(CultureInfo.InvariantCulture) + "\"," +
"\"subtitleLineMaximumLength\":\"" + p.SubtitleLineMaximumLength.ToString(CultureInfo.InvariantCulture) + "\"," +
@@ -95,7 +95,7 @@ namespace Nikse.SubtitleEdit.Core.Common
{
var name = Json.DecodeJsonText(Json.ReadTag(p, "name"));
var maxNumberOfLines = Convert.ToInt32(Json.ReadTag(p, "maxNumberOfLines"), CultureInfo.InvariantCulture);
- var cpsIncludesSpace = Convert.ToBoolean(Json.ReadTag(p, "cpsIncludesSpace"), CultureInfo.InvariantCulture);
+ var cpsLineLengthStrategy = Json.ReadTag(p, "cpsLineLengthStrategy");
var mergeLinesShorterThan = Convert.ToInt32(Json.ReadTag(p, "mergeLinesShorterThan"), CultureInfo.InvariantCulture);
var minimumMillisecondsBetweenLines = Convert.ToInt32(Json.ReadTag(p, "minimumMillisecondsBetweenLines"), CultureInfo.InvariantCulture);
var subtitleLineMaximumLength = Convert.ToInt32(Json.ReadTag(p, "subtitleLineMaximumLength"), CultureInfo.InvariantCulture);
@@ -115,7 +115,7 @@ namespace Nikse.SubtitleEdit.Core.Common
{
Name = name,
MaxNumberOfLines = maxNumberOfLines,
- CpsIncludesSpace = cpsIncludesSpace,
+ CpsLineLengthStrategy = cpsLineLengthStrategy,
MergeLinesShorterThan = mergeLinesShorterThan,
MinimumMillisecondsBetweenLines = minimumMillisecondsBetweenLines,
SubtitleLineMaximumLength = subtitleLineMaximumLength,
diff --git a/src/libse/Common/Settings.cs b/src/libse/Common/Settings.cs
index 885e6b465..4e5293e0a 100644
--- a/src/libse/Common/Settings.cs
+++ b/src/libse/Common/Settings.cs
@@ -8,6 +8,7 @@ using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
+using Nikse.SubtitleEdit.Core.Common.TextLengthCalculator;
namespace Nikse.SubtitleEdit.Core.Common
{
@@ -1231,8 +1232,7 @@ $HorzAlign = Center
public bool AutoWrapLineWhileTyping { get; set; }
public double SubtitleMaximumCharactersPerSeconds { get; set; }
public double SubtitleOptimalCharactersPerSeconds { get; set; }
- public bool CharactersPerSecondsIgnoreWhiteSpace { get; set; }
- public bool IgnoreArabicDiacritics { get; set; }
+ public string CpsLineLengthStrategy { get; set; }
public double SubtitleMaximumWordsPerMinute { get; set; }
public DialogType DialogStyle { get; set; }
public ContinuationStyle ContinuationStyle { get; set; }
@@ -1394,7 +1394,6 @@ $HorzAlign = Center
DefaultSubtitleFormat = "SubRip";
DefaultEncoding = TextEncoding.Utf8WithBom;
AutoConvertToUtf8 = false;
- IgnoreArabicDiacritics = false;
AutoGuessAnsiEncoding = true;
ShowRecentFiles = true;
RememberSelectedLine = true;
@@ -1524,7 +1523,7 @@ $HorzAlign = Center
SubtitleMaximumDisplayMilliseconds = SubtitleMaximumDisplayMilliseconds,
SubtitleMinimumDisplayMilliseconds = SubtitleMinimumDisplayMilliseconds,
SubtitleMaximumWordsPerMinute = (decimal)SubtitleMaximumWordsPerMinute,
- CpsIncludesSpace = !CharactersPerSecondsIgnoreWhiteSpace,
+ CpsLineLengthStrategy = CpsLineLengthStrategy,
MinimumMillisecondsBetweenLines = MinimumMillisecondsBetweenLines,
DialogStyle = DialogStyle,
ContinuationStyle = ContinuationStyle
@@ -1545,7 +1544,7 @@ $HorzAlign = Center
SubtitleMaximumDisplayMilliseconds = 7000,
SubtitleMinimumDisplayMilliseconds = 833,
SubtitleMaximumWordsPerMinute = 300,
- CpsIncludesSpace = true,
+ CpsLineLengthStrategy = string.Empty,
MinimumMillisecondsBetweenLines = 84, // 2 frames for 23.976 fps videos
DialogStyle = DialogType.DashBothLinesWithoutSpace,
ContinuationStyle = ContinuationStyle.NoneEllipsisForPauses
@@ -1561,7 +1560,7 @@ $HorzAlign = Center
SubtitleMaximumDisplayMilliseconds = 7000,
SubtitleMinimumDisplayMilliseconds = 833,
SubtitleMaximumWordsPerMinute = 300,
- CpsIncludesSpace = true,
+ CpsLineLengthStrategy = string.Empty,
MinimumMillisecondsBetweenLines = 84, // 2 frames for 23.976 fps videos
DialogStyle = DialogType.DashBothLinesWithSpace,
ContinuationStyle = ContinuationStyle.NoneEllipsisForPauses
@@ -1577,7 +1576,7 @@ $HorzAlign = Center
SubtitleMaximumDisplayMilliseconds = 7000,
SubtitleMinimumDisplayMilliseconds = 833,
SubtitleMaximumWordsPerMinute = 300,
- CpsIncludesSpace = true,
+ CpsLineLengthStrategy = string.Empty,
MinimumMillisecondsBetweenLines = 84, // 2 frames for 23.976 fps videos
DialogStyle = DialogType.DashSecondLineWithoutSpace,
ContinuationStyle = ContinuationStyle.LeadingTrailingEllipsis
@@ -1593,7 +1592,7 @@ $HorzAlign = Center
SubtitleMaximumDisplayMilliseconds = 7000,
SubtitleMinimumDisplayMilliseconds = 1000,
SubtitleMaximumWordsPerMinute = 300,
- CpsIncludesSpace = true,
+ CpsLineLengthStrategy = string.Empty,
MinimumMillisecondsBetweenLines = 84, // 2 frames for 23.976 fps videos
DialogStyle = DialogType.DashBothLinesWithSpace,
ContinuationStyle = ContinuationStyle.NoneEllipsisForPauses,
@@ -1609,7 +1608,7 @@ $HorzAlign = Center
SubtitleMaximumDisplayMilliseconds = 7000,
SubtitleMinimumDisplayMilliseconds = 1000,
SubtitleMaximumWordsPerMinute = 300,
- CpsIncludesSpace = true,
+ CpsLineLengthStrategy = typeof(CalcIgnoreArabicDiacritics).Name,
MinimumMillisecondsBetweenLines = 84, // 2 frames for 23.976 fps videos
DialogStyle = DialogType.DashBothLinesWithSpace,
ContinuationStyle = ContinuationStyle.NoneEllipsisForPauses,
@@ -1625,7 +1624,7 @@ $HorzAlign = Center
SubtitleMaximumDisplayMilliseconds = 7000,
SubtitleMinimumDisplayMilliseconds = 1000,
SubtitleMaximumWordsPerMinute = 300,
- CpsIncludesSpace = true,
+ CpsLineLengthStrategy = string.Empty,
MinimumMillisecondsBetweenLines = 84, // 2 frames for 23.976 fps videos
DialogStyle = DialogType.DashBothLinesWithoutSpace,
ContinuationStyle = ContinuationStyle.NoneEllipsisForPauses,
@@ -1641,7 +1640,7 @@ $HorzAlign = Center
SubtitleMaximumDisplayMilliseconds = 7000,
SubtitleMinimumDisplayMilliseconds = 1000,
SubtitleMaximumWordsPerMinute = 300,
- CpsIncludesSpace = true,
+ CpsLineLengthStrategy = string.Empty,
MinimumMillisecondsBetweenLines = 84, // 2 frames for 23.976 fps videos
DialogStyle = DialogType.DashSecondLineWithoutSpace,
ContinuationStyle = ContinuationStyle.NoneEllipsisForPauses,
@@ -1657,7 +1656,7 @@ $HorzAlign = Center
SubtitleMaximumDisplayMilliseconds = 10000,
SubtitleMinimumDisplayMilliseconds = 1000,
SubtitleMaximumWordsPerMinute = 300,
- CpsIncludesSpace = true,
+ CpsLineLengthStrategy = string.Empty,
MinimumMillisecondsBetweenLines = 200, // 5 frames for 25 fps videos
DialogStyle = DialogType.DashBothLinesWithSpace,
ContinuationStyle = ContinuationStyle.None
@@ -1673,7 +1672,7 @@ $HorzAlign = Center
SubtitleMaximumDisplayMilliseconds = 7007,
SubtitleMinimumDisplayMilliseconds = 1400,
SubtitleMaximumWordsPerMinute = 280,
- CpsIncludesSpace = true,
+ CpsLineLengthStrategy = string.Empty,
MinimumMillisecondsBetweenLines = 125,
DialogStyle = DialogType.DashSecondLineWithoutSpace,
ContinuationStyle = ContinuationStyle.OnlyTrailingDots
@@ -1689,7 +1688,7 @@ $HorzAlign = Center
SubtitleMaximumDisplayMilliseconds = 7000,
SubtitleMinimumDisplayMilliseconds = 1400,
SubtitleMaximumWordsPerMinute = 280,
- CpsIncludesSpace = true,
+ CpsLineLengthStrategy = string.Empty,
MinimumMillisecondsBetweenLines = 120,
DialogStyle = DialogType.DashSecondLineWithoutSpace,
ContinuationStyle = ContinuationStyle.OnlyTrailingDots
@@ -1705,7 +1704,7 @@ $HorzAlign = Center
SubtitleMaximumDisplayMilliseconds = 7007,
SubtitleMinimumDisplayMilliseconds = 1200,
SubtitleMaximumWordsPerMinute = 300,
- CpsIncludesSpace = true,
+ CpsLineLengthStrategy = string.Empty,
MinimumMillisecondsBetweenLines = 125,
DialogStyle = DialogType.DashSecondLineWithSpace,
ContinuationStyle = ContinuationStyle.OnlyTrailingDots
@@ -1721,7 +1720,7 @@ $HorzAlign = Center
SubtitleMaximumDisplayMilliseconds = 7000,
SubtitleMinimumDisplayMilliseconds = 1200,
SubtitleMaximumWordsPerMinute = 300,
- CpsIncludesSpace = true,
+ CpsLineLengthStrategy = string.Empty,
MinimumMillisecondsBetweenLines = 120,
DialogStyle = DialogType.DashSecondLineWithSpace,
ContinuationStyle = ContinuationStyle.OnlyTrailingDots
@@ -1737,7 +1736,7 @@ $HorzAlign = Center
SubtitleMaximumDisplayMilliseconds = 8008,
SubtitleMinimumDisplayMilliseconds = 2002,
SubtitleMaximumWordsPerMinute = 280,
- CpsIncludesSpace = true,
+ CpsLineLengthStrategy = string.Empty,
MinimumMillisecondsBetweenLines = 125,
DialogStyle = DialogType.DashBothLinesWithSpace,
ContinuationStyle = ContinuationStyle.LeadingTrailingDashDots
@@ -1753,7 +1752,7 @@ $HorzAlign = Center
SubtitleMaximumDisplayMilliseconds = 8000,
SubtitleMinimumDisplayMilliseconds = 2000,
SubtitleMaximumWordsPerMinute = 280,
- CpsIncludesSpace = true,
+ CpsLineLengthStrategy = string.Empty,
MinimumMillisecondsBetweenLines = 120,
DialogStyle = DialogType.DashBothLinesWithSpace,
ContinuationStyle = ContinuationStyle.LeadingTrailingDashDots
@@ -1769,7 +1768,7 @@ $HorzAlign = Center
SubtitleMaximumDisplayMilliseconds = 5005,
SubtitleMinimumDisplayMilliseconds = 792,
SubtitleMaximumWordsPerMinute = 300,
- CpsIncludesSpace = true,
+ CpsLineLengthStrategy = string.Empty,
MinimumMillisecondsBetweenLines = 125,
DialogStyle = DialogType.DashBothLinesWithSpace,
ContinuationStyle = ContinuationStyle.None
@@ -1785,7 +1784,7 @@ $HorzAlign = Center
SubtitleMaximumDisplayMilliseconds = 5000,
SubtitleMinimumDisplayMilliseconds = 800,
SubtitleMaximumWordsPerMinute = 300,
- CpsIncludesSpace = true,
+ CpsLineLengthStrategy = string.Empty,
MinimumMillisecondsBetweenLines = 120,
DialogStyle = DialogType.DashBothLinesWithSpace,
ContinuationStyle = ContinuationStyle.None
@@ -1801,7 +1800,7 @@ $HorzAlign = Center
SubtitleMaximumDisplayMilliseconds = 5005,
SubtitleMinimumDisplayMilliseconds = 792,
SubtitleMaximumWordsPerMinute = 300,
- CpsIncludesSpace = true,
+ CpsLineLengthStrategy = string.Empty,
MinimumMillisecondsBetweenLines = 167,
DialogStyle = DialogType.DashBothLinesWithSpace,
ContinuationStyle = ContinuationStyle.None
@@ -1817,7 +1816,7 @@ $HorzAlign = Center
SubtitleMaximumDisplayMilliseconds = 5000,
SubtitleMinimumDisplayMilliseconds = 800,
SubtitleMaximumWordsPerMinute = 300,
- CpsIncludesSpace = true,
+ CpsLineLengthStrategy = string.Empty,
MinimumMillisecondsBetweenLines = 160,
DialogStyle = DialogType.DashBothLinesWithSpace,
ContinuationStyle = ContinuationStyle.None
@@ -1833,7 +1832,7 @@ $HorzAlign = Center
SubtitleMaximumDisplayMilliseconds = 5005,
SubtitleMinimumDisplayMilliseconds = 792,
SubtitleMaximumWordsPerMinute = 300,
- CpsIncludesSpace = true,
+ CpsLineLengthStrategy = string.Empty,
MinimumMillisecondsBetweenLines = 250,
DialogStyle = DialogType.DashBothLinesWithSpace,
ContinuationStyle = ContinuationStyle.None
@@ -1849,7 +1848,7 @@ $HorzAlign = Center
SubtitleMaximumDisplayMilliseconds = 5000,
SubtitleMinimumDisplayMilliseconds = 800,
SubtitleMaximumWordsPerMinute = 300,
- CpsIncludesSpace = true,
+ CpsLineLengthStrategy = string.Empty,
MinimumMillisecondsBetweenLines = 240,
DialogStyle = DialogType.DashBothLinesWithSpace,
ContinuationStyle = ContinuationStyle.None
@@ -2871,7 +2870,7 @@ $HorzAlign = Center
var subtitleMinimumDisplayMilliseconds = listNode.SelectSingleNode("SubtitleMinimumDisplayMilliseconds")?.InnerText;
var subtitleMaximumDisplayMilliseconds = listNode.SelectSingleNode("SubtitleMaximumDisplayMilliseconds")?.InnerText;
var subtitleMaximumWordsPerMinute = listNode.SelectSingleNode("SubtitleMaximumWordsPerMinute")?.InnerText;
- var cpsIncludesSpace = listNode.SelectSingleNode("CpsIncludesSpace")?.InnerText;
+ var cpsLineLengthStrategy = listNode.SelectSingleNode("CpsLineLengthStrategy")?.InnerText;
var maxNumberOfLines = listNode.SelectSingleNode("MaxNumberOfLines")?.InnerText;
var mergeLinesShorterThan = listNode.SelectSingleNode("MergeLinesShorterThan")?.InnerText;
var minimumMillisecondsBetweenLines = listNode.SelectSingleNode("MinimumMillisecondsBetweenLines")?.InnerText;
@@ -2931,7 +2930,7 @@ $HorzAlign = Center
SubtitleMinimumDisplayMilliseconds = Convert.ToInt32(subtitleMinimumDisplayMilliseconds, CultureInfo.InvariantCulture),
SubtitleMaximumDisplayMilliseconds = Convert.ToInt32(subtitleMaximumDisplayMilliseconds, CultureInfo.InvariantCulture),
SubtitleMaximumWordsPerMinute = Convert.ToDecimal(subtitleMaximumWordsPerMinute, CultureInfo.InvariantCulture),
- CpsIncludesSpace = Convert.ToBoolean(cpsIncludesSpace, CultureInfo.InvariantCulture),
+ CpsLineLengthStrategy = cpsLineLengthStrategy,
MaxNumberOfLines = Convert.ToInt32(maxNumberOfLines, CultureInfo.InvariantCulture),
MergeLinesShorterThan = Convert.ToInt32(mergeLinesShorterThan, CultureInfo.InvariantCulture),
MinimumMillisecondsBetweenLines = Convert.ToInt32(minimumMillisecondsBetweenLines, CultureInfo.InvariantCulture),
@@ -3362,16 +3361,10 @@ $HorzAlign = Center
settings.General.SubtitleOptimalCharactersPerSeconds = Convert.ToDouble(subNode.InnerText, CultureInfo.InvariantCulture);
}
- subNode = node.SelectSingleNode("CharactersPerSecondsIgnoreWhiteSpace");
+ subNode = node.SelectSingleNode("CpsLineLengthStrategy");
if (subNode != null)
{
- settings.General.CharactersPerSecondsIgnoreWhiteSpace = Convert.ToBoolean(subNode.InnerText, CultureInfo.InvariantCulture);
- }
-
- subNode = node.SelectSingleNode("IgnoreArabicDiacritics");
- if (subNode != null)
- {
- settings.General.IgnoreArabicDiacritics = Convert.ToBoolean(subNode.InnerText, CultureInfo.InvariantCulture);
+ settings.General.CpsLineLengthStrategy = subNode.InnerText;
}
subNode = node.SelectSingleNode("SubtitleMaximumWordsPerMinute");
@@ -7289,7 +7282,7 @@ $HorzAlign = Center
SubtitleMaximumDisplayMilliseconds = settings.General.SubtitleMaximumDisplayMilliseconds,
SubtitleMinimumDisplayMilliseconds = settings.General.SubtitleMinimumDisplayMilliseconds,
SubtitleMaximumWordsPerMinute = (decimal)settings.General.SubtitleMaximumWordsPerMinute,
- CpsIncludesSpace = !settings.General.CharactersPerSecondsIgnoreWhiteSpace,
+ CpsLineLengthStrategy = settings.General.CpsLineLengthStrategy,
MinimumMillisecondsBetweenLines = settings.General.MinimumMillisecondsBetweenLines,
DialogStyle = settings.General.DialogStyle,
ContinuationStyle = settings.General.ContinuationStyle
@@ -9279,7 +9272,7 @@ $HorzAlign = Center
textWriter.WriteElementString("SubtitleMaximumDisplayMilliseconds", profile.SubtitleMaximumDisplayMilliseconds.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("SubtitleMaximumWordsPerMinute", profile.SubtitleMaximumWordsPerMinute.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("MinimumMillisecondsBetweenLines", profile.MinimumMillisecondsBetweenLines.ToString(CultureInfo.InvariantCulture));
- textWriter.WriteElementString("CpsIncludesSpace", profile.CpsIncludesSpace.ToString(CultureInfo.InvariantCulture));
+ textWriter.WriteElementString("CpsLineLengthStrategy", profile.CpsLineLengthStrategy);
textWriter.WriteElementString("MaxNumberOfLines", profile.MaxNumberOfLines.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("MergeLinesShorterThan", profile.MergeLinesShorterThan.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("DialogStyle", profile.DialogStyle.ToString());
@@ -9357,8 +9350,7 @@ $HorzAlign = Center
textWriter.WriteElementString("AutoWrapLineWhileTyping", settings.General.AutoWrapLineWhileTyping.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("SubtitleMaximumCharactersPerSeconds", settings.General.SubtitleMaximumCharactersPerSeconds.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("SubtitleOptimalCharactersPerSeconds", settings.General.SubtitleOptimalCharactersPerSeconds.ToString(CultureInfo.InvariantCulture));
- textWriter.WriteElementString("CharactersPerSecondsIgnoreWhiteSpace", settings.General.CharactersPerSecondsIgnoreWhiteSpace.ToString(CultureInfo.InvariantCulture));
- textWriter.WriteElementString("IgnoreArabicDiacritics", settings.General.IgnoreArabicDiacritics.ToString(CultureInfo.InvariantCulture));
+ textWriter.WriteElementString("CpsLineLengthStrategy", settings.General.CpsLineLengthStrategy);
textWriter.WriteElementString("SubtitleMaximumWordsPerMinute", settings.General.SubtitleMaximumWordsPerMinute.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("DialogStyle", settings.General.DialogStyle.ToString());
textWriter.WriteElementString("ContinuationStyle", settings.General.ContinuationStyle.ToString());
diff --git a/src/libse/Common/StringExtensions.cs b/src/libse/Common/StringExtensions.cs
index 2dde8fa1d..cba5d7fbf 100644
--- a/src/libse/Common/StringExtensions.cs
+++ b/src/libse/Common/StringExtensions.cs
@@ -1,4 +1,5 @@
-using System;
+using Nikse.SubtitleEdit.Core.Common.TextLengthCalculator;
+using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
@@ -34,7 +35,7 @@ namespace Nikse.SubtitleEdit.Core.Common
}
//
- if (threeLengthTag && len > 3 && text[len - 4] == '<' && text[len - 3] == '/')
+ if (threeLengthTag && text[len - 4] == '<' && text[len - 3] == '/')
{
return true;
}
@@ -538,75 +539,14 @@ namespace Nikse.SubtitleEdit.Core.Common
/// Count characters excl. white spaces, ssa-tags, html-tags, control-characters, normal spaces and
/// Arabic diacritics depending on parameter.
///
- public static int CountCharacters(this string value, bool removeNormalSpace, bool ignoreArabicDiacritics)
+ public static int CountCharacters(this string value, string strategy)
{
- int length = 0;
- const char zeroWidthSpace = '\u200B';
- const char zeroWidthNoBreakSpace = '\uFEFF';
- char normalSpace = removeNormalSpace ? ' ' : zeroWidthSpace;
- bool ssaTagOn = false;
- bool htmlTagOn = false;
- var max = value.Length;
- for (int i = 0; i < max; i++)
- {
- char ch = value[i];
- if (ssaTagOn)
- {
- if (ch == '}')
- {
- ssaTagOn = false;
- }
- }
- else if (htmlTagOn)
- {
- if (ch == '>')
- {
- htmlTagOn = false;
- }
- }
- else if (ch == '{' && i < value.Length - 1 && value[i + 1] == '\\')
- {
- ssaTagOn = true;
- }
- else if (ch == '<' && i < value.Length - 1 && (value[i + 1] == '/' || char.IsLetter(value[i + 1])) &&
- value.IndexOf('>', i) > 0 && IsKnownHtmlTag(value, i))
- {
- htmlTagOn = true;
- }
- else if (!char.IsControl(ch) &&
- ch != zeroWidthSpace &&
- ch != zeroWidthNoBreakSpace &&
- ch != normalSpace &&
- ch != '\u200E' &&
- ch != '\u200F' &&
- ch != '\u202A' &&
- ch != '\u202B' &&
- ch != '\u202C' &&
- ch != '\u202D' &&
- ch != '\u202E' &&
- !(ignoreArabicDiacritics && ch >= '\u064B' && ch <= '\u0653'))
- {
- length++;
- }
- }
-
- return length;
+ return (int)Math.Round(CalcFactory.MakeCalculator(strategy).CountCharacters(value), MidpointRounding.AwayFromZero);
}
- private static bool IsKnownHtmlTag(string input, int idx)
+ public static decimal CountCharacters(this string value)
{
- var s = input.Remove(0, idx + 1).ToLowerInvariant();
- return s.StartsWith('/') ||
- s.StartsWith("i>", StringComparison.Ordinal) ||
- s.StartsWith("b>", StringComparison.Ordinal) ||
- s.StartsWith("u>", StringComparison.Ordinal) ||
- s.StartsWith("font ", StringComparison.Ordinal) ||
- s.StartsWith("ruby", StringComparison.Ordinal) ||
- s.StartsWith("span>", StringComparison.Ordinal) ||
- s.StartsWith("p>", StringComparison.Ordinal) ||
- s.StartsWith("br>", StringComparison.Ordinal) ||
- s.StartsWith("div>", StringComparison.Ordinal) ||
- s.StartsWith("div ", StringComparison.Ordinal);
+ return CalcFactory.MakeCalculator(Configuration.Settings.General.CpsLineLengthStrategy).CountCharacters(value);
}
public static bool HasSentenceEnding(this string value)
diff --git a/src/libse/Common/Subtitle.cs b/src/libse/Common/Subtitle.cs
index 3af7ecf03..313af5c8b 100644
--- a/src/libse/Common/Subtitle.cs
+++ b/src/libse/Common/Subtitle.cs
@@ -488,7 +488,7 @@ namespace Nikse.SubtitleEdit.Core.Common
var duration = Utilities.GetOptimalDisplayMilliseconds(p.Text, optimalCharactersPerSeconds, onlyOptimal);
p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + duration;
- var numberOfCharacters = p.Text.CountCharacters(Configuration.Settings.General.CharactersPerSecondsIgnoreWhiteSpace, Configuration.Settings.General.IgnoreArabicDiacritics);
+ var numberOfCharacters = p.Text.CountCharacters();
while (Utilities.GetCharactersPerSecond(p, numberOfCharacters) > maxCharactersPerSecond)
{
duration++;
diff --git a/src/libse/Common/TextLengthCalculator/CalcAll.cs b/src/libse/Common/TextLengthCalculator/CalcAll.cs
index 155867422..7b611ea39 100644
--- a/src/libse/Common/TextLengthCalculator/CalcAll.cs
+++ b/src/libse/Common/TextLengthCalculator/CalcAll.cs
@@ -3,9 +3,9 @@
public class CalcAll : ICalcLength
{
///
- /// Calculate all text including space (tags are not counted).
+ /// Calculate length of all text including space (tags are not counted).
///
- public decimal CalculateLength(string text)
+ public decimal CountCharacters(string text)
{
const char zeroWidthSpace = '\u200B';
const char zeroWidthNoBreakSpace = '\uFEFF';
diff --git a/src/libse/Common/TextLengthCalculator/CalcCJK.cs b/src/libse/Common/TextLengthCalculator/CalcCJK.cs
index 2dbbeb37b..fe7e893a8 100644
--- a/src/libse/Common/TextLengthCalculator/CalcCJK.cs
+++ b/src/libse/Common/TextLengthCalculator/CalcCJK.cs
@@ -1,18 +1,18 @@
namespace Nikse.SubtitleEdit.Core.Common.TextLengthCalculator
{
- public class CalcCJK : ICalcLength
+ public class CalcCjk : ICalcLength
{
///
/// Calculate all text including space (tags are not counted).
///
- public decimal CalculateLength(string text)
+ public decimal CountCharacters(string text)
{
if (string.IsNullOrEmpty(text))
{
return 0;
}
- const string chineseHalfWidthCharacters = "。「」、・ヲァィゥェォャュョッーアイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙゚";
+ const string japaneseHalfWidthCharacters = "。「」、・ヲァィゥェォャュョッーアイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙゚";
const char zeroWidthSpace = '\u200B';
const char zeroWidthNoBreakSpace = '\uFEFF';
var count = 0m;
@@ -59,7 +59,7 @@
var number = char.GetNumericValue(ch);
if (number >= 0x4E00 && number <= 0x2FA1F)
{
- if (chineseHalfWidthCharacters.Contains(ch))
+ if (japaneseHalfWidthCharacters.Contains(ch))
{
count += 0.5m;
}
diff --git a/src/libse/Common/TextLengthCalculator/CalcCJKNoSpace.cs b/src/libse/Common/TextLengthCalculator/CalcCJKNoSpace.cs
index d0f8392cc..1778838dc 100644
--- a/src/libse/Common/TextLengthCalculator/CalcCJKNoSpace.cs
+++ b/src/libse/Common/TextLengthCalculator/CalcCJKNoSpace.cs
@@ -1,18 +1,18 @@
namespace Nikse.SubtitleEdit.Core.Common.TextLengthCalculator
{
- public class CalcCJKNoSpace : ICalcLength
+ public class CalcCjkNoSpace : ICalcLength
{
///
/// Calculate all text including space (tags are not counted).
///
- public decimal CalculateLength(string text)
+ public decimal CountCharacters(string text)
{
if (string.IsNullOrEmpty(text))
{
return 0;
}
- const string chineseHalfWidthCharacters = "。「」、・ヲァィゥェォャュョッーアイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙゚";
+ const string japaneseHalfWidthCharacters = "。「」、・ヲァィゥェォャュョッーアイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙゚";
const char zeroWidthSpace = '\u200B';
const char zeroWidthNoBreakSpace = '\uFEFF';
var count = 0m;
@@ -60,7 +60,7 @@
var number = char.GetNumericValue(ch);
if (number >= 0x4E00 && number <= 0x2FA1F)
{
- if (chineseHalfWidthCharacters.Contains(ch))
+ if (japaneseHalfWidthCharacters.Contains(ch))
{
count += 0.5m;
}
diff --git a/src/libse/Common/TextLengthCalculator/CalcFactory.cs b/src/libse/Common/TextLengthCalculator/CalcFactory.cs
index 986eecd4b..30d80e34c 100644
--- a/src/libse/Common/TextLengthCalculator/CalcFactory.cs
+++ b/src/libse/Common/TextLengthCalculator/CalcFactory.cs
@@ -9,8 +9,10 @@ namespace Nikse.SubtitleEdit.Core.Common.TextLengthCalculator
{
new CalcAll(),
new CalcNoSpace(),
- new CalcCJK(),
- new CalcCJKNoSpace(),
+ new CalcCjk(),
+ new CalcCjkNoSpace(),
+ new CalcIgnoreArabicDiacritics(),
+ new CalcIgnoreArabicDiacriticsNoSpace()
};
public static ICalcLength MakeCalculator(string strategy)
diff --git a/src/libse/Common/TextLengthCalculator/CalcIgnoreArabicDiacritics.cs b/src/libse/Common/TextLengthCalculator/CalcIgnoreArabicDiacritics.cs
new file mode 100644
index 000000000..c649144ec
--- /dev/null
+++ b/src/libse/Common/TextLengthCalculator/CalcIgnoreArabicDiacritics.cs
@@ -0,0 +1,61 @@
+namespace Nikse.SubtitleEdit.Core.Common.TextLengthCalculator
+{
+ public class CalcIgnoreArabicDiacritics : ICalcLength
+ {
+ ///
+ /// Calculate all text including space (tags are not counted).
+ ///
+ public decimal CountCharacters(string text)
+ {
+ const char zeroWidthSpace = '\u200B';
+ const char zeroWidthNoBreakSpace = '\uFEFF';
+ var length = 0;
+ var ssaTagOn = false;
+ var htmlTagOn = false;
+ var max = text.Length;
+ for (var i = 0; i < max; i++)
+ {
+ var ch = text[i];
+ if (ssaTagOn)
+ {
+ if (ch == '}')
+ {
+ ssaTagOn = false;
+ }
+ }
+ else if (htmlTagOn)
+ {
+ if (ch == '>')
+ {
+ htmlTagOn = false;
+ }
+ }
+ else if (ch == '{' && i < text.Length - 1 && text[i + 1] == '\\')
+ {
+ ssaTagOn = true;
+ }
+ else if (ch == '<' && i < text.Length - 1 && (text[i + 1] == '/' || char.IsLetter(text[i + 1])) &&
+ text.IndexOf('>', i) > 0 && TextLengthHelper.IsKnownHtmlTag(text, i))
+ {
+ htmlTagOn = true;
+ }
+ else if (!char.IsControl(ch) &&
+ ch != zeroWidthSpace &&
+ ch != zeroWidthNoBreakSpace &&
+ ch != '\u200E' &&
+ ch != '\u200F' &&
+ ch != '\u202A' &&
+ ch != '\u202B' &&
+ ch != '\u202C' &&
+ ch != '\u202D' &&
+ ch != '\u202E' &&
+ !(ch >= '\u064B' && ch <= '\u0653'))
+ {
+ length++;
+ }
+ }
+
+ return length;
+ }
+ }
+}
diff --git a/src/libse/Common/TextLengthCalculator/CalcIgnoreArabicDiacriticsNoSpace.cs b/src/libse/Common/TextLengthCalculator/CalcIgnoreArabicDiacriticsNoSpace.cs
new file mode 100644
index 000000000..e9fc272ec
--- /dev/null
+++ b/src/libse/Common/TextLengthCalculator/CalcIgnoreArabicDiacriticsNoSpace.cs
@@ -0,0 +1,62 @@
+namespace Nikse.SubtitleEdit.Core.Common.TextLengthCalculator
+{
+ public class CalcIgnoreArabicDiacriticsNoSpace : ICalcLength
+ {
+ ///
+ /// Calculate all text including space (tags are not counted).
+ ///
+ public decimal CountCharacters(string text)
+ {
+ const char zeroWidthSpace = '\u200B';
+ const char zeroWidthNoBreakSpace = '\uFEFF';
+ var length = 0;
+ var ssaTagOn = false;
+ var htmlTagOn = false;
+ var max = text.Length;
+ for (var i = 0; i < max; i++)
+ {
+ var ch = text[i];
+ if (ssaTagOn)
+ {
+ if (ch == '}')
+ {
+ ssaTagOn = false;
+ }
+ }
+ else if (htmlTagOn)
+ {
+ if (ch == '>')
+ {
+ htmlTagOn = false;
+ }
+ }
+ else if (ch == '{' && i < text.Length - 1 && text[i + 1] == '\\')
+ {
+ ssaTagOn = true;
+ }
+ else if (ch == '<' && i < text.Length - 1 && (text[i + 1] == '/' || char.IsLetter(text[i + 1])) &&
+ text.IndexOf('>', i) > 0 && TextLengthHelper.IsKnownHtmlTag(text, i))
+ {
+ htmlTagOn = true;
+ }
+ else if (!char.IsControl(ch) &&
+ ch != ' ' &&
+ ch != zeroWidthSpace &&
+ ch != zeroWidthNoBreakSpace &&
+ ch != '\u200E' &&
+ ch != '\u200F' &&
+ ch != '\u202A' &&
+ ch != '\u202B' &&
+ ch != '\u202C' &&
+ ch != '\u202D' &&
+ ch != '\u202E' &&
+ !(ch >= '\u064B' && ch <= '\u0653'))
+ {
+ length++;
+ }
+ }
+
+ return length;
+ }
+ }
+}
diff --git a/src/libse/Common/TextLengthCalculator/CalcNoSpace.cs b/src/libse/Common/TextLengthCalculator/CalcNoSpace.cs
index dc0c842b8..7d2dcd752 100644
--- a/src/libse/Common/TextLengthCalculator/CalcNoSpace.cs
+++ b/src/libse/Common/TextLengthCalculator/CalcNoSpace.cs
@@ -5,7 +5,7 @@
///
/// Calculate all text excluding space (tags are not counted).
///
- public decimal CalculateLength(string text)
+ public decimal CountCharacters(string text)
{
const char zeroWidthSpace = '\u200B';
const char zeroWidthNoBreakSpace = '\uFEFF';
diff --git a/src/libse/Common/TextLengthCalculator/ICalcLength.cs b/src/libse/Common/TextLengthCalculator/ICalcLength.cs
index e6e6545da..46162cdb9 100644
--- a/src/libse/Common/TextLengthCalculator/ICalcLength.cs
+++ b/src/libse/Common/TextLengthCalculator/ICalcLength.cs
@@ -2,6 +2,6 @@
{
public interface ICalcLength
{
- decimal CalculateLength(string text);
+ decimal CountCharacters(string text);
}
}
\ No newline at end of file
diff --git a/src/libse/Common/TextLengthCalculator/TextLengthHelper.cs b/src/libse/Common/TextLengthCalculator/TextLengthHelper.cs
index 15385d8c7..972421e87 100644
--- a/src/libse/Common/TextLengthCalculator/TextLengthHelper.cs
+++ b/src/libse/Common/TextLengthCalculator/TextLengthHelper.cs
@@ -4,9 +4,14 @@ namespace Nikse.SubtitleEdit.Core.Common.TextLengthCalculator
{
public static class TextLengthHelper
{
- public static bool IsKnownHtmlTag(string input, int idx)
+ public static decimal CountCharacters(string text)
{
- var s = input.Remove(0, idx + 1).ToLowerInvariant();
+ return CalcFactory.MakeCalculator(Configuration.Settings.General.CpsLineLengthStrategy).CountCharacters(text);
+ }
+
+ public static bool IsKnownHtmlTag(string input, int index)
+ {
+ var s = input.Remove(0, index + 1).ToLowerInvariant();
return s.StartsWith('/') ||
s.StartsWith("i>", StringComparison.Ordinal) ||
s.StartsWith("b>", StringComparison.Ordinal) ||
@@ -14,8 +19,10 @@ namespace Nikse.SubtitleEdit.Core.Common.TextLengthCalculator
s.StartsWith("font ", StringComparison.Ordinal) ||
s.StartsWith("ruby", StringComparison.Ordinal) ||
s.StartsWith("span>", StringComparison.Ordinal) ||
+ s.StartsWith("span ", StringComparison.Ordinal) ||
s.StartsWith("p>", StringComparison.Ordinal) ||
s.StartsWith("br>", StringComparison.Ordinal) ||
+ s.StartsWith("box>", StringComparison.Ordinal) ||
s.StartsWith("div>", StringComparison.Ordinal) ||
s.StartsWith("div ", StringComparison.Ordinal);
}
diff --git a/src/libse/Common/Utilities.cs b/src/libse/Common/Utilities.cs
index 1a9b3712b..b059f19b5 100644
--- a/src/libse/Common/Utilities.cs
+++ b/src/libse/Common/Utilities.cs
@@ -12,6 +12,7 @@ using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Xml;
+using Nikse.SubtitleEdit.Core.Common.TextLengthCalculator;
namespace Nikse.SubtitleEdit.Core.Common
{
@@ -552,7 +553,7 @@ namespace Nikse.SubtitleEdit.Core.Common
}
string s = RemoveLineBreaks(text);
- if (s.CountCharacters(false, Configuration.Settings.General.IgnoreArabicDiacritics) < mergeLinesShorterThan)
+ if (s.CountCharacters() < mergeLinesShorterThan)
{
var lastIndexOfDash = s.LastIndexOf(" -", StringComparison.Ordinal);
if (Configuration.Settings.Tools.AutoBreakDashEarly && lastIndexOfDash > 4 && s.Substring(0, lastIndexOfDash).HasSentenceEnding(language))
@@ -914,7 +915,7 @@ namespace Nikse.SubtitleEdit.Core.Common
optimalCharactersPerSecond = 14.7;
}
- var duration = text.CountCharacters(Configuration.Settings.General.CharactersPerSecondsIgnoreWhiteSpace, Configuration.Settings.General.IgnoreArabicDiacritics) / optimalCharactersPerSecond * TimeCode.BaseUnit;
+ var duration = (double)text.CountCharacters() / optimalCharactersPerSecond * TimeCode.BaseUnit;
if (!onlyOptimal)
{
@@ -976,7 +977,18 @@ namespace Nikse.SubtitleEdit.Core.Common
return 999;
}
- return paragraph.Text.CountCharacters(Configuration.Settings.General.CharactersPerSecondsIgnoreWhiteSpace, Configuration.Settings.General.IgnoreArabicDiacritics) / duration.TotalSeconds;
+ return (double)paragraph.Text.CountCharacters() / duration.TotalSeconds;
+ }
+
+ public static double GetCharactersPerSecond(Paragraph paragraph, ICalcLength calc)
+ {
+ var duration = paragraph.Duration;
+ if (duration.TotalMilliseconds < 1)
+ {
+ return 999;
+ }
+
+ return (double)calc.CountCharacters(paragraph.Text) / duration.TotalSeconds;
}
public static double GetCharactersPerSecond(Paragraph paragraph, int numberOfCharacters)
@@ -990,6 +1002,16 @@ namespace Nikse.SubtitleEdit.Core.Common
return numberOfCharacters / duration.TotalSeconds;
}
+ public static double GetCharactersPerSecond(Paragraph paragraph, decimal numberOfCharacters)
+ {
+ var duration = paragraph.Duration;
+ if (duration.TotalMilliseconds < 1)
+ {
+ return 999;
+ }
+
+ return (double)numberOfCharacters / duration.TotalSeconds;
+ }
public static bool IsRunningOnMono()
{
diff --git a/src/libse/Forms/FixCommonErrors/FixLongLines.cs b/src/libse/Forms/FixCommonErrors/FixLongLines.cs
index ef24434dd..20924967c 100644
--- a/src/libse/Forms/FixCommonErrors/FixLongLines.cs
+++ b/src/libse/Forms/FixCommonErrors/FixLongLines.cs
@@ -14,16 +14,16 @@ namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
public void Fix(Subtitle subtitle, IFixCallbacks callbacks)
{
- string fixAction = Language.BreakLongLine;
- int noOfLongLines = 0;
- for (int i = 0; i < subtitle.Paragraphs.Count; i++)
+ var fixAction = Language.BreakLongLine;
+ var noOfLongLines = 0;
+ for (var i = 0; i < subtitle.Paragraphs.Count; i++)
{
- Paragraph p = subtitle.Paragraphs[i];
+ var p = subtitle.Paragraphs[i];
var lines = p.Text.SplitToLines();
- bool tooLong = false;
- foreach (string line in lines)
+ var tooLong = false;
+ foreach (var line in lines)
{
- if (line.CountCharacters(false, Configuration.Settings.General.IgnoreArabicDiacritics) > Configuration.Settings.General.SubtitleLineMaximumLength)
+ if (line.CountCharacters() > Configuration.Settings.General.SubtitleLineMaximumLength)
{
tooLong = true;
break;
diff --git a/src/libse/Forms/FixCommonErrors/FixShortDisplayTimes.cs b/src/libse/Forms/FixCommonErrors/FixShortDisplayTimes.cs
index fc89b68a7..5f27fa82a 100644
--- a/src/libse/Forms/FixCommonErrors/FixShortDisplayTimes.cs
+++ b/src/libse/Forms/FixCommonErrors/FixShortDisplayTimes.cs
@@ -70,7 +70,7 @@ namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
if (!skip && charactersPerSecond > Configuration.Settings.General.SubtitleMaximumCharactersPerSeconds)
{
var temp = new Paragraph(p);
- var numberOfCharacters = temp.Text.CountCharacters(Configuration.Settings.General.CharactersPerSecondsIgnoreWhiteSpace, Configuration.Settings.General.IgnoreArabicDiacritics);
+ var numberOfCharacters = temp.Text.CountCharacters();
while (Utilities.GetCharactersPerSecond(temp, numberOfCharacters) > Configuration.Settings.General.SubtitleMaximumCharactersPerSeconds)
{
temp.EndTime.TotalMilliseconds++;
diff --git a/src/libse/Forms/FixCommonErrors/FixShortLinesAll.cs b/src/libse/Forms/FixCommonErrors/FixShortLinesAll.cs
index 9f65c6493..993d688ce 100644
--- a/src/libse/Forms/FixCommonErrors/FixShortLinesAll.cs
+++ b/src/libse/Forms/FixCommonErrors/FixShortLinesAll.cs
@@ -22,7 +22,7 @@ namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
if (callbacks.AllowFix(p, fixAction))
{
string s = HtmlUtil.RemoveHtmlTags(p.Text, true);
- if (s.Contains(Environment.NewLine) && s.Replace(Environment.NewLine, " ").Replace(" ", " ").CountCharacters(false, Configuration.Settings.General.IgnoreArabicDiacritics) < Configuration.Settings.General.MergeLinesShorterThan)
+ if (s.Contains(Environment.NewLine) && s.Replace(Environment.NewLine, " ").Replace(" ", " ").CountCharacters() < Configuration.Settings.General.MergeLinesShorterThan)
{
s = Utilities.AutoBreakLine(p.Text, callbacks.Language);
if (s != p.Text)
diff --git a/src/libse/Forms/FixCommonErrors/Helper.cs b/src/libse/Forms/FixCommonErrors/Helper.cs
index 75553be94..c0d2f5166 100644
--- a/src/libse/Forms/FixCommonErrors/Helper.cs
+++ b/src/libse/Forms/FixCommonErrors/Helper.cs
@@ -617,7 +617,7 @@ namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
}
string s = HtmlUtil.RemoveHtmlTags(text, true);
- if (s.Contains(Environment.NewLine) && s.Replace(Environment.NewLine, " ").Replace(" ", " ").CountCharacters(false, Configuration.Settings.General.IgnoreArabicDiacritics) < Configuration.Settings.General.MergeLinesShorterThan)
+ if (s.Contains(Environment.NewLine) && s.Replace(Environment.NewLine, " ").Replace(" ", " ").CountCharacters() < Configuration.Settings.General.MergeLinesShorterThan)
{
s = s.TrimEnd().TrimEnd('.', '?', '!', ':', ';');
s = s.TrimStart('-');
diff --git a/src/libse/Forms/MoveWordUpDown.cs b/src/libse/Forms/MoveWordUpDown.cs
index 90da709ab..1f62742b8 100644
--- a/src/libse/Forms/MoveWordUpDown.cs
+++ b/src/libse/Forms/MoveWordUpDown.cs
@@ -226,10 +226,10 @@ namespace Nikse.SubtitleEdit.Core.Forms
private static string AutoBreakIfNeeded(string s)
{
- bool doBreak = false;
+ var doBreak = false;
foreach (var line in s.SplitToLines())
{
- if (line.CountCharacters(false, Configuration.Settings.General.IgnoreArabicDiacritics) > Configuration.Settings.General.SubtitleLineMaximumLength)
+ if (line.CountCharacters() > Configuration.Settings.General.SubtitleLineMaximumLength)
{
doBreak = true;
break;
@@ -238,6 +238,5 @@ namespace Nikse.SubtitleEdit.Core.Forms
return doBreak ? Utilities.AutoBreakLine(s) : s;
}
-
}
}
diff --git a/src/libse/NetflixQualityCheck/NetflixCheckMaxCps.cs b/src/libse/NetflixQualityCheck/NetflixCheckMaxCps.cs
index 083fc451b..ba745e1d1 100644
--- a/src/libse/NetflixQualityCheck/NetflixCheckMaxCps.cs
+++ b/src/libse/NetflixQualityCheck/NetflixCheckMaxCps.cs
@@ -1,4 +1,5 @@
using Nikse.SubtitleEdit.Core.Common;
+using Nikse.SubtitleEdit.Core.Common.TextLengthCalculator;
using Nikse.SubtitleEdit.Core.SubtitleFormats;
using System;
@@ -11,40 +12,35 @@ namespace Nikse.SubtitleEdit.Core.NetflixQualityCheck
{
public void Check(Subtitle subtitle, NetflixQualityController controller)
{
- var oldIgnoreWhiteSpace = Configuration.Settings.General.CharactersPerSecondsIgnoreWhiteSpace;
- try
+ ICalcLength calc = CalcFactory.MakeCalculator(nameof(CalcAll));
+ var charactersPerSecond = controller.CharactersPerSecond;
+ var comment = "Maximum " + charactersPerSecond + " characters per second";
+ foreach (var p in subtitle.Paragraphs)
{
- Configuration.Settings.General.CharactersPerSecondsIgnoreWhiteSpace = false;
-
- int charactersPerSecond = controller.CharactersPerSecond;
- string comment = "Maximum " + charactersPerSecond + " characters per second";
- foreach (Paragraph p in subtitle.Paragraphs)
+ var jp = new Paragraph(p);
+ if (controller.Language == "ja")
{
- var jp = new Paragraph(p);
- if (controller.Language == "ja")
+ jp.Text = HtmlUtil.RemoveHtmlTags(jp.Text, true);
+ jp.Text = NetflixImsc11Japanese.RemoveTags(jp.Text);
+ }
+
+ if (controller.Language == "ja" || controller.Language == "ko")
+ {
+ calc = CalcFactory.MakeCalculator(nameof(CalcCjk));
+ }
+
+ var charactersPerSeconds = Utilities.GetCharactersPerSecond(jp, calc);
+ if (charactersPerSeconds > charactersPerSecond && !p.StartTime.IsMaxTime)
+ {
+ var fixedParagraph = new Paragraph(p, false);
+ while (Utilities.GetCharactersPerSecond(fixedParagraph) > charactersPerSecond)
{
- jp.Text = HtmlUtil.RemoveHtmlTags(jp.Text, true);
- jp.Text = NetflixImsc11Japanese.RemoveTags(jp.Text);
+ fixedParagraph.EndTime.TotalMilliseconds++;
}
- var charactersPerSeconds = Utilities.GetCharactersPerSecond(jp);
- if (charactersPerSeconds > charactersPerSecond && !p.StartTime.IsMaxTime)
- {
- var fixedParagraph = new Paragraph(p, false);
- while (Utilities.GetCharactersPerSecond(fixedParagraph) > charactersPerSecond)
- {
- fixedParagraph.EndTime.TotalMilliseconds++;
- }
-
- controller.AddRecord(p, fixedParagraph, comment, FormattableString.Invariant($"CPS={charactersPerSeconds:0.##}"));
- }
+ controller.AddRecord(p, fixedParagraph, comment, FormattableString.Invariant($"CPS={charactersPerSeconds:0.##}"));
}
}
- finally
- {
- Configuration.Settings.General.CharactersPerSecondsIgnoreWhiteSpace = oldIgnoreWhiteSpace;
- }
}
-
}
}
diff --git a/src/libse/NetflixQualityCheck/NetflixCheckMaxLineLength.cs b/src/libse/NetflixQualityCheck/NetflixCheckMaxLineLength.cs
index 503644da1..5ec400393 100644
--- a/src/libse/NetflixQualityCheck/NetflixCheckMaxLineLength.cs
+++ b/src/libse/NetflixQualityCheck/NetflixCheckMaxLineLength.cs
@@ -25,7 +25,7 @@ namespace Nikse.SubtitleEdit.Core.NetflixQualityCheck
{
if (CalculateJapaneseLength(text) > 11)
{
- string comment = "Single vertical line length > 11";
+ var comment = "Single vertical line length > 11";
controller.AddRecord(p, p.StartTime.ToHHMMSSFF(), comment, line.Length.ToString(CultureInfo.InvariantCulture));
}
}
@@ -33,16 +33,16 @@ namespace Nikse.SubtitleEdit.Core.NetflixQualityCheck
{
if (CalculateJapaneseLength(text) > 13)
{
- string comment = "Single horizontal line length > 13";
+ var comment = "Single horizontal line length > 13";
controller.AddRecord(p, p.StartTime.ToHHMMSSFF(), comment, line.Length.ToString(CultureInfo.InvariantCulture));
}
}
}
- else if (line.CountCharacters(false, Configuration.Settings.General.IgnoreArabicDiacritics) > controller.SingleLineMaxLength)
+ else if (line.CountCharacters() > controller.SingleLineMaxLength)
{
var fixedParagraph = new Paragraph(p, false);
fixedParagraph.Text = Utilities.AutoBreakLine(fixedParagraph.Text, controller.SingleLineMaxLength, controller.SingleLineMaxLength - 3, controller.Language);
- string comment = "Single line length > " + controller.SingleLineMaxLength;
+ var comment = "Single line length > " + controller.SingleLineMaxLength;
controller.AddRecord(p, fixedParagraph, comment, line.Length.ToString(CultureInfo.InvariantCulture));
}
}
diff --git a/src/libse/NetflixQualityCheck/NetflixCheckNumberOfLines.cs b/src/libse/NetflixQualityCheck/NetflixCheckNumberOfLines.cs
index 31088fa02..48f78637c 100644
--- a/src/libse/NetflixQualityCheck/NetflixCheckNumberOfLines.cs
+++ b/src/libse/NetflixQualityCheck/NetflixCheckNumberOfLines.cs
@@ -11,7 +11,7 @@ namespace Nikse.SubtitleEdit.Core.NetflixQualityCheck
{
public void Check(Subtitle subtitle, NetflixQualityController controller)
{
- foreach (Paragraph p in subtitle.Paragraphs)
+ foreach (var p in subtitle.Paragraphs)
{
if (p.Text.SplitToLines().Count > 2)
{
@@ -21,16 +21,16 @@ namespace Nikse.SubtitleEdit.Core.NetflixQualityCheck
{
fixedParagraph = null; // cannot fix text
}
- string comment = "Two lines maximum";
+ var comment = "Two lines maximum";
controller.AddRecord(p, fixedParagraph, comment);
}
else if (p.Text.SplitToLines().Count == 2 && p.Text.Contains(Environment.NewLine) &&
- p.Text.Replace(Environment.NewLine, " ").Replace(" ", " ").CountCharacters(false, Configuration.Settings.General.IgnoreArabicDiacritics) <= controller.SingleLineMaxLength &&
+ p.Text.Replace(Environment.NewLine, " ").Replace(" ", " ").CountCharacters() <= controller.SingleLineMaxLength &&
p.Text != Utilities.AutoBreakLine(p.Text, controller.SingleLineMaxLength, controller.SingleLineMaxLength + 1, controller.Language))
{
var fixedParagraph = new Paragraph(p, false);
fixedParagraph.Text = Utilities.AutoBreakLine(fixedParagraph.Text, controller.SingleLineMaxLength, controller.SingleLineMaxLength + 1, controller.Language);
- string comment = "Text can fit on one line";
+ var comment = "Text can fit on one line";
controller.AddRecord(p, fixedParagraph, comment);
}
}
diff --git a/src/ui/Controls/SubtitleListView.cs b/src/ui/Controls/SubtitleListView.cs
index b8a922fea..767e3e972 100644
--- a/src/ui/Controls/SubtitleListView.cs
+++ b/src/ui/Controls/SubtitleListView.cs
@@ -1542,14 +1542,14 @@ namespace Nikse.SubtitleEdit.Controls
string s = HtmlUtil.RemoveHtmlTags(paragraph.Text, true);
foreach (string line in s.SplitToLines())
{
- if (line.CountCharacters(false, Configuration.Settings.General.IgnoreArabicDiacritics) > Configuration.Settings.General.SubtitleLineMaximumLength)
+ if (line.CountCharacters() > Configuration.Settings.General.SubtitleLineMaximumLength)
{
item.SubItems[ColumnIndexText].BackColor = Configuration.Settings.Tools.ListViewSyntaxErrorColor;
return;
}
}
int noOfLines = paragraph.NumberOfLines;
- if (s.CountCharacters(false, Configuration.Settings.General.IgnoreArabicDiacritics) <= Configuration.Settings.General.SubtitleLineMaximumLength * noOfLines)
+ if (s.CountCharacters() <= Configuration.Settings.General.SubtitleLineMaximumLength * noOfLines)
{
if (noOfLines > Configuration.Settings.General.MaxNumberOfLines && _settings.Tools.ListViewSyntaxMoreThanXLines)
{
diff --git a/src/ui/Forms/ErrorsGoTo.cs b/src/ui/Forms/ErrorsGoTo.cs
index ee2b8bb4c..85a887af6 100644
--- a/src/ui/Forms/ErrorsGoTo.cs
+++ b/src/ui/Forms/ErrorsGoTo.cs
@@ -115,7 +115,7 @@ namespace Nikse.SubtitleEdit.Forms
var s = HtmlUtil.RemoveHtmlTags(paragraph.Text, true);
foreach (var line in s.SplitToLines())
{
- var count = line.CountCharacters(false, Configuration.Settings.General.IgnoreArabicDiacritics);
+ var count = line.CountCharacters();
if (count > Configuration.Settings.General.SubtitleLineMaximumLength)
{
errors.Add($"Line too long: {count} > {Configuration.Settings.General.SubtitleLineMaximumLength}");
@@ -123,7 +123,7 @@ namespace Nikse.SubtitleEdit.Forms
}
var noOfLines = paragraph.NumberOfLines;
- if (s.CountCharacters(false, Configuration.Settings.General.IgnoreArabicDiacritics) <= Configuration.Settings.General.SubtitleLineMaximumLength * noOfLines)
+ if (s.CountCharacters() <= Configuration.Settings.General.SubtitleLineMaximumLength * noOfLines)
{
if (noOfLines > Configuration.Settings.General.MaxNumberOfLines)
{
diff --git a/src/ui/Forms/FixCommonErrors.cs b/src/ui/Forms/FixCommonErrors.cs
index d38d0a31c..314ca8a18 100644
--- a/src/ui/Forms/FixCommonErrors.cs
+++ b/src/ui/Forms/FixCommonErrors.cs
@@ -374,7 +374,7 @@ namespace Nikse.SubtitleEdit.Forms
{
ce.FixContinuationStyleTicked = false;
}
-
+
_fixActions = new List
{
new FixItem(_language.RemovedEmptyLinesUnsedLineBreaks, string.Empty, () => new FixEmptyLines().Fix(Subtitle, this), ce.EmptyLinesTicked),
@@ -1472,12 +1472,12 @@ namespace Nikse.SubtitleEdit.Forms
labelTextLineTotal.ForeColor = UiUtil.ForeColor;
buttonSplitLine.Visible = false;
var abl = Utilities.AutoBreakLine(s, _autoDetectGoogleLanguage).SplitToLines();
- if (abl.Count > Configuration.Settings.General.MaxNumberOfLines || abl.Any(li => li.CountCharacters(false, Configuration.Settings.General.IgnoreArabicDiacritics) > Configuration.Settings.General.SubtitleLineMaximumLength))
+ if (abl.Count > Configuration.Settings.General.MaxNumberOfLines || abl.Any(li => li.CountCharacters() > Configuration.Settings.General.SubtitleLineMaximumLength))
{
buttonSplitLine.Visible = true;
labelTextLineTotal.ForeColor = Color.Red;
}
- labelTextLineTotal.Text = string.Format(_languageGeneral.TotalLengthX, text.CountCharacters(false, Configuration.Settings.General.IgnoreArabicDiacritics));
+ labelTextLineTotal.Text = string.Format(_languageGeneral.TotalLengthX, text.CountCharacters());
}
private void ButtonFixesSelectAllClick(object sender, EventArgs e)
diff --git a/src/ui/Forms/Main.cs b/src/ui/Forms/Main.cs
index 73348f26f..5574234eb 100644
--- a/src/ui/Forms/Main.cs
+++ b/src/ui/Forms/Main.cs
@@ -5195,10 +5195,10 @@ namespace Nikse.SubtitleEdit.Forms
private void ShowSettings()
{
- string oldVideoPlayer = Configuration.Settings.General.VideoPlayer;
- string oldMpvVideoOutput = Configuration.Settings.General.MpvVideoOutputWindows;
- string oldListViewLineSeparatorString = Configuration.Settings.General.ListViewLineSeparatorString;
- bool oldCpsWhiteSpaceSetting = Configuration.Settings.General.CharactersPerSecondsIgnoreWhiteSpace;
+ var oldVideoPlayer = Configuration.Settings.General.VideoPlayer;
+ var oldMpvVideoOutput = Configuration.Settings.General.MpvVideoOutputWindows;
+ var oldListViewLineSeparatorString = Configuration.Settings.General.ListViewLineSeparatorString;
+ var oldCpsWhiteSpaceSetting = Configuration.Settings.General.CpsLineLengthStrategy;
string oldSubtitleFontSettings = Configuration.Settings.General.SubtitleFontName +
Configuration.Settings.General.SubtitleTextBoxFontBold +
Configuration.Settings.General.CenterSubtitleInTextBox +
@@ -5378,7 +5378,7 @@ namespace Nikse.SubtitleEdit.Forms
mediaPlayer.ShowFullscreenButton = Configuration.Settings.General.VideoPlayerShowFullscreenButton;
if (oldListViewLineSeparatorString != Configuration.Settings.General.ListViewLineSeparatorString ||
- oldCpsWhiteSpaceSetting != Configuration.Settings.General.CharactersPerSecondsIgnoreWhiteSpace)
+ oldCpsWhiteSpaceSetting != Configuration.Settings.General.CpsLineLengthStrategy)
{
SubtitleListview1.InitializeLanguage(_languageGeneral, Configuration.Settings);
SaveSubtitleListviewIndices();
@@ -9850,7 +9850,7 @@ namespace Nikse.SubtitleEdit.Forms
buttonSplitLine.Visible = false;
var s = text.Replace(Environment.NewLine, " ");
- var len = text.CountCharacters(false, Configuration.Settings.General.IgnoreArabicDiacritics);
+ var len = text.CountCharacters();
int numberOfLines = Utilities.GetNumberOfLines(text.Trim());
int maxLines = int.MaxValue;
@@ -9864,8 +9864,8 @@ namespace Nikse.SubtitleEdit.Forms
{
if (len <= Configuration.Settings.General.SubtitleLineMaximumLength * Math.Max(numberOfLines, 2) &&
splitLines.Count == 2 && splitLines[0].StartsWith('-') && splitLines[1].StartsWith('-') &&
- (splitLines[0].CountCharacters(false, Configuration.Settings.General.IgnoreArabicDiacritics) > Configuration.Settings.General.SubtitleLineMaximumLength ||
- splitLines[1].CountCharacters(false, Configuration.Settings.General.IgnoreArabicDiacritics) > Configuration.Settings.General.SubtitleLineMaximumLength))
+ (splitLines[0].CountCharacters() > Configuration.Settings.General.SubtitleLineMaximumLength ||
+ splitLines[1].CountCharacters() > Configuration.Settings.General.SubtitleLineMaximumLength))
{
if (buttonUnBreak.Visible)
{
@@ -9934,7 +9934,7 @@ namespace Nikse.SubtitleEdit.Forms
var lang = LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitle, 50);
var abl = Utilities.AutoBreakLine(s, lang).SplitToLines();
- if (abl.Count > maxLines || abl.Any(li => li.CountCharacters(false, Configuration.Settings.General.IgnoreArabicDiacritics) > Configuration.Settings.General.SubtitleLineMaximumLength))
+ if (abl.Count > maxLines || abl.Any(li => li.CountCharacters() > Configuration.Settings.General.SubtitleLineMaximumLength))
{
buttonSplitLine.Visible = buttonAutoBreak.Visible;
}
@@ -9958,7 +9958,7 @@ namespace Nikse.SubtitleEdit.Forms
var lang = LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitle, 50);
var abl = Utilities.AutoBreakLine(s, lang).SplitToLines();
- if (abl.Count > maxLines || abl.Any(li => li.CountCharacters(false, Configuration.Settings.General.IgnoreArabicDiacritics) > Configuration.Settings.General.SubtitleLineMaximumLength) &&
+ if (abl.Count > maxLines || abl.Any(li => li.CountCharacters() > Configuration.Settings.General.SubtitleLineMaximumLength) &&
!textBoxListViewTextOriginal.Visible)
{
buttonSplitLine.Visible = buttonAutoBreak.Visible;
@@ -28679,7 +28679,7 @@ namespace Nikse.SubtitleEdit.Forms
int pos = textBox.SelectionStart;
var textNoHtml = HtmlUtil.RemoveHtmlTags(text, true);
var s = textNoHtml.Replace(Environment.NewLine, string.Empty); // we don't count new line in total length... correct?
- int totalLength = s.CountCharacters(false, Configuration.Settings.General.IgnoreArabicDiacritics);
+ var totalLength = s.CountCharacters();
string totalL;
if (Configuration.Settings.Tools.ListViewSyntaxColorWideLines)
diff --git a/src/ui/Forms/Options/Settings.Designer.cs b/src/ui/Forms/Options/Settings.Designer.cs
index 61597f6bc..8da828067 100644
--- a/src/ui/Forms/Options/Settings.Designer.cs
+++ b/src/ui/Forms/Options/Settings.Designer.cs
@@ -40,12 +40,13 @@
this.comboBoxSaveAsFileNameFrom = new System.Windows.Forms.ComboBox();
this.labelSaveAsFileNameFrom = new System.Windows.Forms.Label();
this.groupBoxGeneralRules = new System.Windows.Forms.GroupBox();
+ this.comboBoxCpsLineLenCalc = new System.Windows.Forms.ComboBox();
+ this.labelCpsLineLenCalc = new System.Windows.Forms.Label();
this.buttonGapChoose = new System.Windows.Forms.Button();
this.comboBoxContinuationStyle = new System.Windows.Forms.ComboBox();
this.labelContinuationStyle = new System.Windows.Forms.Label();
this.labelDialogStyle = new System.Windows.Forms.Label();
this.comboBoxDialogStyle = new System.Windows.Forms.ComboBox();
- this.checkBoxCpsIncludeWhiteSpace = new System.Windows.Forms.CheckBox();
this.buttonEditProfile = new System.Windows.Forms.Button();
this.comboBoxRulesProfileName = new System.Windows.Forms.ComboBox();
this.labelRulesProfileName = new System.Windows.Forms.Label();
@@ -322,6 +323,9 @@
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.checkBoxShowFrameRate = new System.Windows.Forms.CheckBox();
this.groupBoxShowToolBarButtons = new System.Windows.Forms.GroupBox();
+ this.labelTBBurnIn = new System.Windows.Forms.Label();
+ this.pictureBoxTBBurnIn = new System.Windows.Forms.PictureBox();
+ this.checkBoxTBBurnIn = new System.Windows.Forms.CheckBox();
this.labelTBNetflixQualityCheck = new System.Windows.Forms.Label();
this.pictureBoxNetflixQualityCheck = new System.Windows.Forms.PictureBox();
this.checkBoxNetflixQualityCheck = new System.Windows.Forms.CheckBox();
@@ -422,9 +426,6 @@
this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.labelUpdateFileTypeAssociationsStatus = new System.Windows.Forms.Label();
this.imageListFileTypeAssociations = new System.Windows.Forms.ImageList(this.components);
- this.labelTBBurnIn = new System.Windows.Forms.Label();
- this.pictureBoxTBBurnIn = new System.Windows.Forms.PictureBox();
- this.checkBoxTBBurnIn = new System.Windows.Forms.CheckBox();
this.panelGeneral.SuspendLayout();
this.groupBoxMiscellaneous.SuspendLayout();
this.groupBoxGeneralRules.SuspendLayout();
@@ -473,6 +474,7 @@
this.panelToolBar.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBoxShowToolBarButtons.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBoxTBBurnIn)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxNetflixQualityCheck)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxTBRemoveTextForHi)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxTBFixCommonErrors)).BeginInit();
@@ -498,7 +500,6 @@
this.groupBoxProxySettings.SuspendLayout();
this.groupBoxProxyAuthentication.SuspendLayout();
this.panelFileTypeAssociations.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.pictureBoxTBBurnIn)).BeginInit();
this.SuspendLayout();
//
// buttonOK
@@ -654,12 +655,13 @@
//
// groupBoxGeneralRules
//
+ this.groupBoxGeneralRules.Controls.Add(this.comboBoxCpsLineLenCalc);
+ this.groupBoxGeneralRules.Controls.Add(this.labelCpsLineLenCalc);
this.groupBoxGeneralRules.Controls.Add(this.buttonGapChoose);
this.groupBoxGeneralRules.Controls.Add(this.comboBoxContinuationStyle);
this.groupBoxGeneralRules.Controls.Add(this.labelContinuationStyle);
this.groupBoxGeneralRules.Controls.Add(this.labelDialogStyle);
this.groupBoxGeneralRules.Controls.Add(this.comboBoxDialogStyle);
- this.groupBoxGeneralRules.Controls.Add(this.checkBoxCpsIncludeWhiteSpace);
this.groupBoxGeneralRules.Controls.Add(this.buttonEditProfile);
this.groupBoxGeneralRules.Controls.Add(this.comboBoxRulesProfileName);
this.groupBoxGeneralRules.Controls.Add(this.labelRulesProfileName);
@@ -688,6 +690,26 @@
this.groupBoxGeneralRules.TabStop = false;
this.groupBoxGeneralRules.Text = "Rules";
//
+ // comboBoxCpsLineLenCalc
+ //
+ this.comboBoxCpsLineLenCalc.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+ this.comboBoxCpsLineLenCalc.DropDownWidth = 170;
+ this.comboBoxCpsLineLenCalc.FormattingEnabled = true;
+ this.comboBoxCpsLineLenCalc.Location = new System.Drawing.Point(203, 351);
+ this.comboBoxCpsLineLenCalc.Name = "comboBoxCpsLineLenCalc";
+ this.comboBoxCpsLineLenCalc.Size = new System.Drawing.Size(170, 21);
+ this.comboBoxCpsLineLenCalc.TabIndex = 65;
+ this.comboBoxCpsLineLenCalc.SelectedIndexChanged += new System.EventHandler(this.ProfileUiValueChanged);
+ //
+ // labelCpsLineLenCalc
+ //
+ this.labelCpsLineLenCalc.AutoSize = true;
+ this.labelCpsLineLenCalc.Location = new System.Drawing.Point(6, 354);
+ this.labelCpsLineLenCalc.Name = "labelCpsLineLenCalc";
+ this.labelCpsLineLenCalc.Size = new System.Drawing.Size(104, 13);
+ this.labelCpsLineLenCalc.TabIndex = 64;
+ this.labelCpsLineLenCalc.Text = "Cps/line length style";
+ //
// buttonGapChoose
//
this.buttonGapChoose.Location = new System.Drawing.Point(264, 213);
@@ -742,17 +764,6 @@
this.comboBoxDialogStyle.TabIndex = 57;
this.comboBoxDialogStyle.SelectedIndexChanged += new System.EventHandler(this.ProfileUiValueChanged);
//
- // checkBoxCpsIncludeWhiteSpace
- //
- this.checkBoxCpsIncludeWhiteSpace.AutoSize = true;
- this.checkBoxCpsIncludeWhiteSpace.Location = new System.Drawing.Point(9, 354);
- this.checkBoxCpsIncludeWhiteSpace.Name = "checkBoxCpsIncludeWhiteSpace";
- this.checkBoxCpsIncludeWhiteSpace.Size = new System.Drawing.Size(271, 17);
- this.checkBoxCpsIncludeWhiteSpace.TabIndex = 65;
- this.checkBoxCpsIncludeWhiteSpace.Text = "Characters per second (CPS) includes white spaces";
- this.checkBoxCpsIncludeWhiteSpace.UseVisualStyleBackColor = true;
- this.checkBoxCpsIncludeWhiteSpace.CheckedChanged += new System.EventHandler(this.ProfileUiValueChanged);
- //
// buttonEditProfile
//
this.buttonEditProfile.Location = new System.Drawing.Point(322, 19);
@@ -4072,6 +4083,33 @@
this.groupBoxShowToolBarButtons.TabStop = false;
this.groupBoxShowToolBarButtons.Text = "Show toolbar buttons";
//
+ // labelTBBurnIn
+ //
+ this.labelTBBurnIn.AutoSize = true;
+ this.labelTBBurnIn.Location = new System.Drawing.Point(243, 139);
+ this.labelTBBurnIn.Name = "labelTBBurnIn";
+ this.labelTBBurnIn.Size = new System.Drawing.Size(40, 13);
+ this.labelTBBurnIn.TabIndex = 45;
+ this.labelTBBurnIn.Text = "Burn in";
+ //
+ // pictureBoxTBBurnIn
+ //
+ this.pictureBoxTBBurnIn.Location = new System.Drawing.Point(256, 158);
+ this.pictureBoxTBBurnIn.Name = "pictureBoxTBBurnIn";
+ this.pictureBoxTBBurnIn.Size = new System.Drawing.Size(32, 32);
+ this.pictureBoxTBBurnIn.TabIndex = 44;
+ this.pictureBoxTBBurnIn.TabStop = false;
+ //
+ // checkBoxTBBurnIn
+ //
+ this.checkBoxTBBurnIn.AutoSize = true;
+ this.checkBoxTBBurnIn.Location = new System.Drawing.Point(259, 198);
+ this.checkBoxTBBurnIn.Name = "checkBoxTBBurnIn";
+ this.checkBoxTBBurnIn.Size = new System.Drawing.Size(55, 17);
+ this.checkBoxTBBurnIn.TabIndex = 43;
+ this.checkBoxTBBurnIn.Text = "Visible";
+ this.checkBoxTBBurnIn.UseVisualStyleBackColor = true;
+ //
// labelTBNetflixQualityCheck
//
this.labelTBNetflixQualityCheck.AutoSize = true;
@@ -5074,39 +5112,13 @@
this.imageListFileTypeAssociations.ImageSize = new System.Drawing.Size(32, 32);
this.imageListFileTypeAssociations.TransparentColor = System.Drawing.Color.Transparent;
//
- // labelTBBurnIn
- //
- this.labelTBBurnIn.AutoSize = true;
- this.labelTBBurnIn.Location = new System.Drawing.Point(243, 139);
- this.labelTBBurnIn.Name = "labelTBBurnIn";
- this.labelTBBurnIn.Size = new System.Drawing.Size(40, 13);
- this.labelTBBurnIn.TabIndex = 45;
- this.labelTBBurnIn.Text = "Burn in";
- //
- // pictureBoxTBBurnIn
- //
- this.pictureBoxTBBurnIn.Location = new System.Drawing.Point(256, 158);
- this.pictureBoxTBBurnIn.Name = "pictureBoxTBBurnIn";
- this.pictureBoxTBBurnIn.Size = new System.Drawing.Size(32, 32);
- this.pictureBoxTBBurnIn.TabIndex = 44;
- this.pictureBoxTBBurnIn.TabStop = false;
- //
- // checkBoxTBBurnIn
- //
- this.checkBoxTBBurnIn.AutoSize = true;
- this.checkBoxTBBurnIn.Location = new System.Drawing.Point(259, 198);
- this.checkBoxTBBurnIn.Name = "checkBoxTBBurnIn";
- this.checkBoxTBBurnIn.Size = new System.Drawing.Size(55, 17);
- this.checkBoxTBBurnIn.TabIndex = 43;
- this.checkBoxTBBurnIn.Text = "Visible";
- this.checkBoxTBBurnIn.UseVisualStyleBackColor = true;
- //
// Settings
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1092, 574);
this.Controls.Add(this.labelUpdateFileTypeAssociationsStatus);
+ this.Controls.Add(this.panelGeneral);
this.Controls.Add(this.panelToolBar);
this.Controls.Add(this.panelTools);
this.Controls.Add(this.panelFileTypeAssociations);
@@ -5114,7 +5126,6 @@
this.Controls.Add(this.panelWaveform);
this.Controls.Add(this.panelShortcuts);
this.Controls.Add(this.panelSubtitleFormats);
- this.Controls.Add(this.panelGeneral);
this.Controls.Add(this.panelNetwork);
this.Controls.Add(this.panelVideoPlayer);
this.Controls.Add(this.panelWordLists);
@@ -5209,6 +5220,7 @@
this.groupBox2.PerformLayout();
this.groupBoxShowToolBarButtons.ResumeLayout(false);
this.groupBoxShowToolBarButtons.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBoxTBBurnIn)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxNetflixQualityCheck)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxTBRemoveTextForHi)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxTBFixCommonErrors)).EndInit();
@@ -5242,7 +5254,6 @@
this.groupBoxProxyAuthentication.ResumeLayout(false);
this.groupBoxProxyAuthentication.PerformLayout();
this.panelFileTypeAssociations.ResumeLayout(false);
- ((System.ComponentModel.ISupportInitialize)(this.pictureBoxTBBurnIn)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
@@ -5553,7 +5564,6 @@
private System.Windows.Forms.Button buttonEditProfile;
private System.Windows.Forms.ComboBox comboBoxRulesProfileName;
private System.Windows.Forms.Label labelRulesProfileName;
- private System.Windows.Forms.CheckBox checkBoxCpsIncludeWhiteSpace;
private System.Windows.Forms.Label labelBingTokenEndpoint;
private System.Windows.Forms.CheckBox checkBoxToolsBreakEarlyComma;
private System.Windows.Forms.CheckBox checkBoxToolsBreakEarlyDash;
@@ -5646,5 +5656,7 @@
private System.Windows.Forms.Label labelTBBurnIn;
private System.Windows.Forms.PictureBox pictureBoxTBBurnIn;
private System.Windows.Forms.CheckBox checkBoxTBBurnIn;
+ private System.Windows.Forms.ComboBox comboBoxCpsLineLenCalc;
+ private System.Windows.Forms.Label labelCpsLineLenCalc;
}
}
\ No newline at end of file
diff --git a/src/ui/Forms/Options/Settings.cs b/src/ui/Forms/Options/Settings.cs
index 5ca8b10bb..77a4b0a3d 100644
--- a/src/ui/Forms/Options/Settings.cs
+++ b/src/ui/Forms/Options/Settings.cs
@@ -385,13 +385,14 @@ namespace Nikse.SubtitleEdit.Forms.Options
checkBoxTBFixCommonErrors.Text = LanguageSettings.Current.General.Visible;
checkBoxTBRemoveTextForHi.Text = LanguageSettings.Current.General.Visible;
checkBoxVisualSync.Text = LanguageSettings.Current.General.Visible;
+ checkBoxTBBurnIn.Text = LanguageSettings.Current.General.Visible;
checkBoxSpellCheck.Text = LanguageSettings.Current.General.Visible;
checkBoxNetflixQualityCheck.Text = LanguageSettings.Current.General.Visible;
checkBoxSettings.Text = LanguageSettings.Current.General.Visible;
- checkBoxHelp.Text = LanguageSettings.Current.General.Visible;
+ checkBoxHelp.Text = LanguageSettings.Current.General.Visible;
// Toolbar icons first row
- labelTBOpen.Left = Math.Max(labelTBNew.Right, checkBoxToolbarNew.Right) + 18;
+ labelTBOpen.Left = Math.Max(labelTBNew.Right, checkBoxToolbarNew.Right) + 18;
pictureBoxOpen.Left = labelTBOpen.Left;
checkBoxToolbarOpen.Left = labelTBOpen.Left;
@@ -746,6 +747,7 @@ namespace Nikse.SubtitleEdit.Forms.Options
labelMergeShortLines.Text = language.MergeLinesShorterThan;
labelDialogStyle.Text = language.DialogStyle;
labelContinuationStyle.Text = language.ContinuationStyle;
+ labelCpsLineLenCalc.Text = language.CpsLineLengthStyle;
labelToolsMusicSymbol.Text = language.MusicSymbol;
labelToolsMusicSymbolsToReplace.Text = language.MusicSymbolsReplace;
checkBoxFixCommonOcrErrorsUsingHardcodedRules.Text = language.FixCommonOcrErrorsUseHardcodedRules;
@@ -769,7 +771,6 @@ namespace Nikse.SubtitleEdit.Forms.Options
checkBoxToolsBreakPreferBottomHeavy.Text = language.BreakPreferBottomHeavy;
numericUpDownToolsBreakPreferBottomHeavy.Left = checkBoxToolsBreakPreferBottomHeavy.Left + checkBoxToolsBreakPreferBottomHeavy.Width + 9;
labelToolsBreakBottomHeavyPercent.Left = numericUpDownToolsBreakPreferBottomHeavy.Left + numericUpDownToolsBreakPreferBottomHeavy.Width + 2;
- checkBoxCpsIncludeWhiteSpace.Text = language.CpsIncludesSpace;
buttonEditDoNotBreakAfterList.Text = LanguageSettings.Current.VobSubOcr.Edit;
groupBoxMiscellaneous.Text = language.Miscellaneous;
@@ -908,6 +909,7 @@ namespace Nikse.SubtitleEdit.Forms.Options
SetDialogStyle(Configuration.Settings.General.DialogStyle);
SetContinuationStyle(Configuration.Settings.General.ContinuationStyle);
+ SetCpsLineLengthStyle(Configuration.Settings.General.CpsLineLengthStrategy);
UpdateProfileNames(gs.Profiles);
@@ -961,7 +963,6 @@ namespace Nikse.SubtitleEdit.Forms.Options
checkBoxToolsBreakByPixelWidth.Checked = toolsSettings.AutoBreakUsePixelWidth;
checkBoxToolsBreakPreferBottomHeavy.Checked = toolsSettings.AutoBreakPreferBottomHeavy;
numericUpDownToolsBreakPreferBottomHeavy.Value = (decimal)toolsSettings.AutoBreakPreferBottomPercent;
- checkBoxCpsIncludeWhiteSpace.Checked = !Configuration.Settings.General.CharactersPerSecondsIgnoreWhiteSpace;
textBoxBingClientSecret.Text = Configuration.Settings.Tools.MicrosoftTranslatorApiKey;
comboBoxBoxBingTokenEndpoint.Text = Configuration.Settings.Tools.MicrosoftTranslatorTokenEndpoint;
@@ -1164,6 +1165,24 @@ namespace Nikse.SubtitleEdit.Forms.Options
}
}
+ private void SetCpsLineLengthStyle(string cpsLineLengthStyle)
+ {
+ comboBoxCpsLineLenCalc.Items.Clear();
+ foreach (var calc in CpsLineLength.List())
+ {
+ comboBoxCpsLineLenCalc.Items.Add(calc);
+ if (cpsLineLengthStyle == calc.Code)
+ {
+ comboBoxCpsLineLenCalc.SelectedIndex = comboBoxCpsLineLenCalc.Items.Count - 1;
+ }
+ }
+
+ if (comboBoxCpsLineLenCalc.SelectedIndex < 0)
+ {
+ comboBoxCpsLineLenCalc.SelectedIndex = 0;
+ }
+ }
+
private void SetContinuationStyle(ContinuationStyle continuationStyle)
{
comboBoxContinuationStyle.Items.Clear();
@@ -2018,6 +2037,7 @@ namespace Nikse.SubtitleEdit.Forms.Options
gs.DialogStyle = DialogSplitMerge.GetDialogStyleFromIndex(comboBoxDialogStyle.SelectedIndex);
gs.ContinuationStyle = ContinuationUtilities.GetContinuationStyleFromIndex(comboBoxContinuationStyle.SelectedIndex);
+ gs.CpsLineLengthStrategy = (comboBoxCpsLineLenCalc.SelectedItem as CpsLineLength)?.Code;
toolsSettings.MusicSymbol = comboBoxToolsMusicSymbol.SelectedItem.ToString();
toolsSettings.MusicSymbolReplace = textBoxMusicSymbolsToReplace.Text;
@@ -2038,7 +2058,6 @@ namespace Nikse.SubtitleEdit.Forms.Options
Configuration.Settings.Tools.BDOpenIn = comboBoxBDOpensIn.SelectedIndex == 0 ? "OCR" : "EDIT";
Configuration.Settings.General.AllowLetterShortcutsInTextBox = checkBoxShortcutsAllowLetterOrNumberInTextBox.Checked;
- Configuration.Settings.General.CharactersPerSecondsIgnoreWhiteSpace = !checkBoxCpsIncludeWhiteSpace.Checked;
toolsSettings.OcrFixUseHardcodedRules = checkBoxFixCommonOcrErrorsUsingHardcodedRules.Checked;
toolsSettings.FixShortDisplayTimesAllowMoveStartTime = checkBoxFixShortDisplayTimesAllowMoveStartTime.Checked;
toolsSettings.FixCommonErrorsSkipStepOne = checkBoxFceSkipStep1.Checked;
@@ -3483,8 +3502,7 @@ namespace Nikse.SubtitleEdit.Forms.Options
SetDialogStyle(profile.DialogStyle);
SetContinuationStyle(profile.ContinuationStyle);
-
- checkBoxCpsIncludeWhiteSpace.Checked = profile.CpsIncludesSpace;
+ SetCpsLineLengthStyle(profile.CpsLineLengthStrategy);
_oldProfileId = profile.Id;
_editProfileOn = false;
}
@@ -3504,7 +3522,7 @@ namespace Nikse.SubtitleEdit.Forms.Options
_rulesProfiles[idx].MinimumMillisecondsBetweenLines = (int)numericUpDownMinGapMs.Value;
_rulesProfiles[idx].MaxNumberOfLines = (int)numericUpDownMaxNumberOfLines.Value;
_rulesProfiles[idx].SubtitleMaximumWordsPerMinute = (int)numericUpDownMaxWordsMin.Value;
- _rulesProfiles[idx].CpsIncludesSpace = checkBoxCpsIncludeWhiteSpace.Checked;
+ _rulesProfiles[idx].CpsLineLengthStrategy = (comboBoxCpsLineLenCalc.SelectedItem as CpsLineLength)?.Code;
_rulesProfiles[idx].MergeLinesShorterThan = int.Parse(comboBoxMergeShortLineLength.Text, CultureInfo.InvariantCulture);
_rulesProfiles[idx].DialogStyle = DialogSplitMerge.GetDialogStyleFromIndex(comboBoxDialogStyle.SelectedIndex);
_rulesProfiles[idx].ContinuationStyle = ContinuationUtilities.GetContinuationStyleFromIndex(comboBoxContinuationStyle.SelectedIndex);
diff --git a/src/ui/Forms/Options/SettingsProfile.Designer.cs b/src/ui/Forms/Options/SettingsProfile.Designer.cs
index a77e9f6cc..80baf67f9 100644
--- a/src/ui/Forms/Options/SettingsProfile.Designer.cs
+++ b/src/ui/Forms/Options/SettingsProfile.Designer.cs
@@ -37,7 +37,6 @@
this.labelContinuationStyle = new System.Windows.Forms.Label();
this.labelDialogStyle = new System.Windows.Forms.Label();
this.comboBoxDialogStyle = new System.Windows.Forms.ComboBox();
- this.checkBoxCpsIncludeWhiteSpace = new System.Windows.Forms.CheckBox();
this.labelOptimalCharsPerSecond = new System.Windows.Forms.Label();
this.numericUpDownOptimalCharsSec = new System.Windows.Forms.NumericUpDown();
this.labelSubMaxLen = new System.Windows.Forms.Label();
@@ -72,6 +71,8 @@
this.buttonOK = new System.Windows.Forms.Button();
this.openFileDialogImport = new System.Windows.Forms.OpenFileDialog();
this.toolTipContinuationPreview = new System.Windows.Forms.ToolTip(this.components);
+ this.comboBoxCpsLineLenCalc = new System.Windows.Forms.ComboBox();
+ this.labelCpsLineLenCalc = new System.Windows.Forms.Label();
this.groupBoxStyles.SuspendLayout();
this.groupBoxGeneralRules.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownOptimalCharsSec)).BeginInit();
@@ -128,11 +129,12 @@
//
this.groupBoxGeneralRules.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Right)));
+ this.groupBoxGeneralRules.Controls.Add(this.comboBoxCpsLineLenCalc);
+ this.groupBoxGeneralRules.Controls.Add(this.labelCpsLineLenCalc);
this.groupBoxGeneralRules.Controls.Add(this.comboBoxContinuationStyle);
this.groupBoxGeneralRules.Controls.Add(this.labelContinuationStyle);
this.groupBoxGeneralRules.Controls.Add(this.labelDialogStyle);
this.groupBoxGeneralRules.Controls.Add(this.comboBoxDialogStyle);
- this.groupBoxGeneralRules.Controls.Add(this.checkBoxCpsIncludeWhiteSpace);
this.groupBoxGeneralRules.Controls.Add(this.labelOptimalCharsPerSecond);
this.groupBoxGeneralRules.Controls.Add(this.numericUpDownOptimalCharsSec);
this.groupBoxGeneralRules.Controls.Add(this.labelSubMaxLen);
@@ -203,17 +205,6 @@
this.comboBoxDialogStyle.TabIndex = 194;
this.comboBoxDialogStyle.SelectedIndexChanged += new System.EventHandler(this.UiElementChanged);
//
- // checkBoxCpsIncludeWhiteSpace
- //
- this.checkBoxCpsIncludeWhiteSpace.AutoSize = true;
- this.checkBoxCpsIncludeWhiteSpace.Location = new System.Drawing.Point(9, 318);
- this.checkBoxCpsIncludeWhiteSpace.Name = "checkBoxCpsIncludeWhiteSpace";
- this.checkBoxCpsIncludeWhiteSpace.Size = new System.Drawing.Size(270, 17);
- this.checkBoxCpsIncludeWhiteSpace.TabIndex = 196;
- this.checkBoxCpsIncludeWhiteSpace.Text = "Characters per second (CPS) includes white spaces";
- this.checkBoxCpsIncludeWhiteSpace.UseVisualStyleBackColor = true;
- this.checkBoxCpsIncludeWhiteSpace.CheckedChanged += new System.EventHandler(this.UiElementChanged);
- //
// labelOptimalCharsPerSecond
//
this.labelOptimalCharsPerSecond.AutoSize = true;
@@ -636,6 +627,25 @@
this.toolTipContinuationPreview.InitialDelay = 500;
this.toolTipContinuationPreview.ReshowDelay = 100;
//
+ // comboBoxCpsLineLenCalc
+ //
+ this.comboBoxCpsLineLenCalc.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+ this.comboBoxCpsLineLenCalc.DropDownWidth = 170;
+ this.comboBoxCpsLineLenCalc.FormattingEnabled = true;
+ this.comboBoxCpsLineLenCalc.Location = new System.Drawing.Point(132, 313);
+ this.comboBoxCpsLineLenCalc.Name = "comboBoxCpsLineLenCalc";
+ this.comboBoxCpsLineLenCalc.Size = new System.Drawing.Size(174, 21);
+ this.comboBoxCpsLineLenCalc.TabIndex = 197;
+ //
+ // labelCpsLineLenCalc
+ //
+ this.labelCpsLineLenCalc.AutoSize = true;
+ this.labelCpsLineLenCalc.Location = new System.Drawing.Point(4, 316);
+ this.labelCpsLineLenCalc.Name = "labelCpsLineLenCalc";
+ this.labelCpsLineLenCalc.Size = new System.Drawing.Size(102, 13);
+ this.labelCpsLineLenCalc.TabIndex = 196;
+ this.labelCpsLineLenCalc.Text = "Cps/line length style";
+ //
// SettingsProfile
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -707,12 +717,13 @@
private System.Windows.Forms.NumericUpDown numericUpDownMaxCharsSec;
private System.Windows.Forms.Label labelMinGapMs;
private System.Windows.Forms.NumericUpDown numericUpDownSubtitleLineMaximumLength;
- private System.Windows.Forms.CheckBox checkBoxCpsIncludeWhiteSpace;
private System.Windows.Forms.OpenFileDialog openFileDialogImport;
private System.Windows.Forms.Label labelDialogStyle;
private System.Windows.Forms.ComboBox comboBoxDialogStyle;
private System.Windows.Forms.Label labelContinuationStyle;
private System.Windows.Forms.ComboBox comboBoxContinuationStyle;
private System.Windows.Forms.ToolTip toolTipContinuationPreview;
+ private System.Windows.Forms.ComboBox comboBoxCpsLineLenCalc;
+ private System.Windows.Forms.Label labelCpsLineLenCalc;
}
}
\ No newline at end of file
diff --git a/src/ui/Forms/Options/SettingsProfile.cs b/src/ui/Forms/Options/SettingsProfile.cs
index 901b8ea8c..e806c9fba 100644
--- a/src/ui/Forms/Options/SettingsProfile.cs
+++ b/src/ui/Forms/Options/SettingsProfile.cs
@@ -36,7 +36,7 @@ namespace Nikse.SubtitleEdit.Forms.Options
labelMergeShortLines.Text = language.MergeLinesShorterThan;
labelDialogStyle.Text = language.DialogStyle;
labelContinuationStyle.Text = language.ContinuationStyle;
- checkBoxCpsIncludeWhiteSpace.Text = language.CpsIncludesSpace;
+ labelCpsLineLenCalc.Text = language.CpsLineLengthStyle;
listViewProfiles.Columns[0].Text = LanguageSettings.Current.General.Name;
listViewProfiles.Columns[1].Text = language.SubtitleLineMaximumLength;
listViewProfiles.Columns[2].Text = language.OptimalCharactersPerSecond;
@@ -71,6 +71,24 @@ namespace Nikse.SubtitleEdit.Forms.Options
ShowRulesProfiles(rulesProfiles.FirstOrDefault(p => p.Name == name), true);
}
+ private void SetCpsLineLengthStyle(string cpsLineLengthStyle)
+ {
+ comboBoxCpsLineLenCalc.Items.Clear();
+ foreach (var calc in CpsLineLength.List())
+ {
+ comboBoxCpsLineLenCalc.Items.Add(calc);
+ if (cpsLineLengthStyle == calc.Code)
+ {
+ comboBoxCpsLineLenCalc.SelectedIndex = comboBoxCpsLineLenCalc.Items.Count - 1;
+ }
+ }
+
+ if (comboBoxCpsLineLenCalc.SelectedIndex < 0)
+ {
+ comboBoxCpsLineLenCalc.SelectedIndex = 0;
+ }
+ }
+
private void ShowRulesProfiles(RulesProfile itemToFocus, bool sort)
{
_editOn = false;
@@ -203,7 +221,7 @@ namespace Nikse.SubtitleEdit.Forms.Options
RulesProfiles[idx].MinimumMillisecondsBetweenLines = (int)numericUpDownMinGapMs.Value;
RulesProfiles[idx].MaxNumberOfLines = (int)numericUpDownMaxNumberOfLines.Value;
RulesProfiles[idx].SubtitleMaximumWordsPerMinute = (int)numericUpDownMaxWordsMin.Value;
- RulesProfiles[idx].CpsIncludesSpace = checkBoxCpsIncludeWhiteSpace.Checked;
+ RulesProfiles[idx].CpsLineLengthStrategy = (comboBoxCpsLineLenCalc.SelectedItem as CpsLineLength)?.Code;
RulesProfiles[idx].MergeLinesShorterThan = comboBoxMergeShortLineLength.SelectedIndex + 1;
RulesProfiles[idx].DialogStyle = DialogSplitMerge.GetDialogStyleFromIndex(comboBoxDialogStyle.SelectedIndex);
RulesProfiles[idx].ContinuationStyle = ContinuationUtilities.GetContinuationStyleFromIndex(comboBoxContinuationStyle.SelectedIndex);
@@ -261,7 +279,8 @@ namespace Nikse.SubtitleEdit.Forms.Options
{
numericUpDownMaxWordsMin.Value = p.SubtitleMaximumWordsPerMinute;
}
- checkBoxCpsIncludeWhiteSpace.Checked = RulesProfiles[idx].CpsIncludesSpace;
+
+ SetCpsLineLengthStyle(RulesProfiles[idx].CpsLineLengthStrategy);
var comboIdx = RulesProfiles[idx].MergeLinesShorterThan - 1;
if (comboIdx >= 0 && comboIdx < comboBoxMergeShortLineLength.Items.Count)
{
diff --git a/src/ui/Forms/ProfileChoose.cs b/src/ui/Forms/ProfileChoose.cs
index f082ab3c3..7e1d7f283 100644
--- a/src/ui/Forms/ProfileChoose.cs
+++ b/src/ui/Forms/ProfileChoose.cs
@@ -93,7 +93,7 @@ namespace Nikse.SubtitleEdit.Forms
Configuration.Settings.General.MinimumMillisecondsBetweenLines = RulesProfiles[idx].MinimumMillisecondsBetweenLines;
Configuration.Settings.General.MaxNumberOfLines = RulesProfiles[idx].MaxNumberOfLines;
Configuration.Settings.General.SubtitleMaximumWordsPerMinute = (double)RulesProfiles[idx].SubtitleMaximumWordsPerMinute;
- Configuration.Settings.General.CharactersPerSecondsIgnoreWhiteSpace = !RulesProfiles[idx].CpsIncludesSpace;
+ Configuration.Settings.General.CpsLineLengthStrategy = RulesProfiles[idx].CpsLineLengthStrategy;
Configuration.Settings.General.MergeLinesShorterThan = RulesProfiles[idx].MergeLinesShorterThan;
DialogResult = DialogResult.OK;
}
diff --git a/src/ui/Forms/Statistics.cs b/src/ui/Forms/Statistics.cs
index 7bc69ab69..fbb3ebda2 100644
--- a/src/ui/Forms/Statistics.cs
+++ b/src/ui/Forms/Statistics.cs
@@ -157,9 +157,9 @@ https://github.com/SubtitleEdit/subtitleedit
sb.AppendLine(string.Format(_l.NumberOfLinesX, _subtitle.Paragraphs.Count));
sb.AppendLine(string.Format(_l.LengthInFormatXinCharactersY, _format.FriendlyName, sourceLength));
- sb.AppendLine(string.Format(_l.NumberOfCharactersInTextOnly, allText.ToString().CountCharacters(false, Configuration.Settings.General.IgnoreArabicDiacritics)));
+ sb.AppendLine(string.Format(_l.NumberOfCharactersInTextOnly, allText.ToString().CountCharacters()));
sb.AppendLine(string.Format(_l.TotalDuration, new TimeCode(totalDuration).ToDisplayString()));
- sb.AppendLine(string.Format(_l.TotalCharsPerSecond, allText.ToString().CountCharacters(false, Configuration.Settings.General.IgnoreArabicDiacritics) / (totalDuration / TimeCode.BaseUnit)));
+ sb.AppendLine(string.Format(_l.TotalCharsPerSecond, (double)allText.ToString().CountCharacters() / (totalDuration / TimeCode.BaseUnit)));
sb.AppendLine(string.Format(_l.TotalWords, _totalWords));
sb.AppendLine(string.Format(_l.NumberOfItalicTags, Utilities.CountTagInText(allTextToLower, "")));
sb.AppendLine(string.Format(_l.NumberOfBoldTags, Utilities.CountTagInText(allTextToLower, "")));
@@ -198,12 +198,12 @@ https://github.com/SubtitleEdit/subtitleedit
private static int GetLineLength(Paragraph p)
{
- return p.Text.Replace(Environment.NewLine, string.Empty).CountCharacters(false, Configuration.Settings.General.IgnoreArabicDiacritics);
+ return p.Text.Replace(Environment.NewLine, string.Empty).CountCharacters(Configuration.Settings.General.CpsLineLengthStrategy);
}
private static int GetSingleLineLength(string s)
{
- return s.CountCharacters(false, Configuration.Settings.General.IgnoreArabicDiacritics);
+ return s.CountCharacters(Configuration.Settings.General.CpsLineLengthStrategy);
}
private static int GetSingleLineWidth(string s)
diff --git a/src/ui/Logic/CpsLineLength.cs b/src/ui/Logic/CpsLineLength.cs
new file mode 100644
index 000000000..d2dd18209
--- /dev/null
+++ b/src/ui/Logic/CpsLineLength.cs
@@ -0,0 +1,34 @@
+using Nikse.SubtitleEdit.Core.Common.TextLengthCalculator;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace Nikse.SubtitleEdit.Logic
+{
+ public class CpsLineLength
+ {
+ public string Code { get; set; }
+ public override string ToString()
+ {
+ switch (Code)
+ {
+ case nameof(CalcNoSpace):
+ return LanguageSettings.Current.Settings.CpsLineLengthStyleCalcNoSpace;
+ case nameof(CalcCjk):
+ return LanguageSettings.Current.Settings.CpsLineLengthStyleCalcCjk;
+ case nameof(CalcCjkNoSpace):
+ return LanguageSettings.Current.Settings.CpsLineLengthStyleCalcCjkNoSpace;
+ case nameof(CalcIgnoreArabicDiacritics):
+ return LanguageSettings.Current.Settings.CpsLineLengthStyleCalcIgnoreArabicDiacritics;
+ case nameof(CalcIgnoreArabicDiacriticsNoSpace):
+ return LanguageSettings.Current.Settings.CpsLineLengthStyleCalcIgnoreArabicDiacriticsNoSpace;
+ default:
+ return LanguageSettings.Current.Settings.CpsLineLengthStyleCalcAll;
+ }
+ }
+
+ public static List List()
+ {
+ return CalcFactory.Calculators.Select(p => new CpsLineLength { Code = p.GetType().Name }).ToList();
+ }
+ }
+}
diff --git a/src/ui/Logic/Language.cs b/src/ui/Logic/Language.cs
index 42a6f5d9e..2972c84e7 100644
--- a/src/ui/Logic/Language.cs
+++ b/src/ui/Logic/Language.cs
@@ -2591,6 +2591,13 @@ can edit in same subtitle file (collaboration)",
DialogStyleDashSecondLineWithSpace = "Dash second line with space",
DialogStyleDashSecondLineWithoutSpace = "Dash second line without space",
ContinuationStyle = "Continuation style",
+ CpsLineLengthStyle = "Cps/line-length",
+ CpsLineLengthStyleCalcAll = "Count all characters",
+ CpsLineLengthStyleCalcNoSpace = "Count all except space",
+ CpsLineLengthStyleCalcCjk = "CJK 1, latin 0.5",
+ CpsLineLengthStyleCalcCjkNoSpace = "CJK 1, latin 0.5, space 0",
+ CpsLineLengthStyleCalcIgnoreArabicDiacritics = "Ignore Arabic diacritics",
+ CpsLineLengthStyleCalcIgnoreArabicDiacriticsNoSpace = "Ignore Arabic diacritics/space",
ContinuationStyleNone = "None",
ContinuationStyleNoneTrailingDots = "None, dots for pauses (trailing only)",
ContinuationStyleNoneLeadingTrailingDots = "None, dots for pauses",
diff --git a/src/ui/Logic/LanguageDeserializer.cs b/src/ui/Logic/LanguageDeserializer.cs
index fbe4304ec..a5ec24b24 100644
--- a/src/ui/Logic/LanguageDeserializer.cs
+++ b/src/ui/Logic/LanguageDeserializer.cs
@@ -6181,6 +6181,27 @@ namespace Nikse.SubtitleEdit.Logic
case "Settings/ContinuationStyleLeadingTrailingDashDots":
language.Settings.ContinuationStyleLeadingTrailingDashDots = reader.Value;
break;
+ case "Settings/CpsLineLengthStyle":
+ language.Settings.CpsLineLengthStyle = reader.Value;
+ break;
+ case "Settings/CpsLineLengthStyleCalcAll":
+ language.Settings.CpsLineLengthStyleCalcAll = reader.Value;
+ break;
+ case "Settings/CpsLineLengthStyleCalcNoSpace":
+ language.Settings.CpsLineLengthStyleCalcNoSpace = reader.Value;
+ break;
+ case "Settings/CpsLineLengthStyleCalcCjk":
+ language.Settings.CpsLineLengthStyleCalcCjk = reader.Value;
+ break;
+ case "Settings/CpsLineLengthStyleCalcCjkNoSpace":
+ language.Settings.CpsLineLengthStyleCalcCjkNoSpace = reader.Value;
+ break;
+ case "Settings/CpsLineLengthStyleCalcIgnoreArabicDiacritics":
+ language.Settings.CpsLineLengthStyleCalcIgnoreArabicDiacritics = reader.Value;
+ break;
+ case "Settings/CpsLineLengthStyleCalcIgnoreArabicDiacriticsNoSpace":
+ language.Settings.CpsLineLengthStyleCalcIgnoreArabicDiacriticsNoSpace = reader.Value;
+ break;
case "Settings/MusicSymbol":
language.Settings.MusicSymbol = reader.Value;
break;
diff --git a/src/ui/Logic/LanguageStructure.cs b/src/ui/Logic/LanguageStructure.cs
index c4f8ff65e..b85e06e7b 100644
--- a/src/ui/Logic/LanguageStructure.cs
+++ b/src/ui/Logic/LanguageStructure.cs
@@ -2451,6 +2451,13 @@
public string ContinuationStyleNoneTrailingEllipsis { get; set; }
public string ContinuationStyleLeadingTrailingDash { get; set; }
public string ContinuationStyleLeadingTrailingDashDots { get; set; }
+ public string CpsLineLengthStyle { get; set; }
+ public string CpsLineLengthStyleCalcAll { get; set; }
+ public string CpsLineLengthStyleCalcNoSpace { get; set; }
+ public string CpsLineLengthStyleCalcCjk { get; set; }
+ public string CpsLineLengthStyleCalcCjkNoSpace { get; set; }
+ public string CpsLineLengthStyleCalcIgnoreArabicDiacritics { get; set; }
+ public string CpsLineLengthStyleCalcIgnoreArabicDiacriticsNoSpace { get; set; }
public string MusicSymbol { get; set; }
public string MusicSymbolsReplace { get; set; }
public string FixCommonOcrErrorsUseHardcodedRules { get; set; }
diff --git a/src/ui/Logic/UiUtil.cs b/src/ui/Logic/UiUtil.cs
index f574e2a8f..166e61f34 100644
--- a/src/ui/Logic/UiUtil.cs
+++ b/src/ui/Logic/UiUtil.cs
@@ -685,9 +685,9 @@ namespace Nikse.SubtitleEdit.Logic
public static void FixLargeFonts(Control mainCtrl, Control ctrl)
{
- using (Graphics graphics = mainCtrl.CreateGraphics())
+ using (var graphics = mainCtrl.CreateGraphics())
{
- SizeF textSize = graphics.MeasureString(ctrl.Text, ctrl.Font);
+ var textSize = graphics.MeasureString(ctrl.Text, ctrl.Font);
if (textSize.Height > ctrl.Height - 4)
{
SetButtonHeight(mainCtrl, (int)Math.Round(textSize.Height + 7.5), 1);
@@ -698,7 +698,7 @@ namespace Nikse.SubtitleEdit.Logic
public static void SetSaveDialogFilter(SaveFileDialog saveFileDialog, SubtitleFormat currentFormat)
{
var sb = new StringBuilder();
- int index = 0;
+ var index = 0;
foreach (SubtitleFormat format in SubtitleFormat.AllSubtitleFormats)
{
sb.Append(format.Name + "|*" + format.Extension + "|");
@@ -717,9 +717,9 @@ namespace Nikse.SubtitleEdit.Logic
var lines = text.SplitToLines();
const int max = 3;
var sb = new StringBuilder();
- for (int i = 0; i < lines.Count; i++)
+ for (var i = 0; i < lines.Count; i++)
{
- string line = lines[i];
+ var line = lines[i];
if (i > 0)
{
sb.Append('/');
@@ -732,7 +732,7 @@ namespace Nikse.SubtitleEdit.Logic
return;
}
- var count = line.CountCharacters(false, Configuration.Settings.General.IgnoreArabicDiacritics);
+ var count = line.CountCharacters();
sb.Append(count);
if (count > Configuration.Settings.General.SubtitleLineMaximumLength || i >= Configuration.Settings.General.MaxNumberOfLines)
{
@@ -748,9 +748,9 @@ namespace Nikse.SubtitleEdit.Logic
var lines = text.SplitToLines();
const int max = 3;
var sb = new StringBuilder();
- for (int i = 0; i < lines.Count; i++)
+ for (var i = 0; i < lines.Count; i++)
{
- string line = lines[i];
+ var line = lines[i];
if (i > 0)
{
sb.Append('/');
@@ -763,13 +763,14 @@ namespace Nikse.SubtitleEdit.Logic
return;
}
- int lineWidth = TextWidth.CalcPixelWidth(line);
+ var lineWidth = TextWidth.CalcPixelWidth(line);
sb.Append(lineWidth);
if (lineWidth > Configuration.Settings.General.SubtitleLineMaximumPixelWidth)
{
label.ForeColor = Color.Red;
}
}
+
label.Text = sb.ToString();
}
diff --git a/src/ui/SubtitleEdit.csproj b/src/ui/SubtitleEdit.csproj
index 7d71e021c..7800df9ba 100644
--- a/src/ui/SubtitleEdit.csproj
+++ b/src/ui/SubtitleEdit.csproj
@@ -1271,6 +1271,7 @@
+