カスタムフォントを使用してカスタムシンボル(「€」など)を含むテキストを含むPDFページを生成しようとしています。私は、UIGraphicsBeginPDFContextToDataとUIGraphicsBeginPDFPageを使用してPDFコンテキストとページを作成しました。テキストをレンダリングするための私のコードは次のようになります。iOS PDFファイルのQuartz埋め込みフォント
(理由CTFontGetGlyphsForCharactersの)€の-symbolの作品をレンダリングNSString *fontFile = [[NSBundle mainBundle] pathForResource:@"somefont.otf" ofType:nil];
CGDataProviderRef dataProvider = CGDataProviderCreateWithFilename([fontFile cStringUsingEncoding:NSASCIIStringEncoding]);
CGFontRef cgfont = CGFontCreateWithDataProvider(dataProvider);
CTFontRef ctfont = CTFontCreateWithGraphicsFont(cgfont, 10, NULL, NULL);
CFRelease(dataProvider);
NSString *text = @"Hello €";
int len = [text length];
CGGlyph glyphs[len];
CTFontGetGlyphsForCharacters(ctfont, (const unichar*)[text cStringUsingEncoding:NSUnicodeStringEncoding], glyphs, len);
CGContextSetTextDrawingMode(_context, kCGTextFill);
CGContextShowGlyphsAtPoint(_context, 10, 10, glyphs, len);
CFRelease(cgfont);
CFRelease(ctfont);
を、しかしフォントがPDFファイルに埋め込まれていません。これを行う方法はありますか?
これを解決しましたか? – Tom
別のフォントを使用している場合、PDFに埋め込まれますか?それとも埋め込まれないこの特定のフォントだけですか? –
私はシステムフォント「HelveticaNeue」を使用してしまいました。 – toucan