Results 1 to 8 of 8

Thread: Reading in a Font?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2001
    Posts
    152

    Question Reading in a Font?

    I am trying to do the following:

    1. A user types in a text box a string "Hello"
    2. They choose a Font (Arial, Times, etc)
    3. They click "Go" for lack of a better term

    Now is the hard part, I want to read the text string that they typed in and create an image using whatever font they selected. Basically it will check the encoded version of each character the user typed in and match it to the character in the font. Any ideas of any way to read in a Font and output an Image from that font?

    Any help is appreciated...

    Thanks.

  2. #2
    Addicted Member csammis's Avatar
    Join Date
    Mar 2001
    Location
    /dev/null
    Posts
    226
    Could you explain your goal a little bit more? If I catch your meaning, you want to extract individual glyphs out of the font file based on the user input...?
    Things I've Said:
    "Life's funny like that...elephants can wear frilly lace panties, and Dubya still looks like a monkey in a big chair"
    "Take four goats and strap one to each foot of a llama. Presto, goat-powered llama!"
    "You want to get me to work more, get me a Coke. No? Then deal with inferior garbage, I'm not coding another line and your clients can go to......thanks, I'd love a Coke right about now!"

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2001
    Posts
    152
    Basically it is simple... someone types something in and then you convert it into an image. Down the road you can add color, etc... The encoded values of the characters from the operating system will give you the correct glyph location in the font. However opening the font and rendering them into images is slightly more confusing.

    Does this clarify it a bit more?

  4. #4
    Megatron
    Guest
    Try:
    Code:
    Picture1.FontName = txtFont
    Picture1.AutoRedraw = True
    Picture1.Print txtText
    SavePicture Picture1.Image, "C:\MyFile.bmp"

  5. #5
    Addicted Member csammis's Avatar
    Join Date
    Mar 2001
    Location
    /dev/null
    Posts
    226
    That clarifies it perfectly...unfortunatly I don't know how .TTF files are structured well enough to tell you how to read a single glyph in. You can try www.wotsit.org, which has a large collection of file formats, and if you figure out how to read it in, post back here and we might be able to decide how to translate it into an image
    Things I've Said:
    "Life's funny like that...elephants can wear frilly lace panties, and Dubya still looks like a monkey in a big chair"
    "Take four goats and strap one to each foot of a llama. Presto, goat-powered llama!"
    "You want to get me to work more, get me a Coke. No? Then deal with inferior garbage, I'm not coding another line and your clients can go to......thanks, I'd love a Coke right about now!"

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Mar 2001
    Posts
    152
    Alright, I will elaborate a bit more... Megatron, thanks for that, yes that does work, but there is more I need to do (we actually had something similar running, but the next part was a problem). If you can help me leverage your example then that would be great.

    We have people who use Extended Characters like Cyrillic, KOI-8, etc and want them to work as well. We can find all of these in the Arial Unicode MS font so I can use this font. However, it seems that when the user tries to input characters in the text box all we ever see are ???? question marks. I believe this is because it is outside the standard ASCII range.

    I thought using their font code(like 05D6 for character X) would help alleviate this, but I am not sure.

    Any ideas? Also, can you make a text box Unicode compliant???

  7. #7
    Addicted Member csammis's Avatar
    Join Date
    Mar 2001
    Location
    /dev/null
    Posts
    226
    RichTextBoxes can use Unicode
    Things I've Said:
    "Life's funny like that...elephants can wear frilly lace panties, and Dubya still looks like a monkey in a big chair"
    "Take four goats and strap one to each foot of a llama. Presto, goat-powered llama!"
    "You want to get me to work more, get me a Coke. No? Then deal with inferior garbage, I'm not coding another line and your clients can go to......thanks, I'd love a Coke right about now!"

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Mar 2001
    Posts
    152
    csammis, yes and this works from the input side and you can get the Rich Text from the control which might look something like this:

    {\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\froman\fcharset0 Times New Roman;}{\f1\fnil\fcharset0 Arial Unicode MS;}}
    \viewkind4\uc1\pard\sb100\sa100\b\f0\fs24\u1048?\u1052?\u1071?\b0
    \par \pard\f1\fs17
    \par }

    If you parse it closely enough you can see the \u1048 which are Unicode characters. I am not sure what alot of the other junk is however and would love to know but it is not exactly necessary.

    If you try and get the straight Text out, you will still get ?????. Now that we have the glyph locations is there any way to get them from the font?

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