Articoli con Tag ‘Fonts’

iPhone FontsBook: codice sorgente per visualizzare i font di sistema

A completare l’articolo How to: custom fonts su iOS 3.2 vi propongo i sorgenti di FontsBook, una semplice applicazione iPhone che mostra in una tabella tutti i font di sistema, raggruppati per famiglia.

FontsBookFontsBookFontsBook

Continua...

How to: custom fonts su iOS 3.2

Con la release 3.2 di iOS è possibile includere nelle risorse di un’applicazione propri font, da usare esatamente come quelli di forniti di sistema:

Applications that want to use custom fonts can now include those fonts in their application bundle and register those fonts with the system by including the UIAppFonts key in their Info.plist file. The value of this key is an array of strings identifying the font files in the application’s bundle. When the system sees the key, it loads the specified fonts and makes them available to the application.

Continua...

iPhone: tutti i font di sistema

L’Apple iPhone mette a disposizione un numero limitato di Font agli sviluppatori. La lista dei font disponibili è facilmente ottenibile da codice, come vedremo. Se volete usare un vostro font, ad esempio includendolo nelle risorse, la cosa è un pochino più articolata e conivolge anche la questione delle licenze (diritti) sui font “embeddati”… ne riparleremo in seguito. Tornando invece ai font ufficiali presenti nell’Apple iPhone questi sono (cliccate sull’immagine per ingrandire):

iphonefonts

L’SDK di Apple iPhone permette di accedere a degli speciali font di sistema. Questi sono identificati da particolari costanti e sono:

1
2
3
UIFont *myBoldFont   = [UIFont boldSystemFontOfSize:12.0];
UIFont *mySystemFont = [UIFont SystemFontOfSize:12.0];
UIFont *myItalicFont = [UIFont italicSystemFontOfSize:12.0];

Se volete invece ottenere un puntatore ad uno odei font mostrati nell’immagine di sopra basta usare:

1
UIFont *myCustomFont = [UIFont fontWithName:@"Helvetica-Bold" size:22.0];

Come avrete notato la gestione del font è particolare; oltre alla famiglia (Helvetica, Courier, etc…) bisogna specificare il tipo (bold, italic, etc…). In pratica, quindi, un font deve essere fornito di queste caratteristiche. L’Helvetica, ad esempio, è presente con:

1
2
3
4
Helvetica
Helvetica-Bold
Helvetica-Oblique
Helvetica-BoldOblique

Se volete visualizzare direttamente i vostri font sull’iPhone, ecco qualche linea di codice utile:

1
2
3
4
5
6
7
8
9
10
11
12
NSArray *listOfFonts = [[NSArray alloc] initWithArray:[UIFont familyNames]];
NSArray *subFontTypes;

for (int i=0; i<[listOfFonts count]; i++) {
    NSLog(@"Font Family: %@", [listOfFonts objectAtIndex:i]);
    subFontTypes = [[NSArray alloc] initWithArray:[UIFont fontNamesForFamilyName:[listOfFonts objectAtIndex:i]]];
    for (int j=0; j<[subFontTypes count]; j++) {
        NSLog(@"+----->Type: %@", [subFontTypes objectAtIndex:j]);
    }
    [subFontTypes release];
}
[listOfFonts release];

Con le SDK 2.2.1, sul mio simulatore, ho ottenuto:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
Font Family: Courier
+----->Type: Courier
+----->Type: Courier-BoldOblique
+----->Type: Courier-Oblique
+----->Type: Courier-Bold
Font Family: AppleGothic
+----->Type: AppleGothic
Font Family: Arial
+----->Type: ArialMT
+----->Type: Arial-BoldMT
+----->Type: Arial-BoldItalicMT
+----->Type: Arial-ItalicMT
Font Family: STHeiti TC
+----->Type: STHeitiTC-Light
+----->Type: STHeitiTC-Medium
Font Family: Hiragino Kaku Gothic ProN
+----->Type: HiraKakuProN-W6
+----->Type: HiraKakuProN-W3
Font Family: Courier New
+----->Type: CourierNewPS-BoldMT
+----->Type: CourierNewPS-ItalicMT
+----->Type: CourierNewPS-BoldItalicMT
+----->Type: CourierNewPSMT
Font Family: Zapfino
+----->Type: Zapfino
Font Family: Arial Unicode MS
+----->Type: ArialUnicodeMS
Font Family: STHeiti SC
+----->Type: STHeitiSC-Medium
+----->Type: STHeitiSC-Light
Font Family: American Typewriter
+----->Type: AmericanTypewriter
+----->Type: AmericanTypewriter-Bold
Font Family: Helvetica
+----->Type: Helvetica-Oblique
+----->Type: Helvetica-BoldOblique
+----->Type: Helvetica
+----->Type: Helvetica-Bold
Font Family: Marker Felt
+----->Type: MarkerFelt-Thin
Font Family: Helvetica Neue
+----->Type: HelveticaNeue
+----->Type: HelveticaNeue-Bold
Font Family: DB LCD Temp
+----->Type: DBLCDTempBlack
Font Family: Verdana
+----->Type: Verdana-Bold
+----->Type: Verdana-BoldItalic
+----->Type: Verdana
+----->Type: Verdana-Italic
Font Family: Times New Roman
+----->Type: TimesNewRomanPSMT
+----->Type: TimesNewRomanPS-BoldMT
+----->Type: TimesNewRomanPS-BoldItalicMT
+----->Type: TimesNewRomanPS-ItalicMT
Font Family: Georgia
+----->Type: Georgia-Bold
+----->Type: Georgia
+----->Type: Georgia-BoldItalic
+----->Type: Georgia-Italic
Font Family: STHeiti J
+----->Type: STHeitiJ-Medium
+----->Type: STHeitiJ-Light
Font Family: Arial Rounded MT Bold
+----->Type: ArialRoundedMTBold
Font Family: Trebuchet MS
+----->Type: TrebuchetMS-Italic
+----->Type: TrebuchetMS
+----->Type: Trebuchet-BoldItalic
+----->Type: TrebuchetMS-Bold
Font Family: STHeiti K
+----->Type: STHeitiK-Medium
+----->Type: STHeitiK-Light

Continua...


Stop SOPA