From bbc56f3df32adf0a601adf4758a64ec39bb185b4 Mon Sep 17 00:00:00 2001 From: niksedk Date: Sat, 29 Jun 2013 06:57:54 +0000 Subject: [PATCH] Fixed baseline horizontal alignment in Export to Blu-ray sup - thx THXTEX :) git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@1895 99eadd0c-20b8-1223-b5c4-2a2b2df33de2 --- src/Changelog.txt | 3 ++- src/Forms/ExportPngXml.cs | 17 ++++++++++++++--- src/Logic/TextDraw.cs | 8 +++----- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/Changelog.txt b/src/Changelog.txt index 940a58b04..1725a408f 100644 --- a/src/Changelog.txt +++ b/src/Changelog.txt @@ -16,7 +16,8 @@ * Fixed annoying crash when loading a subtitle from 'source view' * OCR - Change ocr fix language when changing spell check dictionary * Fixed Hebrew in PAC files - thx Yaniv - * Fixed minor language detection bug regarding Korean - thx Hoyt :) + * Fixed minor language detection bug regarding Korean - thx Hoyt + * Fixed baseline horizontal alignment in Export to Blu-ray sup - thx THXTEX 3.3.6 (15th June 2013) diff --git a/src/Forms/ExportPngXml.cs b/src/Forms/ExportPngXml.cs index 421e25ea7..edef5803c 100644 --- a/src/Forms/ExportPngXml.cs +++ b/src/Forms/ExportPngXml.cs @@ -1042,16 +1042,16 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine + BdnXmlTimeCode(param.P.EndTime) + "\" Forced=\"False\">"); int x = (width - param.Bitmap.Width) / 2; - int y = height - (param.Bitmap.Height + border); + int y = height - (param.Bitmap.Height + param.BottomMargin); switch (param.Alignment) { case ContentAlignment.BottomLeft: x = border; - y = height - (param.Bitmap.Height + border); + y = height - (param.Bitmap.Height + param.BottomMargin); break; case ContentAlignment.BottomRight: x = height - param.Bitmap.Width - border; - y = height - (param.Bitmap.Height + border); + y = height - (param.Bitmap.Height + param.BottomMargin); break; case ContentAlignment.MiddleCenter: x = (width - param.Bitmap.Width) / 2; @@ -1313,6 +1313,17 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine + if (parameter.BackgroundColor != Color.Transparent) g.FillRectangle(new SolidBrush(parameter.BackgroundColor), 0, 0, bmp.Width, bmp.Height); + // align lines with gjpqy a bit lower + var lines = text.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + if (lines[lines.Length - 1].Contains("g") || lines[lines.Length - 1].Contains("j") || lines[lines.Length - 1].Contains("p") || lines[lines.Length - 1].Contains("q") || lines[lines.Length - 1].Contains("y")) + { + string textNoBelow = lines[lines.Length - 1].Replace("g", "a").Replace("j", "a").Replace("p", "a").Replace("q", "a").Replace("y", "a"); + int removeFromBottomMargin = (int)Math.Round((TextDraw.MeasureTextHeight(font, lines[lines.Length - 1], parameter.SubtitleFontBold) - TextDraw.MeasureTextHeight(font, textNoBelow, parameter.SubtitleFontBold))); + parameter.BottomMargin -= removeFromBottomMargin; + if (parameter.BottomMargin < 0) + parameter.BottomMargin = 0; + } + var lefts = new List(); foreach (string line in Utilities.RemoveHtmlFontTag(text.Replace("", string.Empty).Replace("", string.Empty)).Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries)) { diff --git a/src/Logic/TextDraw.cs b/src/Logic/TextDraw.cs index 9ffc9fdfc..8542485c0 100644 --- a/src/Logic/TextDraw.cs +++ b/src/Logic/TextDraw.cs @@ -77,7 +77,7 @@ namespace Nikse.SubtitleEdit.Logic if (list[i].X > width) width = list[i].X; } - int max = 45; + int max = 50; if (max > list.Length) max = list.Length; for (int i = 0; i < max; i++) @@ -111,10 +111,8 @@ namespace Nikse.SubtitleEdit.Logic if (list[i].Y > height) height = list[i].Y; } - int max = 85; - if (max > list.Length) - max = list.Length; - for (int i = 0; i < max; i++) + + for (int i = 0; i < list.Length; i++) { if (list[i].Y > height) height = list[i].Y;