windows.fonts: speed up cached fonts.

db4
John Benediktsson 2012-09-20 12:13:52 -07:00
parent ba307bb38d
commit 3470492e21
1 changed files with 8 additions and 6 deletions

View File

@ -19,11 +19,11 @@ MEMO: windows-fonts ( -- fonts )
: windows-font-name ( string -- string' )
windows-fonts ?at drop ;
MEMO:: (cache-font) ( font -- HFONT )
font size>> neg ! nHeight
MEMO:: (cache-font) ( name size bold? italic? -- HFONT )
size neg ! nHeight
0 0 0 ! nWidth, nEscapement, nOrientation
font bold?>> FW_BOLD FW_NORMAL ? ! fnWeight
font italic?>> TRUE FALSE ? ! fdwItalic
bold? FW_BOLD FW_NORMAL ? ! fnWeight
italic? TRUE FALSE ? ! fdwItalic
FALSE ! fdwUnderline
FALSE ! fdWStrikeOut
DEFAULT_CHARSET ! fdwCharSet
@ -31,11 +31,13 @@ MEMO:: (cache-font) ( font -- HFONT )
CLIP_DEFAULT_PRECIS ! fdwClipPrecision
DEFAULT_QUALITY ! fdwQuality
DEFAULT_PITCH ! fdwPitchAndFamily
font name>> windows-font-name
name windows-font-name
CreateFont
dup win32-error=0/f ;
: cache-font ( font -- HFONT ) strip-font-colors (cache-font) ;
: cache-font ( font -- HFONT )
{ [ name>> ] [ size>> ] [ bold?>> ] [ italic?>> ] } cleave
(cache-font) ;
[ \ (cache-font) reset-memoized ] "windows.fonts" add-startup-hook