示例#1
0
void CFX_FolderFontInfo::ScanFile(CFX_ByteString& path)
{
    FXSYS_FILE* pFile = FXSYS_fopen(path, "rb");
    if (pFile == NULL) {
        return;
    }
    FXSYS_fseek(pFile, 0, FXSYS_SEEK_END);
    FX_DWORD filesize = FXSYS_ftell(pFile);
    FX_BYTE buffer[16];
    FXSYS_fseek(pFile, 0, FXSYS_SEEK_SET);
    size_t readCnt = FXSYS_fread(buffer, 12, 1, pFile);
    if (GET_TT_LONG(buffer) == 0x74746366) {
        FX_DWORD nFaces = GET_TT_LONG(buffer + 8);
        FX_LPBYTE offsets = FX_Alloc(FX_BYTE, nFaces * 4);
        if (!offsets) {
            FXSYS_fclose(pFile);
            return;
        }
        readCnt = FXSYS_fread(offsets, nFaces * 4, 1, pFile);
        for (FX_DWORD i = 0; i < nFaces; i ++) {
            FX_LPBYTE p = offsets + i * 4;
            ReportFace(path, pFile, filesize, GET_TT_LONG(p));
        }
        FX_Free(offsets);
    } else {
        ReportFace(path, pFile, filesize, 0);
    }
    FXSYS_fclose(pFile);
}
示例#2
0
void CFPF_SkiaFontMgr::ScanFile(const CFX_ByteString& file) {
  FXFT_Face face = GetFontFace(file.AsStringC());
  if (face) {
    CFPF_SkiaPathFont* pFontDesc = new CFPF_SkiaPathFont;
    pFontDesc->SetPath(file.c_str());
    ReportFace(face, pFontDesc);
    m_FontFaces.push_back(pFontDesc);
    FXFT_Done_Face(face);
  }
}
void CFPF_SkiaFontMgr::ScanFile(FX_BSTR file)
{
    FXFT_Face face = GetFontFace(file);
    if (face) {
        CFPF_SkiaPathFont *pFontDesc = new CFPF_SkiaPathFont;
        pFontDesc->SetPath(file.GetCStr());
        ReportFace(face, pFontDesc);
        m_FontFaces.Add(pFontDesc);
        FXFT_Done_Face(face);
    }
}
void CFX_FolderFontInfo::ScanFile(CFX_ByteString& path)
{
    FXSYS_FILE* pFile = FXSYS_fopen(path, "rb");
    if (pFile == NULL) {
        return;
    }
    FXSYS_fseek(pFile, 0, FXSYS_SEEK_END);
    FX_DWORD filesize = FXSYS_ftell(pFile);
    uint8_t buffer[16];
    FXSYS_fseek(pFile, 0, FXSYS_SEEK_SET);
    size_t readCnt = FXSYS_fread(buffer, 12, 1, pFile);
    if (readCnt != 1) {
        FXSYS_fclose(pFile);
        return;
    }

    if (GET_TT_LONG(buffer) == 0x74746366) {
        FX_DWORD nFaces = GET_TT_LONG(buffer + 8);
        if (nFaces > std::numeric_limits<FX_DWORD>::max() / 4) {
            FXSYS_fclose(pFile);
            return;
        }
        FX_DWORD face_bytes = nFaces * 4;
        uint8_t* offsets = FX_Alloc(uint8_t, face_bytes);
        readCnt = FXSYS_fread(offsets, face_bytes, 1, pFile);
        if (readCnt != face_bytes) {
            FX_Free(offsets);
            FXSYS_fclose(pFile);
            return;
        }
        for (FX_DWORD i = 0; i < nFaces; i ++) {
            uint8_t* p = offsets + i * 4;
            ReportFace(path, pFile, filesize, GET_TT_LONG(p));
        }
        FX_Free(offsets);
    } else {
        ReportFace(path, pFile, filesize, 0);
    }
    FXSYS_fclose(pFile);
}