Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Embedded font puzzler
Message
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires
Versions des environnements
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
MS SQL Server
Divers
Thread ID:
01523380
Message ID:
01523385
Vues:
43
>Hi All, I'm having some problems using an embedded font ( it's a free one - no licence required ). The scenario is: I added the font file to my Resources.resx file , set it's build action to Embedded , and at runtime I use the code below to load it.
>
>
>
>PrivateFontCollection pfc = new PrivateFontCollection();
>byte[] fontdata = MyNamespace.Properties.Resources.MyTTFont;
>
>IntPtr ptrFont = Marshal.AllocCoTaskMem(fontdata.length);
>Marshal.Copy(fontdata,0,ptrfont,fontdata.Length);
>pfc.AddMemoryFont(ptrfont,fontdata.Length);
>Marshal.FreeCoTaskMem(ptrfont);
>
>Font f = new Font(pfc.Families[0],20.00);
>
>
>
>I use this code in two places, one is a pretty bog standard about screen ( Winform ) the other is a MDIForm - what I'm experiencing is: The first time I run the app, the font on the MDIForm reverts to the default font but the about screen works perfectly using my custom font. Both of the forms use the same code ( it's in a helper class ). If I then close the app and run it again - both of my forms use the custom font with no problems. As an aside I noticed that the Windows\Font folder now contains my custom font ( which is what I wanted to avoid ) Any ideas ?

Never done this but I suppose the obvious question is whether the font is added to the collection before the MDIForm is instantiated ?
(Or, when you say it 'reverts' to the default do you mean it initially uses the loaded font)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform