Text this: Phase transitions in full counting statistics of free fermions and directed polymers