Esempio n. 1
0
/***********************************************************************
 *           PSDRV_GetTextExtentExPoint
 */
BOOL PSDRV_GetTextExtentExPoint(PSDRV_PDEVICE *physDev, LPCWSTR str, INT count,
                                INT maxExt, LPINT lpnFit, LPINT alpDx, LPSIZE size)
{
    int     	    nfit = 0;
    int     	    i;
    float   	    width = 0.0;
    float   	    scale;

    assert(physDev->font.fontloc == Builtin);

    TRACE("%s %i\n", debugstr_wn(str, count), count);

    scale = physDev->font.fontinfo.Builtin.scale;
    for (i = 0; i < count && str[i] != '\0'; ++i)
    {
	float scaled_width;
	width += PSDRV_UVMetrics(str[i], physDev->font.fontinfo.Builtin.afm)->WX;
	scaled_width = width * scale;
	if (alpDx)
	    alpDx[i] = scaled_width;
	if (scaled_width <= maxExt)
	    ++nfit;
    }

    size->cx = width * physDev->font.fontinfo.Builtin.scale;
    size->cy = physDev->font.fontinfo.Builtin.tm.tmHeight;

    if (lpnFit)
	*lpnFit = nfit;

    TRACE("cx=%li cy=%li\n", size->cx, size->cy);

    return TRUE;
}
Esempio n. 2
0
BOOL PSDRV_WriteBuiltinGlyphShow(PSDRV_PDEVICE *physDev, LPCWSTR str, INT count)
{
    int i;
    LPCSTR name;

    for (i = 0; i < count; ++i)
    {
	name = PSDRV_UVMetrics(str[i], physDev->font.fontinfo.Builtin.afm)->N->sz;

	PSDRV_WriteGlyphShow(physDev, name);
    }

    return TRUE;
}
Esempio n. 3
0
SHORT PSDRV_CalcAvgCharWidth(const AFM *afm)
{
    float   w = 0.0;
    int     i;

    for (i = 0; i < 27; ++i)
    {
    	const AFMMETRICS    *afmm;

	afmm = PSDRV_UVMetrics(UVweight[i].UV, afm);
	if (afmm->UV != UVweight[i].UV)     /* UVMetrics returns first glyph */
	    return MeanCharWidth(afm);	    /*   in font if UV is missing    */

	w += afmm->WX * (float)(UVweight[i].weight);
    }

    w /= 1000.0;

    return (SHORT)(w + 0.5);
}
Esempio n. 4
0
/***********************************************************************
 *           PSDRV_GetCharWidth
 */
BOOL PSDRV_GetCharWidth(PSDRV_PDEVICE *physDev, UINT firstChar, UINT lastChar, LPINT buffer)
{
    UINT    	    i;

    assert(physDev->font.fontloc == Builtin);

    TRACE("U+%.4X U+%.4X\n", firstChar, lastChar);

    if (lastChar > 0xffff || firstChar > lastChar)
    {
    	SetLastError(ERROR_INVALID_PARAMETER);
    	return FALSE;
    }

    for (i = firstChar; i <= lastChar; ++i)
    {
        *buffer = floor( PSDRV_UVMetrics(i, physDev->font.fontinfo.Builtin.afm)->WX
                         * physDev->font.fontinfo.Builtin.scale + 0.5 );
	TRACE("U+%.4X: %i\n", i, *buffer);
	++buffer;
    }

    return TRUE;
}