62 if (font == NULL) { |
64 if (font == NULL) { |
63 // cannot load font - hide the text node to avoid errors when trying to draw |
65 // cannot load font - hide the text node to avoid errors when trying to draw |
64 asc_set_flag(node->flags, ASC_SCENE_NODE_HIDDEN); |
66 asc_set_flag(node->flags, ASC_SCENE_NODE_HIDDEN); |
65 return; |
67 return; |
66 } |
68 } |
67 static int alignments[] = { |
69 static TTF_HorizontalAlignment alignments[] = { |
68 TTF_WRAPPED_ALIGN_LEFT, |
70 TTF_HORIZONTAL_ALIGN_LEFT, |
69 TTF_WRAPPED_ALIGN_CENTER, |
71 TTF_HORIZONTAL_ALIGN_CENTER, |
70 TTF_WRAPPED_ALIGN_RIGHT |
72 TTF_HORIZONTAL_ALIGN_RIGHT |
71 }; |
73 }; |
72 TTF_SetFontWrappedAlign( |
74 TTF_SetFontWrapAlignment( |
73 font, alignments[text->base.flags & ASC_TEXT_ALIGNMENT_MASK]); |
75 font, alignments[text->base.flags & ASC_TEXT_ALIGNMENT_MASK]); |
74 SDL_Surface *surface = TTF_RenderUTF8_Blended_Wrapped( |
76 // TODO: it looks like TTF_RenderText_Blended_Wrapped is broken in SDL 3 |
75 font, text->text.ptr, asc_col_sdl(text->color), text->max_width |
77 SDL_Surface *surface = TTF_RenderText_Blended( |
|
78 font, text->text.ptr, text->text.length, asc_col_sdl(text->color)//, text->max_width |
76 ); |
79 ); |
77 if (surface == NULL) { |
80 if (surface == NULL) { |
78 asc_error("Rendering TTF surface failed: %s", SDL_GetError()); |
81 asc_error("Rendering TTF surface failed: %s", SDL_GetError()); |
79 return; |
82 return; |
80 } |
83 } |