How can i change string to font object??

I am making a simple text editor using C#. And i want to change the font size of the text. I did it and stored the font settings in the registry, by converting the font object to string. Now when i start the editor i want that font settings to be reloaded in it.
So how can i change the string stored in the registry back to the font object so as to restore the font settings
ps: I can't save the file as .rtf, as i am dealing with only plain text.
thanks.


Answer this question

How can i change string to font object??

  • walt13671

    thanks for replying but i asked how to change the whole string to the font object, not just the font name and fontsize. You know that font object has many other properties besides those two properties like color,style etc. Manipulating string(ie getting substring, trimming etc.) would be very cubersome.
    So i wonder if anyone has the idea how can i change the whole string back to font as it was saved


  • mccdan

  • ostridge

    You can create font object and pass fontname and font size to it


    Font f=new Font(fontname,fontsize);
     

    fontname and fontsize are variable you set its value by reading the registry value
    and convert fontsize to float
    if you store this values as string with delemiter use splite to get this values
    and pass them to Font constructor
    and then set font property to it

    textBox1.Font=f;
     



  • How can i change string to font object??