The special {nb} code fails with some fonts when text shaping is turned on.
Minimal code
Please include some minimal Python code reproducing your issue:
pdf = FPDF(format='letter')
pdf.add_font('gentium', style='', fname='GenBkBasR.ttf')
pdf.add_page()
pdf.set_font('gentium', '', 24)
pdf.set_text_shaping(True)
pdf.write(text='Pages {nb}')
pdf.ln()
pdf.set_text_shaping(False)
pdf.write(text='Pages {nb}')
pdf.output('test.pdf')
Result

Environment
Please provide the following information:
- Operating System: Ubuntu
- Python version: 11
fpdf2 version used: 2.7.7