diff --git a/PdfFile/PdfFile.cpp b/PdfFile/PdfFile.cpp index 05242f18e5..6524ec080d 100644 --- a/PdfFile/PdfFile.cpp +++ b/PdfFile/PdfFile.cpp @@ -886,23 +886,29 @@ HRESULT CPdfFile::put_FontName(const std::wstring& wsName) { if (!m_pInternal->pWriter) return S_FALSE; + std::wstring wsFont = wsName; if (m_pInternal->pEditor && wsName.find(L"Embedded: ") == 0) { - std::wstring sSub = wsName.substr(0, 10); + std::wstring sSub = wsName.substr(10); bool bBold = false, bItalic = false; std::wstring wsFontPath; - if (m_pInternal->pEditor->IsBase14(sSub, bBold, bItalic, wsFontPath) && (bBold || bItalic)) + if (m_pInternal->pEditor->IsBase14(sSub, bBold, bItalic, wsFontPath)) { - LONG lStyle = 0; - if (bBold) - lStyle |= 1; - if (bItalic) - lStyle |= 2; - put_FontStyle(lStyle); + if (bBold || bItalic) + { + LONG lStyle = 0; + if (bBold) + lStyle |= 1; + if (bItalic) + lStyle |= 2; + put_FontStyle(lStyle); + } } - m_pInternal->pWriter->AddFont(wsName, bBold, bItalic, wsFontPath, 0); + else + wsFont = sSub; + m_pInternal->pWriter->AddFont(wsFont, bBold, bItalic, wsFontPath, 0); } - return m_pInternal->pWriter->put_FontName(wsName); + return m_pInternal->pWriter->put_FontName(wsFont); } HRESULT CPdfFile::get_FontPath(std::wstring* wsPath) { diff --git a/PdfFile/PdfWriter.cpp b/PdfFile/PdfWriter.cpp index 55d337c4a7..52bc1d4bf4 100644 --- a/PdfFile/PdfWriter.cpp +++ b/PdfFile/PdfWriter.cpp @@ -2928,7 +2928,7 @@ int CPdfWriter::IsEmbeddedBase14(const std::wstring& wsName) { if (wsName.find(L"Embedded: ") != 0) return -1; - std::wstring sSub = wsName.substr(0, 10); + std::wstring sSub = wsName.substr(10); if (sSub == L"Helvetica") return 0; if (sSub == L"Helvetica-Bold") diff --git a/PdfFile/SrcReader/PdfAnnot.cpp b/PdfFile/SrcReader/PdfAnnot.cpp index 43643794fe..02c1621bb5 100644 --- a/PdfFile/SrcReader/PdfAnnot.cpp +++ b/PdfFile/SrcReader/PdfAnnot.cpp @@ -2470,6 +2470,7 @@ std::map AnnotMarkup::SetFont(PDFDoc* pdfDoc, Object else if (bItalic) sFontName += "-Oblique"; } + wsFontName = UTF8_TO_U(sFontName); const unsigned char* pData14 = NULL; unsigned int nSize14 = 0;