473,770 Members | 5,976 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 PrivateFontColl ection. (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.DrawSt ring 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.GetMan ifestResourceSt ream("Graphyx.c ustom.ttf");

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

// 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.AddMemoryFo nt((System.IntP tr)pFontData,
(int)fontStream .Length);
}
}
// Close the resource stream
fontStream.Clos e();
}

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

ff = pfc.Families[0];

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

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

Feb 8 '06 #1
0 6501

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

Similar topics

8
8089
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 could work in reverse, i.e. we have a cost model written in Excel that calculates the profitability of customer accounts based on several inputs and they need to be updated at least once per year. These cost models sit on lots of people's hard...
2
16214
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 Button1 from regular to bold, change the size etc. This line of code: Button1.Font.Bold = True
7
2973
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 already formatted as "Shopping" ---Bold "for" -----Regular Now I want to underline whole text by preserving old style i.e. Bold and
1
1869
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 those referred to a LinkButton type of control. But in cases where someone is using the PushButton there are no posted solutions. Whenever these changes are made to the PushButton control they do not make any requested changes. I have seen one...
1
5617
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) Content for the text field should be provided by an XML file 3) Content styled by external css file 4) Fonts need to be embedded so as to apply anti-alias
6
2857
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 font of Arial and 8.25pt. Great.
1
1524
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 text of the sample) I don't want to copy the font files to the Windows\Fonts\ folder. Tried that, causes a lot of issues with deleting the font file when the preview is done, even after disposing the text box, removing the font resources, and/or...
0
1565
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 font. So I have made the font an embedded resource and, by adapting code from http://www.bobpowell.net/tipstricks.htm, I now have the font working correctly in debug mode. I set the Font property of my control to the required font, which is...
4
1995
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 thing to want to do, surely there's a million solutions to it". Anyway - jumping into Google I was surprised at what I found. As far as I can tell, "embedded fonts" came about circa early 90's that involved packaging fonts into some sort of...
0
10230
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10004
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9870
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7416
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6678
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5313
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5450
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3576
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2817
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.