Howdy.
I have been peeking a little bit in the API docs, but can't find a perticular function for changing the font size in the current DC that I am writing text to ( "TextOut" function )
Does anyone know how to change font size (And font name for that matter) in an easy way?
well - there are many "directions" to approach from
if you know the font name, you can use EnumFontFamiliesEx to make a list of available sizes
fonts are not easy to play with - lol
http://www.masm32.com/board/index.php?topic=15747.msg130057#msg130057
that example is for monospace fonts
it is a little different for true-type fonts, but you get the idea
Here is what I do to change the font to use in TextOut:
Create the font with the attributes you want with CreateFontIndirect, save the handle to the created font...
Then just do:
invoke SelectObject, hDC, hFontBold ; <-- where hFontBold is the handle to the font I created with CreateFontIndirect, and hDC is the handle to the DC you want to use with TextOut
Don't forget to delete the font in WM_CLOSE
invoke DeleteObject, hFontBold
\masm32\examples\exampl07\butntest\lib\makefont.asm contains a simplified procedure for creating a font.
And this is a modification of it:
;------------------------------------------------------------------
; This is a modification of the MakeFont procedure from the MASM32
; examples, with the height and width specifications replaced with
; a point size specification.
;------------------------------------------------------------------
MakeFont proc pointSize:dword,weight:dword,italic:dword,lpFontName:dword
invoke GetDC, 0
invoke GetDeviceCaps, eax, LOGPIXELSY
mul pointSize
xor edx, edx
mov ecx, 72
div ecx
invoke CreateFont,eax,0,NULL,NULL,weight,italic,NULL,NULL,
DEFAULT_CHARSET,OUT_TT_PRECIS,CLIP_DEFAULT_PRECIS,
PROOF_QUALITY,DEFAULT_PITCH or FF_DONTCARE,
lpFontName
ret
MakeFont endp
now you see what i meant about all the different directions :bg
it depends on what you have to start with, and what you want to end up with
QuoteMakeFont
[/b] MakeFont hHandFont, Height:40, Underline:TRUE, "Lucida Handwriting"
MakeFont hVertFont, Height:32, Escapement:900
Rem[/color] - in order to facilitate creating font variants, MakeFont keeps settings between calls
- place in WM_CREATE handler
[/b]
For the lazy ones, an excerpt from the MasmBasic help file ;-)