Passwords don't need to be legible in the first place. There's nothing wrong with correcthorsebatterystaple.
On the other hand, forbidding spaces is absolutely misguided.
Unless the website silently lowercases all passwords. A lot of them do, in the name of making life easier for people who have Caps Lock on.
IIRC Facebook creates three passwords to deal with character case issues; the one you enter, an inverted case version and a version with the first characters case inverted.
I'd be very surprised if they created all 3. They probably check the other 2 variations if the first one fails though:
In order to be performant, since the check is not against your actual password but just against a stored hash (salted/bcyrpted/etc), I wouldn't be surprised if they simply stored all 3 hash results.