Fix for PDF text not being selectable on Mac OSX

Produces selectable text when printing/rasterizing to PDF on OSX.

https://github.com/ariya/phantomjs/issues/10373

Please note: this PR is the same as the original one by FreshXOpenSource: https://github.com/ariya/phantomjs/pull/11509 - the only difference is that I have tried to refactor the PR to meet Contribution Guidelines.