Results 1 to 5 of 5

Thread: Storing a font in database

  1. #1

    Thread Starter
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018

    Storing a font in database

    I have a font dialogbox which allows users to choose a new font.

    The problem I have is that I am not sure how to efficiently store this font in a sql server table.

    Any Ideas ?


    TIA

    Parksie

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: Storing a font in database

    I store a font in a database in three columns representing three properties of the Font object. The columns I name FontFamily, FontSize and FontStyle and they represent the FontFamily.Name, Size and Style properties of the Font object. Those properties are easy to get from the Font object and to save to a record and they also correspond directly to the arguments of one of the constructors of the Font class, so recreating the Font in code is also easy.

    The alternative would be to serialise the Font object and save the output to a single column, the values from which you can then deserialise at a later time.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018

    Resolved Re: Storing a font in database

    Thanks for that JMC.

    I think i'm going to have to store the attributes as I don't think you can serialize a font.

    Cheers

    Parksie

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: Storing a font in database

    Given that the Font class implements the ISerializable interface, I'm guessing that you can serialise a font.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5
    Fanatic Member dom_stapleton's Avatar
    Join Date
    Sep 2005
    Location
    Leigh-on-Sea, UK
    Posts
    665

    Re: Storing a font in database

    How would you go about serialising and deserialising an object that implements the ISerializable interface?
    I use Microsoft Visual Basic 2008 Express Edition.

    If my post has been helpful, please rate it, unless you don't believe in Karma... which actually I don't!

    Resources:
    Visual Basic Tutorials (1, 2) | MSDN Library | Google | Krugle | Search Forums

    Free components:
    Windows Forms Components | XP Common Controls Library

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width