Learning to Align: Addressing Character Frequency Distribution Shifts in Handwritten Text Recognition