Пример #1
0
FXFT_Face CFGAS_FontMgr::LoadFace(IFX_SeekableReadStream* pFontStream,
                                  int32_t iFaceIndex) {
  if (!pFontStream)
    return nullptr;

  CFX_FontMgr* pFontMgr = CFX_GEModule::Get()->GetFontMgr();
  pFontMgr->InitFTLibrary();
  FXFT_Library library = pFontMgr->GetFTLibrary();
  if (!library)
    return nullptr;

  FXFT_Stream ftStream = FX_Alloc(FXFT_StreamRec, 1);
  FXSYS_memset(ftStream, 0, sizeof(FXFT_StreamRec));
  ftStream->base = nullptr;
  ftStream->descriptor.pointer = pFontStream;
  ftStream->pos = 0;
  ftStream->size = static_cast<unsigned long>(pFontStream->GetSize());
  ftStream->read = _ftStreamRead;
  ftStream->close = _ftStreamClose;

  FXFT_Open_Args ftArgs;
  FXSYS_memset(&ftArgs, 0, sizeof(FXFT_Open_Args));
  ftArgs.flags |= FT_OPEN_STREAM;
  ftArgs.stream = ftStream;

  FXFT_Face pFace = nullptr;
  if (FXFT_Open_Face(library, &ftArgs, iFaceIndex, &pFace)) {
    FX_Free(ftStream);
    return nullptr;
  }

  FXFT_Set_Pixel_Sizes(pFace, 0, 64);
  return pFace;
}
FXFT_Face CFPF_SkiaFontMgr::GetFontFace(IFX_FileRead *pFileRead, FX_INT32 iFaceIndex)
{
    if (!pFileRead) {
        return NULL;
    }
    if (pFileRead->GetSize() == 0) {
        return NULL;
    }
    if (iFaceIndex < 0) {
        return NULL;
    }
    FXFT_StreamRec streamRec;
    FXSYS_memset32(&streamRec, 0, sizeof(FXFT_StreamRec));
    streamRec.size = pFileRead->GetSize();
    streamRec.descriptor.pointer = pFileRead;
    streamRec.read = FPF_SkiaStream_Read;
    streamRec.close = FPF_SkiaStream_Close;
    FXFT_Open_Args args;
    args.flags = FT_OPEN_STREAM;
    args.stream = &streamRec;
    FXFT_Face face;
    if (FXFT_Open_Face(m_FTLibrary, &args, iFaceIndex, &face)) {
        return NULL;
    }
    FXFT_Set_Pixel_Sizes(face, 0, 64);
    return face;
}
FXFT_Face CFPF_SkiaFontMgr::GetFontFace(FX_BSTR bsFile, FX_INT32 iFaceIndex )
{
    if (bsFile.IsEmpty()) {
        return NULL;
    }
    if (iFaceIndex < 0) {
        return NULL;
    }
    FXFT_Open_Args args;
    args.flags = FT_OPEN_PATHNAME;
    args.pathname = (FT_String*)bsFile.GetCStr();
    FXFT_Face face;
    if (FXFT_Open_Face(m_FTLibrary, &args, iFaceIndex, &face)) {
        return FALSE;
    }
    FXFT_Set_Pixel_Sizes(face, 0, 64);
    return face;
}
Пример #4
0
FXFT_Face CFPF_SkiaFontMgr::GetFontFace(const CFX_ByteStringC& bsFile,
                                        int32_t iFaceIndex) {
  if (bsFile.IsEmpty()) {
    return nullptr;
  }
  if (iFaceIndex < 0) {
    return nullptr;
  }
  FXFT_Open_Args args;
  args.flags = FT_OPEN_PATHNAME;
  args.pathname = const_cast<FT_String*>(bsFile.c_str());
  FXFT_Face face;
  if (FXFT_Open_Face(m_FTLibrary, &args, iFaceIndex, &face)) {
    return FALSE;
  }
  FXFT_Set_Pixel_Sizes(face, 0, 64);
  return face;
}
FXFT_Face CFPF_SkiaFontMgr::GetFontFace(FX_LPCBYTE pBuffer, size_t szBuffer, FX_INT32 iFaceIndex )
{
    if (!pBuffer || szBuffer < 1) {
        return NULL;
    }
    if (iFaceIndex < 0) {
        return NULL;
    }
    FXFT_Open_Args args;
    args.flags = FT_OPEN_MEMORY;
    args.memory_base = pBuffer;
    args.memory_size = szBuffer;
    FXFT_Face face;
    if (FXFT_Open_Face(m_FTLibrary, &args, iFaceIndex, &face)) {
        return FALSE;
    }
    FXFT_Set_Pixel_Sizes(face, 0, 64);
    return face;
}
Пример #6
0
FXFT_Face CFPF_SkiaFontMgr::GetFontFace(const uint8_t* pBuffer,
                                        size_t szBuffer,
                                        int32_t iFaceIndex) {
  if (!pBuffer || szBuffer < 1) {
    return nullptr;
  }
  if (iFaceIndex < 0) {
    return nullptr;
  }
  FXFT_Open_Args args;
  args.flags = FT_OPEN_MEMORY;
  args.memory_base = pBuffer;
  args.memory_size = szBuffer;
  FXFT_Face face;
  if (FXFT_Open_Face(m_FTLibrary, &args, iFaceIndex, &face)) {
    return FALSE;
  }
  FXFT_Set_Pixel_Sizes(face, 0, 64);
  return face;
}
Пример #7
0
FX_BOOL _LoadFile(FXFT_Library library, FXFT_Face* Face, IFX_FileRead* pFile, FXFT_Stream* stream)
{
    FXFT_Stream stream1 = (FXFT_Stream)FX_Alloc(FX_BYTE, sizeof (FXFT_StreamRec));
    if (!stream1) {
        return FALSE;
    }
    stream1->base = NULL;
    stream1->size = (unsigned long)pFile->GetSize();
    stream1->pos = 0;
    stream1->descriptor.pointer = pFile;
    stream1->close = _FTStreamClose;
    stream1->read = _FTStreamRead;
    FXFT_Open_Args args;
    args.flags = FT_OPEN_STREAM;
    args.stream = stream1;
    if (FXFT_Open_Face(library, &args, 0, Face)) {
        FX_Free(stream1);
        return FALSE;
    }
    if (stream) {
        *stream = stream1;
    }
    return TRUE;
}