English 中文(简体)
不使用电话装置的习俗
原标题:custom font not working on iphone device

我正试图把一个外部信tt带进我的SOS项目之一。 ont在 em子里进行罚款,但没有在实际装置上显示。

我正在使用海委会4.2汇编仪。 在另一个项目中,由Amplus LLVM汇编商3.0,同一字体工程。 我不理解我如何能够确定这一点? 我需要采取哪些步骤与陆地边界核查和视察委员会4.2汇编者合作?

最佳回答

下面的“习俗”帮助

UILabel *label1 = [[UILabel alloc] initWithFrame:CGRectMake(10, 30, 240, 40)];
[label1 setFont: [UIFont fontWithName: @"Grinched" size:24]];
[label1 setText:@"Grinched Font"];
[[self view] addSubview:label1];

UILabel *label2 = [[UILabel alloc] initWithFrame:CGRectMake(10, 80, 240, 40)];
[label2 setFont: [UIFont fontWithName: @"Energon" size:18]];
[label2 setText:@"Energon Font"];
[[self view] addSubview:label2];

http://sugartin.info/07/25/load-and-access-custom-fonts/“rel=“nofollow”>。

问题回答

保证在目标——“和”下添加; 建设阶段——和; 制版Bundle Resources。 我也存在同样的问题,通过人工添加这一清单,老板开始在装置上展示。

You have a limited choice regarding fonts, so you have to choose between the fonts available...

This answer is useful as a reference: What fonts do iPhone applications support?

第一负荷如下:

(void)loadFont{ // Get the path to our custom font and create a data provider.

  NSString *fontPath = [[NSBundle mainBundle] pathForResource:@"mycustomfont" ofType:@"ttf"];

  CGDataProviderRef fontDataProvider = CGDataProviderCreateWithFilename([fontPath UTF8String]);

// Create the font with the data provider, then release the data provider. customFont =

  CGFontCreateWithDataProvider(fontDataProvider); CGDataProviderRelease(fontDataProvider);

}

Then use them as below:

-(void)drawRect:(CGRect)rect{

  [super drawRect:rect]; // Get the context.

  CGContextRef context = UIGraphicsGetCurrentContext();

  CGContextClearRect(context, rect); // Set the customFont to be the font used to draw.

  CGContextSetFont(context, customFont);

  // Set how the context draws the font, what color, how big.

  CGContextSetTextDrawingMode(context, kCGTextFillStroke); CGContextSetFillColorWithColor(context, self.fontColor.CGColor); UIColor * strokeColor = [UIColor blackColor];

  CGContextSetStrokeColorWithColor(context, strokeColor.CGColor); CGContextSetFontSize(context, 48.0f);

  // Create an array of Glyph s the size of text that will be drawn.

  CGGlyph textToPrint[[self.theText length]];

  // Loop through the entire length of the text.

  for (int i = 0; i < [self.theText length]; ++i) { // Store each letter in a Glyph and subtract the MagicNumber to get appropriate value.

    textToPrint[i] = [[self.theText uppercaseString] characterAtIndex:i] + 3 - 32;

  }

  CGAffineTransform textTransform = CGAffineTransformMake(1.0, 0.0, 0.0, -1.0, 0.0, 0.0);

  CGContextSetTextMatrix(context, textTransform);

  CGContextShowGlyphsAtPoint(context, 20, 50, textToPrint, [self.theText length]);

}

在有些情况下,你可能无法使用一些互联网下载的字体:Here





相关问题
Code sign Error

I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

• 如何将搜查线重新定位?

我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。

热门标签