void YourView::OnDraw(CDC* pDC, const CRect& cDrawRect)
{
...
CFont cFontToDraw;
CreateCalculatedFont(&cFontToDraw, pDC, cDrawRect);
HGDIOBJ hOldFont = pDC->SelectObject(&cFontToDraw);
...
pDC->DrawText(..);
...
pDC->SelectObject(hOldFont);
cFontToDraw.DeleteObject();
}
void YourView::CreateCalculatedFont(CFont* pcFontToCreate,
CDC* pDC,
const CRect& cDrawRect)
{
pcFontToCreate->CreateFontIndirect(..);
}
An alternative solution (for a statical font collection)
has been already given by the first answer :)