From fbfcd14b5f14609fba7a919c67431a1912b0da51 Mon Sep 17 00:00:00 2001 From: Michael Curran Date: Mon, 22 Jan 2024 10:57:53 +1000 Subject: [PATCH] Adobe Reader: support alternative text on formulas in PDFs (#16067) Fixes #12715 Summary of the issue: Authors of PDFs can provide alternative text on formular nodes via the 'alt' attribute. However, NvDA ignores this and replaces it with a single space, with the assumption that the formula will contain an inner mathml tree structure. The idea of embedding a full mathml tree structure with in formula nodes was never standardized, and only a few experimental PDFs actually exist. However, it is becoming common for authors to place alt text (perhaps a simple english representation of math) on formula nodes. Description of user facing changes In Adobe Reader, alternative text for formulas will be reported if provided by the author. Description of development approach Adobe Acrobat vbuf backend: Don't replace content in formula tags with a space, rather only do this for math nodes. this ensures NvDA still exposes alt text on formulas. this approach still allows for supporting embedded mathml trees if they exist as a direct child of the formula. --- .../vbufBackends/adobeAcrobat/adobeAcrobat.cpp | 17 +++++++++++++++-- user_docs/en/changes.t2t | 1 + 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/nvdaHelper/vbufBackends/adobeAcrobat/adobeAcrobat.cpp b/nvdaHelper/vbufBackends/adobeAcrobat/adobeAcrobat.cpp index 636f4ab4c20..f95de352c8d 100644 --- a/nvdaHelper/vbufBackends/adobeAcrobat/adobeAcrobat.cpp +++ b/nvdaHelper/vbufBackends/adobeAcrobat/adobeAcrobat.cpp @@ -437,6 +437,7 @@ AdobeAcrobatVBufStorage_controlFieldNode_t* AdobeAcrobatVBufBackend_t::fillVBuf( } BSTR stdName = NULL; + BSTR tagName = NULL; int textFlags = 0; // Whether to render just a space in place of the content. bool renderSpace = false; @@ -453,8 +454,18 @@ AdobeAcrobatVBufStorage_controlFieldNode_t* AdobeAcrobatVBufBackend_t::fillVBuf( // This is an inline element. parentNode->isBlock=false; } - if (wcscmp(stdName, L"Formula") == 0) { - // We don't want the content of formulas, + } + + // Get tagName. + if ((res = domElement->GetTagName(&tagName)) != S_OK) { + LOG_DEBUG(L"IPDDomElement::GetTagName returned " << res); + tagName = NULL; + } + if (tagName) { + parentNode->addAttribute(L"acrobat::tagname", tagName); + if (wcscmp(tagName, L"math") == 0) { + // We don't want the content of math nodes here, + // As it will be fetched by NVDAObjects outside of the virtualBuffer. // but we still want a space so the user can get at them. renderSpace = true; } @@ -736,6 +747,8 @@ AdobeAcrobatVBufStorage_controlFieldNode_t* AdobeAcrobatVBufBackend_t::fillVBuf( delete pageNum; if (stdName) SysFreeString(stdName); + if (tagName) + SysFreeString(tagName); if (domElement) { LOG_DEBUG(L"Releasing IPDDomElement"); domElement->Release(); diff --git a/user_docs/en/changes.t2t b/user_docs/en/changes.t2t index 63feb6b08df..517722e8d1b 100644 --- a/user_docs/en/changes.t2t +++ b/user_docs/en/changes.t2t @@ -19,6 +19,7 @@ What's New in NVDA - Add-on Store: - When pressing ``ctrl+tab``, focus properly moves to the new current tab title. (#14986, @ABuffEr) - +- In Adobe Reader, NVDA no longer ignores alternative text set on formulas in PDFs. (#12715) -