Friends,
I am trying to build a simple iphone application to view a local webpage that uses dynamic fonts. The url is www.eenadu.net.
I have just a single view based application and inserted a webview into the view and implementing the webviewdelegate in viewcontroller. The site uses ttf/eot fonts that are dynamically downloadable by browser from http://www.eenadu.net/eenadu.ttf or http://www.eenadu.net/EENADU0.eot.
Here is what I am doing in the code by doing some research:
Code:
( void ) loadFont {
NSString *fontPath = [[NSBundle mainBundle] pathForResource:@"eenadu" ofType:@"ttf"];
CGDataProviderRef fontDataProvider = CGDataProviderCreateWithFilename([fontPath UTF8String]);
// Create the font with the data provider, then release the data provider. customFont =
CGFontCreateWithDataProvider(fontDataProvider);
CGDataProviderRelease(fontDataProvider);
fontPath = [[NSBundle mainBundle] pathForResource:@"eenadu" ofType:@"eot"];
fontDataProvider = CGDataProviderCreateWithFilename([fontPath UTF8String]);
// Create the font with the data provider, then release the data provider. customFont =
CGFontCreateWithDataProvider(fontDataProvider);
CGDataProviderRelease(fontDataProvider);
}
(void) viewDidLoad {
[super viewDidLoad];
[self loadFont];
[webView setBackgroundColor:[UIColor whiteColor]];
NSString *urlAddress = @"http://www.eenadu.net/";
NSURL *url = [NSURL URLWithString:urlAddress];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[webView loadRequest:requestObj];
}
I see that the page loads however doesn't display the font. Please help.
Also, For loadFont, I have included the fonts in the build with right names and took care of the case as well.