Search code examples
winformsfontsresourcescustom-controlscustom-font

How to set custom font from Resources for custom control?


I have created a custom control by overriding from control. I have implemented some customization to serialize and deserialize the font settings. However, when I set the font from resources by using AddMemoryFont() method, the font is not getting updated to the control. Even I have overridden the Font property and FontChanged event and called the base functions.

Is there something I'm missing to update the font from resources? If yes, share any suggestions to update the font.

Sample

Note Getting the font from resources as in the suggestion Custom Font

Thanks in Advance,

Arulpriya


Solution

  • i have checked this. I can also able to reproduce the issue in my side. i have resolved this by creating new font with FontFamily, not with FaceName.

    return new Font(privateFontCollection.Familes[0],10f);
    

    Can you pls try this?