mirror of
https://github.com/gnustep/libs-steptalk.git
synced 2025-02-22 19:11:05 +00:00
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/steptalk/trunk@17373 72102866-910b-0410-8b05-ffd578937521
47 lines
804 B
Smalltalk
47 lines
804 B
Smalltalk
" listFonts.st
|
|
|
|
Example that will create a 'rtf file containing smaples of all available
|
|
fonts.
|
|
|
|
"
|
|
|
|
[| :text
|
|
|
|
main
|
|
|
|
| fontManager |
|
|
|
|
Environment loadModule:'AppKit'.
|
|
|
|
text := NSTextView alloc initWithFrame:NSNullRect.
|
|
text setRichText:YES.
|
|
|
|
fontManager := NSFontManager sharedFontManager.
|
|
|
|
(fontManager availableFontFamilies)
|
|
do: [ :font |
|
|
self addFontSample:font
|
|
].
|
|
|
|
"text writeRTFDToFile:'Fonts.rtf' atomically:YES."
|
|
|
|
^nil
|
|
!
|
|
|
|
addFontSample:fontName
|
|
|
|
| attr |
|
|
|
|
Transcript showLine:fontName.
|
|
|
|
attr := NSMutableDictionary dictionary.
|
|
attr setObject:(NSFont fontWithName:fontName size:0)
|
|
forKey:NSFontAttributeName.
|
|
|
|
text setTypingAttributes:attr.
|
|
" text insertText:(fontName,'\n')."
|
|
|
|
^self
|
|
|
|
|
|
]
|