character size from image file.

git-svn-id: svn://qnap.local/TwoTerm/trunk@2005 5590a31f-7b70-45f8-8c82-aa3a8e5f4507
This commit is contained in:
Kelvin Sherlock 2011-01-22 18:28:20 +00:00
parent 04d96f94ce
commit 1396edfad4
2 changed files with 14 additions and 1 deletions

View File

@ -18,6 +18,7 @@
+(CharacterGenerator *)generator;
@property (nonatomic, readonly) NSSize characterSize;
-(NSImage *)imageForCharacter: (unsigned)character;

View File

@ -12,6 +12,8 @@
@implementation CharacterGenerator
@synthesize characterSize = _size;
static CGImageRef PNGImage(NSString *path)
{
CGImageRef image = NULL;
@ -45,11 +47,13 @@ static CGImageRef PNGImage(NSString *path)
CGImageRef mask;
CGImageRef src;
NSSize size;
mainBundle = [NSBundle mainBundle];
imagePath = [mainBundle pathForResource: @"a2-charset-80" ofType: @"png"];
//imagePath = [mainBundle pathForResource: @"a2-charset-80" ofType: @"png"];
imagePath = [mainBundle pathForResource: @"vt100-charset" ofType: @"png"];
@ -59,6 +63,14 @@ static CGImageRef PNGImage(NSString *path)
src = PNGImage(imagePath);
size.width = CGImageGetWidth(src);
size.height = CGImageGetHeight(src);
size.width /= 16;
size.height /= 16;
_size = size;
if (src)
{
mask = CGImageMaskCreate(CGImageGetWidth(src),