News for hackers. Stuff that matters.
Re:Tofu – The opposite of a font by userbinator on Sunday August 06, 2017 @04:40PM (#14943369)
WARNING: PLEASE DO NOT RUN THIS CODE ON A HARD DRIVE, I'M NOT SURE HOW LONG IT WOULD TAKE. I USED A RAM DISK

I haven't looked at the implementation, but this seems to imply it is very I/O intensive and already takes a very long time in RAM. Yet, nothing about the problem statement suggests it would be such a task --- it sounds like something that could be very straightforwardly done completely in memory.

Re:Tofu – The opposite of a font by chungy on Sunday August 06, 2017 @08:03PM (#14944434)
That warning made me want to try it on my hard disk just to see how long it would take...

It was only a couple minutes. That's a bit disappointing.

Re:Tofu – The opposite of a font by sleepychu on Sunday August 06, 2017 @08:19PM (#14944476)
SSD or spinning platter?
Re:Tofu – The opposite of a font by chungy on Sunday August 06, 2017 @08:21PM (#14944480)
Spinning platter. ZFS with compression is probably helping that.
Re:Tofu – The opposite of a font by panic on Sunday August 06, 2017 @08:24PM (#14944490)
Your OS is probably caching the file at the virtual memory layer, so it doesn't even have to hit the filesystem at all.
Re:Tofu – The opposite of a font by sillysaurus3 on Sunday August 06, 2017 @10:07PM (#14944824)
A good lesson not to try to guess where the bottlenecks in a program will be. :)
Re:Tofu – The opposite of a font by wereHamster on Monday August 07, 2017 @03:05AM (#14945825)
mount -o sync :)
Re:Tofu – The opposite of a font by juanpotato on Sunday August 06, 2017 @05:47PM (#14943784)
You're right and I should have added more details. fontforge only accepts file paths and not strings sadly
Re:Tofu – The opposite of a font by monsieurbanana on Monday August 07, 2017 @08:34AM (#14947016)
Libraries to treat strings as files are pretty common, in python they have one in the std:

https://docs.python.org/2/library/stringio.html

Re:Tofu – The opposite of a font by juanpotato on Monday August 07, 2017 @11:57AM (#14948480)
But that's a file, it accepts a file path. I already looked into this
Re:Tofu – The opposite of a font by CJefferson on Sunday August 06, 2017 @04:49PM (#14943443)
It's just that the python library used won't read SVG from a string, online from a file given a filename, so each character must be written to disk, then read back in.
Re:Tofu – The opposite of a font by userbinator on Sunday August 06, 2017 @05:07PM (#14943534)
Wow. To me that's definitely in the realm of "fix this if you need to run this program more than once" inefficiency. After looking at the implementation, it doesn't seem like it takes advantage of TTF's "composite glyphs" feature either, which would be the most straightforward way of generating a font like this --- once you define the box and the digit glyphs, each character is then composed entirely of references to the box and the appropriate digit glyphs.
Re:Tofu – The opposite of a font by juanpotato on Sunday August 06, 2017 @05:49PM (#14943800)
Yeah I tried looking to see how much I would need to change to fix it, but I'm not too great in C which is what fontforge was written in.

Oh man I gotta look into the composite glyphs. I don't know much about fonts in general. Thanks for this bit of information.

Re:Tofu – The opposite of a font by Zyst on Sunday August 06, 2017 @07:44PM (#14944366)
>To me that's definitely in the realm of "fix this if you need to run this program more than once"

Maybe the programmer doesn't need to use this more than once?

Re:Tofu – The opposite of a font by ClassyJacket on Sunday August 06, 2017 @07:20PM (#14944279)
Hobbyist-only coder here who hacks together high-level crap, not memory management and such. Question -

If this program needed to operate from memory instead of a disk, why didn't the coder just... code it that way? Are they saying to use a RAM disk to ensure you don't encounter automatic paging out to disk by the OS?

Re:Tofu – The opposite of a font by codefined on Sunday August 06, 2017 @08:00PM (#14944427)
I believe it's a requirement of font forge that they're using.

It requires file paths, and it will be doing a large amount of reading. Easiest way of solving this is probably just to fake that your memory is a hard drive.

Re:Tofu – The opposite of a font by djsumdog on Monday August 07, 2017 @02:34AM (#14945724)
As other comments have stated, most operating systems do a pretty good job at caching this type of I/O anyway. It goes back to the idea of not optimizing until you know where the bottlenecks really are. A lot of time the underlying layers may take care of it for you.