You have an image (PNG, GIF, or BMP) which contains all of the basic English characters: a-z, A-Z, 0-9, some punctuation. The characters are monospaced (all have the same width and also height) and in a specific (predictable) order. This is the "pseudofont". The challenge is this: Create a function that the user may pass a string to, which will create an image of the string using the letters in the pseudofont image. You'll probably want to use the GD library, but there are alternatives.
If you wish to participate in this exercise, there really aren't any rules. I'd like to see whatever comes out of this, even if you end up going in a completely different direction. There also aren't any prizes or rewards except pride and perhaps bragging rights. Some features you might want to consider adding if you're feeling especially ambitious:
- If the pseudofont is black-and-white, allow the user to specify a foreground and background color or transparency (replace black with foreground, white with background).
- Allow different-sized pseudofonts. Note: With a predictable character order and monospaced characters, you can derive the character width and height.
- Allow the user to specify attributes like spacing (extra space between characters) or even scaling (i.e. double the height or width)
- Allow the user to specify the output file format.
- Allow the user to specify a maximum image width and create a word-wrapping scheme for long texts.
- If a character is encountered that doesn't exist in the pseudofont, allow the option to grab it from an existing system font.
- I'm sure you can think of dozens others.
I'd really like to see others participate in this challenge. If you intend to participate, let me know below, just so I'm not sitting here waiting to see if anybody's interested. Also, if you think this is a lame challenge, I'd love to see others post their challenges.
Update: For the purpose of the exercise, I've created a pseudofont image. It contains the following characters in the following order:
Code: Select all
The last is intended to be a space, not an underscore. Each character is 7px wide with one pixel of padding to the right of each character. You may include the padding as part of each character or you may trim it off. Here it is:
(I think the spacing is right for all characters, if but anybody notices any discrepancies, let me know.)