📄 usp10.c
字号:
psva[cnt].uJustification = 2;
psva[cnt].fClusterStart = 1;
psva[cnt].fDiacritic = 0;
psva[cnt].fZeroWidth = 0;
pwLogClust[cnt] = cnt;
}
return S_OK;
}
/***********************************************************************
* ScriptPlace (USP10.@)
*
* Produce advance widths for a run.
*
* PARAMS
* hdc [I] Device context.
* psc [I/O] Opaque pointer to a script cache.
* pwGlyphs [I] Array of glyphs.
* cGlyphs [I] Number of glyphs in pwGlyphs.
* psva [I] Array of visual attributes.
* psa [I/O] String analysis.
* piAdvance [O] Array of advance widths.
* pGoffset [O] Glyph offsets.
* pABC [O] Combined ABC width.
*
* RETURNS
* Success: S_OK
* Failure: Non-zero HRESULT value.
*/
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 )
{
int wcnt;
HRESULT hr;
LPABC lpABC;
TRACE("(%p, %p, %p, %s, %d, %p, %p, %p)\n", hdc, psc, pwGlyphs,
debugstr_wn(pwGlyphs, cGlyphs), cGlyphs, psva, psa, piAdvance);
if ((hr = get_script_cache(hdc, psc))) return hr;
/* Here we need to calculate the width of the run unit. At this point the input string
* has been converted to glyphs and we still need to translate back to the original chars
* to get the correct ABC widths. */
if (!(lpABC = usp_zero_alloc(sizeof(ABC) * cGlyphs))) return E_OUTOFMEMORY;
memset(pABC, 0, sizeof(ABC));
/* FIXME: set pGoffset to more reasonable values */
if (!GetCharABCWidthsI(get_cache_hdc(psc), 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;
}
}
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;
}
}
TRACE("Total for run: abcA=%d, abcB=%d, abcC=%d\n", pABC->abcA, pABC->abcB, pABC->abcC);
usp_free(lpABC);
return S_OK;
}
/***********************************************************************
* ScriptGetCMap (USP10.@)
*
* Retrieve glyph indices.
*
* PARAMS
* hdc [I] Device context.
* psc [I/O] Opaque pointer to a script cache.
* pwcInChars [I] Array of Unicode characters.
* cChars [I] Number of characters in pwcInChars.
* dwFlags [I] Flags.
* pwOutGlyphs [O] Buffer to receive the array of glyph indices.
*
* RETURNS
* Success: S_OK
* Failure: Non-zero HRESULT value.
*/
HRESULT WINAPI ScriptGetCMap(HDC hdc, SCRIPT_CACHE *psc, const WCHAR *pwcInChars,
int cChars, DWORD dwFlags, WORD *pwOutGlyphs)
{
int cnt;
HRESULT hr;
TRACE("(%p,%p,%s,%d,0x%x,%p)\n", hdc, psc, debugstr_wn(pwcInChars, cChars),
cChars, dwFlags, pwOutGlyphs);
if ((hr = get_script_cache(hdc, psc))) return hr;
TRACE("Before: ");
for (cnt = 0; cnt < cChars; cnt++)
TRACE("%4x",pwcInChars[cnt]);
TRACE("\n");
GetGlyphIndicesW(get_cache_hdc(psc), pwcInChars, cChars, pwOutGlyphs, 0);
TRACE("After: ");
for (cnt = 0; cnt < cChars; cnt++) {
TRACE("%04x",pwOutGlyphs[cnt]);
}
TRACE("\n");
return S_OK;
}
/***********************************************************************
* 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)
{
HRESULT hr;
TRACE("(%p, %p, %d, %d, %04x, %p, %p, %p, %d, %p, %d, %p, %p, %p)\n",
hdc, psc, x, y, fuOptions, lprc, psa, pwcReserved, iReserved, pwGlyphs, cGlyphs,
piAdvance, piJustify, pGoffset);
if (!hdc && psc && !*psc) return E_INVALIDARG;
if (!piAdvance || !psa || !pwGlyphs) return E_INVALIDARG;
if ((hr = get_script_cache(hdc, psc))) return hr;
fuOptions &= ETO_CLIPPED + ETO_OPAQUE;
if (!psa->fNoGlyphIndex) /* Have Glyphs? */
fuOptions |= ETO_GLYPH_INDEX; /* Say don't do translation to glyph */
if (!ExtTextOutW(get_cache_hdc(psc), x, y, fuOptions, lprc, pwGlyphs, cGlyphs, NULL))
return S_FALSE;
return S_OK;
}
/***********************************************************************
* ScriptCacheGetHeight (USP10.@)
*
* Retrieve the height of the font in the cache.
*
* PARAMS
* hdc [I] Device context.
* psc [I/O] Opaque pointer to a script cache.
* height [O] Receives font height.
*
* RETURNS
* Success: S_OK
* Failure: Non-zero HRESULT value.
*/
HRESULT WINAPI ScriptCacheGetHeight(HDC hdc, SCRIPT_CACHE *psc, LONG *height)
{
HRESULT hr;
TRACE("(%p, %p, %p)\n", hdc, psc, height);
if (!height) return E_INVALIDARG;
if ((hr = get_script_cache(hdc, psc))) return hr;
*height = get_cache_height(psc);
return S_OK;
}
/***********************************************************************
* ScriptGetGlyphABCWidth (USP10.@)
*
* Retrieve the width of a glyph.
*
* PARAMS
* hdc [I] Device context.
* psc [I/O] Opaque pointer to a script cache.
* glyph [I] Glyph to retrieve the width for.
* abc [O] ABC widths of the glyph.
*
* RETURNS
* Success: S_OK
* Failure: Non-zero HRESULT value.
*/
HRESULT WINAPI ScriptGetGlyphABCWidth(HDC hdc, SCRIPT_CACHE *psc, WORD glyph, ABC *abc)
{
HRESULT hr;
TRACE("(%p, %p, 0x%04x, %p)\n", hdc, psc, glyph, abc);
if ((hr = get_script_cache(hdc, psc))) return hr;
/* FIXME: get this from the cache */
if (!GetCharABCWidthsW(get_cache_hdc(psc), glyph, glyph, abc)) return E_HANDLE;
return S_OK;
}
/***********************************************************************
* ScriptLayout (USP10.@)
*
* Map embedding levels to visual and/or logical order.
*
* PARAMS
* runs [I] Size of level array.
* level [I] Array of embedding levels.
* vistolog [O] Map of embedding levels from visual to logical order.
* logtovis [O] Map of embedding levels from logical to visual order.
*
* RETURNS
* Success: S_OK
* Failure: Non-zero HRESULT value.
*
* BUGS
* This stub works correctly for any sequence of a single
* embedding level but not for sequences of different
* embedding levels, i.e. mixtures of RTL and LTR scripts.
*/
HRESULT WINAPI ScriptLayout(int runs, const BYTE *level, int *vistolog, int *logtovis)
{
int i, j = runs - 1, k = 0;
TRACE("(%d, %p, %p, %p)\n", runs, level, vistolog, logtovis);
if (!level || (!vistolog && !logtovis))
return E_INVALIDARG;
for (i = 0; i < runs; i++)
{
if (level[i] % 2)
{
if (vistolog) *vistolog++ = j;
if (logtovis) *logtovis++ = j;
j--;
}
else
{
if (vistolog) *vistolog++ = k;
if (logtovis) *logtovis++ = k;
k++;
}
}
return S_OK;
}
/***********************************************************************
* ScriptStringGetLogicalWidths (USP10.@)
*
* Returns logical widths from a string analysis.
*
* PARAMS
* ssa [I] string analysis.
* piDx [O] logical widths returned.
*
* RETURNS
* Success: S_OK
* Failure: a non-zero HRESULT.
*/
HRESULT WINAPI ScriptStringGetLogicalWidths(SCRIPT_STRING_ANALYSIS ssa, int *piDx)
{
int i, j, next = 0;
StringAnalysis *analysis = ssa;
TRACE("%p, %p\n", ssa, piDx);
if (!analysis) return S_FALSE;
for (i = 0; i < analysis->numItems; i++)
{
for (j = 0; j < analysis->glyphs[i].numGlyphs; j++)
{
piDx[next] = analysis->glyphs[i].piAdvance[j];
next++;
}
}
return S_OK;
}
/***********************************************************************
* ScriptStringValidate (USP10.@)
*
* Validate a string analysis.
*
* PARAMS
* ssa [I] string analysis.
*
* RETURNS
* Success: S_OK
* Failure: S_FALSE if invalid sequences are found
* or a non-zero HRESULT if it fails.
*/
HRESULT WINAPI ScriptStringValidate(SCRIPT_STRING_ANALYSIS ssa)
{
StringAnalysis *analysis = ssa;
TRACE("(%p)\n", ssa);
if (!analysis) return E_INVALIDARG;
return (analysis->invalid) ? S_FALSE : S_OK;
}
/***********************************************************************
* ScriptString_pSize (USP10.@)
*
* Retrieve width and height of an analysed string.
*
* PARAMS
* ssa [I] string analysis.
*
* RETURNS
* Success: Pointer to a SIZE structure.
* Failure: NULL
*/
const SIZE * WINAPI ScriptString_pSize(SCRIPT_STRING_ANALYSIS ssa)
{
unsigned int i, j;
StringAnalysis *analysis = ssa;
TRACE("(%p)\n", ssa);
if (!analysis) return NULL;
if (!analysis->sz)
{
if (!(analysis->sz = usp_alloc(sizeof(SIZE)))) return NULL;
analysis->sz->cy = analysis->sc->height;
analysis->sz->cx = 0;
for (i = 0; i < analysis->numItems; i++)
for (j = 0; j < analysis->glyphs[i].numGlyphs; j++)
analysis->sz->cx += analysis->glyphs[i].piAdvance[j];
}
return analysis->sz;
}
/***********************************************************************
* ScriptString_pLogAttr (USP10.@)
*
* Retrieve logical attributes of an analysed string.
*
* PARAMS
* ssa [I] string analysis.
*
* RETURNS
* Success: Pointer to an array of SCRIPT_LOGATTR structures.
* Failure: NULL
*/
const SCRIPT_LOGATTR * WINAPI ScriptString_pLogAttr(SCRIPT_STRING_ANALYSIS ssa)
{
StringAnalysis *analysis = ssa;
TRACE("(%p)\n", ssa);
if (!analysis) return NULL;
return analysis->logattrs;
}
/***********************************************************************
* ScriptString_pcOutChars (USP10.@)
*
* Retrieve the length of a string after clipping.
*
* PARAMS
* ssa [I] String analysis.
*
* RETURNS
* Success: Pointer to the length.
* Failure: NULL
*/
const int * WINAPI ScriptString_pcOutChars(SCRIPT_STRING_ANALYSIS ssa)
{
StringAnalysis *analysis = ssa;
TRACE("(%p)\n", ssa);
if (!analysis) return NULL;
return &analysis->clip_len;
}
/***********************************************************************
* ScriptStringGetOrder (USP10.@)
*
* Retrieve a glyph order map.
*
* PARAMS
* ssa [I] String analysis.
* order [I/O] Array of glyph positions.
*
* RETURNS
* Success: S_OK
* Failure: a non-zero HRESULT.
*/
HRESULT WINAPI ScriptStringGetOrder(SCRIPT_STRING_ANALYSIS ssa, UINT *order)
{
unsigned int i, j, k;
StringAnalysis *analysis = ssa;
TRACE("(%p)\n", ssa);
if (!analysis) return S_FALSE;
/* FIXME: handle RTL scripts */
for (i = 0, k = 0; i < analysis->numItems; i++)
for (j = 0; j < analysis->glyphs[i].numGlyphs; j++, k++)
order[k] = k;
return S_OK;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -