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 https://i.imgur.com/0gZQ1eQ.png would be:

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

which would render as https://i.imgur.com/FxskU9Q.png. 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 code-golf, so the lowest code size wins.

  • 5
    \$\begingroup\$ 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. \$\endgroup\$
    – Sanchises
    Apr 15 '18 at 7:36
  • \$\begingroup\$ 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? \$\endgroup\$
    – Laikoni
    Apr 15 '18 at 8:02
  • \$\begingroup\$ 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. \$\endgroup\$ Apr 15 '18 at 8:33
  • \$\begingroup\$ Embedding is done. \$\endgroup\$ Apr 15 '18 at 8:35
  • \$\begingroup\$ This needs more clarification. 1 Get rid of the bonuses please. See Sanchises' comment above. 2 Which image formats must be supported? \$\endgroup\$
    Apr 16 '18 at 5:52