c# - Form Font Embedding -



c# - Form Font Embedding -

it's while i'm trying figure out what's happening in piece of code.

[system.runtime.interopservices.dllimport("gdi32.dll")] private static extern intptr addfontmemresourceex(intptr pbfont, uint cbfont, intptr pdv, [system.runtime.interopservices.in] ref uint pcfonts); public static privatefontcollection myfontcollection = new privatefontcollection(); public static fontfamily robotobold = null; public static fontfamily robotothin = null; public enum fonts { roboto_bold = 0, roboto_thin = 1 } public static void loadfonts() { array fonts = enum.getvalues(typeof(fonts)); foreach (fonts font in fonts) { byte[] fontdata = (byte[])resources.resourcemanager.getobject(font.tostring()); intptr fontptr = system.runtime.interopservices.marshal.alloccotaskmem(fontdata.length); system.runtime.interopservices.marshal.copy(fontdata, 0, fontptr, fontdata.length); uint dummy = 0; myfontcollection.addmemoryfont(fontptr, fontdata.length); addfontmemresourceex(fontptr, (uint)fontdata.length, intptr.zero, ref dummy); system.runtime.interopservices.marshal.freecotaskmem(fontptr); } robotobold = program.myfontcollection.families[(int)program.fonts.roboto_bold]; robotothin = program.myfontcollection.families[(int)program.fonts.roboto_thin]; }

actually reads .ttf i've embedded resources, if debug, within fontfamilys read message:

{name = name 'name' not exist in current context}

i've tried figure out what's happening, can't find error. resource beingness read correctly using resourcemanager, think something's wrong while adding font.

c# winforms fonts

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -