Skip to content

Commit

Permalink
Fix: Temporary disableFontFaces on IOS 10.3
Browse files Browse the repository at this point in the history
-temp fix until mozilla/pdf.js#8267 is resolved
  • Loading branch information
JustinHoldstock authored Apr 11, 2017
1 parent 88304c9 commit 67de2d7
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/lib/Browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,15 @@ class Browser {
static isAndroid() {
return /Android/g.test(navigator.userAgent);
}

/**
* Returns whether or not the device is running IOS 10.3.X that has Font Ligature rendering issue.
*
* @return {boolean} True if device is running IOS 10.3.x
*/
static isIOSWithFontIssue() {
return Browser.isIOS() && /(?:OS\s)10_3/i.test(navigator.userAgent);
}
}

export default Browser;
4 changes: 4 additions & 0 deletions src/lib/viewers/doc/DocBaseViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,10 @@ class DocBaseViewer extends BaseViewer {
enhanceTextSelection: true // improves text selection if true
});

// Disable font faces on IOS 10.3.X
// @NOTE(JustinHoldstock) 2017-04-11: Check to remove this after next IOS release after 10.3.1
PDFJS.disableFontFace = PDFJS.disableFontFace || Browser.isIOSWithFontIssue();

// Use chunk size set in viewer options if available
let rangeChunkSize = this.getViewerOption('rangeChunkSize');

Expand Down
21 changes: 21 additions & 0 deletions src/lib/viewers/doc/__tests__/DocBaseViewer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1004,6 +1004,27 @@ describe('src/lib/viewers/doc/DocBaseViewer', () => {
expect(stubs.pdfViewer.linkService.setDocument).to.be.called;
});
});

// @NOTE(JustinHoldstock) 2017-04-11: Check to remove this after next IOS release after 10.3.1
it('should test user agent if on Safari Mobile for IOS 10.3', () => {
const doc = {
url: 'url'
};
sandbox.stub(PDFJS, 'getDocument').returns(Promise.resolve(doc));
sandbox.stub(docBase, 'getViewerOption').returns(100);
docBase.options.location = {
locale: 'en-US'
};

const getStub = sandbox.stub(Browser, 'isIOSWithFontIssue').returns(true);

docBase.initViewer('url');

// Mobile stub cannot be called if get stub is never called.
// See note for this test, for more info.
expect(getStub).to.be.called;
expect(PDFJS.disableFontFace).to.be.true;
});
});

describe('setupPdfjs()', () => {
Expand Down

0 comments on commit 67de2d7

Please sign in to comment.