Example #1
0
static int atlas_add_glyph_pgf(vita2d_pgf *font, unsigned int character)
{
	SceFontCharInfo char_info;
	if (sceFontGetCharInfo(font->font_handle, character, &char_info) < 0)
		return 0;

	int pos_x;
	int pos_y;
	if (!texture_atlas_insert(font->tex_atlas, character,
		char_info.bitmapWidth, char_info.bitmapHeight,
		char_info.bitmapLeft, char_info.bitmapTop,
		char_info.sfp26AdvanceH,
		char_info.sfp26AdvanceV,
		0, &pos_x, &pos_y))
			return 0;

	vita2d_texture *tex = font->tex_atlas->tex;

	SceFontGlyphImage glyph_image;
	glyph_image.pixelFormat = SCE_FONT_PIXELFORMAT_8;
	glyph_image.xPos64 = pos_x << 6;
	glyph_image.yPos64 = pos_y << 6;
	glyph_image.bufWidth = vita2d_texture_get_width(tex);
	glyph_image.bufHeight = vita2d_texture_get_height(tex);
	glyph_image.bytesPerLine = vita2d_texture_get_stride(tex);
	glyph_image.pad = 0;
	glyph_image.bufferPtr = (unsigned int)vita2d_texture_get_datap(tex);

	return sceFontGetCharGlyphImage(font->font_handle, character, &glyph_image) == 0;
}
Example #2
0
static int atlas_add_glyph(texture_atlas *atlas, unsigned int glyph_index, const FT_BitmapGlyph bitmap_glyph, int glyph_size)
{
	const FT_Bitmap *bitmap = &bitmap_glyph->bitmap;

	unsigned char *buffer = malloc(bitmap->width * bitmap->rows);
	unsigned int w = bitmap->width;
	unsigned int h = bitmap->rows;

	int j, k;
	for (j = 0; j < h; j++) {
		for (k = 0; k < w; k++) {
			if (bitmap->pixel_mode == FT_PIXEL_MODE_MONO) {
				buffer[j*w + k] =
					(bitmap->buffer[j*bitmap->pitch + k/8] & (1 << (7 - k%8)))
					? 0xFF : 0;
			} else {
				buffer[j*w + k] = bitmap->buffer[j*bitmap->pitch + k];
			}
		}
	}

	int ret = texture_atlas_insert(atlas, glyph_index, buffer,
		bitmap->width, bitmap->rows,
		bitmap_glyph->left, bitmap_glyph->top,
		bitmap_glyph->root.advance.x, bitmap_glyph->root.advance.y,
		glyph_size);

	free(buffer);

	return ret;
}
Example #3
0
static int atlas_add_glyph(vita2d_pgf *font, unsigned int character)
{
	SceFontHandle font_handle = font->font_handle_list->font_handle;
	SceFontCharInfo char_info;
	bp2d_position position;
	void *texture_data;
	vita2d_texture *tex = font->atlas->texture;

	vita2d_pgf_font_handle *tmp = font->font_handle_list;
	while (tmp) {
		if (tmp->in_font_group == NULL || tmp->in_font_group(character)) {
			font_handle = tmp->font_handle;
			break;
		}
		tmp = tmp->next;
	}

	if (sceFontGetCharInfo(font_handle, character, &char_info) < 0)
		return 0;

	bp2d_size size = {
		char_info.bitmapWidth,
		char_info.bitmapHeight
	};

	texture_atlas_entry_data data = {
		char_info.bitmapLeft,
		char_info.bitmapTop,
		char_info.sfp26AdvanceH,
		char_info.sfp26AdvanceV,
		0
	};

	if (!texture_atlas_insert(font->atlas, character, &size, &data,
				  &position))
			return 0;

	texture_data = vita2d_texture_get_datap(tex);

	SceFontGlyphImage glyph_image;
	glyph_image.pixelFormat = SCE_FONT_PIXELFORMAT_8;
	glyph_image.xPos64 = position.x << 6;
	glyph_image.yPos64 = position.y << 6;
	glyph_image.bufWidth = vita2d_texture_get_width(tex);
	glyph_image.bufHeight = vita2d_texture_get_height(tex);
	glyph_image.bytesPerLine = vita2d_texture_get_stride(tex);
	glyph_image.pad = 0;
	glyph_image.bufferPtr = (unsigned int)texture_data;

	return sceFontGetCharGlyphImage(font_handle, character, &glyph_image) == 0;
}