本文整理汇总了C#中System.Drawing.Font.ToLogFont方法的典型用法代码示例。如果您正苦于以下问题:C# Font.ToLogFont方法的具体用法?C# Font.ToLogFont怎么用?C# Font.ToLogFont使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Font
的用法示例。
在下文中一共展示了Font.ToLogFont方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetFontFaceName
public static string GetFontFaceName(string fn)
{
Font ft = new Font(fn, 9F);
LOGFONT lt = new LOGFONT();
ft.ToLogFont(lt);
return lt.lfFaceName;
}
示例2: SetFont
public void SetFont(Font font)
{
var lf = new LogFont();
font.ToLogFont(lf);
lf.lfPitchAndFamily = FIXED_PITCH | FF_MODERN;
NativeMethods.SendMessage(hIMEWnd, (int) WindowMessage.WM_IME_CONTROL, IMC_SETCOMPOSITIONFONT, lf);
}
示例3: CreateFontObject
private static IntPtr CreateFontObject(Font font, bool antiAliasing)
{
NativeStructs.LOGFONT logFont = new NativeStructs.LOGFONT();
font.ToLogFont(logFont);
int nHeight = logFont.lfHeight;
int nWidth = logFont.lfWidth;
int nEscapement = logFont.lfEscapement;
int nOrientation = logFont.lfOrientation;
int fnWeight = logFont.lfWeight;
uint fdwItalic = logFont.lfItalic;
uint fdwUnderline = logFont.lfUnderline;
uint fdwStrikeOut = logFont.lfStrikeOut;
uint fdwCharSet = logFont.lfCharSet;
uint fdwOutputPrecision = logFont.lfOutPrecision;
uint fdwClipPrecision = logFont.lfClipPrecision;
uint fdwQuality;
if (antiAliasing)
{
fdwQuality = NativeConstants.ANTIALIASED_QUALITY;
}
else
{
fdwQuality = NativeConstants.NONANTIALIASED_QUALITY;
}
uint fdwPitchAndFamily = logFont.lfPitchAndFamily;
string lpszFace = logFont.lfFaceName;
IntPtr hFont = SafeNativeMethods.CreateFontW(
nHeight,
nWidth,
nEscapement,
nOrientation,
fnWeight,
fdwItalic,
fdwUnderline,
fdwStrikeOut,
fdwCharSet,
fdwOutputPrecision,
fdwClipPrecision,
fdwQuality,
fdwPitchAndFamily,
lpszFace);
if (hFont == IntPtr.Zero)
{
NativeMethods.ThrowOnWin32Error("CreateFontW returned NULL");
}
return hFont;
}
示例4: ToLogFont_TooSmall
public void ToLogFont_TooSmall ()
{
Font f = new Font ("Arial", 10);
object o = new object ();
f.ToLogFont (o);
// no PInvoke conversion exists !?!?
}
示例5: ToLogFont_Int
public void ToLogFont_Int ()
{
Font f = new Font ("Arial", 10);
int i = 1;
f.ToLogFont (i);
Assert.AreEqual (1, i);
}
示例6: ToLogFont_DenyUnmanagedCode
public void ToLogFont_DenyUnmanagedCode ()
{
Font f;
LOGFONT lf;
lf = new LOGFONT();
f = new Font("Arial", 10);
f.ToLogFont(lf);
}
示例7: ToLogFont_AssertUnmanagedCode
public void ToLogFont_AssertUnmanagedCode ()
{
Font f = new Font("Arial", 10);
LOGFONT lf = new LOGFONT();
f.ToLogFont (lf);
Assert.AreEqual (400, lf.lfWeight, "lfWeight");
Assert.AreEqual (1, lf.lfCharSet, "lfCharSet");
Assert.AreEqual (f.Name, lf.lfFaceName, "lfFaceName");
LOGFONT_STRUCT lfs = new LOGFONT_STRUCT ();
f.ToLogFont (lfs);
Assert.AreEqual (0, lfs.lfWeight, "struct-lfWeight");
Assert.AreEqual (0, lfs.lfCharSet, "struct-lfCharSet");
Assert.AreEqual (0, lfs.lfHeight, "struct-lfHeight");
Assert.AreEqual (0, lfs.lfWidth, "struct-lfWidth");
Assert.AreEqual (0, lfs.lfEscapement, "struct-lfEscapement");
Assert.AreEqual (0, lfs.lfOrientation, "struct-lfOrientation");
Assert.AreEqual (0, lfs.lfWeight, "struct-lfWeight");
Assert.AreEqual (0, lfs.lfItalic, "struct-lfItalic");
Assert.AreEqual (0, lfs.lfUnderline, "struct-lfUnderline");
Assert.AreEqual (0, lfs.lfStrikeOut, "struct-lfStrikeOut");
Assert.AreEqual (0, lfs.lfCharSet, "struct-lfCharSet");
Assert.AreEqual (0, lfs.lfOutPrecision, "struct-lfOutPrecision");
Assert.AreEqual (0, lfs.lfClipPrecision, "struct-lfClipPrecision");
Assert.AreEqual (0, lfs.lfQuality, "struct-lfQuality");
Assert.AreEqual (0, lfs.lfPitchAndFamily, "struct-lfPitchAndFamily");
Assert.IsNull (lfs.lfFaceName, "struct-lfFaceName");
}
示例8: GetLogFont
public static void GetLogFont(Font font, Graphics graphics, out LOGFONT logfont)
{
object o = new LOGFONT();
if (graphics != null)
{
font.ToLogFont(o, graphics);
}
else
{
font.ToLogFont(o);
}
logfont = (LOGFONT)o;
}
示例9: SetIMEWindowFont
private void SetIMEWindowFont(Font f)
{
if (lf == null) {
lf = new LOGFONT();
f.ToLogFont(lf);
lf.lfFaceName = f.Name; // This is very important! "Font.ToLogFont" Method sets invalid value to LOGFONT.lfFaceName
}
SendMessage(
hIMEWnd,
WM_IME_CONTROL,
new IntPtr(IMC_SETCOMPOSITIONFONT),
lf
);
}
示例10: LoadSubtitles
public bool LoadSubtitles(IGraphBuilder graphBuilder, string filename)
{
FreeSubtitles();
LoadSettings();
{
//remove InternalScriptRenderer as it takes subtitle pin
IBaseFilter isr = null;
DirectShowUtil.FindFilterByClassID(graphBuilder, ClassId.InternalScriptRenderer, out isr);
if (isr != null)
{
graphBuilder.RemoveFilter(isr);
DirectShowUtil.ReleaseComObject(isr);
}
}
vobSub = (IDirectVobSub)DirectVobSubUtil.AddToGraph(graphBuilder);
if (vobSub == null)
return false;
{
//set style
Log.Debug("VideoPlayerVMR9: Setting DirectVobsub parameters");
LOGFONT logFont = new LOGFONT();
int txtcolor;
bool fShadow, fOutLine, fAdvancedRenderer = false;
int size = Marshal.SizeOf(typeof(LOGFONT));
vobSub.get_TextSettings(logFont, size, out txtcolor, out fShadow, out fOutLine, out fAdvancedRenderer);
FontStyle fontStyle = defStyle.fontIsBold ? FontStyle.Regular : FontStyle.Bold;
Font Subfont = new Font(defStyle.fontName, defStyle.fontSize, fontStyle, GraphicsUnit.Point,
(byte)defStyle.fontCharset);
Subfont.ToLogFont(logFont);
fShadow = defStyle.shadow > 0;
fOutLine = defStyle.isBorderOutline;
vobSub.put_TextSettings(logFont, size, defStyle.fontColor, fShadow, fOutLine, fAdvancedRenderer);
vobSub.put_FileName(filename);
bool fBuffer, fOnlyForced, fPolygonize;
vobSub.get_VobSubSettings(out fBuffer, out fOnlyForced, out fPolygonize);
vobSub.put_VobSubSettings(fBuffer, !this.autoShow, fPolygonize);
}
{
//load sub streams
IBaseFilter hms = null;
DirectShowUtil.FindFilterByClassID(graphBuilder, ClassId.HaaliGuid, out hms);
if (hms == null)
DirectShowUtil.FindFilterByClassID(graphBuilder, ClassId.LAVFilterSource, out hms);
if (hms == null)
DirectShowUtil.FindFilterByClassID(graphBuilder, ClassId.LAVFilter, out hms);
embeddedSelector = hms as IAMStreamSelect;
if (embeddedSelector != null)
{
AddStreams(embeddedSelector);
}
vobSub.get_LanguageCount(out extCount);
if (intSubs.Count > 0)
{
//if there are embedded subtitles,
//last stream of directvobsub is currently selected embedded subtitle
extCount--;
}
}
FFDShowEngine.DisableFFDShowSubtitles(graphBuilder);
Current = 0;
if (selectionOff)
{
Enable = false;
}
else
{
Enable = autoShow;
}
return true;
}
示例11: Dispose_ToLogFont_LoopCharSet
public void Dispose_ToLogFont_LoopCharSet ()
{
#if !TARGET_JVM
Font f = new Font (name, 12.5f);
f.Dispose ();
LOGFONT lf = new LOGFONT ();
for (int i = Byte.MinValue; i < Byte.MaxValue; i++) {
byte b = (byte) i;
lf.lfHeight = b;
lf.lfWidth = b;
lf.lfEscapement = b;
lf.lfOrientation = b;
lf.lfWeight = b;
lf.lfItalic = b;
lf.lfUnderline = b;
lf.lfStrikeOut = b;
lf.lfCharSet = b;
lf.lfOutPrecision = b;
lf.lfClipPrecision = b;
lf.lfQuality = b;
lf.lfPitchAndFamily = b;
lf.lfFaceName = b.ToString ();
try {
f.ToLogFont (lf);
}
catch (ArgumentException) {
Assert.AreEqual (b, lf.lfHeight, "lfHeight");
Assert.AreEqual (b, lf.lfWidth, "lfWidth");
Assert.AreEqual (b, lf.lfEscapement, "lfEscapement");
Assert.AreEqual (b, lf.lfOrientation, "lfOrientation");
Assert.AreEqual (b, lf.lfWeight, "lfWeight");
Assert.AreEqual (b, lf.lfItalic, "lfItalic");
Assert.AreEqual (b, lf.lfUnderline, "lfUnderline");
Assert.AreEqual (b, lf.lfStrikeOut, "lfStrikeOut");
// special case for 0
Assert.AreEqual ((i == 0) ? (byte)1 : b, lf.lfCharSet, "lfCharSet");
Assert.AreEqual (b, lf.lfOutPrecision, "lfOutPrecision");
Assert.AreEqual (b, lf.lfClipPrecision, "lfClipPrecision");
Assert.AreEqual (b, lf.lfQuality, "lfQuality");
Assert.AreEqual (b, lf.lfPitchAndFamily, "lfPitchAndFamily");
Assert.AreEqual (b.ToString (), lf.lfFaceName, "lfFaceName");
}
catch (Exception e) {
Assert.Fail ("Unexcepted exception {0} at iteration {1}", e, i);
}
}
#endif
}
示例12: FontToLogFont
static private void FontToLogFont(Font value, NativeMethods.LOGFONT logfont) {
value.ToLogFont(logfont);
}
示例13: IsSymbolFont
/// <summary>
/// Determines whether a font uses the 'symbol' character set.
/// </summary>
/// <remarks>
/// Symbol fonts do not typically contain glyphs that represent letters of the alphabet.
/// Instead they might contain pictures and symbols. As such, they are not useful for
/// drawing text. Which means you can't use a symbol font to write out its own name for
/// illustrative purposes (like for the font drop-down chooser).
/// </remarks>
public static bool IsSymbolFont(Font font)
{
NativeStructs.LOGFONT logFont = new NativeStructs.LOGFONT();
font.ToLogFont(logFont);
return logFont.lfCharSet == NativeConstants.SYMBOL_CHARSET;
}
示例14: LogicalFont
/// ------------------------------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the <see cref="LogicalFont"/> class.
/// </summary>
/// <param name="createFrom">The font to use as the basis for the logical font.</param>
/// <remarks>If it's not obvious why we need this class in order to determine if a font
/// is a symbol font, see the Dr. Gui article entitled
/// <see href="http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/dnaraskdr/html/askgui12302003.asp">
/// Determining the Character Set Used by a Font</see></remarks>
/// ------------------------------------------------------------------------------------
public LogicalFont(Font createFrom)
{
createFrom.ToLogFont(this);
}
示例15: Dispose_ToLogFont
public void Dispose_ToLogFont ()
{
Font f = new Font (name, 12.5f);
f.Dispose ();
LOGFONT lf = new LOGFONT();
f.ToLogFont (lf);
}