mirror of
https://github.com/gnustep/libs-steptalk.git
synced 2025-02-23 03:20:57 +00:00
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/steptalk/trunk@13642 72102866-910b-0410-8b05-ffd578937521
45 lines
765 B
Smalltalk
45 lines
765 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 |
|
|
|
|
attr := NSMutableDictionary dictionary.
|
|
attr setObject:(NSFont fontWithName:fontName size:0)
|
|
forKey:NSFontAttributeName.
|
|
|
|
text setTypingAttributes:attr.
|
|
text insertText:(fontName,'\n').
|
|
|
|
^self
|
|
|
|
|
|
]
|