本文整理汇总了C#中FontStyle类的典型用法代码示例。如果您正苦于以下问题:C# FontStyle类的具体用法?C# FontStyle怎么用?C# FontStyle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FontStyle类属于命名空间,在下文中一共展示了FontStyle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: setFontStyle
private void setFontStyle(RichTextBox rtb, FontStyle style)
{
if (rtb.SelectionLength == 0)
setCharFontStyle(rtb, style);
else
{
// to avoid screen refreshing, we create a fake RichTextBox
using (RichTextBox a = new RichTextBox())
{
a.SuspendLayout();
a.SelectedRtf = rtb.SelectedRtf;
a.SelectAll();
int selectionStart = a.SelectionStart;
int selectionLength = a.SelectionLength;
int selectionEnd = selectionStart + selectionLength;
for (int x = selectionStart; x < selectionEnd; ++x)
{
// Set temporary selection
a.Select(x, 1);
// Toggle font style of the selection
setCharFontStyle(a, style);
}
// Restore the original selection
a.SelectAll();
rtb.SelectedRtf = a.SelectedRtf;
}
}
}
示例2: Set
public void Set(TextBlock textBlock)
{
this.fontFamily = textBlock.FontFamily;
this.fontWeight = textBlock.FontWeight;
this.fontStyle = textBlock.FontStyle;
this.fontStretch = textBlock.FontStretch;
}
示例3: 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();
}
示例4: QFont
public QFont(string fileName, float size, FontStyle style, QFontBuilderConfiguration config)
{
PrivateFontCollection pfc = new PrivateFontCollection();
pfc.AddFontFile(fileName);
var fontFamily = pfc.Families[0];
if (!fontFamily.IsStyleAvailable(style))
throw new ArgumentException("Font file: " + fileName + " does not support style: " + style );
if (config == null)
config = new QFontBuilderConfiguration();
TransformViewport? transToVp = null;
float fontScale = 1f;
if (config.TransformToCurrentOrthogProjection)
transToVp = OrthogonalTransform(out fontScale);
using(var font = new Font(fontFamily, size * fontScale * config.SuperSampleLevels, style)){
fontData = BuildFont(font, config, null);
}
if (config.ShadowConfig != null)
Options.DropShadowActive = true;
if (transToVp != null)
Options.TransformToViewport = transToVp;
if(config.UseVertexBuffer)
InitVBOs();
}
示例5: SccPositionAndStyle
public SccPositionAndStyle(Color color, FontStyle style, int y, int x)
{
ForeColor = color;
Style = style;
X = x;
Y = y;
}
示例6: DrawStringContext
public DrawStringContext(string text, int thickness, Color color, FontStyle fontStyle)
{
_Thickness = thickness;
_Text = text;
_Color = color;
_FontStyle = fontStyle;
}
示例7: 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);
}
示例8: 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;
}
示例9: 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);
}
示例10: GetFont
public static Font GetFont(string fontFamilyName, float pointSize, FontStyle style)
{
string key = createHashString(fontFamilyName, pointSize, style);
try
{
if (fontCollection.ContainsKey(key))
{
Font font = fontCollection[key];
if (font != null)
{
return font;
}
}
}
catch (Exception)
{
}
Font font2 = getFont(fontFamilyName, pointSize, style);
if (font2 == null)
{
font2 = GetFont("Microsoft Sans Serif", pointSize, style);
}
if ((font2 != null) && dpiSet)
{
fontCollection.Add(key, font2);
}
return font2;
}
示例11: DrawText
/// <summary>
/// 利用颜色和大小,在指定点绘制文字
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="text"></param>
/// <param name="color"></param>
/// <param name="fontSize"></param>
public static void DrawText(float x, float y, object text, Color color, int fontSize = 10, FontStyle style = FontStyle.Normal)
{
_usingGuiStyle.normal.textColor = color;
_usingGuiStyle.fontSize = fontSize;
_usingGuiStyle.fontStyle = style;
GUI.Label(new Rect(x, y, 0, 0), text.ToString(), _usingGuiStyle);
}
示例12: FontStyleTo_CFM
/// <summary>
/// Converts a <see cref="FontStyle"/> to <see cref="CFM"/> constant.
/// </summary>
/// <param name="fontStyle">The <see cref="FontStyle"/> to convert.</param>
/// <returns>A <see cref="CFM"/> constant</returns>
public static CFM FontStyleTo_CFM(FontStyle fontStyle)
{
CFM cfm_ = 0;
if ((fontStyle & FontStyle.Bold) == FontStyle.Bold)
{
cfm_ |= CFM.BOLD;
}
if ((fontStyle & FontStyle.Italic) == FontStyle.Italic)
{
cfm_ |= CFM.ITALIC;
}
if ((fontStyle & FontStyle.Strikeout) == FontStyle.Strikeout)
{
cfm_ |= CFM.STRIKEOUT;
}
if ((fontStyle & FontStyle.Underline) == FontStyle.Underline)
{
cfm_ |= CFM.UNDERLINE;
}
return cfm_;
}
示例13: FontKey
public FontKey(string fontname, float fontSize, FontStyle fs)
{
//font name/ not filename
this.FontNameIndex = RegisterFontName(fontname.ToLower());
this.FontSize = fontSize;
this.FontStyle = fs;
}
示例14: Typeface
public Typeface(FontFamily fontFamily, FontStyle style, FontWeight weight, FontStretch stretch)
{
this.FontFamily = fontFamily;
this.Style = style;
this.Weight = weight;
this.Stretch = stretch;
}
示例15: Font
/// <summary>
/// The default constructor.
/// </summary>
/// <param name="name">The name of the font.</param>
/// <param name="style">The style of the font.</param>
/// <param name="size">The point-size of the font.</param>
public Font(string name, FontStyle style, double size)
{
this.Name = name;
this.Style = style;
this.Size = (float)size;
LoadedFonts.Add(name, this);
}