473,387 Members | 1,542 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,387 software developers and data experts.

C# Embedded font for button

Hello all,

I've added a font to my project and set it to "Embedded Resource".

I load the font into a global PrivateFontCollection. (InitCustomFont -
shown below)

I then set the font of a label to be equal to the custom font
(SetCustomFont - shown below)

The font size changes but the family doesn't. If I write directly to
the form using Graphics.DrawString the new font is displayed???

Does that mean I can't change the font of labels/buttons etc. to
resource fonts?

Gareth

private void InitCustomFont()
{
// Load the resource
Stream fontStream =
this.GetType().Assembly.GetManifestResourceStream( "Graphyx.custom.ttf");

// Create a buffer to read into
byte[] fontData = new byte[fontStream.Length];

// Fetch the font program from the resource
fontStream.Read(fontData, 0, (int)fontStream.Length);

unsafe
{
fixed (byte* pFontData = fontData)
{

// Pass the font to the font collection
pfc.AddMemoryFont((System.IntPtr)pFontData,
(int)fontStream.Length);
}
}
// Close the resource stream
fontStream.Close();
}

private void SetCustomFont()
{
System.Drawing.Font fn;
FontFamily ff;

ff = pfc.Families[0];

fn = new Font(ff, 16, FontStyle.Regular);

//lblHelp.Font = new System.Drawing.Font("Courier New", 16.0f,
(FontStyle)2);
lblHelp.Font = fn;
}

Feb 8 '06 #1
0 6466

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

Similar topics

8
by: Colleyville Alan | last post by:
I have been working on an Access app that takes info from a file and writes it to a spreadsheet on a form, simultaneously saving the spreadsheet to Excel. I got the idea that the same concept...
2
by: Jim | last post by:
Working with VB.net under VS.Net 2003. Have a simple form with a Button1. I want to change the font on the button when the button is clicked. Is there a way to Dynamically change the Font for...
7
by: Sakharam Phapale | last post by:
Hi All, How to preserve the old font properties while changing new one? I posted same question 2 months back, but I had very small time then. eg. "Shopping for" is a text in RichTextBox and...
1
by: Blasting Cap | last post by:
I am having trouble changing the font for a PushButton control in a datagrid button column. I have seen several posts refer to styles and simple changes to the HTML for font changes but most of...
1
by: erictomlinson | last post by:
I'm dying here trying to figure this out for days. Here's the scenario: 1) External script.as file dynamically imported to loader.swf file that creates a textfield (createTextField) 2)...
6
by: andrew.ames | last post by:
Hi I have a pretty basic windows application created in Visual Studio 2005 and VB.NET. I set my Form's font to Arial 8.25pt, so when i added a label and a button they automatically have a...
1
by: CMiner | last post by:
What I am trying to do is this: Let a user browse for font files that are not installed, select one, and show a sample of the font in a text box (That way the user can change the size, style, and...
0
by: =?Utf-8?B?Qm9iIFdhaXRl?= | last post by:
I have written a calculator emulator which uses an LCD font in VB.NET in VS2005. This application will be installed by means of an MSI file and I dont want the user to have to manually install the...
4
by: DamienS | last post by:
Hi, After many years of using html/css/asp etc for the first time I've had a requirement to use a custom font in a website. "That shouldn't be too hard" thought I, "that would be a pretty common...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.