473,397 Members | 2,116 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Fetching Font information ?

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("EnumFontFamili esEx = " + 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
--
sachin
Nov 16 '05 #1
1 2632
Hi
checkout these link , they may help

http://www.jisys.com/wordreports/use...stomfonts.html

http://custom.programming-in.net/art...p?f=CreateFont
Mohamed Mahfouz
MEA Developer Support Center
ITworx on behalf of Microsoft EMEA GTSC

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Fabian Neumann | last post by:
Hi! I got a problem with font-family inheritance. Let's say I have CSS definitions like: p { font:normal 10pt Verdana; } strong { font:normal 14pt inherit;
7
by: Derrick | last post by:
Can anyone tell me how to persist and retrieve the font characteristics that a user chooses to have displayed in a personalized label field on the front of their application? I wanted to be able...
1
by: Husam | last post by:
Hi EveryBody: I am doing windows application project by using Vb.Net. The function of this project is to send e-mail by adding system.web.dll as refrance to my project and using system.web.mail...
2
by: Florian Albrecht | last post by:
Hi there, as I am trying to write a recordset class, I am interested in fetching field information from an oracle db. Several information on the fields are very simple to request. So I already...
4
by: lanarkcp | last post by:
This section of code works perfectly in IE, but not Firefox or Netscape, where the paragraph formatting and color are lost. Suggestions?? Thanks. <head> <meta http-equiv="content-type"...
22
by: Sandman | last post by:
So, I have this content management system I've developed myself. The system has a solid community part where members can register and then participate in forums, write weblogs and a ton of other...
18
by: Diogenes | last post by:
Hi All; I, like others, have been frustrated with designing forms that look and flow the same in both IE and Firefox. They simply did not scale the same. I have discovered, to my chagrin,...
2
by: SunshineInTheRain | last post by:
I'm trying to modify a long long code within a button click by make the insert/update/delete/select using the same transaction. Purpose is to make sure every operation can be rollback instead of some...
4
by: tokcy | last post by:
HI every one, i am using tooltip on click of link and i want like when that tooltip open then background window would be blure(). can anyone help me...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.