Re: FONGOBJ_xxx,how to get a character width in logical units? by Tim
Tim
Sat Dec 31 13:45:46 CST 2005
MSX.GK <MSX.GK@discussions.microsoft.com> wrote:
>Thanks for your respones, here is the code segment:
>
>LONG GetCharWidth( FONTOBJ* pfo, WCHAR wc )
>{
> FD_GLYPHSET *pfdg = NULL;
> LONG width = 0;
>
> pfdg = FONTOBJ_pfdg( pfo );
> if ( pfdg && pfdg->cRuns > 0 )
> {
> ULONG i = 0;
> for ( i = 0; i < pfdg->cRuns; i++ )
> {
> if ( wc >= pfdg->awcrun[i].wcLow && wc <= pfdg->awcrun[i].wcLow
>+ pfdg->awcrun[i].cGlyphs )
> {
> GLYPHDATA gd= {0};
> GLYPHDATA *pgd = NULL;
> HGLYPH *pglyph = pfdg->awcrun[i].phg;
> ULONG uIndex = wc - pfdg->awcrun[i].wcLow;
> FONTOBJ_cGetGlyphs( pfo, FO_PATHOBJ, 1, &pglyph[uIndex],
>(LPVOID)&pgd );
>
> // how should i calculate the logical height here? use
>(pgd->fxD / POINTSIZE), it looks like wrong ?
> width = ????;
In what units? The fields in GLYPHDATA have already been translated to
pixels. Remember, however, that they are in 28.4 fixed-point format. If
you just want integer pixels, use pgd->fxD >> 4.
--
- Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.