예제 #1
0
void cache_glyphs()
{
	SDL_Color fg={0,0,0,255};

#if RENDER_MODE==1
	SDL_Color bg={255,255,255,255};
#endif

	if (!font) return;
	
	if (style!=TTF_GetFontStyle(font)) TTF_SetFontStyle(font,style);

	if (kerning != !!TTF_GetFontKerning(font)) TTF_SetFontKerning(font,kerning);

	if (hinting != TTF_GetFontHinting(font)) TTF_SetFontHinting(font,hinting);
	if (outline != TTF_GetFontOutline(font)) TTF_SetFontOutline(font,outline);
}
예제 #2
0
void cache_glyphs()
{
    int i;
    char title[800];
    SDL_Color fg={0,0,0,255};
#if RENDER_MODE==1
    SDL_Color bg={255,255,255,255};
#endif

    free_glyphs();
    if(!font)
        return;
    if(style!=TTF_GetFontStyle(font))
        TTF_SetFontStyle(font,style);
    if(kerning != !!TTF_GetFontKerning(font))
        TTF_SetFontKerning(font,kerning);
    if(hinting != TTF_GetFontHinting(font))
        TTF_SetFontHinting(font,hinting);
    if(outline != TTF_GetFontOutline(font))
        TTF_SetFontOutline(font,outline);
    for(i=0; i<128; i++)
    {
        /* cache rendered surface */
#if RENDER_MODE==0
        text[i]=TTF_RenderGlyph_Solid(font,i+start_glyph,fg);
#elif RENDER_MODE==1
        text[i]=TTF_RenderGlyph_Shaded(font,i+start_glyph,fg,bg);
#elif RENDER_MODE==2
        text[i]=TTF_RenderGlyph_Blended(font,i+start_glyph,fg);
#endif
        if(!text[i])
        {
            printf("TTF_RenderGlyph_Shaded: %s\n", TTF_GetError());
            exit(4);
        }
        /* cache metrics */
        TTF_GlyphMetrics(font, i+start_glyph,
            &gm[i].minx, &gm[i].maxx,
            &gm[i].miny, &gm[i].maxy,
            &gm[i].advance);
    }

    sprintf(title,"%s-%s:%d+0x%04x",TTF_FontFaceFamilyName(font),
        TTF_FontFaceStyleName(font),font_size,start_glyph);
    SDL_WM_SetCaption(title,"latin1");
}
예제 #3
0
파일: i_ttf.c 프로젝트: PrisimaTheFox/SRB2
// Load TTF font from file.
INT32 I_TTFLoadFont(const char *file, UINT32 ptsize)
{
	TTF_Font *tmpfont = NULL;
	float fontsize;

	// If a font is currently loaded, unload it.
	if (currentfont)
	{
		TTF_CloseFont(currentfont);
	}

	// Scale the specified font point size for the current resolution.
	fontsize = (ptsize * 0.005f) * (res.width - res.height);

	tmpfont = TTF_OpenFont(file, fontsize);

	if (!tmpfont)
		return FONTHANDLE;

	// set pointer for current font
	currentfont = tmpfont;

	// set current font point size
	currentfontpoint = ptsize;

	// get font properties, and set them
	currentfontstyle = TTF_GetFontStyle(currentfont);
	TTF_SetFontStyle(currentfont, currentfontstyle);

	// these functions only exist in SDL_ttf 2.0.10 onwards
#if SDL_TTF_VERSION_ATLEAST(2,0,10)
	currentfontkerning = TTF_GetFontKerning(currentfont);
	TTF_SetFontKerning(currentfont, currentfontkerning);

	currentfonthinting = TTF_GetFontHinting(currentfont);
	TTF_SetFontHinting(currentfont, currentfonthinting);

	currentfontoutline = TTF_GetFontOutline(currentfont);
	TTF_SetFontOutline(currentfont, currentfontoutline);
#endif

	return 0;
}
예제 #4
0
		int LOBJECT_METHOD(getFontKerning, TTF_Font * font){
			int result = TTF_GetFontKerning(font);
			state.push_integer(result);
			return 1;
		}
예제 #5
0
파일: SDLFont.cpp 프로젝트: benzap/Kampf
boolType SDLFont::getKerning() {
    int kerning = TTF_GetFontKerning(this->fontContext);
    return (kerning > 0) ? true : false;
}
예제 #6
0
static mrb_value
mrb_sdl2_ttf_font_get_kerning(mrb_state *mrb, mrb_value self)
{
  return mrb_fixnum_value(TTF_GetFontKerning(mrb_sdl2_font_get_ptr(mrb, self)));
}