Order it now! Amazon prioritizes orders on a first come, first served basis.


View Full Version : Restore KindleDX's font dialog justification toggle


Gearhead
07-21-2009, 11:24 AM
Selectable text justification is one the issues that I've been keen to have Amazon address. They actually built this feature into all Kindles but left it disabled. I've not seen any issues when using the built in left justification but maybe there is a reason Amazon left it disabled. Maybe it is buggy? Maybe some publishers are forcing Amazon to keep the feature off the Kindle? This is the third generation of the Kindle hardware without an official left justification toggle and it doesn't seem likely that Amazon will enable this so I'll go over the steps I took to enable the built in justification toggle (full, left) on the DX.

First, a bit of background. Out of the box, the Kindle uses full text justification. This means that the left and right margins are even. This looks good to most folks. It is how most printed books look and works well enough. I find that full justification is distracting and prefer a single space between words with a ragged right margin. This is a more agreeable to me when you have the ability to change font sizes, it keeps the white space uniform between the words no matter what font size. (see attached images)

I've been following ebs lead on the screen saver fix and poked around the DX until I found the settings that need to be changed to enable the justification toggle. Once these settings are added to your DX, you will see the toggle show up automatically on the font (aA button) screen.

The settings to allow the toggle reside in this file:

system/com.amazon.ebook.booklet.reader/reader.pref.default

Here is how mine looks now:


#Reader Booklet
#Tue Jul 21 09:31:16 GMT 2009
FONT_SIZE=36
JUSTIFICATION=left
LAST_BOOK_READ=/mnt/us/documents/UR-asin_B001RF3U9K-type_EBOK-v_0.azw
ALLOW_JUSTIFICATION_CHANGE=true


You can view this file in any text editor. It is in the user mountable section at the same level as the documents folder. Unfortunately, you can't just add ALLOW_JUSTIFICATION_CHANGE=true because the Kindle framework rewrites this file when shutting down. The settings need to be injected after boot but before the java framework is started. Since I already implemented ebs usbnetworking auto start script, I decided to hijack it to see what happened. It worked. My changes are in bold


#!/bin/sh

_FUNCTIONS=/etc/rc.d/functions
[ -f ${_FUNCTIONS} ] && . ${_FUNCTIONS}

US_ENABLE=/mnt/us/usbnet/AUTO

case "$1" in

start)
if [ -f ${US_ENABLE} ]; then
/mnt/us/usbnet/usbnetwork

echo "JUSTIFICATION = left" >> /mnt/us/system/com.amazon.ebook.booklet.reader/reader.pref
echo "ALLOW_JUSTIFICATION_CHANGE = true" >> /mnt/us/system/com.amazon.ebook.booklet.reader/reader.pref

else
msg "not usbnet" I
fi
;;

stop)
;;
*)
msg "Usage: $0 {start|stop}" W >&2
exit 1
;;
esac

exit 0


With these changes, I rebooted once into auto usbnetworking. That injected the changes. Another reboot is needed to get back to normal mode. Although this works, the echo lines should be moved to separate script and there needs to be some shell logic written to prevent injecting the justification lines into the reader.pref file if they already exist. If there is enough interest, these changes could be packaged up into a binary file to make updating easier. Also, there needs to be a way to reverse this change.

-robert

rfog
07-21-2009, 01:35 PM
WOW!

Yesterday I was messing with some similar: interline. In Kindle 2 you can press Shift+Alt+<number>, but in DX cannot.

Then I searched about that but I couldn't find where K2 stores those justification.

How do you search for the strings. I tried to decompile java programs stored in /opt/amazon/ebook/booklet but the result was not usable...

ebs
07-21-2009, 01:43 PM
WOW!
How do you search for the strings. I tried to decompile java programs stored in /opt/amazon/ebook/booklet but the result was not usable...

I use "jad -f -nolvt" to decompile extracted class files. Output is almost always unusable for re-compilation, but it will show all strings.

If you really want to change some the logic - use something like IDA to produce java assembly and jasmin to compile it back or just re-write the whole file and use normal java tools to compile it.

ectoplasm
08-22-2009, 02:08 PM
..Unfortunately, you can't just add ALLOW_JUSTIFICATION_CHANGE=true because the Kindle framework rewrites this file when shutting down.


..Although this works, the echo lines should be moved to separate script and there needs to be some shell logic written to prevent injecting the justification lines into the reader.pref file if they already exist.

If the reader.pref file is rewritten when shutting down, why do you have to worry about injecting the lines more than once?

Gearhead
08-25-2009, 01:28 PM
If the reader.pref file is rewritten when shutting down, why do you have to worry about injecting the lines more than once?

You have a point there. It shouldn't matter. But...it is possible there are conditions when the file is not rewritten. The obfuscated code makes it difficult to tell for sure.

-robert

ectoplasm
08-28-2009, 07:27 PM
Thanks to Gearhead for figuring this out.

When I first got this working, I thought something was wrong, until I realized this only works on some books. In fact, less than half of the books on my Kindle DX will react to this switch. However, in my view, if I can "fix" any books with this switch, it is a good thing.

I don't care to have extra space between words in sentences just to have an aligned right margin.

I do have an alternative procedure that works on any book. I'll post a thread about that soon.

Here is a script I made that is separate from the usbnetwork script:

#!/bin/bash

grep_output=`grep ALLOW_JUSTIFICATION_CHANGE "/mnt/us/system/com.amazon.ebook.booklet.reader/reader.pref"`
if [ "$grep_output" == "" ]; then
echo "Not found - adding"
echo "JUSTIFICATION = left" >> /mnt/us/system/com.amazon.ebook.booklet.reader/reader.pref
echo "ALLOW_JUSTIFICATION_CHANGE = true" >> /mnt/us/system/com.amazon.ebook.booklet.reader/reader.pref
else
echo "Justification option already exists in pref file."
fi


1) Create file named justify_option (with above contents) in /etc/init.d using vi editor, or however you can get it in there.
2) Make it executable (I forgot the exact chmod command)
3) Make a link using command:
ln -s /etc/init.d/justify_option /etc/rcS.d/S73justify_option
4) Reboot