Comment puis-je obtenir une liste des familles NSFont disponibles, de préférence avec le nom fontName: equivalents.Comment puis-je obtenir une liste des familles NSFont disponibles?
15
A
Répondre
26
NSLog(@"%@",[[[NSFontManager sharedFontManager] availableFontFamilies] description]);
donne:
"Abadi MT Condensed Extra Bold",
"Abadi MT Condensed Light",
"Academy Engraved LET",
"Al Bayan",
"American Typewriter",
"Andale Mono",
Arial,
"Arial Black",
"Arial Hebrew",
"Arial Narrow",
"Arial Rounded MT Bold",
"Arial Unicode MS",
Ayuthaya,
Baghdad,
"Bank Gothic",
Baskerville,
"Baskerville Old Face",
Batang,
"Bauhaus 93",
"Bell MT",
"Bernard MT Condensed",
BiauKai,
"Big Caslon",
"Birch Std",
"Blackmoor LET",
"Blackoak Std",
"BlairMdITC TT",
"Bodoni Ornaments ITC TT",
"Bodoni SvtyTwo ITC TT",
"Bodoni SvtyTwo OS ITC TT",
"Bodoni SvtyTwo SC ITC TT",
"Book Antiqua",
"Bookman Old Style",
"Bookshelf Symbol 7",
"Bordeaux Roman Bold LET",
"Bradley Hand ITC TT",
Braggadocio,
"Britannic Bold",
"Brush Script MT",
"Brush Script Std",
Calibri,
"Calisto MT",
Cambria,
Candara,
Capitals,
Casual,
Century,
"Century Gothic",
"Century Schoolbook",
Chalkboard,
Chalkduster,
"Chaparral Pro",
"Charcoal CY",
"Charlemagne Std",
Cochin,
"Colonna MT",
"Comic Sans MS",
Consolas,
Constantia,
"Cooper Black",
"Cooper Std",
Copperplate,
"Copperplate Gothic Bold",
"Copperplate Gothic Light",
Corbel,
"Corsiva Hebrew",
Courier,
"Courier New",
Cracked,
"Curlz MT",
"DecoType Naskh",
Desdemona,
"Devanagari MT",
Didot,
"Edwardian Script ITC",
"Engravers MT",
"Euphemia UCAS",
Eurostile,
"Footlight MT Light",
"Franklin Gothic Book",
"Franklin Gothic Medium",
Futura,
Garamond,
"GB18030 Bitmap",
"Geeza Pro",
Geneva,
"Geneva CY",
Georgia,
"Giddyup Std",
"Gill Sans",
"Gill Sans MT",
"Gill Sans Ultra Bold",
"Gloucester MT Extra Condensed",
"Goudy Old Style",
"Gujarati MT",
Gulim,
GungSeo,
"Gurmukhi MT",
Haettenschweiler,
"Handwriting - Dakota",
Harrington,
HeadLineA,
Hei,
"Heiti SC",
"Heiti TC",
Helvetica,
"Helvetica CY",
"Helvetica Neue",
Herculanum,
"Hiragino Kaku Gothic Pro",
"Hiragino Kaku Gothic ProN",
"Hiragino Kaku Gothic Std",
"Hiragino Kaku Gothic StdN",
"Hiragino Maru Gothic Pro",
"Hiragino Maru Gothic ProN",
"Hiragino Mincho Pro",
"Hiragino Mincho ProN",
"Hiragino Sans GB",
"Hobo Std",
"Hoefler Text",
Impact,
"Imprint MT Shadow",
InaiMathi,
"Jazz LET",
Kai,
Kailasa,
"Kino MT",
Kokonor,
"Kozuka Gothic Pr6N",
"Kozuka Gothic Pro",
"Kozuka Mincho Pr6N",
"Kozuka Mincho Pro",
Krungthep,
KufiStandardGK,
"Letter Gothic Std",
"LiHei Pro",
"LiSong Pro",
"Lithos Pro",
"Lucida Blackletter",
"Lucida Bright",
"Lucida Calligraphy",
"Lucida Console",
"Lucida Fax",
"Lucida Grande",
"Lucida Handwriting",
"Lucida Sans",
"Lucida Sans Typewriter",
"Lucida Sans Unicode",
"Marker Felt",
Marlett,
"Matura MT Script Capitals",
Meiryo,
Menlo,
"Mesquite Std",
"Microsoft Sans Serif",
"Minion Pro",
Mistral,
"Modern No. 20",
"Mona Lisa Solid ITC TT",
Monaco,
"MS Gothic",
"MS Mincho",
"MS PGothic",
"MS PMincho",
"MS Reference Sans Serif",
"MS Reference Specialty",
Mshtakan,
"MT Extra",
"Myriad Pro",
Nadeem,
"New Peninim MT",
"News Gothic MT",
"Nueva Std",
"OCR A Std",
Onyx,
Optima,
"Orator Std",
Osaka,
Palatino,
Papyrus,
"Party LET",
PCMyungjo,
Perpetua,
"Perpetua Titling MT",
PilGi,
"Plantagenet Cherokee",
Playbill,
PMingLiU,
"Poplar Std",
"PortagoITC TT",
"Prestige Elite Std",
"Princetown LET",
Raanana,
Rockwell,
"Rockwell Extra Bold",
"Rosewood Std",
"Santa Fe LET",
Sathu,
"Savoye LET",
"SchoolHouse Cursive B",
"SchoolHouse Printed A",
Silom,
SimSun,
Skia,
"Snell Roundhand",
Stencil,
"Stencil Std",
STFangsong,
STHeiti,
STKaiti,
"Stone Sans ITC TT",
"Stone Sans Sem ITC TT",
STSong,
Symbol,
"Synchro LET",
Tahoma,
"Tekton Pro",
Thonburi,
Times,
"Times New Roman",
"Trajan Pro",
"Trebuchet MS",
"Tw Cen MT",
"Type Embellishments One LET",
Verdana,
Webdings,
"Wide Latin",
Wingdings,
"Wingdings 2",
"Wingdings 3",
"Zapf Dingbats",
Zapfino,
"Adobe Arabic",
"Adobe Caslon Pro",
"Adobe Fan Heiti Std",
"Adobe Fangsong Std",
"Adobe Garamond Pro",
"Adobe Gothic Std",
"Adobe Hebrew",
"Adobe Heiti Std",
"Adobe Kaiti Std",
"Adobe Ming Std",
"Adobe Myungjo Std",
"Adobe Song Std",
"Apple Braille",
"Apple Chancery",
"Apple Garamond BT",
"Apple LiGothic",
"Apple LiSung",
"Apple Symbols",
AppleGothic,
AppleMyungjo,
"Monotype Corsiva",
"Monotype Sorts"
dans 10.6.4
7
[[NSFontManager sharedFontManager] availableFontFamilies]
(auparavant, je l'avais écrit -[NSFontManager availableFontFamilies]
, ce qui est une manière classique d'écrire un nom de méthode, mais pourrait être source de confusion si on l'interprète comme exemple de code.)
1
Vérifiez la documentation Apple, par exemple: http://support.apple.com/kb/HT5379. - [NSFontManager availableFontFamilies] peut révéler des polices qui ne font pas partie de la version d'OS X que vous ciblez (je pense que c'est parce qu'elles ont été chargées avec d'autres applications, par exemple Adobe Illustrator).
0
#import <Cocoa/Cocoa.h>
@interface FontController : NSObject {
IBOutlet NSTextField *text;
}
- (IBAction)takeFontFamilyFrom: (id)sender;
- (IBAction)takeFontSizeFrom: (id)sender;
- (IBAction)takeFontAttributeFrom: (id)sender;
@end
#import "FontController.h"
NSFontManager *fm;
@implementation FontController
+ (void)initialize
{
fm = [NSFontManager sharedFontManager];
}
- (IBAction)takeFontFamilyFrom: (id)sender
{
NSFont *font = [text font];
font = [fm convertFont: font
toFamily: [sender stringValue]];
[text setFont: font];
}
- (IBAction)takeFontSizeFrom: (id)sender
{
NSFont *font = [text font];
font = [fm convertFont: font
toSize: [sender doubleValue]];
[text setFont: font];
}
- (IBAction)takeFontAttributeFrom: (id)sender
{
NSFont *font = [text font];
NSFontTraitMask attribute = [sender tag];
if (NSOnState == [sender state])
{
font = [fm convertFont: font toHaveTrait: attribute];
}
else
{
font = [fm convertFont: font toNotHaveTrait: attribute];
}
[sender setState: ([fm traitsOfFont: font] & attribute)];
[text setFont: font];
}
@end
2
Voilà comment cela peut être fait pour Swift:
let fontFamilyNames = NSFontManager.sharedFontManager().availableFontFamilies
print("avaialble fonts is \(fontFamilyNames)")
Questions connexes
- 1. obtenir une liste des énumérations disponibles
- 2. Cross-plateforme pour obtenir une liste des polices disponibles
- 3. Comment obtenir la liste des résolutions d'écran disponibles?
- 4. Comment obtenir une liste des rapports disponibles sur une instance de services de reporting
- 5. Liste des apps Django disponibles?
- 6. Liste des correctifs VS2010 disponibles
- 7. Obtenez une liste de podcasts iTunes disponibles?
- 8. Comment faire pour obtenir une liste des interfaces COM disponibles dans Windows
- 9. Comment puis-je obtenir la liste des arguments disponibles pour une fonction PHP?
- 10. Comment puis-je obtenir une liste des réseaux sans fil disponibles sur Linux?
- 11. Comment puis-je obtenir les polices disponibles dans WPF
- 12. Remplir ComboBox avec Liste des polices disponibles
- 13. Comment obtenir la liste des widgets installés?
- 14. Comment obtenir une liste des sessions Windows?
- 15. Comment obtenir une liste des objets Prolog
- 16. Liste des objets COM disponibles avec Powershell
- 17. Comment obtenir une sous-liste en C#
- 18. Liste des utilisateurs disponibles à une certaine date
- 19. Comment créer une NSFont à la fois en gras et en italique?
- 20. Liste des types de support "application/..." disponibles
- 21. Comment obtenir la liste complète des jeux de données disponibles dans un projet (VS)
- 22. Comment l'émulateur GAE limite la liste des modules Python disponibles?
- 23. Liste des polices GDI + disponibles dans Delphi 2009 win32
- 24. mysql: comment puis-je obtenir une liste de bases de données disponibles?
- 25. Comment obtenir les indicatifs régionaux disponibles?
- 26. Combien de familles de polices sont disponibles pour Google Font API?
- 27. Obtenez la liste des lecteurs disponibles et leurs tailles
- 28. Obtenir la liste des serveurs disponibles dans le groupe de serveurs SQL
- 29. C# - Incrémenter une liste de services web dans un répertoire et une liste disponibles Webmethods
- 30. familles de polices sur l'iPhone
Ouais, doit l'avoir manqué, je creusait autour de la documentation NSFont ... – BadPirate