Move the disableFontFace option from the global PDFJS object and into getDocument instead
				
					
				
			This commit is contained in:
		
							parent
							
								
									f3900c4e57
								
							
						
					
					
						commit
						c7c583583b
					
				@ -160,6 +160,10 @@ function setPDFNetworkStreamFactory(pdfNetworkStreamFactory) {
 | 
			
		||||
 * @property {boolean} isEvalSupported - (optional) Determines if we can eval
 | 
			
		||||
 *   strings as JS. Primarily used to improve performance of font rendering,
 | 
			
		||||
 *   and when parsing PDF functions. The default value is `true`.
 | 
			
		||||
 * @property {boolean} disableFontFace - (optional) By default fonts are
 | 
			
		||||
 *   converted to OpenType fonts and loaded via font face rules. If disabled,
 | 
			
		||||
 *   fonts will be rendered using a built-in font renderer that constructs the
 | 
			
		||||
 *   glyphs with primitive path commands. The default value is `false`.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@ -258,6 +262,9 @@ function getDocument(src) {
 | 
			
		||||
  if (typeof params.isEvalSupported !== 'boolean') {
 | 
			
		||||
    params.isEvalSupported = true;
 | 
			
		||||
  }
 | 
			
		||||
  if (typeof params.disableFontFace !== 'boolean') {
 | 
			
		||||
    params.disableFontFace = false;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // Set the main-thread verbosity level.
 | 
			
		||||
  setVerbosityLevel(params.verbosity);
 | 
			
		||||
@ -344,7 +351,7 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
 | 
			
		||||
      length: source.length,
 | 
			
		||||
    },
 | 
			
		||||
    maxImageSize: source.maxImageSize,
 | 
			
		||||
    disableFontFace: getDefaultSetting('disableFontFace'),
 | 
			
		||||
    disableFontFace: source.disableFontFace,
 | 
			
		||||
    disableCreateObjectURL: getDefaultSetting('disableCreateObjectURL'),
 | 
			
		||||
    postMessageTransfers: worker.postMessageTransfers,
 | 
			
		||||
    docBaseUrl: source.docBaseUrl,
 | 
			
		||||
@ -1831,7 +1838,7 @@ var WorkerTransport = (function WorkerTransportClosure() {
 | 
			
		||||
            }
 | 
			
		||||
            var font = new FontFaceObject(exportedData, {
 | 
			
		||||
              isEvalSupported: params.isEvalSupported,
 | 
			
		||||
              disableFontFace: getDefaultSetting('disableFontFace'),
 | 
			
		||||
              disableFontFace: params.disableFontFace,
 | 
			
		||||
              fontRegistry,
 | 
			
		||||
            });
 | 
			
		||||
            var fontReady = (fontObjs) => {
 | 
			
		||||
 | 
			
		||||
@ -342,8 +342,6 @@ function getDefaultSetting(id) {
 | 
			
		||||
      return globalSettings ? globalSettings.disableStream : false;
 | 
			
		||||
    case 'disableRange':
 | 
			
		||||
      return globalSettings ? globalSettings.disableRange : false;
 | 
			
		||||
    case 'disableFontFace':
 | 
			
		||||
      return globalSettings ? globalSettings.disableFontFace : false;
 | 
			
		||||
    case 'disableCreateObjectURL':
 | 
			
		||||
      return globalSettings ? globalSettings.disableCreateObjectURL : false;
 | 
			
		||||
    default:
 | 
			
		||||
 | 
			
		||||
@ -65,15 +65,6 @@ PDFJS.Util = Util;
 | 
			
		||||
PDFJS.PageViewport = PageViewport;
 | 
			
		||||
PDFJS.createPromiseCapability = createPromiseCapability;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * By default fonts are converted to OpenType fonts and loaded via font face
 | 
			
		||||
 * rules. If disabled, the font will be rendered using a built in font
 | 
			
		||||
 * renderer that constructs the glyphs with primitive path commands.
 | 
			
		||||
 * @var {boolean}
 | 
			
		||||
 */
 | 
			
		||||
PDFJS.disableFontFace = (PDFJS.disableFontFace === undefined ?
 | 
			
		||||
                         false : PDFJS.disableFontFace);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Disable range request loading of PDF files. When enabled and if the server
 | 
			
		||||
 * supports partial content requests then the PDF will be fetched in chunks.
 | 
			
		||||
 | 
			
		||||
@ -210,10 +210,10 @@ let PDFViewerApplication = {
 | 
			
		||||
        PDFJS.disableAutoFetch = value;
 | 
			
		||||
      }),
 | 
			
		||||
      preferences.get('disableFontFace').then(function resolved(value) {
 | 
			
		||||
        if (PDFJS.disableFontFace === true) {
 | 
			
		||||
        if (AppOptions.get('disableFontFace') === true) {
 | 
			
		||||
          return;
 | 
			
		||||
        }
 | 
			
		||||
        PDFJS.disableFontFace = value;
 | 
			
		||||
        AppOptions.set('disableFontFace', value);
 | 
			
		||||
      }),
 | 
			
		||||
      preferences.get('useOnlyCssZoom').then(function resolved(value) {
 | 
			
		||||
        AppOptions.set('useOnlyCssZoom', value);
 | 
			
		||||
@ -269,7 +269,8 @@ let PDFViewerApplication = {
 | 
			
		||||
        PDFJS.disableAutoFetch = (hashParams['disableautofetch'] === 'true');
 | 
			
		||||
      }
 | 
			
		||||
      if ('disablefontface' in hashParams) {
 | 
			
		||||
        PDFJS.disableFontFace = (hashParams['disablefontface'] === 'true');
 | 
			
		||||
        AppOptions.set('disableFontFace',
 | 
			
		||||
                       hashParams['disablefontface'] === 'true');
 | 
			
		||||
      }
 | 
			
		||||
      if ('disablehistory' in hashParams) {
 | 
			
		||||
        AppOptions.set('disableHistory',
 | 
			
		||||
@ -1604,7 +1605,7 @@ function webViewerInitialized() {
 | 
			
		||||
  if (typeof PDFJSDev !== 'undefined' &&
 | 
			
		||||
      PDFJSDev.test('FIREFOX || MOZCENTRAL') &&
 | 
			
		||||
      !PDFViewerApplication.supportsDocumentFonts) {
 | 
			
		||||
    PDFJS.disableFontFace = true;
 | 
			
		||||
    AppOptions.set('disableFontFace', true);
 | 
			
		||||
    PDFViewerApplication.l10n.get('web_fonts_disabled', null,
 | 
			
		||||
      'Web fonts are disabled: unable to use embedded PDF fonts.').
 | 
			
		||||
        then((msg) => {
 | 
			
		||||
 | 
			
		||||
@ -139,6 +139,11 @@ const defaultOptions = {
 | 
			
		||||
            '../external/bcmaps/' : '../web/cmaps/'),
 | 
			
		||||
    kind: OptionKind.API,
 | 
			
		||||
  },
 | 
			
		||||
  disableFontFace: {
 | 
			
		||||
    /** @type {boolean} */
 | 
			
		||||
    value: false,
 | 
			
		||||
    kind: OptionKind.API,
 | 
			
		||||
  },
 | 
			
		||||
  isEvalSupported: {
 | 
			
		||||
    /** @type {boolean} */
 | 
			
		||||
    value: true,
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user