macOS/iOS API解説

iOS , Mac アプリケーション開発のために使われる主要フレームワークの日本語情報です。2010年代に書かれた内容です。今後更新はありません。

目次

boundingRectForGlyph:

グリフのバウンディングボックスを返します
-(NSRect)boundingRectForGlyph:(NSGlyph)aGlyph:

解説

指定したグリフ(aGlyph)のバウンディングボックスを返します。

返り値

( NSRect )

矩形

引数

( NSGlyph )aGlyph

グリフ

フレームワーク

ApplicationKit

クラス

NSFont

Instance Methods

使用可能

10.0

参照

- boundingRectForFont

例文

#import "MyView.h"

//MyViewはNSViewのサブクラス
@implementation MyView

-(void)drawRect:(NSRect)rect
{

	NSFont *font =[NSFont boldSystemFontOfSize:50.0];
	NSLog([font fontName]);
	NSBezierPath *thePath = [NSBezierPath bezierPath];
	NSGlyph glyphID[11]={43,72,79,79,82,04,58,82,85,79,71};
			
			[thePath moveToPoint:NSMakePoint(10,10)];
			[thePath appendBezierPathWithGlyphs:&glyphID[0]
										count:11
										inFont:font
											];
			[[NSColor blueColor] set];
			[thePath fill];
			
			NSRect glyphRect = [font boundingRectForGlyph:glyphID[0]];
			NSLog(@"%f,%f-%f,%f",glyphRect.origin.x,glyphRect.origin.y,glyphRect.size.width,glyphRect.size.height);			
}

@end