tag:blogger.com,1999:blog-3911337215074644290.post5636737894758116222..comments2023-05-01T03:18:39.575-06:00Comments on UI Hacker - Code for Fun: iPhone: Custom font loading : complete examplejustinhttp://www.blogger.com/profile/06696548898804101545noreply@blogger.comBlogger30125tag:blogger.com,1999:blog-3911337215074644290.post-34184595371583260712012-01-25T07:57:09.226-07:002012-01-25T07:57:09.226-07:00Great Classes very helpful, especially for portabi...Great Classes very helpful, especially for portability.<br /><br />If people are loading the text to screen via viewDidLoad method use this:<br />[self.view addSubview:myTitle];<br /><br />Instead of:<br />[self addSubview:myTitle];<br /><br />Hope that helps some newbie programmers.<br /><br />Nome Skavinski.Nome Skavinskihttps://www.blogger.com/profile/14051167325397767354noreply@blogger.comtag:blogger.com,1999:blog-3911337215074644290.post-12568915731209748572011-11-12T20:46:31.075-07:002011-11-12T20:46:31.075-07:00Hi Justin ,
i want to use custom fonts with UITe...Hi Justin , <br /><br />i want to use custom fonts with UITextView .. Please help ! <br /><br />Thanks<br />YasirYasir Ayazhttps://www.blogger.com/profile/13268542034736127158noreply@blogger.comtag:blogger.com,1999:blog-3911337215074644290.post-58602741838125859642011-03-20T23:34:05.127-06:002011-03-20T23:34:05.127-06:00Hi Justin,
I am trying to use above in project a...Hi Justin,<br /><br />I am trying to use above in project and just added above classes, and then added customfontmyfont view to a viewcontroller, and my controller is not showing it up.. your little help on this would be really appreciated.. thanks a ton..GameOnehttps://www.blogger.com/profile/01074612847875932428noreply@blogger.comtag:blogger.com,1999:blog-3911337215074644290.post-83938301206876919212010-05-04T18:08:18.338-06:002010-05-04T18:08:18.338-06:00It looks like someone has built a far more robust ...It looks like someone has built a far more robust custom font engine than my example here. I haven't tried it yet, but the example project looks great: http://github.com/zynga/FontLabel<br /><br />Thanks to all who have used my code, and sorry for not replying to all the questions.justinhttps://www.blogger.com/profile/06696548898804101545noreply@blogger.comtag:blogger.com,1999:blog-3911337215074644290.post-32382926843394737332010-04-25T01:16:17.761-06:002010-04-25T01:16:17.761-06:00Great helpful code!
But I'm stuck trying to r...Great helpful code!<br /><br />But I'm stuck trying to right align the text. Could anyone please point it out please????dhomeshttps://www.blogger.com/profile/18149581578943955228noreply@blogger.comtag:blogger.com,1999:blog-3911337215074644290.post-14056129522633079452010-02-20T18:22:45.853-07:002010-02-20T18:22:45.853-07:00any good tool to find the glyh offset ?any good tool to find the glyh offset ?BiBeephttps://www.blogger.com/profile/05177325651069408512noreply@blogger.comtag:blogger.com,1999:blog-3911337215074644290.post-26943413601407680542010-02-06T08:44:15.426-07:002010-02-06T08:44:15.426-07:00how could i use it for UIWebview's default fon...how could i use it for UIWebview's default font?Unknownhttps://www.blogger.com/profile/16399115079403312655noreply@blogger.comtag:blogger.com,1999:blog-3911337215074644290.post-10794138281531818802010-01-29T03:20:09.193-07:002010-01-29T03:20:09.193-07:00Justin, this is great. I am not a programmer but a...Justin, this is great. I am not a programmer but a font developer. Would you be interested to talk about bringing our fonts to iPhone? Please write me at peter at typotheque dot comptrblkhttps://www.blogger.com/profile/01582444029974371430noreply@blogger.comtag:blogger.com,1999:blog-3911337215074644290.post-37531354513975434432009-12-06T01:30:16.914-07:002009-12-06T01:30:16.914-07:00I wanted to have custom fonts, cause I habe Chines...I wanted to have custom fonts, cause I habe Chinese text and I wanted nice chinese signs (like when you draw with a brush).<br />But it seems that it doesn't work with chinese fonts. Maybe you know why? I want to print this f.e.: 你<br />And I would like to use a font like HDZB_36.TTF (first result in google)Unknownhttps://www.blogger.com/profile/11428986373721780341noreply@blogger.comtag:blogger.com,1999:blog-3911337215074644290.post-18976424275474058522009-12-03T11:59:21.827-07:002009-12-03T11:59:21.827-07:00I am using the code exactly as presented, but gett...I am using the code exactly as presented, but getting a leak on this line in initWithFrame:<br /><br />[self setCurText: [[NSMutableString alloc] initWithString:@""] ];<br /><br />By doing "Build and Analyze" I get this report:<br />"Potential leak of an object on line 26" (the setCurText line above is line 26)<br /><br />Anyone else see this? Any fixes that can correct it?<br /><br />Thanks!Unknownhttps://www.blogger.com/profile/16771574742830740583noreply@blogger.comtag:blogger.com,1999:blog-3911337215074644290.post-12164920282838207952009-10-21T14:25:52.621-06:002009-10-21T14:25:52.621-06:00So I wast using this code got most stuff to work, ...So I wast using this code got most stuff to work, cept when I try to use say<br /><br />[myLabel initTextWithSize:11 color:[UIColor colorWithRed:...] bgColor:[UIColor colorWithRed:...]<br /><br />I'm not really sure why not? I've changed the CGSetContextFillWithColor method in the CustomFontMyFont class too specify a [UIColor ..].CGColor and that works, but don't know why I can't pass it through initWithText?Unknownhttps://www.blogger.com/profile/05453658758035144791noreply@blogger.comtag:blogger.com,1999:blog-3911337215074644290.post-33562685974578812142009-10-07T02:21:03.455-06:002009-10-07T02:21:03.455-06:00if i use in a for cycle:
[myLabel updateText:[my_...if i use in a for cycle:<br /><br />[myLabel updateText:[my_array objectAtIndex:i]];<br /><br />The label return not a string but a number<br /><br />myArray = [[NSArray alloc] initWithObjects:<br /> @"111",<br /> @"222",<br /> @"333",<br /> @"444",<br /> @"555",<br /> nil];<br /><br />Return<br />001,002,003,004,005<br />Why?<br />Any solution?<br />Thz.Unknownhttps://www.blogger.com/profile/06640117996750953747noreply@blogger.comtag:blogger.com,1999:blog-3911337215074644290.post-38918230923857058552009-08-21T12:05:22.122-06:002009-08-21T12:05:22.122-06:00This code works fine if you only need ASCII, no un...This code works fine if you only need ASCII, no unicode or extended characters. For a unicode solution that's mostly similar except that it reads the font's cmap to find the glyphs, registered developers should consult this thread <br /><br />https://devforums.apple.com/message/113783Scotthttps://www.blogger.com/profile/05660438646665553790noreply@blogger.comtag:blogger.com,1999:blog-3911337215074644290.post-9717265073783076592009-08-20T09:07:05.414-06:002009-08-20T09:07:05.414-06:00Hey This class is great, seems to work fine, The o...Hey This class is great, seems to work fine, The only problem I have run into is that when you put the custom font inside of each cell of a table view, it will scroll down fine, but as soon as you scroll the table view up, it crashes with this error. <br /><br />NSInvalidArgumentException, [RootViewController updateText:] unrecognized selector sent to class 0x84a0<br /><br />any ideas? thanks!prestonparrishttps://www.blogger.com/profile/11176985273846902500noreply@blogger.comtag:blogger.com,1999:blog-3911337215074644290.post-34888321214328552302009-07-31T02:17:33.903-06:002009-07-31T02:17:33.903-06:00Thanks!
I found a leaking object in CustomFontBas...Thanks!<br /><br />I found a leaking object in CustomFontBase.m<br /><br />Replace:<br /><br />[self setCurText: [[NSMutableString alloc] initWithString:@""]];<br /><br />with:<br /><br />curText = [[NSMutableString alloc] initWithString:@""];<br /><br />and all should be goodAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-3911337215074644290.post-7695267667518611042009-04-23T20:54:00.000-06:002009-04-23T20:54:00.000-06:00OMG U R00lZ d00dOMG U R00lZ d00dUnknownhttps://www.blogger.com/profile/13466135201559119063noreply@blogger.comtag:blogger.com,1999:blog-3911337215074644290.post-44104835055165909832009-04-19T06:14:00.000-06:002009-04-19T06:14:00.000-06:00Thanks! This solve all of my problems :)Thanks! This solve all of my problems :)dimixhttps://www.blogger.com/profile/07470314451094110221noreply@blogger.comtag:blogger.com,1999:blog-3911337215074644290.post-33289907413045906442009-04-02T16:04:00.000-06:002009-04-02T16:04:00.000-06:00Would you mind looking at my code to see what is w...Would you mind looking at my code to see what is wrong. This still isn't working. The file can be found here: http://cdreich.com/MyCode.html<BR/><BR/>Thank you sooo much for all of your help. I am sorry if I am a bother.Unknownhttps://www.blogger.com/profile/17611401072177083048noreply@blogger.comtag:blogger.com,1999:blog-3911337215074644290.post-82222107845622766002009-04-02T14:54:00.000-06:002009-04-02T14:54:00.000-06:00the Usage code goes in any UIView subclass where y...the Usage code goes in any UIView subclass where you're building a view with code. You need to import your custom font class, then use the Usage code where you're building the view. All the code you need is provided here. take note that I don't use Interface Builder. everything I create is built entirely with code, so if you're using IB, I can't give good advice.justinhttps://www.blogger.com/profile/06696548898804101545noreply@blogger.comtag:blogger.com,1999:blog-3911337215074644290.post-82961725961964486672009-04-02T14:35:00.000-06:002009-04-02T14:35:00.000-06:00That last portion of code that you added, where do...That last portion of code that you added, where does it go? I got everything else done and it returns a blank screen. I assume that that last part is the part that actually does stuff. Would you consider emailing the files? If not, I understand but I have been searching for how to do this FOREVER and can't get it to work. Thanks!Unknownhttps://www.blogger.com/profile/17611401072177083048noreply@blogger.comtag:blogger.com,1999:blog-3911337215074644290.post-37298083107638785362009-03-16T14:02:00.000-06:002009-03-16T14:02:00.000-06:00Thanks for the post. It's easier to learn from...Thanks for the post. It's easier to learn from<BR/>code than from documentation.<BR/>I'll return a couple of clues: that declaration<BR/>for the glyphs array needs a constant at compile<BR/>time, not a runtime variable for the array size;<BR/>and that chars array is unused in your example.<BR/>And if you open Font Book, click on Edit>>Special <BR/>Charcters, and select your font, you'll see part<BR/>of the reason for the glyphoffset variable.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3911337215074644290.post-45384304590725907842009-03-09T13:50:00.000-06:002009-03-09T13:50:00.000-06:00You call the autoSizeWidthNow simply by sending th...You call the autoSizeWidthNow simply by sending that message to your new custom font text field:<BR/><BR/>[myLabel autoSizeWidthNow];<BR/><BR/>This will allow you to center or right-align the text as it adjusts the frame of your text field. The only problem is that you can't seem to create a text field and call the autoSizeWidthNow function on the same frame. I had to set up a timer to call autoSizeWidthNow a fraction of a second later, because objective-c doesn't seems to recognize resized UIView frame/bounds dimensions until the next frame. If anyone has any insight into that, I'd be interested to learn. It seems like there should be something like setNeedsDisplay, but for UIView elements, not just the CG drawing layer. Hope that helps explain my code!justinhttps://www.blogger.com/profile/06696548898804101545noreply@blogger.comtag:blogger.com,1999:blog-3911337215074644290.post-47571711733150228512009-03-01T03:07:00.000-07:002009-03-01T03:07:00.000-07:00Oh, and by the way: is it possible to let CG draw ...Oh, and by the way: is it possible to let CG draw centered text?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3911337215074644290.post-29132565100541469482009-03-01T02:59:00.000-07:002009-03-01T02:59:00.000-07:00How do you use the autoSizeWidthNow method?How do you use the autoSizeWidthNow method?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3911337215074644290.post-20290708784774386852009-02-10T15:23:00.000-07:002009-02-10T15:23:00.000-07:00Justin, thanks a lot! You saved my nerves )Justin, thanks a lot! You saved my nerves )k-zahttps://www.blogger.com/profile/04242402740175028440noreply@blogger.com