Hello

I'm using Freetype to display fonts embedded in pdf data.

My problem seems to be with an embedded CCF file, where the CID mappings is
only defined in the pdf data.
I load a Compact File Format (CFF) stream into memory.
But when I try to select a character map, using FT_Select_CharMap, I get
error 0x26, Invalid_CharMap_Handle.
I've attached the CFF, font.cff, and a simple c++ program, cff.c, which
highlights the problem.

>From the pdf file I know that the font is a CID one.
So you can work out the mapping from the PDF strings to Unicode strings.
But this information doesn't seem to be available in the CFF stream.
So my question is how do I handle this situation?
I can't see any way in Freetype to add the missing character encoding.
Do I have to decompress the CFF stream, which should be a type1 font and
then explicitly add the missing character encoding information?

I can provide more analysis if necessary but I didn't want to go in to too
much technical detail in my first email.

Any advice would be appreciated, regards Tony Smith

Attachment: font.cff
Description: Binary data

#include "ft2build.h"
#include FT_FREETYPE_H
#include FT_TRUETYPE_TABLES_H
#include FT_CID_H
#include <stdio.h>

int main( void )
{
  const char * aCffFile = "font.cff";
  FT_Library  library;
  FT_Face     face;
  FT_Error error;

  error = FT_Init_FreeType( &library );

  FT_Byte * fontInMemory=NULL;
  long fontInMemorySize=0;
  FILE * fp = fopen( aCffFile, "r+b" );
  fseek(fp, 0L, SEEK_END);
  fontInMemorySize = ftell(fp);
  fseek(fp, 0L, SEEK_SET);

  fontInMemory = new FT_Byte[fontInMemorySize+1];
  fread(fontInMemory, 1, fontInMemorySize, fp );
  fclose( fp );
  fontInMemory[fontInMemorySize]=0;

  error = FT_New_Memory_Face( library, fontInMemory, fontInMemorySize, 0, &face );

  error = FT_Select_Charmap( face, FT_ENCODING_UNICODE );
  printf( "error %i \r\n", (int)error );

  error = FT_Done_Face( face );
  error = FT_Done_FreeType( library );

  delete []fontInMemory;

}
_______________________________________________
Freetype mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/freetype

Reply via email to