Beispiel #1
0
void CXML_Parser::SkipLiterals(FX_BSTR str)
{
    m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex;
    if (IsEOF()) {
        return;
    }
    FX_INT32 i = 0, iLen = str.GetLength();
    do {
        while (m_dwIndex < m_dwBufferSize) {
            if (str.GetAt(i) != m_pBuffer[m_dwIndex ++]) {
                i = 0;
            } else {
                i ++;
                if (i == iLen) {
                    break;
                }
            }
        }
        m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex;
        if (i == iLen) {
            return;
        }
        if (m_dwIndex < m_dwBufferSize || IsEOF()) {
            break;
        }
    } while (ReadNextBlock());
    while (!m_pDataAcc->IsEOF()) {
        ReadNextBlock();
        m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwBufferSize;
    }
    m_dwIndex = m_dwBufferSize;
}
static FX_DWORD FPF_SKIANormalizeFontName(FX_BSTR bsfamily)
{
    FX_DWORD dwHash = 0;
    FX_INT32 iLength = bsfamily.GetLength();
    FX_LPCSTR pBuffer = bsfamily.GetCStr();
    for (FX_INT32 i = 0; i < iLength; i++) {
        FX_CHAR ch = pBuffer[i];
        if (ch == ' ' || ch == '-' || ch == ',') {
            continue;
        }
        dwHash = 31 * dwHash + FXSYS_tolower(ch);
    }
    return dwHash;
}
void CFPF_SkiaFontMgr::ScanPath(FX_BSTR path)
{
    void *handle = FX_OpenFolder(path.GetCStr());
    if (!handle) {
        return;
    }
    CFX_ByteString filename;
    FX_BOOL	bFolder = FALSE;
    while (FX_GetNextFile(handle, filename, bFolder)) {
        if (bFolder) {
            if (filename == FX_BSTRC(".") || filename == FX_BSTRC("..")) {
                continue;
            }
        } else {
            CFX_ByteString ext = filename.Right(4);
            ext.MakeLower();
            if (ext != FX_BSTRC(".ttf") && ext != FX_BSTRC(".ttc")) {
                continue;
            }
        }
        CFX_ByteString fullpath = path;
        fullpath += "/";
        fullpath += filename;
        if (bFolder) {
            ScanPath(fullpath);
        } else {
            ScanFile(fullpath);
        }
    }
    FX_CloseFolder(handle);
}
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;
}
FX_BOOL CFXCRT_FileAccess_CRT::Open(FX_BSTR fileName, FX_DWORD dwMode)
{
    if (m_hFile) {
        return FALSE;
    }
    CFX_ByteString strMode;
    FXCRT_GetFileModeString(dwMode, strMode);
    m_hFile = FXSYS_fopen(fileName.GetCStr(), (FX_LPCSTR)strMode);
    return m_hFile != NULL;
}
Beispiel #6
0
FX_BOOL CFXCRT_FileAccess_Posix::Open(FX_BSTR fileName, FX_DWORD dwMode)
{
    if (m_nFD > -1) {
        return FALSE;
    }
    FX_INT32 nFlags, nMasks;
    FXCRT_Posix_GetFileMode(dwMode, nFlags, nMasks);
    m_nFD = open(fileName.GetCStr(), nFlags, nMasks);
    return m_nFD > -1;
}
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);
    }
}
Beispiel #8
0
void CXML_AttrMap::RemoveAt(FX_BSTR space, FX_BSTR name)
{
    if (m_pMap == NULL) {
        return;
    }
    for (int i = 0; i < m_pMap->GetSize(); i ++) {
        CXML_AttrItem& item = GetAt(i);
        if ((space.IsEmpty() || item.m_QSpaceName == space) && item.m_AttrName == name) {
            m_pMap->RemoveAt(i);
            return;
        }
    }
}
Beispiel #9
0
FX_DWORD CXML_Element::CountElements(FX_BSTR space, FX_BSTR tag) const
{
    int count = 0;
    for (int i = 0; i < m_Children.GetSize(); i += 2) {
        ChildType type = (ChildType)(FX_UINTPTR)m_Children.GetAt(i);
        if (type != Element) {
            continue;
        }
        CXML_Element* pKid = (CXML_Element*)m_Children.GetAt(i + 1);
        if ((space.IsEmpty() || pKid->m_QSpaceName == space) && pKid->m_TagName == tag) {
            count ++;
        }
    }
    return count;
}
Beispiel #10
0
CFX_ByteString CXML_Element::GetNamespaceURI(FX_BSTR qName) const
{
    const CFX_WideString* pwsSpace;
    const CXML_Element *pElement = this;
    do {
        if (qName.IsEmpty()) {
            pwsSpace = pElement->m_AttrMap.Lookup(FX_BSTRC(""), FX_BSTRC("xmlns"));
        } else {
            pwsSpace = pElement->m_AttrMap.Lookup(FX_BSTRC("xmlns"), qName);
        }
        if (pwsSpace) {
            break;
        }
        pElement = pElement->GetParent();
    } while(pElement);
    return pwsSpace ? FX_UTF8Encode(*pwsSpace) : CFX_ByteString();
}
Beispiel #11
0
void CXML_AttrMap::SetAt(FX_BSTR space, FX_BSTR name, FX_WSTR value)
{
    for (int i = 0; i < GetSize(); i++) {
        CXML_AttrItem& item = GetAt(i);
        if ((space.IsEmpty() || item.m_QSpaceName == space) && item.m_AttrName == name) {
            item.m_Value = value;
            return;
        }
    }
    if (!m_pMap) {
        m_pMap = FX_NEW CFX_ObjectArray < CXML_AttrItem > ;
    }
    if (!m_pMap) {
        return;
    }
    CXML_AttrItem* pItem = (CXML_AttrItem*)m_pMap->AddSpace();
    if (!pItem) {
        return;
    }
    pItem->m_QSpaceName = space;
    pItem->m_AttrName = name;
    pItem->m_Value = value;
}
Beispiel #12
0
FX_BOOL FX_File_Move(FX_BSTR fileNameSrc, FX_BSTR fileNameDst)
{
    return rename(fileNameSrc.GetCStr(), fileNameDst.GetCStr());
}
Beispiel #13
0
FX_BOOL FX_File_Delete(FX_BSTR fileName)
{
    return remove(fileName.GetCStr()) > -1;
}
Beispiel #14
0
FX_BOOL FX_File_Exist(FX_BSTR fileName)
{
    return access(fileName.GetCStr(), F_OK) > -1;
}