mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 19:22:53 +01:00
Fix "Batch convert" issue with new auto-br optimzation
This commit is contained in:
parent
8523cce93e
commit
e091b30707
@ -17,6 +17,7 @@ namespace Nikse.SubtitleEdit.Core
|
|||||||
|
|
||||||
private static readonly Graphics Graphics = Graphics.FromHwnd(IntPtr.Zero);
|
private static readonly Graphics Graphics = Graphics.FromHwnd(IntPtr.Zero);
|
||||||
private static readonly Font DefaultFont = SystemFonts.DefaultFont;
|
private static readonly Font DefaultFont = SystemFonts.DefaultFont;
|
||||||
|
private static readonly object GdiLock = new object();
|
||||||
|
|
||||||
public TextSplitResult(List<string> lines)
|
public TextSplitResult(List<string> lines)
|
||||||
{
|
{
|
||||||
@ -24,15 +25,24 @@ namespace Nikse.SubtitleEdit.Core
|
|||||||
LengthPixels = new List<float>();
|
LengthPixels = new List<float>();
|
||||||
if (Configuration.Settings.Tools.AutoBreakUsePixelWidth)
|
if (Configuration.Settings.Tools.AutoBreakUsePixelWidth)
|
||||||
{
|
{
|
||||||
var lineOneWidth = Graphics.MeasureString(Lines[0], DefaultFont).Width;
|
lock (GdiLock)
|
||||||
LengthPixels.Add(lineOneWidth);
|
{
|
||||||
|
var lineOneWidth = Graphics.MeasureString(Lines[0], DefaultFont).Width;
|
||||||
|
LengthPixels.Add(lineOneWidth);
|
||||||
|
}
|
||||||
|
|
||||||
var lineTwoWidth = Graphics.MeasureString(Lines[1], DefaultFont).Width;
|
lock (GdiLock)
|
||||||
LengthPixels.Add(lineTwoWidth);
|
{
|
||||||
|
var lineTwoWidth = Graphics.MeasureString(Lines[1], DefaultFont).Width;
|
||||||
|
LengthPixels.Add(lineTwoWidth);
|
||||||
|
}
|
||||||
|
|
||||||
if (Math.Abs(SpaceLengthPixels) < 0.01)
|
if (Math.Abs(SpaceLengthPixels) < 0.01)
|
||||||
{
|
{
|
||||||
SpaceLengthPixels = Graphics.MeasureString(" ", DefaultFont).Width;
|
lock (GdiLock)
|
||||||
|
{
|
||||||
|
SpaceLengthPixels = Graphics.MeasureString(" ", DefaultFont).Width;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user