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);
}
void CFX_FolderFontInfo::ScanPath(CFX_ByteString& path)
{
    void* handle = FX_OpenFolder(path);
    if (handle == NULL) {
        return;
    }
    CFX_ByteString filename;
    FX_BOOL bFolder;
    while (FX_GetNextFile(handle, filename, bFolder)) {
        if (bFolder) {
            if (filename == "." || filename == "..") {
                continue;
            }
        } else {
            CFX_ByteString ext = filename.Right(4);
            ext.MakeUpper();
            if (ext != ".TTF" && ext != ".OTF" && ext != ".TTC") {
                continue;
            }
        }
        CFX_ByteString fullpath = path;
#if _FXM_PLATFORM_  == _FXM_PLATFORM_WINDOWS_
        fullpath += "\\";
#else
        fullpath += "/";
#endif
        fullpath += filename;
        if (bFolder) {
            ScanPath(fullpath);
        } else {
            ScanFile(fullpath);
        }
    }
    FX_CloseFolder(handle);
}
Example #3
0
FX_INT32 GetStyleType(const CFX_ByteString &bsStyle, FX_BOOL bRevert)
{
    FX_INT32 iLen = bsStyle.GetLength();
    if (!iLen) {
        return -1;
    }
    int iSize = sizeof(g_FontStyles) / sizeof(FX_FontStyle);
    const FX_FontStyle *pStyle = NULL;
    for (int i = iSize - 1; i >= 0; --i) {
        pStyle = g_FontStyles + i;
        if (!pStyle || pStyle->len > iLen) {
            continue;
        }
        if (!bRevert) {
            if (bsStyle.Left(pStyle->len).Compare(pStyle->style) == 0) {
                return i;
            }
        } else {
            if (bsStyle.Right(pStyle->len).Compare(pStyle->style) == 0) {
                return i;
            }
        }
    }
    return -1;
}