Make sure font weight value is within allowed range
(cherry picked from commit 5e91383e3fc942ae6c86aeb01d281e59be5ae125)