Desktop Functions: Smart Device Functions:
|
Search Results for "LOGFONT" in [All]uxtheme1: GetThemeFont
public extern static Int32 GetThemeFont(IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, int iPropId, out LOGFONT pFont);
Public Shared Function GetThemeFont(hTheme As IntPtr, hdc As IntPtr, iPartId As Integer, iStateId As Integer, iPropId As Integer, ByRef pFont As LOGFONT) As Int32
public extern static Int32 GetThemeSysFont(IntPtr hTheme, int iFontId, out LOGFONT plf);
Public Shared Function GetThemeSysFont(hTheme As IntPtr, iFontId As Integer, ByRef plf As LOGFONT) As Int32 user32
private struct LOGFONT
public LOGFONT(string lfFaceName)
/// Since <see cref="LOGFONT"/> is a struct instead of a class,
public LOGFONT lfCaptionFont;
public LOGFONT lfSMCaptionFont;
public LOGFONT lfMenuFont;
public LOGFONT lfStatusFont;
public LOGFONT lfMessageFont; Structures5: LOGFONT
public class LOGFONT
public class LOGFONT
sb.Append("LOGFONT\n");
Public Structure LOGFONT
Public Class LOGFONT
sb.Append("LOGFONT" & vbLf) 1) In VB .NET, the CharSet property had to be set to Ansi for it to work with LogFonts embedded in Eastman/Wang style annotation. 2) The FromLogFont method in VB .NET returned "Times New Roman" as the Font.name for many LogFont.lfFaceName that were not "Times New Roman."
// EXAMPLE 1 - Filling a Font object with a LOGFONT.
// An ActiveX control returns a handle to a LOGFONT in unmanaged global mem.
IntPtr hHGlobalLOGFONT = (IntPtr)LayoutDesign.CtlLayout.BorderTextLogfont;
IntPtr pLOGFONT = DLLKernel32.GlobalLock(hHGlobalLOGFONT);
LOGFONT lf = new LOGFONT();
// Copy the LOGFONT data into managed mem.
Marshal.PtrToStructure(pLOGFONT, lf);
Font fontReceived = Font.FromLogFont(lf);
DLLKernel32.GlobalUnlock(hHGlobalLOGFONT);
IntPtr hHGlobalLOGFONT = (IntPtr)LayoutDesign.CtlLayout.BorderTextLogfont;
IntPtr pLOGFONT = DLLKernel32.GlobalLock(hHGlobalLOGFONT);
LOGFONT lf = new LOGFONT();
// Load the LOGFONT struct from the managed Font object.
fontReceived.ToLogFont(lf);
// Copy the LOGFONT data into managed mem.
Marshal.StructureToPtr(pLOGFONT, lf, false);
DLLKernel32.GlobalUnlock(hHGlobalLOGFONT);
(IntPtr)LayoutDesign.CtlLayout.BorderTextLogfont = hHGlobalLOGFONT; The .NET Framework class Font, has a method, Font::FromLogfont that takes an Object reference as it's method parameter. You must define a managed LOGFONT class using the same format as the C# signature above. When using the StructLayout attribute on the class definition, you must set the CharSet property to Auto (the default is Ansi, which will not work correctly). The only difficulty encountered is passing the string value (the designated Font Face Name) to the FromLogfont method; apparently, this must have the attribute: [MarshalAs(UnmanagedType::ByValTStr)] enum value for the method to work correctly. Then, when instantiating a new Font in your managed application, you must cast the LOGFONT class (with appropriate member values assigned) to a System::Object for the function to work without generating a runtime exception. Note that neither of the C# LOGFONT classes return the proper value for lfPitchAndFamily using Font.ToLogFont, it always returns FF_DONTCARE. Delegates
private delegate int EnumFontExDelegate(ref ENUMLOGFONTEX lpelfe, IntPtr lpntme, int FontType, int lParam);
Private Delegate Function EnumFontExDelegate(ByRef lpelfe As ENUMLOGFONTEX, ByVal lpntme As IntPtr, ByVal FontType As Integer, ByVal lParam As Integer) As Integer gdi327: CreateFont
static extern IntPtr CreateFontIndirect([In] ref LOGFONT lplf);
LOGFONT lplf // characteristics
static extern IntPtr CreateFontIndirect([In] ref LOGFONT lplf);
LOGFONT lplf // characteristics
static extern int EnumFontFamiliesEx(IntPtr hdc, [In] ref LOGFONT lpLogfont,
LOGFONT lf = CreateLogFont("");
IntPtr plogFont = Marshal.AllocHGlobal(Marshal.SizeOf(lf));
Marshal.StructureToPtr(lf, plogFont, true);
ret = EnumFontFamiliesEx(ptr, plogFont, del1, IntPtr.Zero, 0);
Marshal.DestroyStructure(plogFont, typeof(LOGFONT));
[In] IntPtr pLogfont,
public class LOGFONT
public struct ENUMLOGFONTEX
public LOGFONT elfLogFont;
public delegate int EnumFontExDelegate(ref ENUMLOGFONTEX lpelfe, ref NEWTEXTMETRICEX lpntme, int FontType, int lParam);
public int callback1(ref ENUMLOGFONTEX lpelfe, ref NEWTEXTMETRICEX lpntme, int FontType, int lParam)
public static LOGFONT CreateLogFont(string fontname)
LOGFONT lf = new LOGFONT();
public struct LOGFONT
public struct ENUMLOGFONT
public LOGFONT elfLogFont;
public ENUMLOGFONT LogFont;
public extern static Int32 EnumFontFamiliesEx(IntPtr hdc, ref LOGFONT lpLogfont, FONTENUMPROC lpEnumFontFamExProc, IntPtr lParam, UInt32 dwFlags);
public delegate Int32 FONTENUMPROC(ref ENUMLOGFONT lpelf, ref NEWTEXTMETRIC lpntm, UInt32 FontType, IntPtr lParam);
public static int EnumFontFamExProc(ref ENUMLOGFONT lpelf, ref NEWTEXTMETRIC lpntm, uint FontType, IntPtr lParam)
allFontData.Add(new FontData() { LogFont = lpelf, TextMetric = lpntm, FontType = FontType });
var logfont = new LOGFONT() { lfCharSet = (byte)FontLanguageCharSet.DEFAULT_CHARSET };
EnumFontFamiliesEx(hdc, ref logfont, new FONTENUMPROC(EnumFontFamExProc), IntPtr.Zero, 0);
List<string> mono = (from f in allFonts where ((f.LogFont.elfLogFont.lfPitchAndFamily & 0x3) == (int)GdiFonts.FontPitch.FIXED_PITCH) & (GdiFonts.FontLanguageCharSet)f.LogFont.elfLogFont.lfCharSet == GdiFonts.FontLanguageCharSet.ANSI_CHARSET select f.LogFont.elfFullName).ToList<string>();
List<string> variable = (from f in allFonts where ((f.LogFont.elfLogFont.lfPitchAndFamily & 0x3) == (int)GdiFonts.FontPitch.VARIABLE_PITCH) & (GdiFonts.FontLanguageCharSet)f.LogFont.elfLogFont.lfCharSet == GdiFonts.FontLanguageCharSet.ANSI_CHARSET select f.LogFont.elfFullName).ToList<string>();
static extern int EnumFontFamiliesEx(IntPtr hdc, [In] ref LOGFONT lpLogfont,
LOGFONT lf = CreateLogFont("");
IntPtr plogFont = Marshal.AllocHGlobal(Marshal.SizeOf(lf));
Marshal.StructureToPtr(lf, plogFont, true);
ret = EnumFontFamiliesEx(ptr, plogFont, del1, IntPtr.Zero, 0);
Marshal.DestroyStructure(plogFont, typeof(LOGFONT));
[In] IntPtr pLogfont,
public class LOGFONT
public struct ENUMLOGFONTEX
public LOGFONT elfLogFont;
public delegate int EnumFontExDelegate(ref ENUMLOGFONTEX lpelfe, ref NEWTEXTMETRICEX lpntme, int FontType, int lParam);
public int callback1(ref ENUMLOGFONTEX lpelfe, ref NEWTEXTMETRICEX lpntme, int FontType, int lParam)
public static LOGFONT CreateLogFont(string fontname)
LOGFONT lf = new LOGFONT();
public struct LOGFONT
public struct ENUMLOGFONT
public LOGFONT elfLogFont;
public ENUMLOGFONT LogFont;
public extern static Int32 EnumFontFamiliesEx(IntPtr hdc, ref LOGFONT lpLogfont, FONTENUMPROC lpEnumFontFamExProc, IntPtr lParam, UInt32 dwFlags);
public delegate Int32 FONTENUMPROC(ref ENUMLOGFONT lpelf, ref NEWTEXTMETRIC lpntm, UInt32 FontType, IntPtr lParam);
public static int EnumFontFamExProc(ref ENUMLOGFONT lpelf, ref NEWTEXTMETRIC lpntm, uint FontType, IntPtr lParam)
allFontData.Add(new FontData() { LogFont = lpelf, TextMetric = lpntm, FontType = FontType });
var logfont = new LOGFONT() { lfCharSet = (byte)FontLanguageCharSet.DEFAULT_CHARSET };
EnumFontFamiliesEx(hdc, ref logfont, new FONTENUMPROC(EnumFontFamExProc), IntPtr.Zero, 0);
List<string> mono = (from f in allFonts where ((f.LogFont.elfLogFont.lfPitchAndFamily & 0x3) == (int)GdiFonts.FontPitch.FIXED_PITCH) & (GdiFonts.FontLanguageCharSet)f.LogFont.elfLogFont.lfCharSet == GdiFonts.FontLanguageCharSet.ANSI_CHARSET select f.LogFont.elfFullName).ToList<string>();
List<string> variable = (from f in allFonts where ((f.LogFont.elfLogFont.lfPitchAndFamily & 0x3) == (int)GdiFonts.FontPitch.VARIABLE_PITCH) & (GdiFonts.FontLanguageCharSet)f.LogFont.elfLogFont.lfCharSet == GdiFonts.FontLanguageCharSet.ANSI_CHARSET select f.LogFont.elfFullName).ToList<string>(); 11: TextOut [CharSet = CharSet.Auto] According to my experience this parameter should be used when using a LOGFONT structure and the CreateFontIndirect fuction, otherwise the selected font will not be displayed. All flags will be done (lfItalic, lfUnderline ...) but not the lfFaceName string. comdlg3212: ChooseFont
public IntPtr lpLogFont;
CF_INITTOLOGFONTSTRUCT = 0x00000040,
LOGFONT logfont = new LOGFONT();
logfont.lfFaceName = "Segoe UI";
IntPtr pLogfont = Marshal.AllocHGlobal(Marshal.SizeOf(logfont));
Marshal.StructureToPtr(logfont, pLogfont, false);
| (int)CHOOSEFONTFLAGS.CF_INITTOLOGFONTSTRUCT
choosefont.lpLogFont = pLogfont;
Marshal.FreeHGlobal(pLogfont); |