本文整理汇总了C#中FontWeight类的典型用法代码示例。如果您正苦于以下问题:C# FontWeight类的具体用法?C# FontWeight怎么用?C# FontWeight使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FontWeight类属于命名空间,在下文中一共展示了FontWeight类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FormattedTextImpl
public FormattedTextImpl(string text, string fontFamilyName, double fontSize, FontStyle fontStyle,
TextAlignment textAlignment, FontWeight fontWeight, TextWrapping wrapping)
{
_text = text ?? string.Empty;
// Replace 0 characters with zero-width spaces (200B)
_text = _text.Replace((char)0, (char)0x200B);
var typeface = TypefaceCache.GetTypeface(fontFamilyName, fontStyle, fontWeight);
_paint = new SKPaint();
//currently Skia does not measure properly with Utf8 !!!
//Paint.TextEncoding = SKTextEncoding.Utf8;
_paint.TextEncoding = SKTextEncoding.Utf16;
_paint.IsStroke = false;
_paint.IsAntialias = true;
_paint.LcdRenderText = true;
_paint.SubpixelText = true;
_paint.Typeface = typeface;
_paint.TextSize = (float)fontSize;
_paint.TextAlign = textAlignment.ToSKTextAlign();
_wrapping = wrapping;
Rebuild();
}
示例2: DrawableFont
///<summary>
/// Creates a new DrawableFont instance.
///</summary>
///<param name="family">The font family or the full path to the font file.</param>
///<param name="style">The style of the font.</param>
///<param name="weight">The weight of the font.</param>
///<param name="stretch">The font stretching type.</param>
public DrawableFont(string family, FontStyleType style, FontWeight weight, FontStretch stretch)
{
Family = family;
Style = style;
Weight = weight;
Stretch = stretch;
}
示例3: FormattedText
/// <summary>
/// Initializes a new instance of the <see cref="FormattedText"/> class.
/// </summary>
/// <param name="text">The text.</param>
/// <param name="fontFamilyName">The font family.</param>
/// <param name="fontSize">The font size.</param>
/// <param name="fontStyle">The font style.</param>
/// <param name="textAlignment">The text alignment.</param>
/// <param name="fontWeight">The font weight.</param>
public FormattedText(
string text,
string fontFamilyName,
double fontSize,
FontStyle fontStyle,
TextAlignment textAlignment,
FontWeight fontWeight)
{
Contract.Requires<ArgumentNullException>(text != null);
Contract.Requires<ArgumentNullException>(fontFamilyName != null);
Contract.Requires<ArgumentException>(fontSize > 0);
Text = text;
FontFamilyName = fontFamilyName;
FontSize = fontSize;
FontStyle = fontStyle;
FontWeight = fontWeight;
TextAlignment = textAlignment;
var platform = PerspexLocator.Current.GetService<IPlatformRenderInterface>();
if (platform == null)
{
throw new Exception("Could not create FormattedText: IPlatformRenderInterface not registered.");
}
PlatformImpl = platform.CreateFormattedText(
text,
fontFamilyName,
fontSize,
fontStyle,
textAlignment,
fontWeight);
}
示例4: Typeface
public Typeface(FontFamily fontFamily, FontStyle style, FontWeight weight, FontStretch stretch)
{
this.FontFamily = fontFamily;
this.Style = style;
this.Weight = weight;
this.Stretch = stretch;
}
示例5: FormattedText
/// <summary>
/// Initializes a new instance of the <see cref="FormattedText"/> class.
/// </summary>
/// <param name="text">The text.</param>
/// <param name="fontFamilyName">The font family.</param>
/// <param name="fontSize">The font size.</param>
/// <param name="fontStyle">The font style.</param>
/// <param name="textAlignment">The text alignment.</param>
/// <param name="fontWeight">The font weight.</param>
public FormattedText(
string text,
string fontFamilyName,
double fontSize,
FontStyle fontStyle,
TextAlignment textAlignment,
FontWeight fontWeight)
{
//TODO: Find out why it was null in the first place. Demo project - AvalonStudio
//https://github.com/VitalElement/AvalonStudio/commit/787fb9396feb74e6ca6bd4e08436269a349df9c6
text = text ?? "";
Text = text;
FontFamilyName = fontFamilyName;
FontSize = fontSize;
FontStyle = fontStyle;
FontWeight = fontWeight;
TextAlignment = textAlignment;
var platform = PerspexLocator.Current.GetService<IPlatformRenderInterface>();
PlatformImpl = platform.CreateFormattedText(
text,
fontFamilyName,
fontSize,
fontStyle,
textAlignment,
fontWeight);
}
示例6: FormattedTextImpl
public FormattedTextImpl(
Pango.Context context,
string text,
string fontFamily,
double fontSize,
FontStyle fontStyle,
TextAlignment textAlignment,
FontWeight fontWeight)
{
Contract.Requires<ArgumentNullException>(context != null);
Contract.Requires<ArgumentNullException>(text != null);
Layout = new Pango.Layout(context);
_text = text;
Layout.SetText(text);
Layout.FontDescription = new Pango.FontDescription
{
Family = fontFamily,
Size = Pango.Units.FromDouble(CorrectScale(fontSize)),
Style = (Pango.Style)fontStyle,
Weight = fontWeight.ToCairo()
};
Layout.Alignment = textAlignment.ToCairo();
Layout.Attributes = new Pango.AttrList();
}
示例7: Font
public Font(string family, float size, FontWeight weight, FontSlant style)
{
this.Family = family;
this.Size = size;
this.Weight = weight;
this.Style = style;
}
示例8: Font
public Font(string family, FontStyle style, FontWeight weight, float size)
{
Family = family;
mStyle = style;
Weight = weight;
Size = size;
}
示例9: FormattedTextImpl
public FormattedTextImpl(
string text,
string fontFamily,
double fontSize,
FontStyle fontStyle,
TextAlignment textAlignment,
FontWeight fontWeight)
{
var factory = Locator.Current.GetService<DWrite.Factory>();
var format = new DWrite.TextFormat(
factory,
fontFamily,
(DWrite.FontWeight)fontWeight,
(DWrite.FontStyle)fontStyle,
(float)fontSize);
TextLayout = new DWrite.TextLayout(
factory,
text ?? string.Empty,
format,
float.MaxValue,
float.MaxValue);
TextLayout.TextAlignment = textAlignment.ToDirect2D();
}
示例10: Typeface
public Typeface(FontFamily fontFamily, FontStyle style = FontStyle.Normal, FontWeight weight = FontWeight.Normal, FontStretch stretch = FontStretch.Normal)
{
this.FontFamily = fontFamily;
this.Style = style;
this.Weight = weight;
this.Stretch = stretch;
}
示例11: FormattedText
public FormattedText(
string text,
string fontFamilyName,
double fontSize,
FontStyle fontStyle,
TextAlignment textAlignment,
FontWeight fontWeight)
{
this.Text = text;
this.FontFamilyName = fontFamilyName;
this.FontSize = fontSize;
this.FontStyle = fontStyle;
this.FontWeight = fontWeight;
this.TextAlignment = textAlignment;
var platform = Locator.Current.GetService<IPlatformRenderInterface>();
this.PlatformImpl = platform.CreateFormattedText(
text,
fontFamilyName,
fontSize,
fontStyle,
textAlignment,
fontWeight);
}
示例12: FormattedTextImpl
public FormattedTextImpl(
string text,
string fontFamily,
double fontSize,
FontStyle fontStyle,
TextAlignment textAlignment,
FontWeight fontWeight,
TextWrapping wrapping)
{
var factory = AvaloniaLocator.Current.GetService<DWrite.Factory>();
using (var format = new DWrite.TextFormat(
factory,
fontFamily,
(DWrite.FontWeight)fontWeight,
(DWrite.FontStyle)fontStyle,
(float)fontSize))
{
format.WordWrapping = wrapping == TextWrapping.Wrap ?
DWrite.WordWrapping.Wrap : DWrite.WordWrapping.NoWrap;
TextLayout = new DWrite.TextLayout(
factory,
text ?? string.Empty,
format,
float.MaxValue,
float.MaxValue);
}
TextLayout.TextAlignment = textAlignment.ToDirect2D();
}
示例13: HtmlFont
public HtmlFont(FontStyle style, FontVariant variant, FontWeight weight, Unit size, FontFamily family)
{
this.style = style;
this.variant = variant;
this.family = family;
this.weight = weight;
this.size = size;
}
示例14: Create
public override object Create(string fontName, double size, FontStyle style, FontWeight weight, FontStretch stretch)
{
object o = NSFont.FromFontName (fontName, (float)size);
o = SetStyle (o, style);
o = SetWeight (o, weight);
o = SetStretch (o, stretch);
return o;
}
示例15: DrawableFont
/// <summary>
/// Initializes a new instance of the <see cref="DrawableFont"/> class.
/// </summary>
/// <param name="family">The font family or the full path to the font file.</param>
/// <param name="style">The style of the font.</param>
/// <param name="weight">The weight of the font.</param>
/// <param name="stretch">The font stretching type.</param>
public DrawableFont(string family, FontStyleType style, FontWeight weight, FontStretch stretch)
{
Throw.IfNullOrEmpty(nameof(family), family);
Family = family;
Style = style;
Weight = weight;
Stretch = stretch;
}