我的文字和字体对我的大部分应用都很好;但是,当我执行.DrawPath()并且路径在GraphicsPath中有一个字符串/文本时,它总是看起来很模糊或模糊。
有人能告诉我如何使用字符串输入.DrawPath看起来像GrahpicsPath.DrawString一样好吗?
//Bay Symbol
dc.DrawImage(Symbols.GetSymbol(SymbolType.Bay, (i + 1).ToString()), (x + (wPx / 2)) - 10, Constants.ELEVATION_START_Y - 35);
public static Bitmap GetSymbol(SymbolType symType, string text = "", bool attachLeg = true)
{
var sym = new Bitmap(50, 50);
sym.SetResolution(150, 150);
using (Graphics dc = Graphics.FromImage(sym))
{
dc.SmoothingMode = SmoothingMode.AntiAlias;
switch (symType)
{
//code removed for clarity
case SymbolType.Bay:
dc.DrawPath(ShopDrawing.Pens.GetSymbolPen(), CreateBaySymbol(text));
if (attachLeg)
AttachSymbolLeg(dc, Constants.BAY_SYMBOL);
break;
};
dc.SmoothingMode = SmoothingMode.Default;
return sym;
}
}
internal static GraphicsPath CreateBaySymbol(string text = "")
{
GraphicsPath myPath = new GraphicsPath();
myPath.AddRectangle(Constants.BAY_SYMBOL);
if (!string.IsNullOrEmpty(text)) { Util.AddStringToPath(myPath, text); }
return myPath;
}
internal static void AddStringToPath(GraphicsPath path, string text)
{
var textSize = TextRenderer.MeasureText(text, Constants.DETAIL_BOX_FONT);
float centerX = (path.GetBounds().Width / 2) - (textSize.Width / 2),
centerY = (path.GetBounds().Height / 2) - (textSize.Height / 2);
//Add the string to the path.
path.AddString(text,
Constants.DETAIL_BOX_FONT.FontFamily,
(int)Constants.DETAIL_BOX_FONT.Style,
Constants.DETAIL_BOX_FONT.Size,
new PointF(centerX + 2, centerY + 2),
StringFormat.GenericDefault)
符号=对下方标高的每个部分进行编号的符号。您可以看到编号将从1开始,然后是2然后是3,依此类推。
这是一个快照,显示所有字体/文本看起来如何好,如宽度和高度的数字,但符号内的编号看起来很糟糕。