Make font size for export images more like vlc/mpv

This commit is contained in:
Nikolaj Olsson 2017-10-01 15:25:00 +02:00
parent 53c0737e76
commit 86fee61d26
2 changed files with 7 additions and 7 deletions

View File

@ -7,9 +7,9 @@ namespace Nikse.SubtitleEdit.Core
public static class TextDraw
{
public static double GetFontSizeFactor(double fontSize)
public static double GetFontSize(double fontSize)
{
return fontSize / (1.614 * fontSize - 10.3);
return fontSize * 0.895d; // font rendered in video players like vlc/mpv are a little smaller than .net, so we adjust font size a bit down
}
public static void DrawText(Font font, StringFormat sf, GraphicsPath path, StringBuilder sb, bool isItalic, bool isBold, bool isUnderline, float left, float top, ref bool newLine, float leftMargin, ref int pathPointsStart)
@ -45,7 +45,7 @@ namespace Nikse.SubtitleEdit.Core
if (isUnderline)
fontStyle |= FontStyle.Underline;
var fontSize = (float) (font.Size * GetFontSizeFactor(font.Size));
var fontSize = (float) GetFontSize(font.Size);
try
{
path.AddString(sb.ToString(), font.FontFamily, (int)fontStyle, fontSize, next, sf);

View File

@ -2580,7 +2580,7 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
surface.InterpolationMode = InterpolationMode.Default;
surface.SmoothingMode = SmoothingMode.HighSpeed;
surface.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
var newFontSize = (float)(0.439 * font.Size + 6.23); // make simple rendering close to same size as normal renderer
var newFontSize = (float)(font.Size * 0.7); // make simple rendering close to same size as normal renderer
using (var newFont = new Font(font.FontFamily, newFontSize, font.Style))
{
for (int j = 0; j < parameter.BorderWidth; j++)
@ -3719,7 +3719,7 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
SubtitleFontSize = style.FontSize,
SubtitleFontBold = style.Bold
};
var fontSize = (float)(mbp.SubtitleFontSize * TextDraw.GetFontSizeFactor(mbp.SubtitleFontSize));
var fontSize = (float) TextDraw.GetFontSize(mbp.SubtitleFontSize);
Font font = SetFont(mbp, fontSize);
SizeF textSize = g.MeasureString("Hj!", font);
int lineHeight = (int)Math.Round(textSize.Height * 0.64f);
@ -4019,7 +4019,7 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
SubtitleFontBold = checkBoxBold.Checked
};
var fontSize = (float)(mbp.SubtitleFontSize * TextDraw.GetFontSizeFactor(mbp.SubtitleFontSize));
var fontSize = (float)TextDraw.GetFontSize(mbp.SubtitleFontSize);
Font font = SetFont(mbp, fontSize);
SizeF textSize = g.MeasureString("Hj!", font);
int lineHeight = (int)Math.Round(textSize.Height * 0.64f);
@ -4325,7 +4325,7 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
SubtitleFontSize = float.Parse(comboBoxSubtitleFontSize.SelectedItem.ToString()),
SubtitleFontBold = _subtitleFontBold
};
var fontSize = (float)(mbp.SubtitleFontSize * TextDraw.GetFontSizeFactor(mbp.SubtitleFontSize));
var fontSize = (float)TextDraw.GetFontSize(mbp.SubtitleFontSize);
Font font = SetFont(mbp, fontSize);
SizeF textSize = g.MeasureString("Hj!", font);