예제 #1
0
// bitmap font font size test
// return face index that has this size or below
static int test_face_size(std::string f, int size, int faceIndex)
{
    TTF_Font* fnt = TTF_OpenFontIndex(f.c_str(), size, faceIndex);
    if(fnt)
    {
        char* style = TTF_FontFaceStyleName(fnt);
        if(style != NULL)
        {
            int faces = TTF_FontFaces(fnt);
            bool found = false;
            for(int i = faces - 1; i >= 0 && !found; i--)
            {
                TTF_Font* tf = TTF_OpenFontIndex(f.c_str(), size, i);
                char* ts = NULL;
                if(NULL != tf && NULL != (ts = TTF_FontFaceStyleName(tf)))
                {
                    if(0 == strcasecmp(ts, style) && TTF_FontHeight(tf) <= size)
                    {
                        faceIndex = i;
                        found = true;
                    }
                }
                TTF_CloseFont(tf);
            }
        }
        TTF_CloseFont(fnt);
    }

    return faceIndex;
}
예제 #2
0
static void font_folder_list(std::ofstream& fout, std::string path)
{
    DIR *dir;
    struct dirent *ent;
    if ((dir = opendir (path.c_str())) != NULL) {
        bool found = false;
        while (!found && (ent = readdir (dir)) != NULL) {
            if( 0 == strcmp( ent->d_name, "." ) ||
                0 == strcmp( ent->d_name, ".." ) ) {
                continue;
            }
            #if (defined _WIN32 || defined WINDOWS)
                std::string f = path + "\\" + ent->d_name;
            #else
                std::string f = path + "/" + ent->d_name;
            #endif

            struct stat stat_buffer;
            if( stat( f.c_str(), &stat_buffer ) == -1 ) {
                continue;
            }
            if( S_ISDIR(stat_buffer.st_mode) ) {
                font_folder_list( fout, f );
                continue;
            }
            TTF_Font* fnt = TTF_OpenFont(f.c_str(), 12);
            long nfaces = 0;
            if(fnt != NULL) {
                nfaces = TTF_FontFaces(fnt);
                TTF_CloseFont(fnt);
                fnt = NULL;
            }
            for(long i = 0; i < nfaces; i++) {
                fnt = TTF_OpenFontIndex(f.c_str(), 12, i);
                if(fnt != NULL) {
                    char *fami = TTF_FontFaceFamilyName(fnt);
                    char *style = TTF_FontFaceStyleName(fnt);
                    bool isbitmap = (0 == strcasecmp(".fon", f.substr(f.length() - 4).c_str()) );
                    if(fami != NULL && (!isbitmap || i == 0) ) {
                        fout << fami << std::endl;
                        fout << f << std::endl;
                        fout << i << std::endl;
                    }
                    if(fami != NULL && style != NULL && 0 != strcasecmp(style, "Regular")) {
                        if(!isbitmap) {
                            fout << fami << " " << style << std::endl;
                            fout << f << std::endl;
                            fout << i << std::endl;
                        }
                    }
                    TTF_CloseFont(fnt);
                    fnt = NULL;
                }
            }
        }
        closedir (dir);
    }

}
예제 #3
0
JNIEXPORT jint JNICALL Java_sdljava_x_swig_SWIG_1SDLTTFJNI_TTF_1FontFaces(JNIEnv *jenv, jclass jcls, jlong jarg1) {
    jint jresult = 0 ;
    TTF_Font *arg1 = (TTF_Font *) 0 ;
    long result;
    
    (void)jenv;
    (void)jcls;
    arg1 = *(TTF_Font **)&jarg1; 
    result = (long)TTF_FontFaces(arg1);
    
    jresult = (jint)result; 
    return jresult;
}
예제 #4
0
KFontProperties::KFontProperties(const TTF_Font *_Font, const KFile *file, int ptSize) :
fontPath(file->getAbsolutePath().c_str()),
familyName(TTF_FontFaceFamilyName(_Font)),
styleName(TTF_FontFaceStyleName(_Font)),
ttf_Style(TTF_GetFontStyle(_Font)),
height(TTF_FontHeight(_Font)),
ascent(TTF_FontAscent(_Font)),
descent(TTF_FontDescent(_Font)),
lineSkip(TTF_FontLineSkip(_Font)),
faces(TTF_FontFaces(_Font)),
monospace(TTF_FontFaceIsFixedWidth(_Font)),
firstGlyph(getFirstGlyph(_Font)),
lastGlyph(getLastGlyph(_Font)),
totalGlyphs(getTotalGlyphs(_Font)),
glyphRanges(getRanges(_Font)),
pointSize(ptSize) {

}
예제 #5
0
		int LOBJECT_METHOD(getFontFaces, TTF_Font * font){
			int result = TTF_FontFaces(font);
			state.push_integer(result);
			return 1;
		}
예제 #6
0
static mrb_value
mrb_sdl2_ttf_font_get_faces(mrb_state *mrb, mrb_value self)
{
  return mrb_fixnum_value(TTF_FontFaces(mrb_sdl2_font_get_ptr(mrb, self)));
}