From 04565bbdd4e85d302d751dc8bbd08be85008531c Mon Sep 17 00:00:00 2001 From: Svetlana Kulikova Date: Mon, 28 Oct 2024 11:55:01 +0300 Subject: [PATCH] Fix change font --- PdfFile/PdfWriter.cpp | 32 ++++++++++++++------------------ PdfFile/SrcWriter/Font14.cpp | 2 +- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/PdfFile/PdfWriter.cpp b/PdfFile/PdfWriter.cpp index e8eaae09ee..b71adfbd05 100644 --- a/PdfFile/PdfWriter.cpp +++ b/PdfFile/PdfWriter.cpp @@ -2129,17 +2129,16 @@ HRESULT CPdfWriter::AddAnnotField(NSFonts::IApplicationFonts* pAppFonts, CAnnotF wsFontKey = pPr->GetFontKey(); std::wstring wsFontName = pPr->GetFontName(); - if (wsFontName == L"Times-Roman" || wsFontName == L"Times-Bold" || wsFontName == L"Times-BoldItalic" || wsFontName == L"Times-Italic") - wsFontName = L"Times New Roman"; int nStyle = pPr->GetFontStyle(); double dFontSize = pPr->GetFontSizeAP(); - put_FontName(wsFontName); - put_FontStyle(nStyle); - put_FontSize(dFontSize); PdfWriter::CFontTrueType* pFontTT = NULL; - if (nWidgetType != 28 && nWidgetType != 29) + if (nWidgetType == 27) { + put_FontName(wsFontName); + put_FontStyle(nStyle); + put_FontSize(dFontSize); + if (m_bNeedUpdateTextFont) UpdateFont(); if (m_pFont) @@ -2401,14 +2400,10 @@ HRESULT CPdfWriter::AddAnnotField(NSFonts::IApplicationFonts* pAppFonts, CAnnotF pTextWidget->SetMaxLen(pPr->GetMaxLen()); if (nWidgetFlag & (1 << 25)) pTextWidget->SetRV(pPr->GetRV()); - bool bAPValue = false; if (nFlags & (1 << 12)) { - bAPValue = true; pTextWidget->SetAPV(); - PdfWriter::CFontCidTrueType* pWasFont = m_pFont; - LONG nLen = 0; BYTE* pRender = pPr->GetRender(nLen); DrawWidgetAP(pAnnot, pRender, nLen); @@ -2416,16 +2411,16 @@ HRESULT CPdfWriter::AddAnnotField(NSFonts::IApplicationFonts* pAppFonts, CAnnotF PdfWriter::CFontDict* pFont = NULL; if (m_pFont14) pFont = m_pFont14; - else if (m_pFont && m_pFont != pWasFont) + else if (m_pFont) pFont = m_pDocument->CreateTrueTypeFont(m_pFont); if (pFont) pWidgetAnnot->SetDA(pFont, oInfo.GetWidgetAnnotPr()->GetFontSize(), dFontSize, oInfo.GetWidgetAnnotPr()->GetTC()); } - - // ВНЕШНИЙ ВИД - pTextWidget->SetFont(m_pFont, dFontSize, isBold, isItalic); - if (!bAPValue && bValue && pTextWidget->Get("T")) + else if (bValue && pTextWidget->Get("T")) + { + pTextWidget->SetFont(m_pFont, dFontSize, isBold, isItalic); DrawTextWidget(pAppFonts, pTextWidget, wsValue); + } } else if (oInfo.IsChoiceWidget()) { @@ -3662,10 +3657,11 @@ void CPdfWriter::DrawWidgetAP(PdfWriter::CAnnotation* pA, BYTE* pRender, LONG nL NSOnlineOfficeBinToPdf::ConvertBufferToRenderer(pRender, nLenRender, pCorrector); RELEASEOBJECT(pCorrector); + pFakePage->SetStrokeColor(0, 0, 0); + pFakePage->SetFillColor(0, 0, 0); m_oCommandManager.Flush(); - - pAP->StartText(NULL, 10); - pAnnot->EndAP(); + pAP->EndDraw(); + pFakePage->EndMarkedContent(); pAnnot->APFromFakePage(pFakePage); diff --git a/PdfFile/SrcWriter/Font14.cpp b/PdfFile/SrcWriter/Font14.cpp index da847794fb..3ae4b8cb09 100644 --- a/PdfFile/SrcWriter/Font14.cpp +++ b/PdfFile/SrcWriter/Font14.cpp @@ -44,7 +44,7 @@ namespace PdfWriter "Courier-Bold", "Courier-Oblique", "Courier-BoldOblique", - "Times", + "Times-Roman", "Times-Bold", "Times-Oblique", "Times-BoldOblique",