Could difficulty be estimated by counting the number of unique characters?
Perhaps, but that would miss out on grammar and be only a rough proxy on vocabulary. I’d rather do some sort of lexical analysis but then that requires a bit more work.
same font size in both
Is the other file an EPUB or something else HTML-based?
We’re not really doing anything to intentionally make text fill the space more precisely on either, so to be honest, the fact that you find the layout in the other file more satisfying is probably just a coincidence rather than the result of any particular optimization on our end.