mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2025-01-31 13:01:39 +01:00
Merge pull request #5808 from OmrSi/Arabic-Diacritics-patch
Don't count Arabic Diacritics in Line length
This commit is contained in:
commit
8942581b47
@ -1610,7 +1610,7 @@ $HorzAlign = Center
|
||||
SubtitleMaximumDisplayMilliseconds = 7000,
|
||||
SubtitleMinimumDisplayMilliseconds = 1000,
|
||||
SubtitleMaximumWordsPerMinute = 300,
|
||||
CpsLineLengthStrategy = typeof(CalcIgnoreArabicDiacriticsCpsOnly).Name,
|
||||
CpsLineLengthStrategy = typeof(CalcIgnoreArabicDiacritics).Name,
|
||||
MinimumMillisecondsBetweenLines = 84, // 2 frames for 23.976 fps videos
|
||||
DialogStyle = DialogType.DashBothLinesWithSpace,
|
||||
ContinuationStyle = ContinuationStyle.NoneEllipsisForPauses,
|
||||
|
@ -12,8 +12,8 @@ namespace Nikse.SubtitleEdit.Core.Common.TextLengthCalculator
|
||||
new CalcNoSpace(),
|
||||
new CalcCjk(),
|
||||
new CalcCjkNoSpace(),
|
||||
new CalcIgnoreArabicDiacriticsCpsOnly(),
|
||||
new CalcIgnoreArabicDiacriticsNoSpaceCpsOnly()
|
||||
new CalcIgnoreArabicDiacritics(),
|
||||
new CalcIgnoreArabicDiacriticsNoSpace()
|
||||
};
|
||||
|
||||
public static ICalcLength MakeCalculator(string strategy)
|
||||
|
@ -1,17 +1,12 @@
|
||||
namespace Nikse.SubtitleEdit.Core.Common.TextLengthCalculator
|
||||
{
|
||||
public class CalcIgnoreArabicDiacriticsNoSpaceCpsOnly : ICalcLength
|
||||
public class CalcIgnoreArabicDiacritics : ICalcLength
|
||||
{
|
||||
/// <summary>
|
||||
/// Calculate all text including space (tags are not counted).
|
||||
/// Calculate all text excluding Arabic Diacritics (tags are not counted).
|
||||
/// </summary>
|
||||
public decimal CountCharacters(string text, bool forCps)
|
||||
{
|
||||
if (!forCps)
|
||||
{
|
||||
return new CalcAll().CountCharacters(text, false);
|
||||
}
|
||||
|
||||
const char zeroWidthSpace = '\u200B';
|
||||
const char zeroWidthNoBreakSpace = '\uFEFF';
|
||||
var length = 0;
|
||||
@ -45,7 +40,6 @@
|
||||
htmlTagOn = true;
|
||||
}
|
||||
else if (!char.IsControl(ch) &&
|
||||
ch != ' ' &&
|
||||
ch != zeroWidthSpace &&
|
||||
ch != zeroWidthNoBreakSpace &&
|
||||
ch != '\u200E' &&
|
@ -1,17 +1,12 @@
|
||||
namespace Nikse.SubtitleEdit.Core.Common.TextLengthCalculator
|
||||
{
|
||||
public class CalcIgnoreArabicDiacriticsCpsOnly : ICalcLength
|
||||
public class CalcIgnoreArabicDiacriticsNoSpace : ICalcLength
|
||||
{
|
||||
/// <summary>
|
||||
/// Calculate all text including space (tags are not counted).
|
||||
/// Calculate all text excluding Arabic Diacritics and space (tags are not counted).
|
||||
/// </summary>
|
||||
public decimal CountCharacters(string text, bool forCps)
|
||||
{
|
||||
if (!forCps)
|
||||
{
|
||||
return new CalcAll().CountCharacters(text, false);
|
||||
}
|
||||
|
||||
const char zeroWidthSpace = '\u200B';
|
||||
const char zeroWidthNoBreakSpace = '\uFEFF';
|
||||
var length = 0;
|
||||
@ -45,6 +40,7 @@
|
||||
htmlTagOn = true;
|
||||
}
|
||||
else if (!char.IsControl(ch) &&
|
||||
ch != ' ' &&
|
||||
ch != zeroWidthSpace &&
|
||||
ch != zeroWidthNoBreakSpace &&
|
||||
ch != '\u200E' &&
|
@ -19,10 +19,10 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
return LanguageSettings.Current.Settings.CpsLineLengthStyleCalcCjk;
|
||||
case nameof(CalcCjkNoSpace):
|
||||
return LanguageSettings.Current.Settings.CpsLineLengthStyleCalcCjkNoSpace;
|
||||
case nameof(CalcIgnoreArabicDiacriticsCpsOnly):
|
||||
return LanguageSettings.Current.Settings.CpsLineLengthStyleCalcIgnoreArabicDiacriticsCpsOnly;
|
||||
case nameof(CalcIgnoreArabicDiacriticsNoSpaceCpsOnly):
|
||||
return LanguageSettings.Current.Settings.CpsLineLengthStyleCalcIgnoreArabicDiacriticsNoSpaceCpsOnly;
|
||||
case nameof(CalcIgnoreArabicDiacritics):
|
||||
return LanguageSettings.Current.Settings.CpsLineLengthStyleCalcIgnoreArabicDiacritics;
|
||||
case nameof(CalcIgnoreArabicDiacriticsNoSpace):
|
||||
return LanguageSettings.Current.Settings.CpsLineLengthStyleCalcIgnoreArabicDiacriticsNoSpace;
|
||||
default:
|
||||
return LanguageSettings.Current.Settings.CpsLineLengthStyleCalcAll;
|
||||
}
|
||||
|
@ -2599,8 +2599,8 @@ can edit in same subtitle file (collaboration)",
|
||||
CpsLineLengthStyleCalcNoSpace = "Count all except space",
|
||||
CpsLineLengthStyleCalcCjk = "CJK 1, latin 0.5",
|
||||
CpsLineLengthStyleCalcCjkNoSpace = "CJK 1, latin 0.5, space 0",
|
||||
CpsLineLengthStyleCalcIgnoreArabicDiacriticsCpsOnly = "Ignore Arabic diacritics, cps only",
|
||||
CpsLineLengthStyleCalcIgnoreArabicDiacriticsNoSpaceCpsOnly = "Ignore Arabic diacritics/space, cps only",
|
||||
CpsLineLengthStyleCalcIgnoreArabicDiacritics = "Ignore Arabic diacritics",
|
||||
CpsLineLengthStyleCalcIgnoreArabicDiacriticsNoSpace = "Ignore Arabic diacritics/space",
|
||||
ContinuationStyleNone = "None",
|
||||
ContinuationStyleNoneTrailingDots = "None, dots for pauses (trailing only)",
|
||||
ContinuationStyleNoneLeadingTrailingDots = "None, dots for pauses",
|
||||
|
@ -6209,10 +6209,10 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
language.Settings.CpsLineLengthStyleCalcCjkNoSpace = reader.Value;
|
||||
break;
|
||||
case "Settings/CpsLineLengthStyleCalcIgnoreArabicDiacritics":
|
||||
language.Settings.CpsLineLengthStyleCalcIgnoreArabicDiacriticsCpsOnly = reader.Value;
|
||||
language.Settings.CpsLineLengthStyleCalcIgnoreArabicDiacritics = reader.Value;
|
||||
break;
|
||||
case "Settings/CpsLineLengthStyleCalcIgnoreArabicDiacriticsNoSpace":
|
||||
language.Settings.CpsLineLengthStyleCalcIgnoreArabicDiacriticsNoSpaceCpsOnly = reader.Value;
|
||||
language.Settings.CpsLineLengthStyleCalcIgnoreArabicDiacriticsNoSpace = reader.Value;
|
||||
break;
|
||||
case "Settings/MusicSymbol":
|
||||
language.Settings.MusicSymbol = reader.Value;
|
||||
|
@ -2460,8 +2460,8 @@
|
||||
public string CpsLineLengthStyleCalcNoSpace { get; set; }
|
||||
public string CpsLineLengthStyleCalcCjk { get; set; }
|
||||
public string CpsLineLengthStyleCalcCjkNoSpace { get; set; }
|
||||
public string CpsLineLengthStyleCalcIgnoreArabicDiacriticsCpsOnly { get; set; }
|
||||
public string CpsLineLengthStyleCalcIgnoreArabicDiacriticsNoSpaceCpsOnly { 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; }
|
||||
|
Loading…
x
Reference in New Issue
Block a user