Fix the issue that GetHeightForWidth returns wrong height after calling GetTextDirection