[LPK] Small fix and a related comment. (#890)
authorBaruch Rutman <peterooch@gmail.com>
Fri, 28 Sep 2018 15:10:10 +0000 (18:10 +0300)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Mon, 8 Oct 2018 14:17:42 +0000 (16:17 +0200)
[LPK][USER32] Fix reading layout checks.

- Both functions don't care about DT_RTLREADING flag.
- Added a different method to check reading order.

[USER32] Remove gcc-build breaker semicolon.

dll/win32/lpk/lpk.c
win32ss/user/user32/windows/font.c

index b99e8a3..2bbb744 100644 (file)
@@ -65,6 +65,7 @@ static void PSM_PrepareToDraw(LPCWSTR str, INT count, LPWSTR new_str, LPINT new_
 static void LPK_DrawUnderscore(HDC hdc, int x, int y, LPCWSTR str, int count, int offset)
 {
     SCRIPT_STRING_ANALYSIS ssa;
+    DWORD dwSSAFlags = SSA_GLYPHS;
     int prefix_x;
     int prefix_end;
     int pos;
@@ -78,8 +79,11 @@ static void LPK_DrawUnderscore(HDC hdc, int x, int y, LPCWSTR str, int count, in
 
     if (ScriptIsComplex(str, count, SIC_COMPLEX) == S_OK)
     {
+        if (GetLayout(hdc) & LAYOUT_RTL || GetTextAlign(hdc) & TA_RTLREADING)
+            dwSSAFlags |= SSA_RTL;
+        
         hr = ScriptStringAnalyse(hdc, str, count, (3 * count / 2 + 16),
-                                -1, SSA_GLYPHS, -1, NULL, NULL, NULL, NULL, NULL, &ssa);
+                                 -1, dwSSAFlags, -1, NULL, NULL, NULL, NULL, NULL, &ssa);
     }
 
     if (hr == S_OK)
@@ -328,6 +332,8 @@ LpkGetCharacterPlacement(
  * without any of these flags the behavior is the string being drawn without the amperstands and
  * with the underscore.
  * user32 has an equivalent function - UserLpkPSMTextOut
+ * 
+ * Note: lpString does not need to be null terminated
  */
 INT WINAPI LpkPSMTextOut(HDC hdc, int x, int y, LPCWSTR lpString, int cString, DWORD dwFlags)
 {
@@ -341,7 +347,7 @@ INT WINAPI LpkPSMTextOut(HDC hdc, int x, int y, LPCWSTR lpString, int cString, D
 
     if (dwFlags & DT_NOPREFIX)
     {
-        LpkExtTextOut(hdc, x, y, (dwFlags & DT_RTLREADING) ? ETO_RTLREADING : 0, NULL, lpString, cString - 1, NULL, 0);
+        LpkExtTextOut(hdc, x, y, 0, NULL, lpString, cString, NULL, 0);
         GetTextExtentPointW(hdc, lpString, cString, &size);
         return size.cx;
     }
@@ -354,7 +360,7 @@ INT WINAPI LpkPSMTextOut(HDC hdc, int x, int y, LPCWSTR lpString, int cString, D
     PSM_PrepareToDraw(lpString, cString, display_str, &len);
 
     if (!(dwFlags & DT_PREFIXONLY))
-        LpkExtTextOut(hdc, x, y, (dwFlags & DT_RTLREADING) ? ETO_RTLREADING : 0, NULL, display_str, len, NULL, 0);
+        LpkExtTextOut(hdc, x, y, 0, NULL, display_str, len, NULL, 0);
 
     if (!(dwFlags & DT_HIDEPREFIX))
     {
index 3d16edd..01b234d 100644 (file)
@@ -414,7 +414,7 @@ INT WINAPI UserLpkPSMTextOut(HDC hdc, int x, int y, LPCWSTR lpString, int cStrin
 {
     SIZE size;
     TEXTMETRICW tm;
-    int len, i = 0, j = 0;;
+    int len, i = 0, j = 0;
     int prefix_count = 0, prefix_offset = -1;
     LPWSTR display_str = NULL;
     int prefix_x, prefix_end;
@@ -426,7 +426,7 @@ INT WINAPI UserLpkPSMTextOut(HDC hdc, int x, int y, LPCWSTR lpString, int cStrin
 
     if (dwFlags & DT_NOPREFIX) /* Windows ignores this */
     {
-        ExtTextOutW(hdc, x, y, (dwFlags & DT_RTLREADING) ? ETO_RTLREADING : 0, NULL, lpString, cString, NULL);
+        TextOutW(hdc, x, y, lpString, cString);
         GetTextExtentPointW(hdc, lpString, cString, &size);
         return size.cx;
     }
@@ -455,7 +455,7 @@ INT WINAPI UserLpkPSMTextOut(HDC hdc, int x, int y, LPCWSTR lpString, int cStrin
     len = wcslen(display_str);
 
     if (!(dwFlags & DT_PREFIXONLY))
-        ExtTextOutW(hdc, x, y, (dwFlags & DT_RTLREADING) ? ETO_RTLREADING : 0, NULL, display_str, len, NULL);
+        TextOutW(hdc, x, y, display_str, len);
 
     if (!(dwFlags & DT_HIDEPREFIX))
     {