高円寺で働くIT社長の細かくない日記

XcodeのUIFontで指定できるフォント一覧(日本語付き)

↓こちらでも紹介されているのですが、日本語がなかったのでxcodeで実装して見た。

http://iphone-dev.g.hatena.ne.jp/tokorom/20090912/1252769688

 

A

f:id:TamaC:20120913175930p:plain

A-B

f:id:TamaC:20120913175933p:plain

B-C

f:id:TamaC:20120913175939p:plain

C-E

f:id:TamaC:20120913175948p:plain

F-G

f:id:TamaC:20120913175953p:plain

G-H

f:id:TamaC:20120913175958p:plain

H-K

f:id:TamaC:20120913180004p:plain

M-O

f:id:TamaC:20120913180034p:plain

P-T

f:id:TamaC:20120913180045p:plain

T-Z

f:id:TamaC:20120913180341p:plain

 

以下、実装メモ

※storyboardでTableViewを入れ、Controllerをつなげています。

 ・TestViewController.h

#import <UIKit/UIKit.h>

@interface TestViewController : UITableViewController <UITableViewDataSource>

@property (weak, nonatomic) IBOutlet UITableView *testTable;
@property (strong, nonatomic) NSArray *fontList;
@property (strong, nonatomic) NSMutableDictionary *fontNames;
@end

 

 

 ・TestViewController.m

 

 #import "TestViewController.h"

@interface TestViewController ()

@end

@implementation TestViewController
@synthesize testTable;
@synthesize fontList;
@synthesize fontNames;

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    // Do any additional setup after loading the view, typically from a nib.
    self.fontNames = [NSMutableDictionary dictionary];
    self.fontList = [[UIFont familyNames] sortedArrayUsingSelector:@selector(compare:)];
    for (int i = 0; i < [fontList count]; i++) {
        // oya
        NSString *fontName = [fontList objectAtIndex:i];
        
        NSArray *childFonts = [[UIFont fontNamesForFamilyName:fontName] sortedArrayUsingSelector:@selector(compare:)];
        [self.fontNames setObject:childFonts forKey:[NSNumber numberWithInt:i]];
    }
    // フォント一覧をログ出力    NSLog(@"%@", self.fontList);
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
        return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
    } else {
        return YES;
    }
}

// セクション数を返す
-(NSInteger)numberOfSectionsInTableView:
(UITableView *)tableView {
    NSLog(@"section=%d", self.fontList.count);
    return self.fontList.count;
}

// 各セクションのタイトルを返す
-(NSString *)tableView:
(UITableView *)tableView
titleForHeaderInSection:(NSInteger)section {
    return [fontList objectAtIndex:section];
}

// セクションに含まれるセル数を返す
-(NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section {
    return self.fontNames objectForKey:[NSNumber numberWithInt:section count];
}

// セルの内容を返す
-(UITableViewCell *)tableView:
(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
    
    NSString *cellFontName = self.fontNames objectForKey:[NSNumber numberWithInt:indexPath.section objectAtIndex:indexPath.row];
    cell.textLabel.text = [NSString stringWithFormat: @"あいう漢字カタカナ123123ABCabc (%@)", cellFontName];
    cell.textLabel.font = [UIFont fontWithName:cellFontName size:16];
    return cell;
}


@end

Mountain Lionでmakeやらsvnやら使えなくなった場合

$ make
-bash: make: command not found

 

おや....?

MacOSでmakeやら使えなくなってしまった。

 

どうやらLionの中盤あたりからシステム開発に使われるようなコマンドはデフォルトでインストールされなくなったぽいですね。

(少なくとも2011年10月頃にLion導入したときはデフォルトで入ってたはず)

 

[解決]

XcodeからCommand Line ToolsをインストールすればOK。

Xcode → Preferences → Downloads → Command Line Toolsをインストール

f:id:TamaC:20120727130418p:plain