Mercurial > dwindows
changeset 1238:700ce342aab8
Divided _acquire_font() into two parts on Windows.
Allowing us to use the HDC of the pixmap to set the font...
allowing for better sized fonts on printer contexts.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Tue, 18 Oct 2011 08:26:36 +0000 |
parents | f8673299ec37 |
children | 7ec60b650e5b |
files | win/dw.c |
diffstat | 1 files changed, 15 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/win/dw.c Tue Oct 18 06:28:43 2011 +0000 +++ b/win/dw.c Tue Oct 18 08:26:36 2011 +0000 @@ -3889,13 +3889,12 @@ SetParent(handle, newparent); } -LOGFONT _get_logfont(HWND handle, char *fontname) +LOGFONT _get_logfont(HDC hdc, char *fontname) { int Italic, Bold; char *myFontName; int z, size = 9; LOGFONT lf; - HDC hdc = GetDC(handle); for(z=0;z<strlen(fontname);z++) { @@ -3904,7 +3903,6 @@ } size = atoi(fontname); lf.lfHeight = -MulDiv(size, GetDeviceCaps(hdc, LOGPIXELSY), 72); - ReleaseDC(handle, hdc); Italic = instring(" Italic", &fontname[z+1]); Bold = instring(" Bold", &fontname[z+1]); lf.lfWidth = 0; @@ -3944,13 +3942,13 @@ /* Create a font handle from specified font name.. * or return a handle to the default font. */ -HFONT _acquire_font(HWND handle, char *fontname) +HFONT _acquire_font2(HDC hdc, char *fontname) { HFONT hfont = 0; if(fontname != DefaultFont && fontname[0]) { - LOGFONT lf = _get_logfont(handle, fontname); + LOGFONT lf = _get_logfont(hdc, fontname); hfont = CreateFontIndirect(&lf); } if(!hfont && _DefaultFont) @@ -3960,6 +3958,17 @@ return hfont; } +/* Create a font handle from specified font name.. + * or return a handle to the default font. + */ +HFONT _acquire_font(HWND handle, char *fontname) +{ + HDC hdc = GetDC(handle); + HFONT hfont = _acquire_font2(hdc, fontname); + ReleaseDC(handle, hdc); + return hfont; +} + /* * Sets the default font used on text based widgets. * Parameters: @@ -8967,7 +8976,7 @@ { if(pixmap) { - HFONT hfont = _acquire_font(pixmap->handle, fontname); + HFONT hfont = _acquire_font2(pixmap->hdc, fontname); if(hfont) { @@ -10061,7 +10070,6 @@ pixmap->width = GetDeviceCaps(p->pd.hDC, HORZRES); pixmap->height = GetDeviceCaps(p->pd.hDC, VERTRES); - /*pixmap->handle = handle;*/ pixmap->hbm = CreateCompatibleBitmap(p->pd.hDC, pixmap->width, pixmap->height); pixmap->hdc = p->pd.hDC; pixmap->transcolor = DW_RGB_TRANSPARENT;