Exemple #1
0
int RenderChar(FT_ULong currentchar, int _sx, int _sy, int _ex, int color)
{
	FT_UInt glyphindex;
	FT_Vector kerning;

	//load char

		if(!(glyphindex = FT_Get_Char_Index(face, currentchar)))
		{
			printf("<FT_Get_Char_Index for Char \"%c\" failed with Errorcode 0x%.2X>\n", (int)currentchar, error);
			return 0;
		}

#if FREETYPE_MAJOR == 2 && FREETYPE_MINOR == 0
		if((error = FTC_SBit_Cache_Lookup(cache, &desc, glyphindex, &sbit)))
#else
		FTC_Node anode;
		if((error = FTC_SBitCache_Lookup(cache, &desc, glyphindex, &sbit, &anode)))
#endif
		{
			printf("<FTC_SBitCache_Lookup for Char \"%c\" failed with Errorcode 0x%.2X>\n", (int)currentchar, error);
			return 0;
		}

		if(use_kerning)
		{
			FT_Get_Kerning(face, prev_glyphindex, glyphindex, ft_kerning_default, &kerning);

			prev_glyphindex = glyphindex;
			kerning.x >>= 6;
		}
		else kerning.x = 0;
Exemple #2
0
int RenderChar(FT_ULong currentchar, int sx, int sy, int ex, int color)
{
	int row, pitch, bit, x = 0, y = 0;
	FT_UInt glyphindex;
	FT_Vector kerning;

	//load char

		if(!(glyphindex = FT_Get_Char_Index(face, currentchar)))
		{
			printf("<FT_Get_Char_Index for Char \"%c\" failed with Errorcode 0x%.2X>\n", (int)currentchar, error);
			return 0;
		}

#ifdef FT_NEW_CACHE_API
		if((error = FTC_SBitCache_Lookup(cache, &desc, glyphindex, &sbit, NULL)))
#else
		if((error = FTC_SBit_Cache_Lookup(cache, &desc, glyphindex, &sbit)))
#endif
		{
			printf("<FTC_SBitCache_Lookup for Char \"%c\" failed with Errorcode 0x%.2X>\n", (int)currentchar, error);
			return 0;
		}

		if(use_kerning)
		{
			FT_Get_Kerning(face, prev_glyphindex, glyphindex, ft_kerning_default, &kerning);

			prev_glyphindex = glyphindex;
			kerning.x >>= 6;
		}
		else kerning.x = 0;
Exemple #3
0
// Freetype - RenderChar
int RenderChar(FT_ULong currentchar, int sx, int sy, int ex, unsigned char *color)
{
	if (currentchar == 32) return;

#ifdef FB8BIT
		int bpp=1;
#else
		int bpp=4;
#endif		
		
	int row, pitch, bit, x = 0, y = 0;
	FT_UInt glyphindex;
	FT_Vector kerning;
	FT_Error error;
	int tmpcolor;

	if(!(glyphindex = FT_Get_Char_Index(face, currentchar)))
	{
		printf("Freetype <FT_Get_Char_Index> fuer Zeichen %x \"%c\" fehlgeschlagen\n", (int)currentchar,(int)currentchar);
		return 0;
	}

#if ((defined(FREETYPE_MAJOR)) && (((FREETYPE_MAJOR == 2) && (((FREETYPE_MINOR == 1) && (FREETYPE_PATCH >= 9)) || (FREETYPE_MINOR > 1))) || (FREETYPE_MAJOR > 2)))
	FTC_Node anode;
	if((error = FTC_SBitCache_Lookup(cache, &desc, glyphindex, &sbit, &anode)))
#else
	if((error = FTC_SBit_Cache_Lookup(cache, &desc, glyphindex, &sbit)))
#endif
	{
		printf("Freetype <FTC_SBitCache_Lookup> fuer Zeichen %x \"%c\" fehlgeschlagen. Fehler: 0x%.2X>\n", (int)currentchar,(int)currentchar, error);
		return 0;
	}
	if(use_kerning)
	{
		FT_Get_Kerning(face, prev_glyphindex, glyphindex, ft_kerning_default, &kerning);

		prev_glyphindex = glyphindex;
		kerning.x >>= 6;
	}
	else
Exemple #4
0
inline FT_Error fontRenderClass::getGlyphBitmap(FTC_Image_Desc *font, FT_ULong glyph_index, FTC_SBit *sbit)
#endif
{
	return FTC_SBit_Cache_Lookup(sbitsCache, font, glyph_index, sbit);
}
Exemple #5
0
int RenderChar(Pixel *dest,FT_ULong currentchar, int sx, int sy, int ex, int color, int ovwidth)
{
	int row, pitch, bit, x = 0, y = 0;
	FT_UInt glyphindex;
	FT_Error error;
	FTC_SBit		sbit;

	//load char

	if(!(glyphindex = FT_Get_Char_Index(face, currentchar)))
	{
		printf("<FT_Get_Char_Index for Char \"%c\" failed\n", (int)currentchar);
		return 0;
	}


#ifdef HAVE_DREAMBOX_HARDWARE
	if((error = FTC_SBit_Cache_Lookup(cache, &desc, glyphindex, &sbit)))
#else
	FTC_Node anode;
	if((error = FTC_SBitCache_Lookup(cache, &desc, glyphindex, &sbit, &anode)))
#endif
	{
		printf("<FTC_SBitCache_Lookup for Char \"%c\" failed with Errorcode 0x%.2X>\n", (int)currentchar, error);
		return 0;
	}


	//render char

	if(color != -1) // don't render char, return charwidth only
	{
		if(sx + sbit->xadvance >= ex) return -1; // limit to maxwidth
		

		for(row = 0; row < sbit->height; row++)
		{
		
			for(pitch = 0; pitch < sbit->pitch; pitch++)
			{
				for(bit = 7; bit >= 0; bit--)
				{
					if(pitch*8 + 7-bit >= sbit->width) break; // render needed bits only

					
					 
					if ((sbit->buffer[row * sbit->pitch + pitch]) & 1<<bit) dest[sx + sbit->left + x + ovwidth*(sy - sbit->top + y - 10)] = color;
					

					x++;
				}
			}

			x = 0;
			y++;
		}

	}

	//return charwidth

	return sbit->xadvance+2;
}