Skip to content

Commit

Permalink
Added support for hd-based fonts.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Drzimotta committed Jul 25, 2011
1 parent 0fa2a55 commit 7a30fa8
Show file tree
Hide file tree
Showing 8 changed files with 209 additions and 195 deletions.
Binary file removed .DS_Store
Binary file not shown.
6 changes: 3 additions & 3 deletions Classes/TextBoxLayer.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ - (id) initWithColor:(ccColor4B)color width:(GLfloat)w height:(GLfloat)h padding
currentPageIndex = 0;

CCBMFontConfiguration *conf = FNTConfigLoadFile(TEXT_FONT_FILE);
linesPerPage = h / conf->commonHeight_;
linesPerPage = h / conf->commonHeight_ * [CCDirector sharedDirector].contentScaleFactor;

NSArray *words = [txt componentsSeparatedByString:@" "];

Expand Down Expand Up @@ -125,7 +125,7 @@ - (int)calculateStringSize:(NSString *)txt {

int totalSize = 0;

for (int i = 0; i < [txt length]; i++) {
for (int i = 0; i < [txt length] / [CCDirector sharedDirector].contentScaleFactor; i++) {

int c = [txt characterAtIndex:i];
ccBMFontDef def = conf->BMFontArray_[c];
Expand Down Expand Up @@ -163,7 +163,7 @@ -(void) ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {

if (!ended) {
ended = YES;

if ([delegate respondsToSelector:@selector(textBox:didFinishAllTextWithPageCount:)]) {
[delegate textBox:self didFinishAllTextWithPageCount:totalPages];
}
Expand Down
6 changes: 3 additions & 3 deletions Classes/TextBoxLayerSampleAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ - (void) applicationDidFinishLaunching:(UIApplication*)application
// attach the openglView to the director
[director setOpenGLView:glView];

// // Enables High Res mode (Retina Display) on iPhone 4 and maintains low res on all other devices
// if( ! [director enableRetinaDisplay:YES] )
// CCLOG(@"Retina Display Not supported");
// Enables High Res mode (Retina Display) on iPhone 4 and maintains low res on all other devices
if( ! [director enableRetinaDisplay:YES] )
CCLOG(@"Retina Display Not supported");

//
// VERY IMPORTANT:
Expand Down
99 changes: 99 additions & 0 deletions Resources/arial16-hd.fnt
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
info face="ArialMT" size=32 bold=0 italic=0 charset="" unicode=0 stretchH=100 smooth=1 aa=1 padding=0,0,0,0 spacing=1,1
common lineHeight=37 base=29 scaleW=512 scaleH=512 pages=1 packed=0
page id=0 file="arial16-hd.png"
chars count=94
char id=32 x=0 y=0 width=0 height=0 xoffset=0 yoffset=29 xadvance=9 page=0 chnl=0
char id=64 x=0 y=0 width=32 height=32 xoffset=2 yoffset=5 xadvance=32 page=0 chnl=0
char id=124 x=32 y=0 width=5 height=32 xoffset=3 yoffset=5 xadvance=8 page=0 chnl=0
char id=125 x=37 y=0 width=11 height=32 xoffset=1 yoffset=5 xadvance=11 page=0 chnl=0
char id=123 x=48 y=0 width=11 height=32 xoffset=1 yoffset=5 xadvance=11 page=0 chnl=0
char id=41 x=59 y=0 width=10 height=32 xoffset=2 yoffset=5 xadvance=11 page=0 chnl=0
char id=40 x=69 y=0 width=10 height=32 xoffset=2 yoffset=5 xadvance=11 page=0 chnl=0
char id=36 x=79 y=0 width=17 height=31 xoffset=1 yoffset=3 xadvance=18 page=0 chnl=0
char id=93 x=96 y=0 width=8 height=31 xoffset=1 yoffset=6 xadvance=9 page=0 chnl=0
char id=91 x=104 y=0 width=8 height=31 xoffset=2 yoffset=6 xadvance=9 page=0 chnl=0
char id=106 x=112 y=0 width=9 height=31 xoffset=-1 yoffset=6 xadvance=7 page=0 chnl=0
char id=81 x=121 y=0 width=24 height=27 xoffset=1 yoffset=5 xadvance=25 page=0 chnl=0
char id=38 x=145 y=0 width=21 height=26 xoffset=1 yoffset=5 xadvance=21 page=0 chnl=0
char id=35 x=166 y=0 width=19 height=26 xoffset=0 yoffset=5 xadvance=18 page=0 chnl=0
char id=37 x=185 y=0 width=27 height=26 xoffset=2 yoffset=5 xadvance=28 page=0 chnl=0
char id=92 x=212 y=0 width=10 height=26 xoffset=0 yoffset=5 xadvance=9 page=0 chnl=0
char id=47 x=222 y=0 width=10 height=26 xoffset=0 yoffset=5 xadvance=9 page=0 chnl=0
char id=83 x=232 y=0 width=20 height=26 xoffset=1 yoffset=5 xadvance=21 page=0 chnl=0
char id=79 x=252 y=0 width=24 height=26 xoffset=2 yoffset=5 xadvance=25 page=0 chnl=0
char id=71 x=276 y=0 width=23 height=26 xoffset=2 yoffset=5 xadvance=25 page=0 chnl=0
char id=67 x=299 y=0 width=22 height=26 xoffset=2 yoffset=5 xadvance=23 page=0 chnl=0
char id=63 x=321 y=0 width=17 height=25 xoffset=1 yoffset=5 xadvance=18 page=0 chnl=0
char id=48 x=338 y=0 width=17 height=25 xoffset=1 yoffset=6 xadvance=18 page=0 chnl=0
char id=57 x=355 y=0 width=17 height=25 xoffset=1 yoffset=6 xadvance=18 page=0 chnl=0
char id=56 x=372 y=0 width=17 height=25 xoffset=1 yoffset=6 xadvance=18 page=0 chnl=0
char id=54 x=389 y=0 width=17 height=25 xoffset=1 yoffset=6 xadvance=18 page=0 chnl=0
char id=53 x=406 y=0 width=17 height=25 xoffset=1 yoffset=6 xadvance=18 page=0 chnl=0
char id=51 x=423 y=0 width=17 height=25 xoffset=1 yoffset=6 xadvance=18 page=0 chnl=0
char id=121 x=440 y=0 width=17 height=25 xoffset=1 yoffset=12 xadvance=16 page=0 chnl=0
char id=116 x=457 y=0 width=10 height=25 xoffset=1 yoffset=6 xadvance=9 page=0 chnl=0
char id=113 x=467 y=0 width=16 height=25 xoffset=1 yoffset=12 xadvance=18 page=0 chnl=0
char id=112 x=483 y=0 width=16 height=25 xoffset=2 yoffset=12 xadvance=18 page=0 chnl=0
char id=103 x=0 y=32 width=16 height=25 xoffset=1 yoffset=12 xadvance=18 page=0 chnl=0
char id=102 x=16 y=32 width=12 height=25 xoffset=0 yoffset=5 xadvance=9 page=0 chnl=0
char id=100 x=28 y=32 width=16 height=25 xoffset=1 yoffset=6 xadvance=18 page=0 chnl=0
char id=98 x=44 y=32 width=16 height=25 xoffset=2 yoffset=6 xadvance=18 page=0 chnl=0
char id=85 x=60 y=32 width=20 height=25 xoffset=3 yoffset=6 xadvance=23 page=0 chnl=0
char id=74 x=80 y=32 width=15 height=25 xoffset=1 yoffset=6 xadvance=16 page=0 chnl=0
char id=33 x=95 y=32 width=6 height=24 xoffset=3 yoffset=6 xadvance=9 page=0 chnl=0
char id=55 x=101 y=32 width=17 height=24 xoffset=2 yoffset=6 xadvance=18 page=0 chnl=0
char id=52 x=118 y=32 width=18 height=24 xoffset=0 yoffset=6 xadvance=18 page=0 chnl=0
char id=50 x=136 y=32 width=18 height=24 xoffset=1 yoffset=6 xadvance=18 page=0 chnl=0
char id=49 x=154 y=32 width=10 height=24 xoffset=3 yoffset=6 xadvance=18 page=0 chnl=0
char id=108 x=164 y=32 width=4 height=24 xoffset=2 yoffset=6 xadvance=7 page=0 chnl=0
char id=107 x=168 y=32 width=15 height=24 xoffset=2 yoffset=6 xadvance=16 page=0 chnl=0
char id=105 x=183 y=32 width=4 height=24 xoffset=2 yoffset=6 xadvance=7 page=0 chnl=0
char id=104 x=187 y=32 width=15 height=24 xoffset=2 yoffset=6 xadvance=18 page=0 chnl=0
char id=90 x=202 y=32 width=20 height=24 xoffset=1 yoffset=6 xadvance=20 page=0 chnl=0
char id=89 x=222 y=32 width=23 height=24 xoffset=0 yoffset=6 xadvance=21 page=0 chnl=0
char id=88 x=245 y=32 width=23 height=24 xoffset=0 yoffset=6 xadvance=21 page=0 chnl=0
char id=87 x=268 y=32 width=31 height=24 xoffset=0 yoffset=6 xadvance=30 page=0 chnl=0
char id=86 x=299 y=32 width=23 height=24 xoffset=0 yoffset=6 xadvance=21 page=0 chnl=0
char id=84 x=322 y=32 width=20 height=24 xoffset=1 yoffset=6 xadvance=20 page=0 chnl=0
char id=82 x=342 y=32 width=22 height=24 xoffset=3 yoffset=6 xadvance=23 page=0 chnl=0
char id=80 x=364 y=32 width=19 height=24 xoffset=2 yoffset=6 xadvance=21 page=0 chnl=0
char id=78 x=383 y=32 width=20 height=24 xoffset=2 yoffset=6 xadvance=23 page=0 chnl=0
char id=77 x=403 y=32 width=24 height=24 xoffset=2 yoffset=6 xadvance=27 page=0 chnl=0
char id=76 x=427 y=32 width=16 height=24 xoffset=2 yoffset=6 xadvance=18 page=0 chnl=0
char id=75 x=443 y=32 width=21 height=24 xoffset=2 yoffset=6 xadvance=21 page=0 chnl=0
char id=73 x=464 y=32 width=6 height=24 xoffset=3 yoffset=6 xadvance=9 page=0 chnl=0
char id=72 x=470 y=32 width=20 height=24 xoffset=3 yoffset=6 xadvance=23 page=0 chnl=0
char id=70 x=490 y=32 width=18 height=24 xoffset=3 yoffset=6 xadvance=20 page=0 chnl=0
char id=69 x=0 y=57 width=19 height=24 xoffset=3 yoffset=6 xadvance=21 page=0 chnl=0
char id=68 x=19 y=57 width=21 height=24 xoffset=2 yoffset=6 xadvance=23 page=0 chnl=0
char id=66 x=40 y=57 width=19 height=24 xoffset=2 yoffset=6 xadvance=21 page=0 chnl=0
char id=65 x=59 y=57 width=24 height=24 xoffset=0 yoffset=6 xadvance=21 page=0 chnl=0
char id=59 x=83 y=57 width=6 height=23 xoffset=3 yoffset=12 xadvance=9 page=0 chnl=0
char id=117 x=89 y=57 width=15 height=19 xoffset=2 yoffset=12 xadvance=18 page=0 chnl=0
char id=115 x=104 y=57 width=16 height=19 xoffset=1 yoffset=12 xadvance=16 page=0 chnl=0
char id=111 x=120 y=57 width=17 height=19 xoffset=1 yoffset=12 xadvance=18 page=0 chnl=0
char id=101 x=137 y=57 width=17 height=19 xoffset=1 yoffset=12 xadvance=18 page=0 chnl=0
char id=99 x=154 y=57 width=16 height=19 xoffset=1 yoffset=12 xadvance=16 page=0 chnl=0
char id=97 x=170 y=57 width=17 height=19 xoffset=1 yoffset=12 xadvance=18 page=0 chnl=0
char id=62 x=187 y=57 width=17 height=18 xoffset=2 yoffset=9 xadvance=19 page=0 chnl=0
char id=60 x=204 y=57 width=17 height=18 xoffset=2 yoffset=9 xadvance=19 page=0 chnl=0
char id=58 x=221 y=57 width=6 height=18 xoffset=3 yoffset=12 xadvance=9 page=0 chnl=0
char id=122 x=227 y=57 width=17 height=18 xoffset=1 yoffset=12 xadvance=16 page=0 chnl=0
char id=120 x=244 y=57 width=17 height=18 xoffset=0 yoffset=12 xadvance=16 page=0 chnl=0
char id=119 x=261 y=57 width=24 height=18 xoffset=0 yoffset=12 xadvance=23 page=0 chnl=0
char id=118 x=285 y=57 width=17 height=18 xoffset=0 yoffset=12 xadvance=16 page=0 chnl=0
char id=114 x=302 y=57 width=11 height=18 xoffset=2 yoffset=12 xadvance=11 page=0 chnl=0
char id=110 x=313 y=57 width=15 height=18 xoffset=2 yoffset=12 xadvance=18 page=0 chnl=0
char id=109 x=328 y=57 width=24 height=18 xoffset=2 yoffset=12 xadvance=27 page=0 chnl=0
char id=43 x=352 y=57 width=17 height=17 xoffset=2 yoffset=10 xadvance=19 page=0 chnl=0
char id=94 x=369 y=57 width=16 height=15 xoffset=1 yoffset=5 xadvance=15 page=0 chnl=0
char id=42 x=385 y=57 width=12 height=12 xoffset=1 yoffset=5 xadvance=12 page=0 chnl=0
char id=61 x=397 y=57 width=17 height=12 xoffset=2 yoffset=12 xadvance=19 page=0 chnl=0
char id=44 x=414 y=57 width=6 height=10 xoffset=3 yoffset=25 xadvance=9 page=0 chnl=0
char id=39 x=420 y=57 width=5 height=10 xoffset=1 yoffset=6 xadvance=6 page=0 chnl=0
char id=34 x=425 y=57 width=10 height=10 xoffset=1 yoffset=6 xadvance=11 page=0 chnl=0
char id=126 x=435 y=57 width=18 height=7 xoffset=1 yoffset=15 xadvance=19 page=0 chnl=0
char id=96 x=453 y=57 width=8 height=7 xoffset=1 yoffset=5 xadvance=11 page=0 chnl=0
char id=45 x=461 y=57 width=10 height=5 xoffset=1 yoffset=19 xadvance=11 page=0 chnl=0
char id=46 x=471 y=57 width=6 height=5 xoffset=3 yoffset=25 xadvance=9 page=0 chnl=0
char id=95 x=477 y=57 width=21 height=4 xoffset=0 yoffset=33 xadvance=18 page=0 chnl=0
Binary file added Resources/arial16-hd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 7a30fa8

Please sign in to comment.