Skip to content

Apply MathCAT settings with libmathcat.SetPreference when changed#19613

Merged
seanbudd merged 6 commits intonvaccess:betafrom
codeofdusk:t19597
Feb 17, 2026
Merged

Apply MathCAT settings with libmathcat.SetPreference when changed#19613
seanbudd merged 6 commits intonvaccess:betafrom
codeofdusk:t19597

Conversation

@codeofdusk
Copy link
Contributor

@codeofdusk codeofdusk commented Feb 13, 2026

Link to issue number:

Closes #19597.

Summary of the issue:

After #19373, NVDA math preferences were not honoured by MathCAT.

Description of how this pull request fixes the issue:

Per #19373 (comment), use libmathcat.SetPreference to apply settings changes when they are saved to the NVDA configuration.

Testing strategy:

Confirmed that I could reproduce #19597 before this PR and not after. Verified that preferences persist across NVDA restarts.

Known issues with pull request:

None known

Code Review Checklist:

  • Documentation:
    • Change log entry
    • User Documentation
    • Developer / Technical Documentation
    • Context sensitive help for GUI changes
  • Testing:
    • Unit tests
    • System (end to end) tests
    • Manual testing
  • UX of all users considered:
    • Speech
    • Braille
    • Low Vision
    • Different web browsers
    • Localization in other languages / culture than English
  • API is compatible with existing add-ons.
  • Security precautions taken.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes NVDA MathCAT settings not being honored at runtime by applying NVDA’s stored MathCAT preferences through libmathcat.SetPreference when MathCAT initializes and when preferences are saved.

Changes:

  • Added applyUserPreferences to push stored MathCAT preferences into the MathCAT runtime via libmathcat.SetPreference.
  • Updated MathCATUserPreferences.save() to apply runtime preferences before writing mathcat.yaml.
  • Updated MathCAT initialization to apply all user preferences (not just braille code) after setting the rules dir / TTS mode.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
source/mathPres/MathCAT/preferences.py Introduces applyUserPreferences and uses it from MathCATUserPreferences.save() to update MathCAT runtime preferences.
source/mathPres/MathCAT/MathCAT.py Applies stored MathCAT preferences during MathCAT startup via applyUserPreferences().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

@seanbudd seanbudd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @codeofdusk

@seanbudd seanbudd added this to the 2026.1 milestone Feb 13, 2026
@seanbudd
Copy link
Member

@GeorgeKerscher - can you confirm testing of this build when it completes? You should be able to find it under an "artifacts" menu under the checks tab for the pull request

@GeorgeKerscher
Copy link

I could not find a link to an alpha to test. Can you provide a direct link and I will test.

@codeofdusk
Copy link
Contributor Author

@GeorgeKerscher honestly it's a little hard to find if you aren't familiar with the UI, but here's a test build. It's unsigned, so you won't be able to use it on secure screens and it'll show a warning when you run it. In the installer, just click "continue running" or create (and run) a portable copy.

@GeorgeKerscher
Copy link

I installed pr19613-4581,c4437fbd (2026.1.0.4581)

I installed as a portable copy. I found that there are still issues:

  • Beps are now being spoken, so that is fixed.
  • The pause factor is not being saved or applied. Even if I manually save settings, the next time I launch, the pause factor returns to 100.
  • The relative speech rate is being saved, but not applied. The speech rate does not change from the Math reading default.
  • The pause factor is also not being applied.

@codeofdusk
Copy link
Contributor Author

codeofdusk commented Feb 13, 2026

@GeorgeKerscher turns out that I can also reproduce the pause factor bug under 890d2d6, and it's unrelated (the factor wasn't being scaled properly when saved to config).

As for relative speech rate, which synthesizer are you using? If you aren't using espeak-ng, can you test under that synth?

@GeorgeKerscher
Copy link

I was using Windows Core voices. When I switched to E-Speak, NVDA did change the voice speed. However, when I went outside the MathML, it did not return to the original speed setting; it stayed at the speech rate set in the MathCAT settings.

@codeofdusk
Copy link
Contributor Author

However, when I went outside the MathML, it did not return to the original speed setting; it stayed at the speech rate set in the MathCAT settings.

Yes, that's been the case with all versions of MathCAT (including the add-on).

@GeorgeKerscher
Copy link

I think that is incorrect. Once outside the MathML expression, the speed returns to the setting in NVDA. I just tested with:
(NVDA) Version: 2025.3.2 (2025.3.2.53588)
and
MathCAT: speech and braille from MathML; Status: Enabled; Installed version: 0.7.5; Channel: Stable; Author: Neil Soiffer soiffer@alum.mit.edu; Publication date: 11/17/2025; Install date: 12/3/2025; Minimum NVDA version: 2025.1; Last tested NVDA version: 2025.3 10 of 18

I am using one core voices, David. Perhaps that is a behavior with E-Speak?

@seanbudd seanbudd marked this pull request as draft February 16, 2026 03:11
Copy link
Member

@seanbudd seanbudd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved pending testing confirmation with George

@seanbudd seanbudd added the conceptApproved Similar 'triaged' for issues, PR accepted in theory, implementation needs review. label Feb 16, 2026
@codeofdusk codeofdusk marked this pull request as ready for review February 16, 2026 05:23
@GeorgeKerscher
Copy link

Please provide a link to an alpha you want me to test. Probably after the merge.

@seanbudd
Copy link
Member

@GeorgeKerscher - weren't you still having issues with speech speed with the current PR build?

@codeofdusk
Copy link
Contributor Author

@seanbudd I can reproduce that issue as of #18323 itself. It's unrelated to my changes.

@seanbudd
Copy link
Member

Thanks for confirming - @GeorgeKerscher can you open a separate issue for the speech problems?

@seanbudd seanbudd merged commit 81c7e50 into nvaccess:beta Feb 17, 2026
34 of 39 checks passed
@GeorgeKerscher
Copy link

I just installed NVDA 2026.1 Beta 3 and my preliminary testing resolves the speed, pause, and bep problems initially reported. Two thumbs up!

@seanbudd
Copy link
Member

Hi @GeorgeKerscher - this PR is not in beta3, can you test alphas or beta4 and confirm?

@GeorgeKerscher
Copy link

A few things:

I am no using NVDA 2026.1 beta 3 as installed. I find four bugs in beta 3:
Zoomed out all the way is not spoken
MathML cannot be copied into Word.
Relative speech rate not honored
Pause factor is not honored or saved

If you give me a link to another alpha to test, I will be happy to test. Also, Should I create a new issue with these items on beta 3?

@seanbudd
Copy link
Member

As mentioned in my previous comment, beta3 doesn't contain any of the fixes from this PR. Please test with alpha or beta4 and open a new issue with anything remaining

@SaschaCowley
Copy link
Member

@GeorgeKerscher to clarify, beta4 will not be out until next week, but these changes are in NVDA alpha 54640,2f8b7d4b

@GeorgeKerscher
Copy link

I am using alpha-54640,2f8b7d4b (2026.2.0.54640)

I am finding:
MathML copied from a web page cannot be copied into Word.
Relative speech rate not honored
Pause factor is not honored

I will submit a new issue. It may be a day or so.

SaschaCowley added a commit that referenced this pull request Feb 18, 2026
Follow-up to #18323, #19373 and #19613

### Summary of the issue:

Since the introduction of MathCAT into NVDA in #18323, NVDA has
persisted MathCAT settings to a YAML file . This is at odds with current
project configuration standards, which use either configobj ini files,
or JSON. This also duplicates settings, as they're also saved to
`nvda.ini`.
Originally, these were stored in `%AppData%\MathCAT\prefs.yaml`, but as
of #19373, they are saved to `mathcat.yaml` in NVDA's config directory.
In neither case was `shouldWriteToDisk` checked before saving the
preferences. Additionaly, [NV Access's Corporate & Government
page](https://www.nvaccess.org/corporate-government/) states "To prevent
NVDA users from modifying their configuration or add-ons directly, user
write access to [`%APPDATA%\nvda`] must also be restricted". If
implemented, this would have stopped users from changing their MathCAT
settings in memory, as they had to be saved to YAML to be loaded by
MathCAT.
In #19613, the logic was changed to programmatically apply these
settings with `libmathcat.SetPreference`, which should solve the problem
of users without write access to their NVDA config directory being able
to change their MathCAT preferences. However, the code that wrote the
settings to the YAML file was not removed, nor did it contain any error
handling.

### Description of user facing changes:

None, but may avoid some errors in the logs.

### Description of developer facing changes:

Pyyaml is no-longer a dependency.
`mathPres.MathCAT.preferences.MathCATUserPreferences.save` has been
renamed to `apply`, and no longer saves the settings to YAML. Settings
persistance is handled by NVDA's configuration system.

### Description of development approach:

Removed the code that wrote MathCAT preferences to YAML, and any code
that only it depended on. Renamed `save` to `apply` using VS Code's
refactoring tool. Searched the repo for `yaml` and after confirming that
we don't rely on `pyyaml` anywhere else, ran `uv remove pyyaml`.

### Testing strategy:

Tested by loading the [Wikipedia page on the quadratic
formula](https://en.wikipedia.org/wiki/Quadratic_formula) in firefox.
Located some math and read it. Changed settings one at a time and tested
that they were applied correctly. Restarted NVDA and ensured that the
new settings were still present.

### Known issues with pull request:

None known
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conceptApproved Similar 'triaged' for issues, PR accepted in theory, implementation needs review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants