2005-07-27 13:02:52 +02:00
|
|
|
/*
|
|
|
|
* Implementation of Uniscribe Script Processor (usp10.dll)
|
|
|
|
*
|
|
|
|
* Copyright 2005 Steven Edwards for CodeWeavers
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2005-07-27 13:02:52 +02:00
|
|
|
*
|
|
|
|
* Notes:
|
|
|
|
* Uniscribe allows for processing of complex scripts such as joining
|
|
|
|
* and filtering characters and bi-directional text with custom line breaks.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
2005-08-10 11:51:40 +02:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
2005-11-28 11:52:55 +01:00
|
|
|
#include "wingdi.h"
|
2005-08-10 11:51:40 +02:00
|
|
|
#include "winuser.h"
|
|
|
|
#include "usp10.h"
|
2005-07-27 13:02:52 +02:00
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
2005-11-15 13:02:16 +01:00
|
|
|
/**
|
|
|
|
* some documentation here:
|
|
|
|
* http://www.microsoft.com/typography/developers/uniscribe/uniscribe.htm
|
|
|
|
*/
|
|
|
|
|
2005-07-27 13:02:52 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(uniscribe);
|
|
|
|
|
2006-02-16 12:06:18 +01:00
|
|
|
#define MAX_SCRIPTS 8
|
|
|
|
|
|
|
|
/* Set up a default for ScriptGetProperties */
|
|
|
|
static const SCRIPT_PROPERTIES Default_Script_0 = {0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0};
|
|
|
|
static const SCRIPT_PROPERTIES Default_Script_1 = {0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0};
|
|
|
|
static const SCRIPT_PROPERTIES Default_Script_2 = {0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0};
|
|
|
|
static const SCRIPT_PROPERTIES Default_Script_3 = {9, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0};
|
|
|
|
static const SCRIPT_PROPERTIES Default_Script_4 = {9, 1, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0};
|
|
|
|
static const SCRIPT_PROPERTIES Default_Script_5 = {9, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 1, 0, 0};
|
|
|
|
static const SCRIPT_PROPERTIES Default_Script_6 = {9, 1, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 1, 0, 0};
|
|
|
|
static const SCRIPT_PROPERTIES Default_Script_7 = {8, 0, 0, 0, 0, 161, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0};
|
|
|
|
static const SCRIPT_PROPERTIES *Global_Script[MAX_SCRIPTS] =
|
|
|
|
{&Default_Script_0,
|
|
|
|
&Default_Script_1,
|
|
|
|
&Default_Script_2,
|
|
|
|
&Default_Script_3,
|
|
|
|
&Default_Script_4,
|
|
|
|
&Default_Script_5,
|
|
|
|
&Default_Script_6,
|
|
|
|
&Default_Script_7};
|
|
|
|
|
2006-02-20 10:19:32 +01:00
|
|
|
typedef struct scriptcache {
|
|
|
|
HDC hdc;
|
|
|
|
} Scriptcache;
|
|
|
|
|
2006-05-12 00:34:55 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* DllMain
|
|
|
|
*
|
|
|
|
*/
|
2005-07-27 13:02:52 +02:00
|
|
|
BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
|
|
|
|
{
|
|
|
|
switch(fdwReason) {
|
|
|
|
case DLL_PROCESS_ATTACH:
|
|
|
|
DisableThreadLibraryCalls(hInstDLL);
|
|
|
|
break;
|
|
|
|
case DLL_PROCESS_DETACH:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2006-01-09 17:16:57 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* ScriptFreeCache (USP10.@)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI ScriptFreeCache(SCRIPT_CACHE *psc)
|
|
|
|
{
|
2006-02-20 10:19:32 +01:00
|
|
|
TRACE("%p\n", psc);
|
2006-01-09 17:16:57 +01:00
|
|
|
|
2006-02-20 10:19:32 +01:00
|
|
|
if (psc) {
|
|
|
|
HeapFree ( GetProcessHeap(), 0, *psc);
|
|
|
|
*psc = NULL;
|
|
|
|
}
|
2006-01-09 17:16:57 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-23 20:14:04 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* ScriptGetProperties (USP10.@)
|
|
|
|
*
|
|
|
|
*/
|
2005-07-27 13:02:52 +02:00
|
|
|
HRESULT WINAPI ScriptGetProperties(const SCRIPT_PROPERTIES ***ppSp, int *piNumScripts)
|
|
|
|
{
|
2006-05-16 21:12:16 +02:00
|
|
|
TRACE("%p,%p\n", ppSp, piNumScripts);
|
2006-01-09 17:16:57 +01:00
|
|
|
|
2006-05-16 21:12:16 +02:00
|
|
|
if (!ppSp && !piNumScripts) return E_INVALIDARG;
|
|
|
|
|
|
|
|
/* Set up a sensible default and intialise pointers */
|
|
|
|
if (piNumScripts) *piNumScripts = MAX_SCRIPTS;
|
|
|
|
if (ppSp) *ppSp = Global_Script;
|
|
|
|
TRACE("ppSp:%p, *ppSp:%p, **ppSp:%p, %d\n",
|
|
|
|
ppSp, ppSp ? *ppSp : NULL, (ppSp && *ppSp) ? **ppSp : NULL,
|
|
|
|
piNumScripts ? *piNumScripts : -1);
|
2006-01-09 17:16:57 +01:00
|
|
|
return 0;
|
2005-07-27 13:02:52 +02:00
|
|
|
}
|
|
|
|
|
2005-11-23 20:14:04 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* ScriptGetFontProperties (USP10.@)
|
|
|
|
*
|
|
|
|
*/
|
2005-08-01 11:18:53 +02:00
|
|
|
HRESULT WINAPI ScriptGetFontProperties(HDC hdc, SCRIPT_CACHE *psc, SCRIPT_FONTPROPERTIES *sfp)
|
|
|
|
{
|
2006-04-13 10:38:31 +02:00
|
|
|
HDC phdc;
|
|
|
|
Scriptcache *pScriptcache;
|
2006-04-20 13:57:06 +02:00
|
|
|
TEXTMETRICW ptm;
|
2006-04-13 10:38:31 +02:00
|
|
|
|
2006-04-20 13:50:44 +02:00
|
|
|
TRACE("%p,%p,%p\n", hdc, psc, sfp);
|
2006-04-21 08:00:14 +02:00
|
|
|
|
|
|
|
if (!psc || !sfp)
|
|
|
|
return E_INVALIDARG;
|
2006-04-13 10:38:31 +02:00
|
|
|
if (!hdc && !*psc) {
|
|
|
|
TRACE("No Script_Cache (psc) and no hdc. Ask for one. Hdc=%p, psc=%p\n", hdc, *psc);
|
|
|
|
return E_PENDING;
|
|
|
|
} else
|
|
|
|
if (hdc && !*psc) {
|
|
|
|
pScriptcache = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(Scriptcache) );
|
|
|
|
pScriptcache->hdc = (HDC) hdc;
|
|
|
|
phdc = hdc;
|
|
|
|
*psc = (Scriptcache *) pScriptcache;
|
2006-04-20 13:50:44 +02:00
|
|
|
} else
|
2006-04-13 10:38:31 +02:00
|
|
|
if (*psc) {
|
|
|
|
pScriptcache = (Scriptcache *) *psc;
|
|
|
|
phdc = pScriptcache->hdc;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sfp->cBytes != sizeof(SCRIPT_FONTPROPERTIES))
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2005-08-01 11:18:53 +02:00
|
|
|
/* return something sensible? */
|
2006-04-21 08:00:14 +02:00
|
|
|
sfp->wgBlank = 0;
|
|
|
|
if (GetTextMetricsW(phdc, &ptm))
|
|
|
|
sfp->wgDefault = ptm.tmDefaultChar;
|
|
|
|
else
|
|
|
|
sfp->wgDefault = 0;
|
|
|
|
sfp->wgInvalid = 0;
|
|
|
|
sfp->wgKashida = 0xffff;
|
|
|
|
sfp->iKashidaWidth = 0;
|
2005-08-01 11:18:53 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-23 20:14:04 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* ScriptRecordDigitSubstitution (USP10.@)
|
|
|
|
*
|
|
|
|
*/
|
2005-07-27 13:02:52 +02:00
|
|
|
HRESULT WINAPI ScriptRecordDigitSubstitution(LCID Locale,SCRIPT_DIGITSUBSTITUTE *psds)
|
|
|
|
{
|
|
|
|
FIXME("%ld,%p\n",Locale,psds);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2005-11-23 20:14:04 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* ScriptApplyDigitSubstitution (USP10.@)
|
|
|
|
*
|
|
|
|
*/
|
2005-07-27 13:02:52 +02:00
|
|
|
HRESULT WINAPI ScriptApplyDigitSubstitution(const SCRIPT_DIGITSUBSTITUTE* psds,
|
|
|
|
SCRIPT_CONTROL* psc, SCRIPT_STATE* pss)
|
|
|
|
{
|
|
|
|
FIXME("%p,%p,%p\n",psds,psc,pss);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2005-11-23 20:14:04 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* ScriptItemize (USP10.@)
|
|
|
|
*
|
|
|
|
*/
|
2005-07-27 13:02:52 +02:00
|
|
|
HRESULT WINAPI ScriptItemize(const WCHAR *pwcInChars, int cInChars, int cMaxItems,
|
|
|
|
const SCRIPT_CONTROL *psControl, const SCRIPT_STATE *psState,
|
|
|
|
SCRIPT_ITEM *pItems, int *pcItems)
|
|
|
|
{
|
2006-02-18 16:00:29 +01:00
|
|
|
/* This implementation currently treats the entire string represented in
|
|
|
|
* pwcInChars as a single entity. Hence pcItems will be set to 1. */
|
|
|
|
|
2006-04-02 12:41:02 +02:00
|
|
|
FIXME("%s,%d,%d,%p,%p,%p,%p: semi-stub\n", debugstr_wn(pwcInChars, cInChars), cInChars, cMaxItems,
|
2005-07-27 13:02:52 +02:00
|
|
|
psControl, psState, pItems, pcItems);
|
2006-01-09 17:16:57 +01:00
|
|
|
|
|
|
|
if (!pwcInChars || !cInChars || !pItems || cMaxItems < 2)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2006-02-18 16:00:29 +01:00
|
|
|
/* Set a sensible default */
|
|
|
|
/* Set SCRIPT_ITEM */
|
|
|
|
pItems[0].iCharPos = 0;
|
|
|
|
/* Set the SCRIPT_ANALYSIS */
|
|
|
|
pItems[0].a.eScript = SCRIPT_UNDEFINED;
|
|
|
|
pItems[0].a.fRTL = 0;
|
|
|
|
pItems[0].a.fLayoutRTL = 0;
|
|
|
|
pItems[0].a.fLinkBefore = 0;
|
|
|
|
pItems[0].a.fLinkAfter = 0;
|
|
|
|
pItems[0].a.fLogicalOrder = 0;
|
|
|
|
pItems[0].a.fNoGlyphIndex = 0;
|
|
|
|
/* set the SCRIPT_STATE */
|
|
|
|
pItems[0].a.s.uBidiLevel = 0;
|
|
|
|
pItems[0].a.s.fOverrideDirection = 0;
|
|
|
|
pItems[0].a.s.fInhibitSymSwap = FALSE;
|
|
|
|
pItems[0].a.s.fCharShape = 0;
|
|
|
|
pItems[0].a.s.fDigitSubstitute = 0;
|
|
|
|
pItems[0].a.s.fInhibitLigate = 0;
|
|
|
|
pItems[0].a.s.fDisplayZWG = 0;
|
|
|
|
pItems[0].a.s.fArabicNumContext = 0;
|
|
|
|
pItems[0].a.s.fGcpClusters = 0;
|
|
|
|
pItems[0].a.s.fReserved = 0;
|
|
|
|
pItems[0].a.s.fEngineReserved = 0;
|
|
|
|
|
|
|
|
/* While not strickly necessary according to the spec, make sure the n+1
|
|
|
|
* item is set up to prevent random behaviour if the caller eroneously
|
|
|
|
* checks the n+1 structure */
|
|
|
|
pItems[1].a.eScript = 0;
|
|
|
|
pItems[1].a.fRTL = 0;
|
|
|
|
pItems[1].a.fLayoutRTL = 0;
|
|
|
|
pItems[1].a.fLinkBefore = 0;
|
|
|
|
pItems[1].a.fLinkAfter = 0;
|
|
|
|
pItems[1].a.fLogicalOrder = 0;
|
|
|
|
pItems[1].a.fNoGlyphIndex = 0;
|
|
|
|
/* set the SCRIPT_STATE */
|
|
|
|
pItems[1].a.s.uBidiLevel = 0;
|
|
|
|
pItems[1].a.s.fOverrideDirection = 0;
|
|
|
|
pItems[1].a.s.fInhibitSymSwap = FALSE;
|
|
|
|
pItems[1].a.s.fCharShape = 0;
|
|
|
|
pItems[1].a.s.fDigitSubstitute = 0;
|
|
|
|
pItems[1].a.s.fInhibitLigate = 0;
|
|
|
|
pItems[1].a.s.fDisplayZWG = 0;
|
|
|
|
pItems[1].a.s.fArabicNumContext = 0;
|
|
|
|
pItems[1].a.s.fGcpClusters = 0;
|
|
|
|
pItems[1].a.s.fReserved = 0;
|
|
|
|
pItems[1].a.s.fEngineReserved = 0;
|
|
|
|
|
|
|
|
/* Set one SCRIPT_STATE item being returned */
|
|
|
|
*pcItems = 1;
|
|
|
|
|
|
|
|
/* Set SCRIPT_ITEM */
|
|
|
|
pItems[1].iCharPos = cInChars - pItems[0].iCharPos ; /* the last + 1 item
|
|
|
|
contains the ptr to the lastchar */
|
2006-04-09 01:15:41 +02:00
|
|
|
TRACE("%s,%d,%d,%p,%p,%p,%p,%d\n", debugstr_wn(pwcInChars, cInChars), cInChars, cMaxItems,
|
2006-02-18 16:00:29 +01:00
|
|
|
psControl, psState, pItems, pcItems, *pcItems);
|
|
|
|
TRACE("Start Pos in string: %d, Stop Pos %d\n", pItems[0].iCharPos, pItems[1].iCharPos);
|
2006-01-09 17:16:57 +01:00
|
|
|
return 0;
|
2005-07-27 13:02:52 +02:00
|
|
|
}
|
2005-11-15 13:02:16 +01:00
|
|
|
|
2005-11-23 20:14:04 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* ScriptStringAnalyse (USP10.@)
|
|
|
|
*
|
|
|
|
*/
|
2005-11-15 13:02:16 +01:00
|
|
|
HRESULT WINAPI ScriptStringAnalyse(HDC hdc,
|
|
|
|
const void *pString,
|
|
|
|
int cString,
|
|
|
|
int cGlyphs,
|
|
|
|
int iCharset,
|
|
|
|
DWORD dwFlags,
|
|
|
|
int iReqWidth,
|
|
|
|
SCRIPT_CONTROL *psControl,
|
|
|
|
SCRIPT_STATE *psState,
|
|
|
|
const int *piDx,
|
|
|
|
SCRIPT_TABDEF *pTabdef,
|
|
|
|
const BYTE *pbInClass,
|
|
|
|
SCRIPT_STRING_ANALYSIS *pssa)
|
|
|
|
{
|
|
|
|
FIXME("(%p,%p,%d,%d,%d,0x%lx,%d,%p,%p,%p,%p,%p,%p): stub\n",
|
|
|
|
hdc, pString, cString, cGlyphs, iCharset, dwFlags,
|
|
|
|
iReqWidth, psControl, psState, piDx, pTabdef, pbInClass, pssa);
|
|
|
|
if (1 > cString || NULL == pString) {
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
if ((dwFlags & SSA_GLYPHS) && NULL == hdc) {
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2006-05-23 14:15:15 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ScriptStringOut (USP10.@)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI ScriptStringOut(SCRIPT_STRING_ANALYSIS ssa,
|
|
|
|
int iX,
|
|
|
|
int iY,
|
|
|
|
UINT uOptions,
|
|
|
|
const RECT *prc,
|
|
|
|
int iMinSel,
|
|
|
|
int iMaxSel,
|
|
|
|
BOOL fDisabled)
|
|
|
|
{
|
|
|
|
FIXME("(%p,%d,%d,0x%1x,%p,%d,%d,%d): stub\n",
|
|
|
|
ssa, iX, iY, uOptions, prc, iMinSel, iMaxSel, fDisabled);
|
|
|
|
if (!ssa) {
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2005-11-23 20:14:04 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* ScriptStringFree (USP10.@)
|
|
|
|
*
|
|
|
|
*/
|
2005-11-15 13:02:16 +01:00
|
|
|
HRESULT WINAPI ScriptStringFree(SCRIPT_STRING_ANALYSIS *pssa) {
|
|
|
|
FIXME("(%p): stub\n",pssa);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2005-11-23 20:14:04 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* ScriptIsComplex (USP10.@)
|
|
|
|
*
|
|
|
|
*/
|
2005-11-15 13:02:16 +01:00
|
|
|
HRESULT WINAPI ScriptIsComplex(const WCHAR* pwcInChars, int cInChars, DWORD dwFlags) {
|
2006-04-09 01:15:41 +02:00
|
|
|
FIXME("(%s,%d,0x%lx): stub\n", debugstr_wn(pwcInChars, cInChars), cInChars, dwFlags);
|
2005-11-15 13:02:16 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
2006-04-20 13:50:44 +02:00
|
|
|
|
2006-02-14 17:38:20 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* ScriptShape (USP10.@)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI ScriptShape(HDC hdc, SCRIPT_CACHE *psc, const WCHAR *pwcChars,
|
|
|
|
int cChars, int cMaxGlyphs,
|
|
|
|
SCRIPT_ANALYSIS *psa, WORD *pwOutGlyphs, WORD *pwLogClust,
|
|
|
|
SCRIPT_VISATTR *psva, int *pcGlyphs)
|
|
|
|
{
|
2006-02-20 10:19:32 +01:00
|
|
|
/* Note SCRIPT_CACHE (*psc) appears to be a good place to save info that needs to be
|
|
|
|
* passed between functions. */
|
|
|
|
|
|
|
|
HDC phdc;
|
|
|
|
int cnt;
|
|
|
|
DWORD hr;
|
|
|
|
Scriptcache *pScriptcache;
|
|
|
|
*pcGlyphs = cChars;
|
|
|
|
FIXME("(%p, %p, %p, %d, %d, %p): semi-stub\n", hdc, psc, pwcChars,
|
|
|
|
cChars, cMaxGlyphs, psa);
|
2006-02-24 10:13:51 +01:00
|
|
|
if (psa) TRACE("psa values: %d, %d, %d, %d, %d, %d, %d\n", psa->eScript, psa->fRTL, psa->fLayoutRTL,
|
2006-02-20 10:19:32 +01:00
|
|
|
psa->fLinkBefore, psa->fLinkAfter,
|
|
|
|
psa->fLogicalOrder, psa->fNoGlyphIndex);
|
|
|
|
|
|
|
|
if (cChars > cMaxGlyphs) return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
if (!hdc && !*psc) {
|
|
|
|
TRACE("No Script_Cache (psc) and no hdc. Ask for one. Hdc=%p, psc=%p\n", hdc, *psc);
|
|
|
|
return E_PENDING;
|
|
|
|
} else
|
|
|
|
if (hdc && !*psc) {
|
2006-04-20 13:50:44 +02:00
|
|
|
pScriptcache = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(Scriptcache) );
|
2006-02-20 10:19:32 +01:00
|
|
|
pScriptcache->hdc = (HDC) hdc;
|
|
|
|
phdc = hdc;
|
|
|
|
*psc = (Scriptcache *) pScriptcache;
|
|
|
|
} else
|
|
|
|
if (*psc) {
|
|
|
|
pScriptcache = (Scriptcache *) *psc;
|
|
|
|
phdc = pScriptcache->hdc;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("Before: ");
|
|
|
|
for (cnt = 0; cnt < cChars; cnt++)
|
|
|
|
TRACE("%4x",pwcChars[cnt]);
|
|
|
|
TRACE("\n");
|
2006-02-14 17:38:20 +01:00
|
|
|
|
2006-02-20 10:19:32 +01:00
|
|
|
if (!psa->fNoGlyphIndex) { /* Glyph translate */
|
|
|
|
hr = GetGlyphIndicesW(phdc, pwcChars, cChars, pwOutGlyphs, 0);
|
|
|
|
TRACE("After: ");
|
|
|
|
for (cnt = 0; cnt < cChars; cnt++) {
|
|
|
|
TRACE("%04x",pwOutGlyphs[cnt]);
|
|
|
|
}
|
2006-04-20 13:50:44 +02:00
|
|
|
TRACE("\n");
|
2006-02-20 10:19:32 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
TRACE("After: ");
|
|
|
|
for (cnt = 0; cnt < cChars; cnt++) { /* no translate so set up */
|
|
|
|
pwOutGlyphs[cnt] = pwcChars[cnt]; /* copy in to out and */
|
|
|
|
TRACE("%04x",pwOutGlyphs[cnt]);
|
|
|
|
}
|
|
|
|
TRACE("\n");
|
|
|
|
}
|
|
|
|
|
2006-02-24 10:13:51 +01:00
|
|
|
/* Set up a valid SCRIPT_VISATTR and LogClust for each char in this run */
|
2006-02-20 10:19:32 +01:00
|
|
|
for (cnt = 0; cnt < cChars; cnt++) {
|
2006-02-24 10:13:51 +01:00
|
|
|
psva[cnt].uJustification = 2;
|
|
|
|
psva[cnt].fClusterStart = 1;
|
2006-02-20 10:19:32 +01:00
|
|
|
psva[cnt].fDiacritic = 0;
|
|
|
|
psva[cnt].fZeroWidth = 0;
|
2006-02-24 10:13:51 +01:00
|
|
|
pwLogClust[cnt] = cnt;
|
2006-02-20 10:19:32 +01:00
|
|
|
}
|
|
|
|
return 0;
|
2006-02-14 17:38:20 +01:00
|
|
|
}
|
2006-02-20 10:19:32 +01:00
|
|
|
|
2006-02-14 17:38:20 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* ScriptPlace (USP10.@)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI ScriptPlace(HDC hdc, SCRIPT_CACHE *psc, const WORD *pwGlyphs,
|
|
|
|
int cGlyphs, const SCRIPT_VISATTR *psva,
|
|
|
|
SCRIPT_ANALYSIS *psa, int *piAdvance, GOFFSET *pGoffset, ABC *pABC )
|
|
|
|
{
|
2006-02-21 10:24:24 +01:00
|
|
|
HDC phdc;
|
|
|
|
int wcnt;
|
|
|
|
LPABC lpABC;
|
|
|
|
Scriptcache *pScriptcache;
|
|
|
|
FIXME("(%p, %p, %p, %s, %d, %p, %p, %p): semi-stub\n", hdc, psc, pwGlyphs,
|
2006-04-09 01:15:41 +02:00
|
|
|
debugstr_wn(pwGlyphs, cGlyphs),
|
2006-02-14 17:38:20 +01:00
|
|
|
cGlyphs, psva, psa,
|
|
|
|
piAdvance);
|
|
|
|
|
2006-02-21 10:24:24 +01:00
|
|
|
/* We need a valid hdc to do any of the font calls. The spec says that hdc is optional and
|
|
|
|
* psc will be used first. If psc and hdc are not specified E_PENDING is returned to get
|
|
|
|
* the caller to return the hdc. For convience, the hdc is cached in SCRIPT_CACHE. */
|
|
|
|
|
|
|
|
if (!hdc && !*psc) {
|
|
|
|
TRACE("No Script_Cache (psc) and no hdc. Ask for one. Hdc=%p, psc=%p\n", hdc, *psc);
|
|
|
|
return E_PENDING;
|
|
|
|
} else
|
|
|
|
if (hdc && !*psc) {
|
|
|
|
pScriptcache = HeapAlloc( GetProcessHeap(), 0, sizeof(Scriptcache) );
|
|
|
|
pScriptcache->hdc = hdc;
|
|
|
|
phdc = hdc;
|
|
|
|
*psc = pScriptcache;
|
|
|
|
} else
|
|
|
|
if (*psc) {
|
|
|
|
pScriptcache = *psc;
|
|
|
|
phdc = pScriptcache->hdc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Here we need to calculate the width of the run unit. At this point the input string
|
|
|
|
* has been converted to glyphs and we till need to translate back to the original chars
|
2006-04-20 13:50:44 +02:00
|
|
|
* to get the correct ABC widths. */
|
2006-02-21 10:24:24 +01:00
|
|
|
|
2006-04-20 13:50:44 +02:00
|
|
|
lpABC = HeapAlloc(GetProcessHeap(), 0 , sizeof(ABC)*cGlyphs);
|
2006-02-21 10:24:24 +01:00
|
|
|
pABC->abcA = 0;
|
|
|
|
pABC->abcB = 0;
|
|
|
|
pABC->abcC = 0;
|
2006-04-20 13:50:44 +02:00
|
|
|
if (!GetCharABCWidthsI(phdc, 0, cGlyphs, (WORD *) pwGlyphs, lpABC ))
|
|
|
|
{
|
|
|
|
WARN("Could not get ABC values\n");
|
|
|
|
for (wcnt = 0; wcnt < cGlyphs; wcnt++) {
|
|
|
|
piAdvance[wcnt] = 0;
|
|
|
|
pGoffset[wcnt].du = 0;
|
|
|
|
pGoffset[wcnt].dv = 0;
|
2006-02-21 10:24:24 +01:00
|
|
|
}
|
|
|
|
}
|
2006-04-20 13:50:44 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
for (wcnt = 0; wcnt < cGlyphs ; wcnt++) { /* add up the char lengths */
|
|
|
|
TRACE(" Glyph=%04x, abcA=%d, abcB=%d, abcC=%d wcnt=%d\n",
|
|
|
|
pwGlyphs[wcnt],
|
|
|
|
lpABC[wcnt].abcA,
|
|
|
|
lpABC[wcnt].abcB,
|
|
|
|
lpABC[wcnt].abcC, wcnt);
|
|
|
|
pABC->abcA += lpABC[wcnt].abcA;
|
|
|
|
pABC->abcB += lpABC[wcnt].abcB;
|
|
|
|
pABC->abcC += lpABC[wcnt].abcC;
|
|
|
|
piAdvance[wcnt] = lpABC[wcnt].abcA + lpABC[wcnt].abcB + lpABC[wcnt].abcC;
|
|
|
|
pGoffset[wcnt].du = 0;
|
|
|
|
pGoffset[wcnt].dv = 0;
|
|
|
|
}
|
2006-02-21 10:24:24 +01:00
|
|
|
}
|
|
|
|
TRACE("Total for run: abcA=%d, abcB=%d, abcC=%d\n", pABC->abcA, pABC->abcB, pABC->abcC);
|
|
|
|
|
2006-04-20 13:50:44 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, lpABC );
|
|
|
|
|
2006-02-21 10:24:24 +01:00
|
|
|
return 0;
|
2006-02-14 17:38:20 +01:00
|
|
|
}
|
2006-02-14 17:38:47 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* ScriptGetCMap (USP10.@)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI ScriptGetCMap(HDC hdc, SCRIPT_CACHE *psc, const WCHAR *pwcInChars,
|
|
|
|
int cChars, DWORD dwFlags, WORD *pwOutGlyphs)
|
|
|
|
{
|
2006-02-22 13:24:52 +01:00
|
|
|
HDC phdc;
|
|
|
|
int cnt;
|
|
|
|
DWORD hr;
|
|
|
|
Scriptcache *pScriptcache;
|
2006-04-30 15:44:30 +02:00
|
|
|
FIXME("(%p,%p,%s,%d,0x%lx,%p): semi-stub\n", hdc, psc, debugstr_wn(pwcInChars,cChars),
|
|
|
|
cChars, dwFlags, pwOutGlyphs);
|
|
|
|
|
|
|
|
if (!psc || !pwcInChars || !pwOutGlyphs)
|
|
|
|
return E_INVALIDARG;
|
2006-02-22 13:24:52 +01:00
|
|
|
|
|
|
|
if (!hdc && !*psc) {
|
|
|
|
TRACE("No Script_Cache (psc) and no hdc. Ask for one. Hdc=%p, psc=%p\n", hdc, *psc);
|
|
|
|
return E_PENDING;
|
|
|
|
} else
|
|
|
|
if (hdc && !*psc) {
|
|
|
|
pScriptcache = HeapAlloc( GetProcessHeap(), 0, sizeof(Scriptcache) );
|
|
|
|
pScriptcache->hdc = hdc;
|
|
|
|
phdc = hdc;
|
|
|
|
*psc = pScriptcache;
|
|
|
|
} else
|
|
|
|
if (*psc) {
|
|
|
|
pScriptcache = *psc;
|
|
|
|
phdc = pScriptcache->hdc;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("Before: ");
|
|
|
|
for (cnt = 0; cnt < cChars; cnt++)
|
|
|
|
TRACE("%4x",pwcInChars[cnt]);
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
hr = GetGlyphIndicesW(phdc, pwcInChars, cChars, pwOutGlyphs, 0);
|
|
|
|
TRACE("After: ");
|
|
|
|
for (cnt = 0; cnt < cChars; cnt++) {
|
|
|
|
TRACE("%04x",pwOutGlyphs[cnt]);
|
|
|
|
}
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
return 0;
|
2006-02-14 17:38:47 +01:00
|
|
|
}
|
2006-02-21 10:47:39 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* ScriptTextOut (USP10.@)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI ScriptTextOut(const HDC hdc, SCRIPT_CACHE *psc, int x, int y, UINT fuOptions,
|
|
|
|
const RECT *lprc, const SCRIPT_ANALYSIS *psa, const WCHAR *pwcReserved,
|
|
|
|
int iReserved, const WORD *pwGlyphs, int cGlyphs, const int *piAdvance,
|
|
|
|
const int *piJustify, const GOFFSET *pGoffset)
|
|
|
|
{
|
2006-04-30 15:44:30 +02:00
|
|
|
HDC phdc;
|
|
|
|
DWORD hr;
|
|
|
|
Scriptcache *pScriptcache;
|
|
|
|
TRACE ("(%p, %p, %d, %d, %04x, %p, %p, %p, %d, %p, %d, %p, %p, %p): stub\n",
|
|
|
|
hdc, psc, x, y, fuOptions, lprc, psa, pwcReserved, iReserved, pwGlyphs, cGlyphs,
|
|
|
|
piAdvance, piJustify, pGoffset);
|
|
|
|
|
|
|
|
if (!psc || !piAdvance || !psa || !pwGlyphs)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
if (!hdc && !*psc) {
|
|
|
|
TRACE("No Script_Cache (psc) and no hdc. Ask for one. Hdc=%p, psc=%p\n", hdc, *psc);
|
|
|
|
return E_PENDING;
|
|
|
|
} else
|
|
|
|
if (hdc && !*psc) {
|
|
|
|
pScriptcache = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(Scriptcache) );
|
|
|
|
pScriptcache->hdc = hdc;
|
|
|
|
phdc = hdc;
|
|
|
|
*psc = pScriptcache;
|
|
|
|
} else
|
|
|
|
if (*psc) {
|
|
|
|
pScriptcache = *psc;
|
|
|
|
phdc = pScriptcache->hdc;
|
|
|
|
}
|
|
|
|
|
|
|
|
fuOptions &= ETO_CLIPPED + ETO_OPAQUE;
|
|
|
|
if (!psa->fNoGlyphIndex) /* Have Glyphs? */
|
|
|
|
fuOptions |= ETO_GLYPH_INDEX; /* Say don't do tranlastion to glyph */
|
|
|
|
|
|
|
|
hr = ExtTextOutW(phdc, x, y, fuOptions, lprc, pwGlyphs, cGlyphs, NULL);
|
|
|
|
|
|
|
|
if (hr) return S_OK;
|
|
|
|
else {
|
|
|
|
FIXME("ExtTextOut returned:=%ld\n", hr);
|
|
|
|
return hr;
|
|
|
|
}
|
2006-02-21 10:47:39 +01:00
|
|
|
}
|