3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4 * PURPOSE: Language Pack DLL.
5 * PROGRAMMERS: Magnus Olsen (greatlrd)
6 * Baruch Rutman (peterooch at gmail dot com)
11 LPK_LPEDITCONTROL_LIST LpkEditControl
= {EditCreate
, EditIchToXY
, EditMouseToIch
, EditCchInWidth
,
12 EditGetLineWidth
, EditDrawText
, EditHScroll
, EditMoveSelection
,
13 EditVerifyText
, EditNextWord
, EditSetMenu
, EditProcessMenu
,
14 EditCreateCaret
, EditAdjustCaret
};
24 return LpkDllInitialize(hDll
,dwReason
,lpReserved
);
36 case DLL_PROCESS_ATTACH
:
37 DisableThreadLibraryCalls(hDll
);
38 /* Tell usp10 it is activated usp10 */
67 LPWSTR reordered_str
= NULL
;
71 UNREFERENCED_PARAMETER(unknown
);
73 if (!(fuOptions
& ETO_IGNORELANGUAGE
))
74 fuOptions
|= ETO_IGNORELANGUAGE
;
76 /* Check text direction */
77 if ((GetLayout(hdc
) & LAYOUT_RTL
) || (GetTextAlign(hdc
) & TA_RTLREADING
))
79 if (!(fuOptions
& ETO_RTLREADING
))
80 fuOptions
|= ETO_RTLREADING
;
83 /* Check if the string requires complex script processing and not a "glyph indices" array */
84 if (ScriptIsComplex(lpString
, uCount
, SIC_COMPLEX
) == S_OK
&& !(fuOptions
& ETO_GLYPH_INDEX
))
86 reordered_str
= HeapAlloc(GetProcessHeap(), 0, uCount
* sizeof(WCHAR
));
88 BIDI_Reorder(hdc
, lpString
, uCount
, GCP_REORDER
,
89 (fuOptions
& ETO_RTLREADING
) ? WINE_GCPW_FORCE_RTL
: WINE_GCPW_FORCE_LTR
,
90 reordered_str
, uCount
, NULL
, &glyphs
, &cGlyphs
);
94 fuOptions
|= ETO_GLYPH_INDEX
;
98 if (glyphs
|| reordered_str
)
100 bResult
= ExtTextOutW(hdc
, x
, y
, fuOptions
, lprc
,
101 glyphs
? (LPWSTR
)glyphs
: reordered_str
, uCount
, lpDx
);
105 bResult
= ExtTextOutW(hdc
, x
, y
, fuOptions
, lprc
, lpString
, uCount
, lpDx
);
107 HeapFree(GetProcessHeap(), 0, glyphs
);
108 HeapFree(GetProcessHeap(), 0, reordered_str
);
113 return ExtTextOutW(hdc
, x
, y
, fuOptions
, lprc
, lpString
, uCount
, lpDx
);
121 LpkGetCharacterPlacement(
126 LPGCP_RESULTSW lpResults
,
130 LPWORD lpGlyphs
= NULL
;
136 UNREFERENCED_PARAMETER(dwUnused
);
138 /* Sanity check (most likely a direct call) */
139 if (!(dwFlags
& GCP_REORDER
))
140 return GetCharacterPlacementW(hdc
, lpString
, uCount
, nMaxExtent
, lpResults
, dwFlags
);
143 if (nSet
> lpResults
->nGlyphs
)
144 nSet
= lpResults
->nGlyphs
;
146 BIDI_Reorder(hdc
, lpString
, uCount
, dwFlags
, WINE_GCPW_FORCE_LTR
, lpResults
->lpOutString
,
147 nSet
, lpResults
->lpOrder
, &lpGlyphs
, &cGlyphs
);
149 lpResults
->nGlyphs
= (UINT
)cGlyphs
;
151 if (lpResults
->lpGlyphs
)
154 StringCchCopyW(lpResults
->lpGlyphs
, cGlyphs
, lpGlyphs
);
156 else if (lpResults
->lpOutString
)
157 GetGlyphIndicesW(hdc
, lpResults
->lpOutString
, nSet
, lpResults
->lpGlyphs
, 0);
162 /* If glyph shaping was requested */
163 if (dwFlags
& GCP_GLYPHSHAPE
)
167 if (lpResults
->lpGlyphs
)
169 for (i
= 0; i
< lpResults
->nGlyphs
; i
++)
171 if (GetCharWidthI(hdc
, 0, 1, (WORD
*)&lpResults
->lpGlyphs
[i
], &c
))
172 lpResults
->lpDx
[i
] = c
;
181 for (i
= 0; i
< nSet
; i
++)
183 if (GetCharWidth32W(hdc
, lpResults
->lpOutString
[i
], lpResults
->lpOutString
[i
], &c
))
184 lpResults
->lpDx
[i
] = c
;
189 /* FIXME: Currently not bidi compliant! */
190 if (lpResults
->lpCaretPos
)
194 lpResults
->lpCaretPos
[0] = 0;
195 for (i
= 1; i
< nSet
; i
++)
197 if (GetTextExtentPoint32W(hdc
, &(lpString
[i
- 1]), 1, &size
))
198 lpResults
->lpCaretPos
[i
] = (pos
+= size
.cx
);
202 if (GetTextExtentPoint32W(hdc
, lpString
, uCount
, &size
))
203 ret
= MAKELONG(size
.cx
, size
.cy
);
205 HeapFree(GetProcessHeap(), 0, lpGlyphs
);