forked from electronicarts/CnC_Generals_Zero_Hour
-
Notifications
You must be signed in to change notification settings - Fork 178
Fix Arabic / complex-script text input (wide WNDCLASS + BMP-aware filters) #2574
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
Open
wahidkurdo
wants to merge
3
commits into
TheSuperHackers:main
Choose a base branch
from
wahidkurdo:fix/arabic-text-input
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+462
−371
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -657,7 +657,12 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT message, | |
| } | ||
| return 0;*/ | ||
|
|
||
| return DefWindowProc( hWnd, message, wParam, lParam ); | ||
| // Complex-text patch: use DefWindowProcW so WM_CHAR messages are | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe it's better to reduce the volume of the comment, and use the following format |
||
| // delivered as UTF-16 code units instead of being transcoded through | ||
| // the process ANSI codepage. Without this, Arabic/Hebrew/CJK input | ||
| // arrives as Latin-1 gibberish when the system ANSI codepage is not | ||
| // Windows-1256 / 1255 / 932 etc. | ||
| return DefWindowProcW( hWnd, message, wParam, lParam ); | ||
|
|
||
| } | ||
|
|
||
|
|
@@ -672,12 +677,16 @@ static Bool initializeAppWindows( HINSTANCE hInstance, Int nCmdShow, Bool runWin | |
|
|
||
| // register the window class | ||
|
|
||
| WNDCLASS wndClass = { CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS, WndProc, 0, 0, hInstance, | ||
| // Complex-text patch: register a wide (Unicode) window class so the | ||
| // window receives WM_CHAR as UTF-16. The ANSI class would otherwise | ||
| // convert characters through the current system ANSI codepage, | ||
| // corrupting Arabic/Hebrew/CJK input. | ||
| WNDCLASSW wndClass = { CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS, WndProc, 0, 0, hInstance, | ||
| LoadIcon (hInstance, MAKEINTRESOURCE(IDI_ApplicationIcon)), | ||
| nullptr/*LoadCursor(nullptr, IDC_ARROW)*/, | ||
| (HBRUSH)GetStockObject(BLACK_BRUSH), nullptr, | ||
| TEXT("Game Window") }; | ||
| RegisterClass( &wndClass ); | ||
| L"Game Window" }; | ||
| RegisterClassW( &wndClass ); | ||
|
|
||
| // Create our main window | ||
| windowStyle = WS_POPUP|WS_VISIBLE; | ||
|
|
@@ -700,8 +709,11 @@ static Bool initializeAppWindows( HINSTANCE hInstance, Int nCmdShow, Bool runWin | |
|
|
||
| gInitializing = true; | ||
|
|
||
| HWND hWnd = CreateWindow( TEXT("Game Window"), | ||
| TEXT("Command and Conquer Generals"), | ||
| // Complex-text patch: use CreateWindowW with wide string literals so | ||
| // the window title and class are registered as UTF-16, matching the | ||
| // WNDCLASSW registration above. | ||
| HWND hWnd = CreateWindowW( L"Game Window", | ||
| L"Command and Conquer Generals", | ||
| windowStyle, | ||
| (GetSystemMetrics( SM_CXSCREEN ) / 2) - (startWidth / 2), // original position X | ||
| (GetSystemMetrics( SM_CYSCREEN ) / 2) - (startHeight / 2),// original position Y | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.