Sunday, March 2, 2014

The Latin Crush

I discovered my iz2s build of finch runs just fine -- no segfaults -- but it never seems to make a connection to the IRC server.  Running it with --debug pointed me towards the threaded DNS resolver function, which never seemed to finish.  So, suspecting glib, I built a small test function and it didn't work either.  Then I noticed the nslookup busybox applet wasn't working either, which put the problem in uclibc.  The internet said there were some unsupported (but reported) flags in the getaddrinfo function in the ancient uclibc used by iz2s.  I patched around it and managed to fix my test program, which could substitute for the broken nslookup applet, but the threaded versions of the function used in finch and glib still don't weem to work.  Oh well.  I'll figure it out someday.

Meanwhile over on the zipit IRC channel, slug_ was busy reworking the ssl functionality in the openwrt build of the links browser, attempting to reduce the jffs disk space required for links by backing the ssl code out to a shared lib and then pointing links at some other random shared lib already on the jffs.  I like the idea, but not so much the implementation because it's totally broken on iz2s.  I'd rather try and fix the openssl compatibility layer in polarssl and/or patch the links https.c file to use it.  Unfortunately that idea is still on the back burner.  But meanwhile, all this somehow got me thinking about shrinking the png files used by the links font system.  I got motivated and ran my cut down latin15 links font set through pngcrush --brute, then rebuilt links to see what would happen.  Turns out, it saved me 40K bytes on the jffs, so I'll take it.

But I didn't stop there.  I got to thinking again about using TTF fonts for links, so I bit the bullet and compiled the links code on the zipit itself in preparation for a heavy gdb session to track down the source of the segfault that stopped me cold the last time I tried this.  Turns out I never got into the gdb session.  I ran links via ssh and noticed the error message, looked it up in the code, and found a self induced segfault due to my shoddy character width calculations on the TTF mono-spaced font.  Oops.

So I fixed that and now it runs.  The good news is the executable comes out to a very reasonable 534K with ssl included via static linking.  Nice.  And as expected, the tiny fonts required by the zipit are much cleaner and far more readable than the original scaled down png fonts. 
I think I can approximate the coverage of the original built-in png fonts on the jffs with just two dejavu fonts (mono and proportional spaced) for only 80K bytes over the current TTF font included on the jffs, possibly more if I need bold and italics.  That gives a savings of maybe 200-250K over the pngcrushed links build, and it might just save my eyes.  Plus I'll have a decent set of fonts on the jffs to work with for other apps like the flipclock.  Even pspmaps might work on the jffs if I keep the map images in /tmp when the SD card is absent.

As you can see in the picture, I still need to do plenty of adjustments to make the TTF glyph metrics match what links was doing with the png files.  That'll take some time because I probably also need to measure the RAM footprint of multiple preloaded TTF font sizes vs the runtime resizing of the png fonts to get something optimal for the 32MB RAM in the zipit.

Update:  Getting closer..  I got multiple fonts and sizes going and I fixed some problems with the spacing and non-printable control characters.  Judging by the link highlight rectangle in the picture below, spacing could possibly use a bit more work.  And if I can figure out why some text isn't printing in the title bar, status bar, and dialog boxes I can probably release an executable package.

Update 2: I fixed the bug with the text in the title bar status bar and dialogs.


I also restored the bold font support and did some comparisons to the original links.  The ttf and png versions used a similar amount of memory with the same mix of bold, normal, and monospace fonts when rendering this test page.

I find the original png fonts (below) a bit fuzzy, especially at the smaller sizes best suited for the zipit screen.

Anyhow, here's the pngcrushed Links executable.  I might try to make it smaller with some more advanced pngcrush settings mentioned on the zipit IRC channel.

links-iz2s-latincrush.zip

I'm hoping to add the font-include-latin-crushed.h file to the openwrt-zipit links package on github, real soon now.

Here's a links-ttf executable.  Probably riddled with bugs, but at least it proves the concept is viable.

links-ttf-iz2s-beta1.zip

And here's a tiny Latin1 ttf font viewer program with source code that might be handy someday if I ever decide to scour the internet for smaller font files.

ttfview-iz2s.zip

Update 3:  I fixed the segfault in Links when selecting languages.  Here you can see it not crashing in that section of the menu.  You can also see the Bepa Roman ttf fonts support more glyphs than I did with my Latin1 built-in-font executables.  If I could figure out what all those characters were, maybe I could restore some more of the original 33 languages on the menu...  Actually, it really demonstrates that I need to move the menu language support into runtime loaded optional shared libs so you can install your own language(s) to go with your own ttf fonts.  If only the standard solution for that wasn't such bloatware.

This screenshot also showcases some new mini scrollbars and a new menu color scheme that I've been testing in the ttf package with more contrast for better readability with the tiny font.  You can't see it here but I also added a blue block cursor in the ttf package for the menu text entry fields.  The original underline cursor was always difficult for me to locate with my bad eyes.

Anyhow, I repackaged some new executables with the segfault fix.

links-iz2s-latincrush2.zip
links-ttf-iz2s-beta2.zip

Update 4:

I added slug's title and statusbar hiding code from the openwrt build for a little extra screen space in the links ttf executable.  Every little bit helps.  So here's the new executable and the modified links source code.

links-ttf-iz2s-beta3.zip
links-ttf-src3.tgz



No comments:

Post a Comment