Refactored the font and table writing functions