本文整理汇总了C#中FontStyle类的典型用法代码示例。如果您正苦于以下问题:C# FontStyle类的具体用法?C# FontStyle怎么用?C# FontStyle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FontStyle类属于命名空间,在下文中一共展示了FontStyle类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
}
}
开发者ID:divyang4481,项目名称:lextudio,代码行数:28,代码来源:FontStyleAction.cs
示例2: Set
public void Set(TextBlock textBlock)
{
this.fontFamily = textBlock.FontFamily;
this.fontWeight = textBlock.FontWeight;
this.fontStyle = textBlock.FontStyle;
this.fontStretch = textBlock.FontStretch;
}
开发者ID:oldnewthing,项目名称:old-Windows8-samples,代码行数:7,代码来源:LocalFontInfo.cs
示例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();
}
开发者ID:jkoritzinsky,项目名称:Avalonia,代码行数:27,代码来源:FormattedTextImpl.cs
示例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();
}
开发者ID:swax,项目名称:QuickFont,代码行数:29,代码来源:QFont.cs
示例5: SccPositionAndStyle
public SccPositionAndStyle(Color color, FontStyle style, int y, int x)
{
ForeColor = color;
Style = style;
X = x;
Y = y;
}
开发者ID:ItsJustSean,项目名称:subtitleedit,代码行数:7,代码来源:ScenaristClosedCaptions.cs
示例6: DrawStringContext
public DrawStringContext(string text, int thickness, Color color, FontStyle fontStyle)
{
_Thickness = thickness;
_Text = text;
_Color = color;
_FontStyle = fontStyle;
}
开发者ID:poobalan-arumugam,项目名称:stateproto,代码行数:7,代码来源:DrawStringContext.cs
示例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);
}
开发者ID:Robertofon,项目名称:Perspex,代码行数:25,代码来源:FormattedText.cs
示例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;
}
开发者ID:highzion,项目名称:Granular,代码行数:7,代码来源:Typeface.cs
示例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);
}
开发者ID:KvanTTT,项目名称:Perspex,代码行数:43,代码来源:FormattedText.cs
示例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;
}
开发者ID:Riketta,项目名称:Stronghold-Kingdoms,代码行数:28,代码来源:FontManager.cs
示例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);
}
开发者ID:zergcom,项目名称:unity,代码行数:15,代码来源:GUI2.cs
示例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_;
}
开发者ID:DeadlyEmbrace,项目名称:CCSWE-Libraries,代码行数:31,代码来源:InteropConvert.cs
示例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;
}
开发者ID:prepare,项目名称:HTML-Renderer,代码行数:7,代码来源:FontKey.cs
示例14: Typeface
public Typeface(FontFamily fontFamily, FontStyle style, FontWeight weight, FontStretch stretch)
{
this.FontFamily = fontFamily;
this.Style = style;
this.Weight = weight;
this.Stretch = stretch;
}
开发者ID:modulexcite,项目名称:Avalonia,代码行数:7,代码来源:Typeface.cs
示例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);
}
开发者ID:Orvid,项目名称:Cosmos,代码行数:13,代码来源:Font.cs
示例16: RichTextBoxWordColoringRule
/// <summary>
/// Initializes a new instance of the <see cref="RichTextBoxWordColoringRule" /> class.
/// </summary>
/// <param name="text">The text to be matched..</param>
/// <param name="textColor">Color of the text.</param>
/// <param name="backgroundColor">Color of the background.</param>
/// <param name="fontStyle">The font style.</param>
public RichTextBoxWordColoringRule(string text, string textColor, string backgroundColor, FontStyle fontStyle)
{
this.Text = text;
this.FontColor = textColor;
this.BackgroundColor = backgroundColor;
this.Style = fontStyle;
}
开发者ID:mattcuba,项目名称:practicesharp,代码行数:14,代码来源:RichTextBoxWordColoringRule.cs
示例17: 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);
}
开发者ID:LevNNN,项目名称:mono,代码行数:25,代码来源:Font.cs
示例18: SetStyle
public override object SetStyle (object handle, FontStyle style)
{
FontDescription fd = (FontDescription) handle;
fd = fd.Copy ();
fd.Style = (Pango.Style)(int)style;
return fd;
}
开发者ID:StEvUgnIn,项目名称:xwt,代码行数:7,代码来源:FontBackendHandler.cs
示例19: RichTextBoxRowColoringRule
/// <summary>
/// Initializes a new instance of the <see cref="RichTextBoxRowColoringRule" /> class.
/// </summary>
/// <param name="condition">The condition.</param>
/// <param name="fontColor">Color of the foregroung text.</param>
/// <param name="backColor">Color of the background text.</param>
/// <param name="fontStyle">The font style.</param>
public RichTextBoxRowColoringRule(string condition, string fontColor, string backColor, FontStyle fontStyle)
{
this.Condition = condition;
this.FontColor = fontColor;
this.BackgroundColor = backColor;
this.Style = fontStyle;
}
开发者ID:ExM,项目名称:NLog,代码行数:14,代码来源:RichTextBoxRowColoringRule.cs
示例20: CreateFont
public static Font CreateFont(FontFamily ff, float fEmSize, FontStyle fs)
{
try { return new Font(ff, fEmSize, fs); }
catch(Exception) { Debug.Assert(false); } // Style unsupported?
return new Font(ff, fEmSize);
}
开发者ID:joshuadugie,项目名称:KeePass-2.x,代码行数:7,代码来源:FontUtil.cs
注:本文中的FontStyle类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论