# Render a monospaced bitmap font from image [closed]

Input is in this format:

image fontwidth fontheight rowwidth xoffset yoffset xgap ygap non-existent charstart thetextitself


thetextitself: The text that should be rendered from the image.

image: The image filename. Implementation may vary; it could be either the filename from your computer, an image URL, or something else, as long as it's possible to use any picture.

fontwidth, fontheight: self explanatory

rowwidth: How many characters a row of characters contains in the image?

xoffset: The starting x coordinate of the character table.

yoffset: The starting y coordinate of the character table.

xgap: The horizontal gap between characters.

ygap: The vertical gap between characters.

non-existent: The character code for the character rendered if the character is (fully or partially) outside the image, hexadecimal of any length.

charstart: The hexadecimal first character any length.

thetextitself: The text to render. The previous parameters are used to find the characters. It's at the end, so that any space included doesn't clash with the next parameter.

So, the appropriate input for this image would be:

https://i.imgur.com/0gZQ1eQ.png 7 11 8 3 5 2 1 00000000 00000 <Test>


which would render as . The exact pixel colors are preserved.

Word wrapping is not needed, but if you use word wrapping, there must be at least 16 characters of horizontal space.

-10 bytes if the code renders tabs (U+0009) correctly (jumps to the next position divisible by 8).

-10 bytes if the code renders Microsoft Windows newlines (U+000D000A) correctly (extends the output image height and jumps to the beginning of the last line).

-10 bytes if the code interprets the combining and zero–width characters as zero–width, but combining characters overlapping their glyph to the next (or the previous; I don't know how Unicode combining characters work) character.

The code must support Unicode characters up to U+FFFF. If the code allows for characters above, -10 bytes.

It's , so the lowest code size wins.

• You may want to get rid of the bonuses - effectively, you're asking people to make 2^4 different programs and only post the shortest. Apr 15, 2018 at 7:36
• What are the units for fontwidth, xoffset xgap etc? Are there any bounds on their range? If not, how should text be displayed with e.g. fondwith=2 and fontheight=100? Apr 15, 2018 at 8:02
• The units are in pixels, and there should be no bounds on their range, aside from limitations like the fact that a byte can only go up to 255. Apr 15, 2018 at 8:33
• Embedding is done. Apr 15, 2018 at 8:35
• This needs more clarification. 1 Get rid of the bonuses please. See Sanchises' comment above. 2 Which image formats must be supported? Apr 16, 2018 at 5:52