Click here to Skip to main content
15,917,473 members
Home / Discussions / C#
   

C#

 
GeneralRe: Instalation Pin
Heath Stewart22-Jul-04 5:40
protectorHeath Stewart22-Jul-04 5:40 
GeneralDCOM replacement in .NET Pin
Muhammad Ahmed21-Jul-04 23:17
Muhammad Ahmed21-Jul-04 23:17 
GeneralRe: DCOM replacement in .NET Pin
mav.northwind21-Jul-04 23:35
mav.northwind21-Jul-04 23:35 
GeneralRe: DCOM replacement in .NET Pin
Muhammad Ahmed22-Jul-04 1:09
Muhammad Ahmed22-Jul-04 1:09 
GeneralRe: DCOM replacement in .NET Pin
mav.northwind22-Jul-04 2:00
mav.northwind22-Jul-04 2:00 
General(OT?): webservice credentials Pin
Stephan Wright21-Jul-04 21:30
Stephan Wright21-Jul-04 21:30 
GeneralRe: (OT?): webservice credentials Pin
Heath Stewart22-Jul-04 4:56
protectorHeath Stewart22-Jul-04 4:56 
QuestionFetching Font information ? Pin
sachinkalse21-Jul-04 21:02
sachinkalse21-Jul-04 21:02 
I am trying to fetch the font information using following code

private void Form1_Load(object sender, System.EventArgs e)
{


IntPtr hdc = Win32API.GetDC(this.Handle);
try
{
LOGFONT lf = CreateLogFont("");
int ret = 0;
try
{
ret = Win32API.EnumFontFamiliesEx
(hdc, ref lf, new Win32API.EnumFontFamExProc(this.callback), 0, 0);
}
catch
{
System.Diagnostics.Trace.WriteLine("Excetion Happend!");
}
System.Diagnostics.Trace.WriteLine("EnumFontFamiliesEx = " + ret.ToString());
}
finally
{
Win32API.ReleaseDC(IntPtr.Zero, hdc);
}

}

private int cnt = 0;

private int callback(
ref ENUMLOGFONTEXDV lpelfe,
ref NEWTEXTMETRICEX lpntme,
uint FontType,
IntPtr lParam
)
{
try
{
++cnt;
string header = "no." + (cnt).ToString() + "::";
System.Diagnostics.Trace.WriteLine(header + lpelfe.elfEnumLogfontEx.elfLogFont.lfFaceName);
System.Diagnostics.Trace.WriteLine(header + lpelfe.elfEnumLogfontEx.elfLogFont.lfCharSet);
}
catch
{
System.Diagnostics.Trace.WriteLine("What happend?");
}
return cnt;
}

private const byte DEFAULT_CHARSET = 1;
private const byte SHIFTJIS_CHARSET = 128;
private const byte JOHAB_CHARSET = 130;
private const byte EASTEUROPE_CHARSET = 238;

private const byte DEFAULT_PITCH = 0;
private const byte FIXED_PITCH = 1;
private const byte VARIABLE_PITCH = 2;
private const byte FF_DONTCARE = (0 << 4);
private const byte FF_ROMAN = (1 << 4);
private const byte FF_SWISS = (2 << 4);
private const byte FF_MODERN = (3 << 4);
private const byte FF_SCRIPT = (4 << 4);
private const byte FF_DECORATIVE = (5 << 4);


public static LOGFONT CreateLogFont(string fontname)
{
LOGFONT lf = new LOGFONT();
lf.lfHeight = 0;
lf.lfWidth = 0;
lf.lfEscapement = 0;
lf.lfOrientation = 0;
lf.lfWeight = 0;
lf.lfItalic = 0;
lf.lfUnderline = 0;
lf.lfStrikeOut = 0;
lf.lfCharSet = SHIFTJIS_CHARSET;
//lf.lfCharSet = DEFAULT_CHARSET;
lf.lfOutPrecision = 0;
lf.lfClipPrecision = 0;
lf.lfQuality = 0;
lf.lfPitchAndFamily = (?_?) ;
lf.lfFaceName = "";


return lf;
}

it works well, but I am not able to toy with "lfPitchAndFamily", I want to fetch font names according to font family name and pitch.
Please guide

ps: what I found is InstalledFontCollection class in .NET Framework Developer's Guide does not give the list of all (installed) fonts . Please refer following link if you are interested
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/_gdiplus_enumerating_installed_fonts_usecsharp.asp
AnswerRe: Fetching Font information ? Pin
Heath Stewart22-Jul-04 4:41
protectorHeath Stewart22-Jul-04 4:41 
GeneralRe: Fetching Font information ? Pin
sachinkalse22-Jul-04 14:50
sachinkalse22-Jul-04 14:50 
GeneralRe: Fetching Font information ? Pin
Heath Stewart23-Jul-04 5:27
protectorHeath Stewart23-Jul-04 5:27 
GeneralRe: Fetching Font information ? Pin
sachinkalse25-Jul-04 16:41
sachinkalse25-Jul-04 16:41 
GeneralRe: Fetching Font information ? Pin
Heath Stewart26-Jul-04 4:38
protectorHeath Stewart26-Jul-04 4:38 
GeneralRe: Fetching Font information ? Pin
sachinkalse26-Jul-04 15:27
sachinkalse26-Jul-04 15:27 
GeneralRe: Fetching Font information ? Pin
Heath Stewart26-Jul-04 17:56
protectorHeath Stewart26-Jul-04 17:56 
GeneralRe: Fetching Font information ? Pin
sachinkalse26-Jul-04 18:26
sachinkalse26-Jul-04 18:26 
GeneralRe: Fetching Font information ? Pin
Heath Stewart26-Jul-04 18:37
protectorHeath Stewart26-Jul-04 18:37 
Generalevaluating simple strings as boolean Pin
MonkeyBob21-Jul-04 20:09
MonkeyBob21-Jul-04 20:09 
GeneralRe: evaluating simple strings as boolean Pin
Angel Reyes21-Jul-04 20:20
Angel Reyes21-Jul-04 20:20 
GeneralRe: evaluating simple strings as boolean Pin
MonkeyBob21-Jul-04 20:57
MonkeyBob21-Jul-04 20:57 
GeneralRe: evaluating simple strings as boolean Pin
mav.northwind21-Jul-04 22:38
mav.northwind21-Jul-04 22:38 
GeneralRe: evaluating simple strings as boolean Pin
Heath Stewart22-Jul-04 4:20
protectorHeath Stewart22-Jul-04 4:20 
GeneralRe: evaluating simple strings as boolean Pin
Nick Parker22-Jul-04 4:13
protectorNick Parker22-Jul-04 4:13 
GeneralCut Image Pin
jzb21-Jul-04 18:50
jzb21-Jul-04 18:50 
GeneralRe: Cut Image Pin
Heath Stewart22-Jul-04 4:10
protectorHeath Stewart22-Jul-04 4:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.