title: Getting SDL_ttf to play nice with SDL2
body: <p>I've recently started migrating from using SDL (1.2.15) to SDL2 (2.0.0), and had previously depended on using the extension library SDL_ttf (2.0.11) to render fonts. When I try to use the same text library I used with version one SDL with SDL2 (admittedly not yet officially released), it compiles just fine. When I run the executable, though (I'm using VS2012 for Desktop at the moment), I get the following error:</p>
  
  <pre><code>Unhandled exception at 0x6C7D8C24 (SDL2.dll) in test.exe: 0xC0000005: Access violation reading location 0x00000045.
  </code></pre>
  
  <p>From what I can gather, this is due to the following bits of code. I have created a Window class to encapsulate some usual SDL functions:</p>
  
  <p>window.cpp:</p>
  
  <pre><code>SDL_Texture* Window::RenderText(const std::string &amp;message, const std::string &amp;fontFile, SDL_Color color, int fontSize){
  //Open the font
  TTF_Font *font = nullptr;
  font = TTF_OpenFont(fontFile.c_str(), fontSize);
  if (font == nullptr)
      throw std::runtime_error("Failed to load font: " + fontFile + TTF_GetError());
  
  //Render the message to an SDL_Surface, as that's what TTF_RenderText_X returns
  SDL_Surface *surf = TTF_RenderText_Blended(font, message.c_str(), color);
  SDL_Texture *texture = SDL_CreateTextureFromSurface(mRenderer.get(), surf);
  //Clean up unneeded stuff
  SDL_FreeSurface(surf);
  TTF_CloseFont(font);
  
  return texture;
  }
  </code></pre>
  
  <p>It's getting tripped up by the </p>
  
  <pre><code>SDL_Texture *texture = SDL_CreateTextureFromSurface(mRenderer.get(), surf);
  </code></pre>
  
  <p>line, where the created SDL_Surface is incompatible with SDL2's definition of Surfaces, and so when it tries to convert the SDL_Surface into an SDL_Texture, it flips out.</p>
  
  <p>I don't think I'm the only one to have run into this issue, so is there a workaround/updated version of SDL_ttf that fixes this, or should I hold off on moving to SDL2 until I can get fonts working?</p>