fix font loading with recent text changes + remove issue about SetSwapInterval not supported

This commit is contained in:
Mathieu Virbel 2012-02-23 17:52:43 +01:00
parent 96c6a3eda4
commit 09d9442758
2 changed files with 9 additions and 9 deletions

View File

@ -98,7 +98,7 @@ cdef TTF_Font *_get_font(self):
fontid = self._get_font_id()
if fontid not in pygame_cache:
# try first the file if it's a filename
fontname = self.options['font_name']
fontname = self.options['font_name_r']
ext = fontname.split('.')[-1]
if ext.lower() == 'ttf':
fontobject = TTF_OpenFont(fontname,
@ -127,7 +127,7 @@ class LabelSDLttf(LabelBase):
def _get_font_id(self):
return '|'.join([unicode(self.options[x]) for x \
in ('font_size', 'font_name', 'bold', 'italic')])
in ('font_size', 'font_name_r', 'bold', 'italic')])
def get_extents(self, text):
try:
@ -136,6 +136,8 @@ class LabelSDLttf(LabelBase):
pass
cdef TTF_Font *font = _get_font(self)
cdef int w, h
if font == NULL:
return 0, 0
TTF_SizeUTF8(font, <char *><bytes>text, &w, &h)
return w, h
@ -160,6 +162,8 @@ class LabelSDLttf(LabelBase):
cdef _SurfaceContainer sc = self._surface
cdef SDL_Surface *st
cdef SDL_Rect r
if font == NULL:
return
c.r = c.g = c.b = 255
st = TTF_RenderUTF8_Blended(font, <char *><bytes>text, c)
if st == NULL:

View File

@ -45,9 +45,6 @@ cdef extern from "SDL.h":
long touchId
long fingerId
unsigned char state
unsigned char padding1
unsigned char padding2
unsigned char padding3
unsigned short x
unsigned short y
short dx
@ -129,7 +126,7 @@ cdef extern from "SDL.h":
void SDL_GL_SwapBuffers()
int SDL_GL_MakeCurrent(SDL_Window* window, SDL_GLContext context)
int SDL_GL_SetSwapInterval(int)
#int SDL_GL_SetSwapInterval(int)
int SDL_Flip(SDL_Surface *)
SDL_Surface *SDL_GetWindowSurface(SDL_Window *)
SDL_GLContext SDL_GL_CreateContext(SDL_Window *)
@ -200,11 +197,11 @@ def setup_window(width, height, use_fake, use_fullscreen):
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
SDL_GL_SetSwapInterval(1);
#SDL_GL_SetSwapInterval(1);
ctx = SDL_GL_CreateContext(win)
assert ctx != NULL
SDL_GL_SetSwapInterval(1);
#SDL_GL_SetSwapInterval(1);
#surface = SDL_GetWindowSurface(win)
cdef SDL_DisplayMode mode
SDL_GetWindowDisplayMode(win, &mode)
@ -218,7 +215,6 @@ def resize_window(w, h):
mode.h = h
SDL_SetWindowDisplayMode(win, &mode)
SDL_GetWindowDisplayMode(win, &mode)
print 'SDL resized window size to', mode.w, mode.h
def set_window_title(str title):