Chapter160:IncludingFontResources

No Comments

Parameter                 Details

fontbytes       bytearrayfromthebinary.ttf

Section160.1:Instantiate’Fontfamily’fromResources

publicFontFamilyManeteke=GetResourceFontFamily(Properties.Resources.manteka);

Section160.2:Integrationmethod

publicstaticFontFamilyGetResourceFontFamily(byte[]fontbytes)

{

PrivateFontCollectionpfc=newPrivateFontCollection();

IntPtrfontMemPointer=Marshal.AllocCoTaskMem(fontbytes.Length); Marshal.Copy(fontbytes,0,fontMemPointer,fontbytes.Length); pfc.AddMemoryFont(fontMemPointer,fontbytes.Length);

Marshal.FreeCoTaskMem(fontMemPointer);

returnpfc.Families[0];

}

Section160.3:Usagewitha’Button’

publicstaticclassRes

{

///<summary>

///URL:https://www.behance.net/gallery/2846011/Manteka

///</summary>

publicstaticFontFamilyManeteke=GetResourceFontFamily(Properties.Resources.manteka);

publicstaticFontFamilyGetResourceFontFamily(byte[]fontbytes)

{

PrivateFontCollectionpfc=newPrivateFontCollection();

IntPtrfontMemPointer=Marshal.AllocCoTaskMem(fontbytes.Length); Marshal.Copy(fontbytes,0,fontMemPointer,fontbytes.Length); pfc.AddMemoryFont(fontMemPointer,fontbytes.Length); Marshal.FreeCoTaskMem(fontMemPointer);

returnpfc.Families[0];

}

}

publicclassFlatButton:Button

{

publicFlatButton():base()

{

Font=newFont(Res.Maneteke,Font.Size);

}

protectedoverridevoidOnFontChanged(EventArgse)

{

base.OnFontChanged(e);

this.Font=newFont(Res.Maneteke,this.Font.Size);

}

}

About us and this blog

We are a digital marketing company with a focus on helping our customers achieve great results across several key areas.

Request a free quote

We offer professional SEO services that help websites increase their organic search score drastically in order to compete for the highest rankings even when it comes to highly competitive keywords.

Subscribe to our newsletter!

More from our blog

See all posts

Leave a Comment