Skip to content

Commit

Permalink
Adobe Reader: support alternative text on formulas in PDFs (#16067)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
michaelDCurran authored Jan 22, 2024
1 parent 738ead5 commit fbfcd14
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
17 changes: 15 additions & 2 deletions nvdaHelper/vbufBackends/adobeAcrobat/adobeAcrobat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions user_docs/en/changes.t2t
Original file line number Diff line number Diff line change
Expand Up @@ -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)
-


Expand Down

0 comments on commit fbfcd14

Please sign in to comment.