macOS/iOS API解説

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

目次

advancementForGlyph:

グリフの幅をサイズで返します
-(NSSize)advancementForGlyph:(NSGlyph)aGlyph:

解説

グリフの幅をサイズで返します。
この幅で次の文字へと送られます。横書きの場合は横方向の、縦書きの時は縦方向の値が返されます。

返り値

( NSSize )

グリフのサイズ

引数

( NSGlyph )aGlyph

グリフ

フレームワーク

ApplicationKit

クラス

NSFont

Instance Methods

使用可能

10.0

参照

- boundingRectForGlyph:
- maximumAdvancement

例文

#import "MyView.h"

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

-(void)drawRect:(NSRect)rect
{
	NSFont *font =[NSFont userFontOfSize:180.0];
	NSLog([font fontName]);
	NSBezierPath *thePath = [NSBezierPath bezierPath];
	NSGlyph glyphID[2]={43,72};
			
			[thePath moveToPoint:NSMakePoint(0,0)];
			[thePath appendBezierPathWithGlyphs:&glyphID[0]
										count:2
										inFont:font
											];
			[[NSColor blueColor] set];
			[thePath fill];
			
			NSSize glyphSize[2];
			
			int i;
			for ( i= 0 ; i < 2 ; i ++){
				glyphSize[i]  = [font advancementForGlyph:glyphID[i]];
				NSLog(@"%f,%f",glyphSize[i].width,glyphSize[i].height);
			}
}

@end