Add option (in image export) to have single lines top justified - thx joedmartin :)

Fix #3248
This commit is contained in:
Nikolaj Olsson 2018-12-23 09:05:57 +01:00
parent 64bfb7f48f
commit e78bed819f
6 changed files with 25 additions and 0 deletions

View File

@ -1,5 +1,15 @@
Subtitle Edit Changelog
3.5.9 (xth March 2019) BETA
* NEW:
* Image export - option to have single lines top justified - thx joedmartin
* IMPROVED:
* Update Hungarian translation - thx Zityi
* FIXED:
* Fix OCR in batch convert - thx danstraughn
* Fixed crash parsing empty word in OCR via Tesseract - thx Barry
* Fix crash in OCR window when closing - thx spetragl
3.5.8 (20th December 2018)
* NEW:

View File

@ -476,6 +476,7 @@ Note: Do check free disk space.</WaveFileMalformed>
<Right>Right</Right>
<Center>Center</Center>
<CenterLeftJustify>Center, left justify</CenterLeftJustify>
<CenterTopJustify>Center, top justify</CenterTopJustify>
<BottomMargin>Bottom margin</BottomMargin>
<LeftRightMargin>Left/right margin</LeftRightMargin>
<SaveBluRraySupAs>Choose Blu-ray sup file name</SaveBluRraySupAs>

View File

@ -660,6 +660,7 @@ namespace Nikse.SubtitleEdit.Core
Center = "Center",
Right = "Right",
CenterLeftJustify = "Center, left justify",
CenterTopJustify = "Center, top justify",
BottomMargin = "Bottom margin",
LeftRightMargin = "Left/right margin",
SaveBluRraySupAs = "Choose Blu-ray sup file name",

View File

@ -1228,6 +1228,9 @@ namespace Nikse.SubtitleEdit.Core
case "ExportPngXml/CenterLeftJustify":
language.ExportPngXml.CenterLeftJustify = reader.Value;
break;
case "ExportPngXml/CenterTopJustify":
language.ExportPngXml.CenterTopJustify = reader.Value;
break;
case "ExportPngXml/BottomMargin":
language.ExportPngXml.BottomMargin = reader.Value;
break;

View File

@ -533,6 +533,7 @@
public string Right { get; set; }
public string Center { get; set; }
public string CenterLeftJustify { get; set; }
public string CenterTopJustify { get; set; }
public string BottomMargin { get; set; }
public string LeftRightMargin { get; set; }
public string SaveBluRraySupAs { get; set; }

View File

@ -57,6 +57,7 @@ namespace Nikse.SubtitleEdit.Forms
public bool AlignLeft { get; set; }
public bool AlignRight { get; set; }
public bool JustifyLeft { get; set; }
public bool JustifyTop { get; set; }
public byte[] Buffer { get; set; }
public int ScreenWidth { get; set; }
public int ScreenHeight { get; set; }
@ -354,6 +355,7 @@ namespace Nikse.SubtitleEdit.Forms
AlignLeft = comboBoxHAlign.SelectedIndex == 0,
AlignRight = comboBoxHAlign.SelectedIndex == 2,
JustifyLeft = comboBoxHAlign.SelectedIndex == 3, // center, left justify
JustifyTop = comboBoxHAlign.SelectedIndex == 4, // center, top justify
ScreenWidth = screenWidth,
ScreenHeight = screenHeight,
VideoResolution = comboBoxResolution.Text,
@ -2001,6 +2003,7 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
mbp.AlignLeft = comboBoxHAlign.SelectedIndex == 0;
mbp.AlignRight = comboBoxHAlign.SelectedIndex == 2;
mbp.JustifyLeft = comboBoxHAlign.SelectedIndex == 3;
mbp.JustifyTop = comboBoxHAlign.SelectedIndex == 4;
mbp.SimpleRendering = checkBoxSimpleRender.Checked;
mbp.BorderWidth = _borderWidth;
mbp.BorderColor = _borderColor;
@ -2531,6 +2534,11 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
baseLinePadding = 0;
}
if (lines.Count == 1 && parameter.JustifyTop) // align top
{
baseLinePadding += (int)Math.Round(TextDraw.MeasureTextHeight(font, "yjK)", parameter.SubtitleFontBold));
}
// TODO: Better baseline - test http://bobpowell.net/formattingtext.aspx
//float baselineOffset=font.SizeInPoints/font.FontFamily.GetEmHeight(font.Style)*font.FontFamily.GetCellAscent(font.Style);
//float baselineOffsetPixels = g.DpiY/72f*baselineOffset;
@ -3414,6 +3422,7 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
comboBoxHAlign.Items.Add(Configuration.Settings.Language.ExportPngXml.Center);
comboBoxHAlign.Items.Add(Configuration.Settings.Language.ExportPngXml.Right);
comboBoxHAlign.Items.Add(Configuration.Settings.Language.ExportPngXml.CenterLeftJustify);
comboBoxHAlign.Items.Add(Configuration.Settings.Language.ExportPngXml.CenterTopJustify);
}
buttonShadowColor.Text = Configuration.Settings.Language.ExportPngXml.ShadowColor;