本文整理汇总了C#中System.Drawing.FontFamily类的典型用法代码示例。如果您正苦于以下问题:C# FontFamily类的具体用法?C# FontFamily怎么用?C# FontFamily使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FontFamily类属于System.Drawing命名空间,在下文中一共展示了FontFamily类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowDialog
public override void ShowDialog(object sender, EventArgs e)
{
FontDlg dlg = new FontDlg(FontFamily.Families);
if (dlg.ShowDialog() == DialogResult.OK)
{
string path = dlg.DestPath;
FontFamily[] fonts = dlg.SelectedFonts();
ProgressDlg pd = new ProgressDlg(DevStringTable.Instance["GUI:Converting"]);
pd.MinVal = 0;
pd.Value = 0;
pd.MaxVal = fonts.Length;
pd.Show();
for (int i = 0; i < fonts.Length; i++)
{
string dest = Path.Combine(path, Path.GetFileNameWithoutExtension(fonts[i].Name) + ".fnt");
currentFont = fonts[i];
Convert(null, new DevFileLocation(dest));
pd.Value = i;
}
pd.Close();
pd.Dispose();
}
}
示例2: AddChips
public AddChips()
{
FontFamily fontFamily = new FontFamily("Arial");
this.InitializeComponent();
this.ControlBox = false;
this.outOfChipsLabel.BorderStyle = BorderStyle.FixedSingle;
}
示例3: FontMetrics
public FontMetrics(Graphics g, Font f)
{
_f = f;
_ffm = f.FontFamily;
_fs = f.Style;
_g = g;
}
示例4: BitmapTypeface
public BitmapTypeface(string Name, bool Bold, bool Italic)
: base(Name, Bold, Italic)
{
this.GlyphMap = new Dictionary<char, Glyph>();
this.FontFamily = GetFamily(Name);
this._CreateSheet(ASCIICharacters);
}
示例5: CreateFont
private void CreateFont (string familyName, float emSize, FontStyle style, GraphicsUnit unit, byte charSet, bool isVertical)
{
#if ONLY_1_1
if (familyName == null)
throw new ArgumentNullException ("familyName");
#endif
originalFontName = familyName;
FontFamily family;
// NOTE: If family name is null, empty or invalid,
// MS creates Microsoft Sans Serif font.
try {
family = new FontFamily (familyName);
}
catch (Exception){
family = FontFamily.GenericSansSerif;
}
setProperties (family, emSize, style, unit, charSet, isVertical);
Status status = GDIPlus.GdipCreateFont (family.NativeObject, emSize, style, unit, out fontObject);
if (status == Status.FontStyleNotFound)
throw new ArgumentException (Locale.GetText ("Style {0} isn't supported by font {1}.", style.ToString (), familyName));
GDIPlus.CheckStatus (status);
}
示例6: DrawSegmentNumbers
public static Bitmap DrawSegmentNumbers(Bitmap bmp, Narray<Rect> bboxes)
{
int numAreaHeight = 10;
Bitmap newbitmap = new Bitmap(bmp.Width, bmp.Height + numAreaHeight, bmp.PixelFormat);
int height = bmp.Height;
using (Graphics g = Graphics.FromImage(newbitmap))
{
SolidBrush bgrnBrush = new SolidBrush(Color.White);
SolidBrush txtBrush = new SolidBrush(Color.Black);
Pen rectPen = new Pen(Color.DarkGray);
g.FillRectangle(bgrnBrush, new Rectangle(Point.Empty, newbitmap.Size));
g.DrawImage(bmp, Point.Empty);
bgrnBrush.Dispose();
FontFamily fontFam;
try { fontFam = new FontFamily("Tahoma"); }
catch { fontFam = FontFamily.GenericSansSerif; }
Font font = new Font(fontFam, 5f);
for (int i = 1; i < bboxes.Length(); i++)
{
Rect b = bboxes[i];
int bposY = (height - b.y1);
// draw bounding rects
g.DrawRectangle(rectPen, Math.Max(0, b.x0-1), Math.Max(0, bposY-1), b.W, b.H+1);
// draw numbers
g.DrawString(i.ToString(), font, txtBrush, b.x0, height + 1);
}
txtBrush.Dispose();
}
return newbitmap;
}
示例7: AddChipsWhenLost
public AddChipsWhenLost()
{
FontFamily fontFamily = new FontFamily("Arial");
InitializeComponent();
ControlBox = false;
label1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
}
示例8: OnDrawItem
/// <summary>
/// Occurs during the drawing of an item
/// </summary>
/// <param name="e"></param>
protected override void OnDrawItem(DrawItemEventArgs e)
{
Rectangle outer = e.Bounds;
outer.Inflate(1, 1);
e.Graphics.FillRectangle(Brushes.White, outer);
Brush fontBrush = Brushes.Black;
if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
{
Rectangle r = e.Bounds;
r.Inflate(-1, -1);
e.Graphics.FillRectangle(Global.HighlightBrush(r, Color.FromArgb(215, 238, 252)), r);
Pen p = new Pen(Color.FromArgb(215, 238, 252));
Global.DrawRoundedRectangle(e.Graphics, p, e.Bounds);
p.Dispose();
}
string name = Items[e.Index].ToString();
FontFamily ff = new FontFamily(name);
Font fnt = new Font("Arial", 10, FontStyle.Regular);
if (ff.IsStyleAvailable(FontStyle.Regular))
{
fnt = new Font(name, 10, FontStyle.Regular);
}
else if (ff.IsStyleAvailable(FontStyle.Italic))
{
fnt = new Font(name, 10, FontStyle.Italic);
}
SizeF box = e.Graphics.MeasureString(name, Font);
e.Graphics.DrawString(name, Font, fontBrush, e.Bounds.X, e.Bounds.Y);
e.Graphics.DrawString("ABC", fnt, fontBrush, e.Bounds.X + box.Width, e.Bounds.Y);
}
示例9: DrawBits
private void DrawBits()
{
try
{
string input = CleanString(toolStripTextBox1.Text);
toolStripTextBox1.Text = input;
byte[] buff = StringToByteArray(input);
Graphics g = pb1.CreateGraphics();
g.Clear(Color.White);
FontFamily fontFamily = new FontFamily("Courier New");
Font font = new Font(fontFamily, 10, FontStyle.Regular, GraphicsUnit.Pixel);
Brush solidBrush = new SolidBrush(Color.FromArgb(255, 0, 0, 255));
if (!toolStripButton2.Checked)
{
for (int i = 0; i < 8; i++)
g.DrawString((7 - i).ToString(), font, solidBrush, new PointF(10, i * 10 + 8));
for (int i = 0; i < buff.Length; i++)
for (int j = 0; j < 8; j++)
if (((1 << j) & buff[i]) != 0)
g.FillRectangle(Brushes.Black, new Rectangle(i * 10 + 20, (7 - j) * 10 + 10, 8, 8));
}
else
{
for (int i = 0; i < 8; i++)
g.DrawString(i.ToString(), font, solidBrush, new PointF(10, i * 10 + 8));
for (int i = 0; i < buff.Length; i++)
for (int j = 0; j < 8; j++)
if (((0x80 >> j) & buff[i]) != 0)
g.FillRectangle(Brushes.Black, new Rectangle(i * 10 + 20, (7 - j) * 10 + 10, 8, 8));
}
}
catch (Exception ex)
{
}
}
示例10: DrawString
/// <summary>
/// Renders text along the path
/// </summary>
/// <param name="self">The graphics object</param>
/// <param name="halo">The pen to render the halo outline</param>
/// <param name="fill">The brush to fill the text</param>
/// <param name="text">The text to render</param>
/// <param name="fontFamily">The font family to use</param>
/// <param name="style">The style</param>
/// <param name="emSize">The size</param>
/// <param name="format">The format</param>
/// <param name="ignoreLength"></param>
/// <param name="path"></param>
public static void DrawString(this Graphics self, Pen halo, Brush fill, string text, FontFamily fontFamily, int style, float emSize, StringFormat format, bool ignoreLength, GraphicsPath path)
{
if (path == null || path.PointCount == 0)
return;
var gp = new GraphicsPath();
gp.AddString(text, fontFamily, style, emSize, new Point(0, 0), format);
SortedList<float, GraphSegment> edges;
var totalLength = GetPathLength(path, out edges);
var warpedPath = PrepareTextPathToWarp(gp, totalLength, ignoreLength, format);
if (warpedPath == null)
return;
var wp = Warp(path, warpedPath, false, 0f);
if (wp != null)
{
if (halo != null)
self.DrawPath(halo, wp);
if (fill != null)
self.FillPath(fill, wp);
}
}
示例11: RenderGlyphs
/// <summary>
/// Renders the <see cref="Duality.Resources.Font"/> using the specified system font family.
/// </summary>
public static void RenderGlyphs(this DualityFont font, FontFamily fontFamily)
{
// Determine System.Drawing font style
SysDrawFontStyle style = SysDrawFontStyle.Regular;
if (font.Style.HasFlag(FontStyle.Bold)) style |= SysDrawFontStyle.Bold;
if (font.Style.HasFlag(FontStyle.Italic)) style |= SysDrawFontStyle.Italic;
// Create a System.Drawing font
SysDrawFont internalFont = null;
if (fontFamily != null)
{
try { internalFont = new SysDrawFont(fontFamily, font.Size, style); }
catch (Exception) { }
}
// If creating the font failed, fall back to a default one
if (internalFont == null)
internalFont = new SysDrawFont(FontFamily.GenericMonospace, font.Size, style);
// Render the font's glyphs
using (internalFont)
{
RenderGlyphs(font, internalFont);
}
}
示例12: FontFamily
static FontFamily() {
Container = new awt.Container();
_installedFonts = new InstalledFontCollection();
_genericMonospace = new FontFamily(GenericFontFamilies.Monospace);
_genericSansSerif = new FontFamily(GenericFontFamilies.SansSerif);
_genericSerif = new FontFamily(GenericFontFamilies.Serif);
}
示例13: CreateInfomationBitmap
private static Bitmap CreateInfomationBitmap(string content, int width, int height,
StringAlignment hAlign = StringAlignment.Near,
StringAlignment vAlign = StringAlignment.Near)
{
Bitmap b = new Bitmap(width, height);
Graphics g = Graphics.FromImage(b);
GraphicsPath path = new GraphicsPath();
FontFamily fontFamily = new FontFamily("微软雅黑");
StringFormat format = new StringFormat();
format.Alignment = hAlign;
format.LineAlignment = vAlign;
path.AddString(content,
fontFamily, (int)FontStyle.Bold, 16, new Rectangle(0, 0, width, height), format);
fontFamily.Dispose();
g.SmoothingMode = SmoothingMode.AntiAlias;
g.FillPath(Brushes.Black, path);
Pen pen = new Pen(Color.Black, 2);
g.DrawPath(pen, path);
g.Dispose();
pen.Dispose();
Bitmap infoBitmap = RenderUtils.BoxBlur(b, 1);
g = Graphics.FromImage(infoBitmap);
g.SmoothingMode = SmoothingMode.AntiAlias;
g.FillPath(Brushes.White, path);
g.Dispose();
return infoBitmap;
}
示例14: OnDrawItem
protected override void OnDrawItem(DrawItemEventArgs e)
{
if (!this.Enabled)
{
e.Graphics.FillRectangle(SystemBrushes.Control, e.Bounds);
}
else
{
e.DrawBackground();
string fontName = null;
if (e.Index == -1)
{
// Text shown in the combobox itself
fontName = this.Text;
}
else
{
fontName = (string)this.Items[e.Index];
}
Font font = null;
if ((fontName != null) && (fontName.Length != 0))
{
try
{
FontFamily fontFamily = new FontFamily(fontName);
FontStyle fontStyle = FontStyle.Regular;
if (!fontFamily.IsStyleAvailable(fontStyle))
{
fontStyle = FontStyle.Italic;
if (!fontFamily.IsStyleAvailable(fontStyle))
{
fontStyle = FontStyle.Bold;
if (!fontFamily.IsStyleAvailable(fontStyle))
{
throw new NotSupportedException();
}
}
}
font = new Font(fontName, (float)((e.Bounds.Height - 2) / 1.2), fontStyle, GraphicsUnit.Pixel);
}
catch (Exception)
{
}
}
Rectangle textBounds = new Rectangle(e.Bounds.Left + 2, e.Bounds.Top, e.Bounds.Width - 2, e.Bounds.Height);
using (TextGraphics textGraphics = new TextGraphics(e.Graphics))
{
textGraphics.DrawText(fontName, textBounds.Location, (font != null) ? font : e.Font, e.ForeColor);
}
if (font != null)
{
font.Dispose();
}
}
}
示例15: DrawText
public void DrawText(int x, int y, string message, Color? color = null, int? fontsize = null, string fontfamily = null, string fontstyle = null)
{
var family = FontFamily.GenericMonospace;
if (fontfamily != null)
{
family = new FontFamily(fontfamily);
}
var fstyle = FontStyle.Regular;
if (fontstyle != null)
{
switch (fontstyle.ToLower())
{
default:
case "regular":
break;
case "bold":
fstyle = FontStyle.Bold;
break;
case "italic":
fstyle = FontStyle.Italic;
break;
case "strikethrough":
fstyle = FontStyle.Strikeout;
break;
case "underline":
fstyle = FontStyle.Underline;
break;
}
}
var font = new Font(family, fontsize ?? 12, fstyle, GraphicsUnit.Pixel);
graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit;
graphics.DrawString(message, font, new SolidBrush(color ?? Color.White), x, y);
}