Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: GetAvailableLanguages now returns the correct list of languages when additional OCR languages have been installed directly, without adding a system language. #2

Merged
merged 1 commit into from Dec 5, 2023

Conversation

hotdogee
Copy link
Contributor

@hotdogee hotdogee commented Dec 4, 2023

The original implementation gets the list of Languages from the Windows.System.UserProfile.GlobalizationPreferences class, then checks if each language has OCR support, by calling IsLanguageSupported from the Windows.Media.Ocr.OcrEngine class. This returns an incomplete list of supported OCR languages since the user may directly install additional OCR languages without adding a system language. The new implementation fetches the list of AvailableRecognizerLanguages directly from the Windows.Media.Ocr.OcrEngine class, instead of fetching the list of languages from the Windows.System.UserProfile.GlobalizationPreferences class and then checking for OCR support.

How to install an OCR language pack

The following commands install the OCR pack for "ja-JP":

$Capability = Get-WindowsCapability -Online | Where-Object { $_.Name -Like 'Language.OCR~~~ja-JP~0.0.1.0' }
$Capability | Add-WindowsCapability -Online

…when additional OCR languages have been installed directly, without adding a system language.

The original implementation gets the list of `Languages` from the `Windows.System.UserProfile.GlobalizationPreferences` class, then checks if each language has OCR support, by calling `IsLanguageSupported` from the `Windows.Media.Ocr.OcrEngine` class. This returns an incomplete list of supported OCR languages since the user may directly install additional OCR languages without adding a system language.
The new implementation fetches the list of `AvailableRecognizerLanguages` directly from the `Windows.Media.Ocr.OcrEngine` class, instead of fetching the list of languages from the `Windows.System.UserProfile.GlobalizationPreferences` class and then checking for OCR support.
@Descolada Descolada merged commit 5634f09 into Descolada:main Dec 5, 2023
@Descolada
Copy link
Owner

Thanks for the contribution! The fix has been implemented, and also led me to discover a memory leak in both the old version and the new, where the HString was not being properly released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants