News for hackers. Stuff that matters.
Re:Show HN: Alter – convert text/code to an image by vog on Saturday November 26, 2016 @04:06AM (#13042647)
> What is this useful for?

I suspect it may be used to enforce custom fonts in an old-fashioned way, but nowadays you would simply deliver the font with you site, or use a font service.

Or, it could serve as some kind of "copy-protection", but it would not protect against OCR.

Thinking more about it, this may be a diabolic way to collect strings from people who want to make them "copy-protectable". So you don't need OCR anymore, but fetch them from the source. ;-)

Either way, it's a nice project with a good execution!

Re:Show HN: Alter – convert text/code to an image by kbr on Saturday November 26, 2016 @11:48AM (#13044526)
Well, I mainly made this after seeing people on Twitter tweet out code perfectly formatted and highlighted, but it's just a screenshot of their text editor.

So basically, the main use-case of Alter is that it lets you tweet code snippets that are a little over 140 characters that are formatted correctly.

It can also be used for more, such as "copy-protection", like you said above.

Re:Show HN: Alter – convert text/code to an image by imafish on Saturday November 26, 2016 @08:30AM (#13043399)
Cmon - don't call this a project. It is a single function. However, I like how OP realized that vanilla js was the correct choice for a simple job.
Re:Show HN: Alter – convert text/code to an image by kbr on Saturday November 26, 2016 @11:55AM (#13044573)
Haha, I agree, it's pretty small. If you look at my other projects, I <3 vanilla js.
Re:Show HN: Alter – convert text/code to an image by jupiter2 on Saturday November 26, 2016 @10:49AM (#13044152)
> Either way, it's a nice project with a good execution!

I agree. Very quick too. I tried it with some ascii art and it makes the overall image a bit thinner, though:(

(not handling spaces correctly)

Image: https://sli.mg/ZSLtf6

Ascii Source: http://www.ascii-art.de/ascii/ghi/gary_larson.txt

Re:Show HN: Alter – convert text/code to an image by kbr on Saturday November 26, 2016 @11:55AM (#13044563)
Yes, I'm working on this.

The problem is that it finds the longest line, by the number of characters in it. Instead of taking the actual width.

Re:Show HN: Alter – convert text/code to an image by jupiter2 on Saturday November 26, 2016 @03:16PM (#13045616)
This is great news. I can understand wanting to keep this as simple as possible but... if you decide to add any features:

1. Transparent Background (and)

2. Choice of character color (to integrate better with a webpage's color scheme, for example)

Re:Show HN: Alter – convert text/code to an image by tyingq on Saturday November 26, 2016 @10:05AM (#13043837)
Could also be useful, if extended with webfonts, for something like a custom T-shirt/mug/etc preview generator.
Re:Show HN: Alter – convert text/code to an image by sliken on Saturday November 26, 2016 @05:16AM (#13042815)
> What is this useful for?

Twitter.