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 */
66 UNREFERENCED_PARAMETER(unknown
);
68 if (!(fuOptions
& ETO_IGNORELANGUAGE
))
69 fuOptions
|= ETO_IGNORELANGUAGE
;
71 /* Check text direction */
72 if ((GetLayout(hdc
) & LAYOUT_RTL
) || (GetTextAlign(hdc
) & TA_RTLREADING
))
74 if (!(fuOptions
& ETO_RTLREADING
))
75 fuOptions
|= ETO_RTLREADING
;
78 /* Check if the string requires complex script processing and not a "glyph indices" array */
79 if (ScriptIsComplex(lpString
, uCount
, SIC_COMPLEX
) == S_OK
&& !(fuOptions
& ETO_GLYPH_INDEX
))
82 LPWSTR reordered_str
= HeapAlloc(GetProcessHeap(), 0, uCount
* sizeof(WCHAR
));
86 BIDI_Reorder(hdc
, lpString
, uCount
, GCP_REORDER
,
87 (fuOptions
& ETO_RTLREADING
) ? WINE_GCPW_FORCE_RTL
: WINE_GCPW_FORCE_LTR
,
88 reordered_str
, uCount
, NULL
, &glyphs
, &cGlyphs
);
92 fuOptions
|= ETO_GLYPH_INDEX
;
94 if (uCount
!= cGlyphs
)
98 bResult
= ExtTextOutW(hdc
, x
, y
, fuOptions
, lprc
,
99 glyphs
? (LPWSTR
)glyphs
: reordered_str
, uCount
, lpDx
);
101 HeapFree(GetProcessHeap(), 0, glyphs
);
102 HeapFree(GetProcessHeap(), 0, reordered_str
);
107 return ExtTextOutW(hdc
, x
, y
, fuOptions
, lprc
, lpString
, uCount
, lpDx
);
115 LpkGetCharacterPlacement(
120 LPGCP_RESULTSW lpResults
,
124 LPWORD lpGlyphs
= NULL
;
130 UNREFERENCED_PARAMETER(dwUnused
);
132 /* Sanity check (most likely a direct call) */
133 if (!(dwFlags
& GCP_REORDER
))
134 return GetCharacterPlacementW(hdc
, lpString
, uCount
, nMaxExtent
, lpResults
, dwFlags
);
137 if (nSet
> lpResults
->nGlyphs
)
138 nSet
= lpResults
->nGlyphs
;
140 BIDI_Reorder(hdc
, lpString
, uCount
, dwFlags
, WINE_GCPW_FORCE_LTR
, lpResults
->lpOutString
,
141 nSet
, lpResults
->lpOrder
, &lpGlyphs
, &cGlyphs
);
143 lpResults
->nGlyphs
= (UINT
)cGlyphs
;
145 if (lpResults
->lpGlyphs
)
148 StringCchCopyW(lpResults
->lpGlyphs
, cGlyphs
, lpGlyphs
);
150 else if (lpResults
->lpOutString
)
151 GetGlyphIndicesW(hdc
, lpResults
->lpOutString
, nSet
, lpResults
->lpGlyphs
, 0);
156 /* If glyph shaping was requested */
157 if (dwFlags
& GCP_GLYPHSHAPE
)
161 if (lpResults
->lpGlyphs
)
163 for (i
= 0; i
< lpResults
->nGlyphs
; i
++)
165 if (GetCharWidthI(hdc
, 0, 1, (WORD
*)&lpResults
->lpGlyphs
[i
], &c
))
166 lpResults
->lpDx
[i
] = c
;
175 for (i
= 0; i
< nSet
; i
++)
177 if (GetCharWidth32W(hdc
, lpResults
->lpOutString
[i
], lpResults
->lpOutString
[i
], &c
))
178 lpResults
->lpDx
[i
] = c
;
183 /* FIXME: Currently not bidi compliant! */
184 if (lpResults
->lpCaretPos
)
188 lpResults
->lpCaretPos
[0] = 0;
189 for (i
= 1; i
< nSet
; i
++)
191 if (GetTextExtentPoint32W(hdc
, &(lpString
[i
- 1]), 1, &size
))
192 lpResults
->lpCaretPos
[i
] = (pos
+= size
.cx
);
196 if (GetTextExtentPoint32W(hdc
, lpString
, uCount
, &size
))
197 ret
= MAKELONG(size
.cx
, size
.cy
);
199 HeapFree(GetProcessHeap(), 0, lpGlyphs
);