, bir Özel'i oluşturmaya çalışıyorum Gerçek olmayan yazı tiplerini filtreleyen Yazı tipi-ailelerini kullanan Yazı Tipi İletişim Kutusu.olmayan true type yazı tipi
Control mükemmel çalışıyor ama bu diyalog bir boyut ve stil seçicileri gerekir. Mevcut kodu gönderiyorum. Lütfen buna bir boyut ve stil seçicisi eklememe yardımcı olun. Aynı zamanda sizin için de yararlı olabilir.
public class FontListBox : ListBox
{
private List<Font> _fonts = new List<Font>();
private Brush _foreBrush;
public FontListBox()
{
DrawMode = DrawMode.OwnerDrawFixed;
ItemHeight = 20;
foreach (FontFamily ff in FontFamily.Families)
{
// determine the first available style, as all fonts don't support all styles
FontStyle? availableStyle = null;
foreach (FontStyle style in Enum.GetValues(typeof(FontStyle)))
{
if (ff.IsStyleAvailable(style))
{
availableStyle = style;
break;
}
}
if (availableStyle.HasValue)
{
Font font = null;
try
{
// do your own Font initialization here
// discard the one you don't like :-)
font = new Font(ff, 12, availableStyle.Value);
}
catch
{
}
if (font != null)
{
_fonts.Add(font);
Items.Add(font);
}
}
}
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (_fonts != null)
{
foreach (Font font in _fonts)
{
font.Dispose();
}
_fonts = null;
}
if (_foreBrush != null)
{
_foreBrush.Dispose();
_foreBrush = null;
}
}
public override Color ForeColor
{
get
{
return base.ForeColor;
}
set
{
base.ForeColor = value;
if (_foreBrush != null)
{
_foreBrush.Dispose();
}
_foreBrush = null;
}
}
private Brush ForeBrush
{
get
{
if (_foreBrush == null)
{
_foreBrush = new SolidBrush(ForeColor);
}
return _foreBrush;
}
}
protected override void OnDrawItem(DrawItemEventArgs e)
{
base.OnDrawItem(e);
if (e.Index < 0)
return;
e.DrawBackground();
e.DrawFocusRectangle();
Rectangle bounds = e.Bounds;
Font font = (Font)Items[e.Index];
e.Graphics.DrawString(font.Name, font, ForeBrush, bounds.Left, bounds.Top);
}
}
public partial class MyFontDialog : Form
{
private FontListBox _fontListBox;
public MyFontDialog()
{
InitializeComponent();
_fontListBox = new FontListBox();
_fontListBox.Dock = DockStyle.Fill;
Controls.Add(_fontListBox);
}
}
Ben https://sourceforge.net/p/newfontpicker/
FontDialog sınıfı zaten TrueType olmayan yazı tiplerini filtreler. Buradaki gerçek çözüm, kötü meta verilere sahip yazı tipini kaldırmaktır. –
http://c-madeeasy.blogspot.com/2011/11/unsolved-this-is-not-true-type-font.html – techno
bkz No.Please Bu açıştürü fontları filtrelemek için çalışır ancak bazı yazı tipleri hala var Olmazsa http://connect.microsoft.com/VisualStudio/feedback/details/708872/this-is-not-a-true-type-font-only-true-type-fonts-are-accepted-exception – techno