本文整理汇总了C#中FontFamily类的典型用法代码示例。如果您正苦于以下问题:C# FontFamily类的具体用法?C# FontFamily怎么用?C# FontFamily使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FontFamily类属于命名空间,在下文中一共展示了FontFamily类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExamineKeystrokes
public ExamineKeystrokes()
{
Title = "Examine Keystrokes";
FontFamily = new FontFamily("Courier New");
Grid grid = new Grid();
Content = grid;
// Make one row "auto" and the other fill the remaining space.
RowDefinition rowdef = new RowDefinition();
rowdef.Height = GridLength.Auto;
grid.RowDefinitions.Add(rowdef);
grid.RowDefinitions.Add(new RowDefinition());
// Display header text.
TextBlock textHeader = new TextBlock();
textHeader.FontWeight = FontWeights.Bold;
textHeader.Text = strHeader;
grid.Children.Add(textHeader);
// Create StackPanel as child of ScrollViewer for displaying events.
scroll = new ScrollViewer();
grid.Children.Add(scroll);
Grid.SetRow(scroll, 1);
stack = new StackPanel();
scroll.Content = stack;
}
示例2: SetCustomData
/// <summary>
/// Main windows에 적용 할 수 있는 간략한 Data 테스트
/// </summary>
private void SetCustomData()
{
// 제목
Title = "Display Some Text";
//// 현재 창에 나타날 data
//Content = "Content can be simple text!";
// font 지정
FontFamily = new FontFamily("Comic Sans MS");
FontSize = 48;
// gradient 효과가 적용된 Brush
Brush brush = new LinearGradientBrush(Colors.Black, Colors.White, new Point(0,0), new Point(1,1));
Background = brush;
Foreground = brush;
// 현재 창의 content 내용에 따라 창의 크기를 조절 할 수 있는 값
SizeToContent = SizeToContent.WidthAndHeight;
// 현재 창의 Resizing 방법 지정
ResizeMode = ResizeMode.CanMinimize;
}
示例3: MakeSingleLineItem
public static FrameworkElement MakeSingleLineItem(string message, bool halfSize = false, bool fullWidth = true)
{
var size = halfSize ? 7 : 12;
var font = new FontFamily(halfSize ? "Lucida Console" : "Arial");
Brush color = Brushes.White;
var element = new TextBlock()
{
Text = message,
Background = Brushes.Transparent,
FontSize = size,
Margin = halfSize ? new Thickness(0, 0, 0, -1) : new Thickness(0, -2, 0, 0),
FontFamily = font,
TextWrapping = TextWrapping.NoWrap,
HorizontalAlignment = System.Windows.HorizontalAlignment.Center,
TextAlignment = System.Windows.TextAlignment.Center,
Foreground = color,
MinWidth = !fullWidth || halfSize ? 0 : BadgeCaps.Width,
UseLayoutRounding = true,
SnapsToDevicePixels = true
};
TextOptions.SetTextFormattingMode(element, TextFormattingMode.Display);
TextOptions.SetTextRenderingMode(element, TextRenderingMode.Aliased);
TextOptions.SetTextHintingMode(element, TextHintingMode.Fixed);
return element;
}
示例4: CreateScheduleClass
public CreateScheduleClass(string AppDirectory)
{
//create the formatting items
FontFamily AdobeJenson = new FontFamily(AppDirectory + AdobeJensonPath);
FontFamily Georgia = new FontFamily("Georgia");
fontFamily = Georgia;
}
示例5: ChatDocument
public ChatDocument(IInlineUploadViewFactory factory, IWebBrowser browser, IPasteViewFactory pasteViewFactory)
{
_factory = factory;
_browser = browser;
_pasteViewFactory = pasteViewFactory;
_handlers = new Dictionary<MessageType, Action<Message, User, Paragraph>>
{
{MessageType.TextMessage, FormatUserMessage},
{MessageType.TimestampMessage, FormatTimestampMessage},
{MessageType.LeaveMessage, FormatLeaveMessage},
{MessageType.KickMessage, FormatKickMessage},
{MessageType.PasteMessage, FormatPasteMessage},
{MessageType.EnterMessage, FormatEnterMessage},
{MessageType.UploadMessage, FormatUploadMessage},
{MessageType.TweetMessage, FormatTweetMessage},
{MessageType.AdvertisementMessage, FormatAdvertisementMessage},
{MessageType.TopicChangeMessage, FormatTopicChangeMessage}
};
FontSize = 14;
FontFamily = new FontFamily("Segoe UI");
AddHandler(Hyperlink.RequestNavigateEvent, new RequestNavigateEventHandler(NavigateToLink));
}
示例6: MeasureText
internal Size MeasureText(string text, FontFamily fontFamily, FontStyle fontStyle,
FontWeight fontWeight,
FontStretch fontStretch, double fontSize)
{
var typeface = new Typeface(fontFamily, fontStyle, fontWeight, fontStretch);
GlyphTypeface glyphTypeface;
if (!typeface.TryGetGlyphTypeface(out glyphTypeface))
{
return MeasureTextSize(text, fontFamily, fontStyle, fontWeight, fontStretch, fontSize);
}
double totalWidth = 0;
double height = 0;
foreach (var t in text)
{
var glyphIndex = glyphTypeface.CharacterToGlyphMap[t];
var width = glyphTypeface.AdvanceWidths[glyphIndex] * fontSize;
var glyphHeight = glyphTypeface.AdvanceHeights[glyphIndex] * fontSize;
if (glyphHeight > height)
{
height = glyphHeight;
}
totalWidth += width;
}
return new Size(totalWidth, height);
}
示例7: FontInfo
public FontInfo(FontFamily fontFamily, double fontSize)
{
FontFamily = fontFamily;
Size = fontSize;
LineHeight = fontSize * FontFamily.LineSpacing;
var fixedWidthCharacter = new FormattedText("X",
CultureInfo.CurrentCulture,
FlowDirection.LeftToRight,
new Typeface(FontFamily.Source),
fontSize,
Brushes.Black);
CharacterWidth = fixedWidthCharacter.Width;
var tabCharacter = new FormattedText("\t",
CultureInfo.CurrentCulture,
FlowDirection.LeftToRight,
new Typeface(FontFamily.Source),
fontSize,
Brushes.Black);
TabWidth = tabCharacter.WidthIncludingTrailingWhitespace;
LeftOffset = 0;
}
示例8: FontChanged
private void FontChanged(object sender, PrefChangeEventArgs e)
{
if (e.PrefName == "fiddler.ui.font.face")
{
var font = e.ValueString;
var fontFamily = new FontFamily(font);
_panel.Dispatcher.BeginInvoke((Action)(() =>
{
var style = new Style(typeof(StackPanel), _panel.Style);
style.Setters.Add(new Setter(TextBlock.FontFamilyProperty, fontFamily));
style.Seal();
_panel.Style = style;
}));
}
if (e.PrefName == "fiddler.ui.font.size")
{
double value;
if (double.TryParse(e.ValueString, out value))
{
_panel.Dispatcher.BeginInvoke((Action) (() =>
{
var fontSizeInPoints = value*96d/72d;
var style = new Style(typeof (StackPanel), _panel.Style);
style.Setters.Add(new Setter(TextBlock.FontSizeProperty, fontSizeInPoints));
style.Seal();
_panel.Style = style;
}));
}
}
}
示例9: AugmentQuickInfoSession
public void AugmentQuickInfoSession(IQuickInfoSession session, IList<object> qiContent, out ITrackingSpan applicableToSpan)
{
applicableToSpan = null;
if (!EnsureTreeInitialized() || session == null || qiContent == null)
return;
// Map the trigger point down to our buffer.
SnapshotPoint? point = session.GetTriggerPoint(_buffer.CurrentSnapshot);
if (!point.HasValue)
return;
ParseItem item = _tree.StyleSheet.ItemBeforePosition(point.Value.Position);
if (item == null || !item.IsValid)
return;
Declaration dec = item.FindType<Declaration>();
if (dec == null || !dec.IsValid || !_allowed.Contains(dec.PropertyName.Text.ToUpperInvariant()))
return;
string fontName = item.Text.Trim('\'', '"');
if (fonts.Families.SingleOrDefault(f => f.Name.Equals(fontName, StringComparison.OrdinalIgnoreCase)) != null)
{
FontFamily font = new FontFamily(fontName);
applicableToSpan = _buffer.CurrentSnapshot.CreateTrackingSpan(item.Start, item.Length, SpanTrackingMode.EdgeNegative);
qiContent.Add(CreateFontPreview(font, 10));
qiContent.Add(CreateFontPreview(font, 11));
qiContent.Add(CreateFontPreview(font, 12));
qiContent.Add(CreateFontPreview(font, 14));
qiContent.Add(CreateFontPreview(font, 25));
qiContent.Add(CreateFontPreview(font, 40));
}
}
示例10: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
string fName = ConfigurationManager.AppSettings["Code39Barcode.FontFamily"];
PrivateFontCollection fCollection = new PrivateFontCollection();
fCollection.AddFontFile(ConfigurationManager.AppSettings["Code39Barcode.FontFile"]);
FontFamily fFamily = new FontFamily(fName, fCollection);
Font f = new Font(fFamily, FontSize);
Bitmap bmp = new Bitmap(Width, Height);
Graphics g = Graphics.FromImage(bmp);
g.Clear(Color.White);
Brush b = new SolidBrush(Color.Black);
g.DrawString("*" + strPortfolioID + "*", f, b, 0, 0);
//PNG format has no visible compression artifacts like JPEG or GIF, so use this format, but it needs you to copy the bitmap into a new bitmap inorder to display the image properly. Weird MS bug.
Bitmap bm = new Bitmap(bmp);
System.IO.MemoryStream ms = new System.IO.MemoryStream();
Response.ContentType = "image/png";
bm.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
ms.WriteTo(Response.OutputStream);
b.Dispose();
bm.Dispose();
Response.End();
}
示例11: PFont
public PFont(string name, double size, bool smooth, char [] charset)
{
Family = new FontFamily (name);
Size = size;
Smooth = smooth;
Charset = charset;
}
示例12: MainWindowViewModel
public MainWindowViewModel()
{
BackgroundColor = new SolidColorBrush(Settings.Background);
ForegroundColor = new SolidColorBrush(Settings.Foreground);
FontFamily = new FontFamily(Settings.FontFamily);
FontSize = Settings.FontSize;
}
示例13: GenerateBarcodeImage
public Bitmap GenerateBarcodeImage(string text, FontFamily fontFamily, int fontSizeInPoints)
{
StringBuilder sb = new StringBuilder();
sb.Append("*");
sb.Append(text);
sb.Append("*");
Bitmap bmp = new Bitmap(1, 1, PixelFormat.Format32bppArgb);
Font font = new Font(fontFamily, fontSizeInPoints, FontStyle.Regular, GraphicsUnit.Point);
Graphics graphics = Graphics.FromImage(bmp);
SizeF textSize = graphics.MeasureString(sb.ToString(), font);
bmp = new Bitmap(bmp, textSize.ToSize());
graphics = Graphics.FromImage(bmp);
graphics.Clear(Color.White);
graphics.TextRenderingHint = TextRenderingHint.SingleBitPerPixel;
graphics.DrawString(sb.ToString(), font, new SolidBrush(Color.Black), 0, 0);
graphics.Flush();
font.Dispose();
graphics.Dispose();
return bmp;
}
示例14: FontInfo
/// <summary>
/// Initializes a new instance of the <see cref="FontInfo"/> class.
/// </summary>
/// <param name="family">The family.</param>
/// <param name="size">The size.</param>
/// <param name="style">The style.</param>
/// <param name="weight">The weight.</param>
public FontInfo(FontFamily family, double size, FontStyle style, FontWeight weight)
{
FontFamily = family;
FontSize = size;
FontStyle = style;
FontWeight = weight;
}
示例15: GetFontData
public FontData GetFontData(string fontFamilyName, bool isItalic, bool isBold)
{
FontData data = new FontData()
{
IsValid = false,
Bytes = null,
FontFamilyName = fontFamilyName,
IsItalic = isItalic,
IsBold = isBold
};
FontFamily fontFamily = new FontFamily(fontFamilyName);
FontStyle fontStyle = isItalic ? FontStyles.Italic : FontStyles.Normal;
FontWeight fontWeight = isBold ? FontWeights.Bold : FontWeights.Normal;
Typeface typeface = new Typeface(fontFamily, fontStyle, fontWeight, FontStretches.Normal);
GlyphTypeface glyphTypeface;
if (typeface.TryGetGlyphTypeface(out glyphTypeface))
{
using (var memoryStream = new MemoryStream())
{
glyphTypeface.GetFontStream().CopyTo(memoryStream);
data.Bytes = memoryStream.ToArray();
data.IsValid = true;
}
}
return data;
}