Пример #1
0
Ret ftk_backend_init(int argc, char* argv[])
{
	ftk_set_display(ftk_display_fb_create(getenv("FTK_FB_NAME") ? getenv("FTK_FB_NAME") : FTK_FB_NAME));
	
	if(ftk_default_display() == NULL)
	{
		size_t i = 0;
		for(i = 0; fb_dev[i] != NULL; i++)
		{
			ftk_set_display(ftk_display_fb_create(fb_dev[i]));
			if(ftk_default_display() != NULL)
			{
				break;
			}
			else
			{
				ftk_loge("open %s failed.\n", fb_dev[i]);
			}
		}
	}

	if(ftk_default_display() == NULL)
	{
		ftk_loge("open display failed %s.\n", FTK_FB_NAME);
		exit(0);
	}
	ftk_init_input();

	return RET_OK;
}
Пример #2
0
static Ret ftk_init_font(void)
{
	FtkFont* font = NULL;
#if defined(USE_FREETYPE) && defined(ANDROID) && defined(ANDROID_NDK)
	font = ftk_font_freetype_create(FTK_FONT, 0, 0, FTK_FONT_SIZE);
#else
	char filename[FTK_MAX_PATH + 1] = {0};
	ftk_strs_cat(filename, FTK_MAX_PATH, 
		ftk_config_get_data_dir(ftk_default_config()), "/data/", FTK_FONT, NULL);
	ftk_normalize_path(filename);
#ifdef USE_FREETYPE
	font = ftk_font_freetype_create(filename, 0, 0, FTK_FONT_SIZE);
#else
	font = ftk_font_default_create(filename, 0, 0, 0);
#endif
#endif
	
	if(font != NULL)
	{
		ftk_set_font(font);
	}
	else
	{
		ftk_deinit();
		ftk_loge("load font failed.\n");
		exit(0);
	}

	return RET_OK;
}
Пример #3
0
static int on_x11_error (Display* display, XErrorEvent* event)
{
	ftk_loge("%s\n", __func__);
	exit(0);

	return 0;
}
Пример #4
0
Ret ftk_backend_init(int argc, char* argv[])
{
	ftk_init_input();
	ftk_set_display(ftk_display_ucosii_create());
	if(ftk_default_display() == NULL)
	{
		ftk_loge("open display failed.\n");
		exit(0);
	}

	return RET_OK;
}
Пример #5
0
int main(int argc, char* argv[])
{
	ftk_set_log_level(FTK_LOG_V);
	printf("log_level=FTK_LOG_E\n");
	ftk_logv("logv\n");	
	ftk_logd("logd\n");	
	ftk_loge("loge\n");	
	
	ftk_set_log_level(FTK_LOG_D);
	printf("log_level=FTK_LOG_E\n");
	ftk_logv("logv\n");	
	ftk_logd("logd\n");	
	ftk_loge("loge\n");	
	
	ftk_set_log_level(FTK_LOG_E);
	printf("log_level=FTK_LOG_E\n");
	ftk_logv("logv\n");	
	ftk_logd("logd\n");	
	ftk_loge("loge\n");	
	
	return 0;
}
Пример #6
0
FtkFont* ftk_font_create (const char* filename, FtkFontDesc* font_desc)
{
	int size = 0;
	FtkFont* thiz = NULL;
	return_val_if_fail(filename != NULL && font_desc != NULL, NULL);

	size = ftk_font_desc_get_size(font_desc);
	thiz = FTK_NEW_PRIV(FtkFont); 
	if(thiz != NULL)
	{
		FT_Error err = 0;
		DECL_PRIV(thiz, priv);

		thiz->ref = 1;
		thiz->height = ftk_font_freetype_height;
		thiz->lookup = ftk_font_freetype_lookup;
		thiz->destroy= ftk_font_freetype_destroy;

		priv->size = size;
		err = FT_Init_FreeType(&priv->library );
		if((err = FT_New_Face(priv->library, filename, 0, &priv->face)))
		{
			ftk_loge("load %s failed.\n", filename);
			FT_Done_FreeType(priv->library);
			FTK_ZFREE(thiz, sizeof(FtkFont));
		}
		else
		{
			err = FT_Select_Charmap(priv->face, ft_encoding_unicode);
			if(err)
			{
				err = FT_Select_Charmap(priv->face, ft_encoding_latin_1 );
			}
			assert(err == 0);
			err = FT_Set_Pixel_Sizes(priv->face, 0, size);
			assert(err == 0);
			ftk_logd("fonfile:%s\n", filename);
			ftk_logd("font family_name:%s\n", priv->face->family_name);
			ftk_logd("font style_name:%s\n", priv->face->style_name);
		}
	}

	return thiz;
}