diff --git a/PdfFile/PdfEditor.cpp b/PdfFile/PdfEditor.cpp index 81525985f0..a6c58d8785 100644 --- a/PdfFile/PdfEditor.cpp +++ b/PdfFile/PdfEditor.cpp @@ -4350,14 +4350,14 @@ void CPdfEditor::ScanAndProcessFonts(PDFDoc* pPDFDocument, XRef* xref, Dict* pRe { Ref oEmbRef; std::wstring wsFontBaseName = NSStrings::GetStringFromUTF32(gfxFont->getName()); - - if (gfxFont->getEmbeddedFontID(&oEmbRef) || PdfReader::IsBaseFont(wsFontBaseName)) + GfxFontLoc* pFontLoc = NULL; + if (gfxFont->getEmbeddedFontID(&oEmbRef) || PdfReader::IsBaseFont(wsFontBaseName) || ((pFontLoc = gfxFont->locateFont(xref, false)) && NSStrings::GetStringFromUTF32(pFontLoc->path).length())) { std::wstring wsFileName, wsFontName; PdfReader::RendererOutputDev::GetFont(xref, pFontManager, pFontList, gfxFont, wsFileName, wsFontName, false); // Собираем информацию о встроенном шрифте - if (gfxFont->getEmbeddedFontID(&oEmbRef) && !PdfReader::IsBaseFont(wsFontBaseName)) + if (!PdfReader::IsBaseFont(wsFontBaseName)) { PdfReader::TFontEntry pFontEntry; Ref nFontRef = oFontRef.getRef(); @@ -4384,6 +4384,7 @@ void CPdfEditor::ScanAndProcessFonts(PDFDoc* pPDFDocument, XRef* xref, Dict* pRe } } + RELEASEOBJECT(pFontLoc); RELEASEOBJECT(gfxFont); } diff --git a/PdfFile/PdfFile.cpp b/PdfFile/PdfFile.cpp index 6138296318..89d7082a64 100644 --- a/PdfFile/PdfFile.cpp +++ b/PdfFile/PdfFile.cpp @@ -1072,12 +1072,30 @@ HRESULT CPdfFile::put_FontName(const std::wstring& wsName) } m_pInternal->pWriter->AddFont(wsFont, bBold, bItalic, wsFontPath, 0); } - else + else if (wsFontPath.empty()) { - const std::map& mFonts = m_pInternal->pReader->GetFonts(); - auto it = mFonts.find(sSub); - if (it != mFonts.end()) - wsFontPath = it->second; + size_t lastSpace = wsName.find_last_of(L' '); + if (lastSpace != std::wstring::npos) + { + std::wstring numberStr = wsName.substr(lastSpace + 1); + int nTargetCode = std::stoi(numberStr); + const std::map& mFonts = m_pInternal->pReader->GetFonts(); + auto it = std::find_if(mFonts.begin(), mFonts.end(), [nTargetCode](const auto& pair) + { + const std::wstring& key = pair.first; + size_t pos = key.rfind(L' '); + if (pos != std::wstring::npos) + { + int keyCode = std::stoi(key.substr(pos + 1)); + return keyCode == nTargetCode; + } + return false; + }); + if (it != mFonts.end()) + wsFont = L"Embedded: " + it->first; + else + wsFont = wsName.substr(10, lastSpace - 10); + } else wsFont = sSub; } diff --git a/PdfFile/SrcReader/RendererOutputDev.cpp b/PdfFile/SrcReader/RendererOutputDev.cpp index 00ed3ce749..ad494c031c 100644 --- a/PdfFile/SrcReader/RendererOutputDev.cpp +++ b/PdfFile/SrcReader/RendererOutputDev.cpp @@ -1461,6 +1461,8 @@ namespace PdfReader wsFontName = wsFontBaseName; if (bNotFullName) EraseSubsetTag(wsFontName); + else + wsFontName += (L" " + std::to_wstring(pFont->getID()->num)); pEntry->wsFilePath = wsFileName; pEntry->wsFontName = wsFontName;