mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-25 12:44:46 +01:00
Merge pull request #773 from xylographe/xrfmt
Minor fix + minor refact (Logic/SubtitleFormats/Pac)
This commit is contained in:
commit
fdb9a49243
@ -94,7 +94,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
comboBoxImageFormat.SelectedIndex = 4;
|
||||
_subtitleColor = Configuration.Settings.Tools.ExportFontColor;
|
||||
_borderColor = Configuration.Settings.Tools.ExportBorderColor;
|
||||
_borderColor = Configuration.Settings.Tools.ExportBorderColor;
|
||||
_previewTimer.Tick += previewTimer_Tick;
|
||||
_previewTimer.Interval = 100;
|
||||
}
|
||||
|
@ -19,18 +19,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
buttonOK.Text = Configuration.Settings.Language.General.Ok;
|
||||
buttonCancel.Text = Configuration.Settings.Language.General.Cancel;
|
||||
Utilities.FixLargeFonts(this, buttonOK);
|
||||
FixLargeFonts();
|
||||
}
|
||||
|
||||
private void FixLargeFonts()
|
||||
{
|
||||
Graphics graphics = this.CreateGraphics();
|
||||
SizeF textSize = graphics.MeasureString(buttonOK.Text, this.Font);
|
||||
if (textSize.Height > buttonOK.Height - 4)
|
||||
{
|
||||
int newButtonHeight = (int)(textSize.Height + 7 + 0.5);
|
||||
Utilities.SetButtonHeight(this, newButtonHeight, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public int LineNumber
|
||||
|
@ -2861,13 +2861,13 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
{
|
||||
const int maximumFindHistoryItems = 10;
|
||||
textWriter.WriteStartElement("FindHistory", "");
|
||||
for (int index = 0; index < settings.Tools.FindHistory.Count; index++)
|
||||
int maxIndex = settings.Tools.FindHistory.Count;
|
||||
if (maxIndex > maximumFindHistoryItems)
|
||||
maxIndex = maximumFindHistoryItems;
|
||||
for (int index = 0; index < maxIndex; index++)
|
||||
{
|
||||
if (index < maximumFindHistoryItems)
|
||||
{
|
||||
var text = settings.Tools.FindHistory[index];
|
||||
textWriter.WriteElementString("Text", text);
|
||||
}
|
||||
var text = settings.Tools.FindHistory[index];
|
||||
textWriter.WriteElementString("Text", text);
|
||||
}
|
||||
textWriter.WriteEndElement();
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
// The PAC format save the contents, time code, position, justification, and italicization of each subtitle. The choice of font is not saved.
|
||||
public class Pac : SubtitleFormat
|
||||
{
|
||||
public static TimeCode PacNullTime = new TimeCode(655, 35, 00, 0);
|
||||
public static readonly TimeCode PacNullTime = new TimeCode(655, 35, 00, 0);
|
||||
|
||||
/// <summary>
|
||||
/// Contains Swedish, Danish, German, Spanish, and French letters
|
||||
@ -1270,75 +1270,91 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
if (count == 2)
|
||||
{
|
||||
_codePage = 0;
|
||||
bool allOk = true;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < LatinLetters.Count; i++)
|
||||
sb.Append(LatinLetters[i]);
|
||||
string latinLetters = sb + "ABCDEFGHIJKLMNOPPQRSTUVWXYZÆØÅÄÖÜabcdefghijklmnopqrstuvwxyzæøäåü(1234567890, .!?-\r\n'\"):;&";
|
||||
var sb = new StringBuilder("ABCDEFGHIJKLMNOPPQRSTUVWXYZÆØÅÄÖÜabcdefghijklmnopqrstuvwxyzæøäåü(1234567890, .!?-\r\n'\"):;&");
|
||||
foreach (string s in LatinLetters)
|
||||
sb.Append(s);
|
||||
var codePageLetters = sb.ToString();
|
||||
var allOk = true;
|
||||
foreach (char ch in HtmlUtil.RemoveHtmlTags(p.Text, true))
|
||||
{
|
||||
if (!latinLetters.Contains(ch))
|
||||
if (!codePageLetters.Contains(ch))
|
||||
{
|
||||
allOk = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (allOk)
|
||||
return 0; // Latin
|
||||
|
||||
index = start;
|
||||
_codePage = 1;
|
||||
index = start;
|
||||
p = GetPacParagraph(ref index, buffer);
|
||||
codePageLetters = "AαBβΓγΔδEϵεZζHηΘθIιKκΛλMμNνΞξOοΠπPρΣσςTτΥυΦϕφXχΨψΩω(1234567890, .!?-\r\n'\"):;&";
|
||||
allOk = true;
|
||||
foreach (char ch in HtmlUtil.RemoveHtmlTags(p.Text, true))
|
||||
{
|
||||
if (!"AαBβΓγΔδEϵεZζHηΘθIιKκΛλMμNνΞξOοΠπPρΣσςTτΥυΦϕφXχΨψΩω(1234567890, .!?-\r\n'\"):;&".Contains(ch))
|
||||
if (!codePageLetters.Contains(ch))
|
||||
{
|
||||
allOk = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (allOk)
|
||||
return 1; // Greek
|
||||
|
||||
index = start;
|
||||
_codePage = 3;
|
||||
index = start;
|
||||
p = GetPacParagraph(ref index, buffer);
|
||||
sb = new StringBuilder("(1234567890, .!?-\r\n'\"):;&");
|
||||
foreach (string s in ArabicLetters)
|
||||
sb.Append(s);
|
||||
codePageLetters = sb.ToString();
|
||||
allOk = true;
|
||||
sb = new StringBuilder();
|
||||
for (int i = 0; i < ArabicLetters.Count; i++)
|
||||
sb.Append(ArabicLetters[i]);
|
||||
string arabicLetters = sb + "(1234567890, .!?-\r\n'\"):;&";
|
||||
foreach (char ch in HtmlUtil.RemoveHtmlTags(p.Text, true))
|
||||
{
|
||||
if (!arabicLetters.Contains(ch))
|
||||
if (!codePageLetters.Contains(ch))
|
||||
{
|
||||
allOk = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (allOk)
|
||||
return 3; // Arabic
|
||||
|
||||
index = start;
|
||||
_codePage = 4;
|
||||
index = start;
|
||||
p = GetPacParagraph(ref index, buffer);
|
||||
sb = new StringBuilder("(1234567890, .!?-\r\n'\"):;&");
|
||||
foreach (string s in HebrewLetters)
|
||||
sb.Append(s);
|
||||
codePageLetters = sb.ToString();
|
||||
allOk = true;
|
||||
sb = new StringBuilder();
|
||||
for (int i = 0; i < HebrewLetters.Count; i++)
|
||||
sb.Append(HebrewLetters[i]);
|
||||
string hebrewLetters = sb + "(1234567890, .!?-\r\n'\"):;&";
|
||||
foreach (char ch in HtmlUtil.RemoveHtmlTags(p.Text, true))
|
||||
{
|
||||
if (!hebrewLetters.Contains(ch))
|
||||
if (!codePageLetters.Contains(ch))
|
||||
{
|
||||
allOk = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (allOk)
|
||||
return 4; // Hebrew
|
||||
|
||||
index = start;
|
||||
_codePage = 4;
|
||||
index = start;
|
||||
p = GetPacParagraph(ref index, buffer);
|
||||
sb = new StringBuilder("(1234567890, .!?-\r\n'\"):;&");
|
||||
foreach (string s in CyrillicLetters)
|
||||
sb.Append(s);
|
||||
codePageLetters = sb.ToString();
|
||||
allOk = true;
|
||||
sb = new StringBuilder();
|
||||
for (int i = 0; i < CyrillicLetters.Count; i++)
|
||||
sb.Append(CyrillicLetters[i]);
|
||||
string cyrillicLetters = sb + "(1234567890, .!?-\r\n'\"):;&";
|
||||
foreach (char chCyrillic in HtmlUtil.RemoveHtmlTags(p.Text, true))
|
||||
foreach (char ch in HtmlUtil.RemoveHtmlTags(p.Text, true))
|
||||
{
|
||||
if (!cyrillicLetters.Contains(chCyrillic))
|
||||
if (!codePageLetters.Contains(ch))
|
||||
{
|
||||
allOk = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (allOk)
|
||||
return 6; // Cyrillic
|
||||
@ -1373,7 +1389,9 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
{
|
||||
if (buffer[index] == 0xFF)
|
||||
{
|
||||
textSample[textIndex++] = 32; // space
|
||||
if (textIndex < textSample.Length - 1)
|
||||
textSample[textIndex++] = 32; // ASCII 32 SP (Space)
|
||||
index++;
|
||||
}
|
||||
else if (buffer[index] == 0xFE)
|
||||
{
|
||||
@ -1385,9 +1403,12 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
}
|
||||
index += 3;
|
||||
}
|
||||
if (textIndex < textSample.Length - 1)
|
||||
textSample[textIndex++] = buffer[index];
|
||||
index++;
|
||||
else
|
||||
{
|
||||
if (textIndex < textSample.Length - 1)
|
||||
textSample[textIndex++] = buffer[index];
|
||||
index++;
|
||||
}
|
||||
}
|
||||
previewBuffer = new byte[textIndex];
|
||||
for (int i = 0; i < textIndex; i++)
|
||||
@ -1622,7 +1643,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
{
|
||||
byte b = buffer[index];
|
||||
|
||||
if (b >= 0x30 && b <= 0x39) // numbers
|
||||
if (b >= 0x30 && b <= 0x39) // decimal digits
|
||||
return Encoding.ASCII.GetString(buffer, index, 1);
|
||||
|
||||
int idx = CyrillicCodes.IndexOf(b);
|
||||
|
@ -11,7 +11,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
//SUB[0 I 01:00:09:10>01:00:12:10]
|
||||
//SUB[0 N 01:00:09:10>01:00:12:10]
|
||||
|
||||
// Time code line can optionally contain "speaker"
|
||||
// Time code line can optionally contain "speaker"
|
||||
//SUB[0 N 01:02:02:03>01:02:03:06] VAL
|
||||
//e eu tenho maiô pra nadar?
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user