diff --git a/common/Drawings/Externals.js b/common/Drawings/Externals.js index f02177542f..502c432be2 100644 --- a/common/Drawings/Externals.js +++ b/common/Drawings/Externals.js @@ -721,23 +721,54 @@ return "Embedded: "; }; - window['AscFonts'].initEmbeddedFonts = function(fonts) + window['AscFonts'].initEmbeddedFonts = function(fonts, isMerge) { const prefix = AscFonts.getEmbeddedFontPrefix(); let fontFiles = AscFonts.g_font_files; - if (CFontFileLoaderEmbed.prototype.startIndex > 0) - fontFiles.splice(CFontFileLoaderEmbed.prototype.startIndex); - - CFontFileLoaderEmbed.prototype.startIndex = fontFiles.length; - let currentIndex = CFontFileLoaderEmbed.prototype.startIndex; - - for (let i = 0, len = fonts.length; i < len; i++) + if (!isMerge) { - let name = prefix + fonts[i]; - AscFonts.g_font_files.push(new CFontFileLoaderEmbed(name)); - AscFonts.g_font_infos_embed.push(new CFontInfoEmbed(name, currentIndex++)); - AscFonts.g_map_font_index_embed[name] = i; + if (CFontFileLoaderEmbed.prototype.startIndex > 0) + fontFiles.splice(CFontFileLoaderEmbed.prototype.startIndex); + + CFontFileLoaderEmbed.prototype.startIndex = fontFiles.length; + let currentIndex = CFontFileLoaderEmbed.prototype.startIndex; + + for (let i = 0, len = fonts.length; i < len; i++) + { + let name = prefix + fonts[i]; + AscFonts.g_font_files.push(new CFontFileLoaderEmbed(name)); + AscFonts.g_font_infos_embed.push(new CFontInfoEmbed(name, currentIndex++)); + AscFonts.g_map_font_index_embed[name] = i; + } + } + else + { + let startIndex = CFontFileLoaderEmbed.prototype.startIndex; + let endIndex = fontFiles.length; + let currentIndex = endIndex; + + for (let i = 0, len = fonts.length; i < len; i++) + { + let name = prefix + fonts[i]; + + let isFound = false; + for (let j = startIndex; j < endIndex; j++) + { + if (fontFiles[j].Id === name) + { + isFound = true; + break; + } + } + + if (isFound) + continue; + + AscFonts.g_font_files.push(new CFontFileLoaderEmbed(name)); + AscFonts.g_font_infos_embed.push(new CFontInfoEmbed(name, currentIndex++)); + AscFonts.g_map_font_index_embed[name] = i; + } } }; diff --git a/pdf/src/document.js b/pdf/src/document.js index 6c062c88ad..62d79055b3 100644 --- a/pdf/src/document.js +++ b/pdf/src/document.js @@ -7382,7 +7382,7 @@ var CPresentation = CPresentation || function(){}; let standardFonts = oFile.nativeFile["getInteractiveFormsStandardFonts"](); let embeddedFonts = oFile.nativeFile["getInteractiveFormsEmbeddedFonts"](); - AscFonts.initEmbeddedFonts(standardFonts.concat(embeddedFonts)); + AscFonts.initEmbeddedFonts(standardFonts.concat(embeddedFonts), true); this.Viewer.checkLoadCMap(); this.Viewer.navigateToPage(nNavigateTo);