I have some fonts that are not standard Windows, so I'm creating a PrivateFontCollection
but I'm having trouble.
These sources are used by the whole program, so I thought about creating a Classe Static
with a get
method, but how could I add the sources to PrivateFontCollection
? I know that we use the AddFontFile
method so I thought about adding the fonts, right after the user login, but I'm not getting it.
Class:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing.Text;
using System.Runtime.InteropServices;
using DevExpress.CodeParser;
namespace Onee.Classes.Font
{
public static class Fonts
{
private static PrivateFontCollection Font_collection;
Font_collection.AddFontFile("C:\Users\thomas\Documents\Workspace\Onee\Onee Beta 1.10.16.2\Onee\Resources\C_Light.otf");
Font_collection.AddFontFile("C:\Users\thomas\Documents\Workspace\Onee\Onee Beta 1.10.16.2\Onee\Resources\C_Bold.otf");
public static PrivateFontCollection Collection
{
get { return Font.Fonts.Font_collection; }
}
}
}
Form:
private void set_font()
{
label4.Font = new Font(Classes.Font.Fonts.Collection.Families[1], 12, FontStyle.Bold);
label_usuario.Font = new Font(Classes.Font.Fonts.Collection.Families[1], 12, FontStyle.Bold);
label3.Font = new Font(Classes.Font.Fonts.Collection.Families[1], 12, FontStyle.Bold);
label2.Font = new Font(Classes.Font.Fonts.Collection.Families[1], 12, FontStyle.Bold);
label5.Font = new Font(Classes.Font.Fonts.Collection.Families[1], 12, FontStyle.Bold);
label1.Font = new Font(Classes.Font.Fonts.Collection.Families[1], 12, FontStyle.Bold);
button_servicos.Font = new Font(Classes.Font.Fonts.Collection.Families[0], 15);
button_comercial.Font = new Font(Classes.Font.Fonts.Collection.Families[0], 15);
button_certificados.Font = new Font(Classes.Font.Fonts.Collection.Families[0], 15);
button_equipamentos.Font = new Font(Classes.Font.Fonts.Collection.Families[0], 15);
button_compras.Font = new Font(Classes.Font.Fonts.Collection.Families[0], 15);
simpleButton1.Font = new Font(Classes.Font.Fonts.Collection.Families[0], 15);
simpleButton2.Font = new Font(Classes.Font.Fonts.Collection.Families[0], 15);
button_opsistema.Font = new Font(Classes.Font.Fonts.Collection.Families[0], 15);
}
Error:
Iwasabletoresolveitasfollows:
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;usingSystem.Drawing.Text;usingSystem.Runtime.InteropServices;usingDevExpress.CodeParser;namespaceOnee.Classes.Font{publicstaticclassFonts{privatestaticPrivateFontCollectionFont_collection=newPrivateFontCollection();publicstaticvoidadd_font(){Font_collection.AddFontFile("C:\Users\thomas\Documents\Workspace\Onee\Onee Beta 1.10.16.2\Onee\Resources\C_Light.otf");
Font_collection.AddFontFile("C:\Users\thomas\Documents\Workspace\Onee\Onee Beta 1.10.16.2\Onee\Resources\C_Bold.otf");
}
public static PrivateFontCollection Collection
{
get { return Font.Fonts.Font_collection; }
}
}
}
Is this approach true?