mirror of
https://github.com/ShareX/ShareX.git
synced 2024-07-02 21:20:28 +12:00
Calculate proper font size for AddString
This commit is contained in:
parent
b66f09f9dc
commit
01682b0e3e
|
@ -177,12 +177,16 @@ public static void DrawTextWithOutline(this Graphics g, string text, PointF posi
|
|||
{
|
||||
using (StringFormat sf = new StringFormat())
|
||||
{
|
||||
gp.AddString(text, font.FontFamily, (int)font.Style, font.Size, position, sf);
|
||||
float emSize = g.DpiY * font.SizeInPoints / 72;
|
||||
gp.AddString(text, font.FontFamily, (int)font.Style, emSize, position, sf);
|
||||
}
|
||||
|
||||
using (Pen borderPen = new Pen(borderColor, borderSize) { LineJoin = LineJoin.Round })
|
||||
if (borderSize > 0)
|
||||
{
|
||||
g.DrawPath(borderPen, gp);
|
||||
using (Pen borderPen = new Pen(borderColor, borderSize) { LineJoin = LineJoin.Round })
|
||||
{
|
||||
g.DrawPath(borderPen, gp);
|
||||
}
|
||||
}
|
||||
|
||||
using (Brush textBrush = new SolidBrush(textColor))
|
||||
|
|
|
@ -47,7 +47,7 @@ public class AnnotationOptions
|
|||
public TextDrawingOptions TextOutlineOptions { get; set; } = new TextDrawingOptions()
|
||||
{
|
||||
Color = PrimaryColor,
|
||||
Size = 40,
|
||||
Size = 30,
|
||||
Bold = true
|
||||
};
|
||||
public Color TextOutlineBorderColor { get; set; } = SecondaryColor;
|
||||
|
|
|
@ -63,7 +63,8 @@ protected void DrawTextWithOutline(Graphics g, string text, TextDrawingOptions o
|
|||
using (Font font = new Font(options.Font, options.Size, options.Style))
|
||||
using (StringFormat sf = new StringFormat { Alignment = options.AlignmentHorizontal, LineAlignment = options.AlignmentVertical })
|
||||
{
|
||||
gp.AddString(text, font.FontFamily, (int)font.Style, font.Size, rect, sf);
|
||||
float emSize = g.DpiY * font.SizeInPoints / 72;
|
||||
gp.AddString(text, font.FontFamily, (int)font.Style, emSize, rect, sf);
|
||||
}
|
||||
|
||||
g.SmoothingMode = SmoothingMode.HighQuality;
|
||||
|
|
Loading…
Reference in a new issue