@Matt, when testing on the iPad simulator, the flag isHD is "NO", because the model name is "iPhone simulator" and doesn't include the "iPad". Have you tested on a real iPad ?
I've managed to make the BitmapFont works but I'm not sur if it's really clean.
My approach is to create a 16 pixel and 32 pixel fonts.
I've added the following macro in the highRes.h :
#define GetFontFNT16(__fileName__) (([[CCDirector sharedDirector] contentScaleFactor] == 2) ? [NSString stringWithFormat:@"%@32.fnt",__fileName__] : [NSString stringWithFormat:@"%@16.fnt",__fileName__])
Then I call the label creation like this :
CCLabelBMFont *label = [CCLabelBMFont labelWithString:@"click to proceed" fntFile:GetFontFNT16(@"silom")];
label.position = ccp(s.width/2, s.height-30);
[self addChild:label];
The part that is not totally clean is the modif in the CCLabelBMFont.m file. I had to modify the createFontChars method, I've added createFontCharsHD method that basically divides all the coordinates of the configuration file by 2.
-(void) createFontCharsHD {
int nextFontPositionX = 0;
int nextFontPositionY = 0;
unichar prev = -1;
int kerningAmount = 0;
CGSize tmpSize = CGSizeZero;
int longestLine = 0;
int totalHeight = 0;
int quantityOfLines = 1;
int stringLen = [string_ length];
// quantity of lines NEEDS to be calculated before parsing the lines,
// since the Y position needs to be calcualted before hand
for( int i=0; i < stringLen-1;i++) {
unichar c = [string_ characterAtIndex:i];
if( c=='\n')
quantityOfLines++;
}
totalHeight = configuration_->commonHeight * quantityOfLines;
nextFontPositionY = -(configuration_->commonHeight - configuration_->commonHeight*quantityOfLines);
for(unsigned int i=0; i<stringLen; i++) {
unichar c = [string_ characterAtIndex:i];
NSAssert( c < kCCBMFontMaxChars, @"BitmapFontAtlas: character outside bounds");
if (c == '\n') {
nextFontPositionX = 0;
nextFontPositionY -= configuration_->commonHeight;
continue;
}
kerningAmount = [self kerningAmountForFirst:prev second:c];
ccBMFontDef fontDef = configuration_->BMFontArray[c];
fontDef.rect.origin.x/=2;
fontDef.rect.origin.y/=2;
fontDef.rect.size.width/=2;
fontDef.rect.size.height/=2;
fontDef.xOffset/=2;
fontDef.yOffset/=2;
fontDef.xAdvance/=2;
kerningAmount/=2;
CGRect rect = fontDef.rect;
CCSprite *fontChar;
fontChar = (CCSprite*) [self getChildByTag:i];
if( ! fontChar ) {
fontChar = [[CCSprite alloc] initWithBatchNode:self rect:rect];
[self addChild:fontChar z:0 tag:i];
[fontChar release];
}
else {
// reusing fonts
[fontChar setTextureRect:rect];
// restore to default in case they were modified
fontChar.visible = YES;
fontChar.opacity = 255;
}
float yOffset = configuration_->commonHeight - fontDef.yOffset;
fontChar.position = ccp( (float)nextFontPositionX + fontDef.xOffset + fontDef.rect.size.width*0.5f + kerningAmount,
(float)nextFontPositionY + yOffset - rect.size.height*0.5f );
// NSLog(@"position.y: %f", fontChar.position.y);
// update kerning
nextFontPositionX += configuration_->BMFontArray[c].xAdvance/2 + kerningAmount;
prev = c;
// Apply label properties
[fontChar setOpacityModifyRGB:opacityModifyRGB_];
// Color MUST be set before opacity, since opacity might change color if OpacityModifyRGB is on
[fontChar setColor:color_];
// only apply opacity if it is different than 255 )
// to prevent modifying the color too (issue #610)
if( opacity_ != 255 )
[fontChar setOpacity: opacity_];
if (longestLine < nextFontPositionX)
longestLine = nextFontPositionX;
}
tmpSize.width = longestLine;
tmpSize.height = totalHeight;
[self setContentSize:tmpSize];
}
Then you just need to modify createfontChars method like this (createFontCharsSD being the previous version of createFontChars) :
-(void)createFontChars {
if([[CCDirector sharedDirector] contentScaleFactor] == 2) {
[self createFontCharsHD];
} else {
[self createFontCharsSD];
}
}