|  | @@ -1440,10 +1440,17 @@ void tnsDeleteBuiltinShaders(){
 | 
	
		
			
				|  |  |      tnsDeleteShaderProgram(T->immShader); T->immShader=0;
 | 
	
		
			
				|  |  |      tnsDeleteShaderProgram(T->TEST_MatcapShader); T->TEST_MatcapShader=0;
 | 
	
		
			
				|  |  |      tnsDeleteShaderProgram(T->TransparentGridShader); T->TransparentGridShader=0;
 | 
	
		
			
				|  |  | +    tnsDeleteShaderProgram(T->SelectionShader); T->SelectionShader=0;
 | 
	
		
			
				|  |  | +    tnsDeleteShaderProgram(T->SceneShader); T->SceneShader=0;
 | 
	
		
			
				|  |  | +    tnsDeleteShaderProgram(T->ShadowShader); T->ShadowShader=0;
 | 
	
		
			
				|  |  | +    tnsDeleteShaderProgram(T->RayShader); T->RayShader=0;
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  void tnsQuit(){
 | 
	
		
			
				|  |  | +    tnsQuitFontManager();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      tnsDeleteBuiltinShaders();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    tnsOffscreen* off; while(off=T->Offscreens.pFirst){ tnsDelete2DOffscreen(off); }
 | 
	
		
			
				|  |  |      tnsTexture* t; while(t=T->Textures.pFirst){ tnsDeleteTexture(t); }
 | 
	
		
			
				|  |  |      
 | 
	
		
			
				|  |  |      arrFree(&T->Vert, &T->MaxVert);
 | 
	
	
		
			
				|  | @@ -1451,6 +1458,7 @@ void tnsQuit(){
 | 
	
		
			
				|  |  |      arrFree(&T->Normal, &T->MaxNormal);
 | 
	
		
			
				|  |  |      arrFree(&T->TexCoord, &T->MaxTexCoord);
 | 
	
		
			
				|  |  |      arrFree(&T->Index, &T->MaxIndex);
 | 
	
		
			
				|  |  | +    arrFree(&T->DrawingCommand, &T->DrawingCommand);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      glDeleteBuffers(1, &T->VertBufObject);
 | 
	
		
			
				|  |  |      glDeleteBuffers(1, &T->ColorBufObject);
 | 
	
	
		
			
				|  | @@ -2578,6 +2586,19 @@ tnsFontManager *FM;
 | 
	
		
			
				|  |  |  void tnsSetuptnsFontManager(){
 | 
	
		
			
				|  |  |      FM = CreateNew(tnsFontManager);
 | 
	
		
			
				|  |  |  };
 | 
	
		
			
				|  |  | +void tnsQuitFontManager(){
 | 
	
		
			
				|  |  | +    tnsInvalidateFontCache();
 | 
	
		
			
				|  |  | +    tnsFont*f=FM->UsingFont;
 | 
	
		
			
				|  |  | +    for(int i=0;i<f->NumFaces;i++){
 | 
	
		
			
				|  |  | +        FT_Done_Face(f->ftface[i]);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    if(f->ftfacemono) FT_Done_Face(f->ftfacemono);
 | 
	
		
			
				|  |  | +    FT_Done_FreeType(f->ftlib);
 | 
	
		
			
				|  |  | +    free(f->characters);
 | 
	
		
			
				|  |  | +    free(f->monocharacters);
 | 
	
		
			
				|  |  | +    free(f);
 | 
	
		
			
				|  |  | +    FreeMem(FM);
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  int next_p2(int a){
 | 
	
		
			
				|  |  |      int rval = 1;
 | 
	
	
		
			
				|  | @@ -2603,6 +2624,7 @@ int tnsInvalidateFontCache(){
 | 
	
		
			
				|  |  |          if (FT_Load_Char(f->ftfacemono, 'a', FT_LOAD_TARGET_NORMAL | FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP)||
 | 
	
		
			
				|  |  |              FT_Get_Glyph(f->ftfacemono->glyph, &glyph)){ SEND_PANIC_ERROR("Monospace font doesn't contain character 'a'"); }
 | 
	
		
			
				|  |  |          f->MonoAdvance=f->ftfacemono->glyph->advance.x/64.0;
 | 
	
		
			
				|  |  | +        if(glyph) FT_Done_Glyph(glyph);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  tnsFontSingleCharacter *tfntFetchCharTextureIDW(uint32_t ch, int UseMono);
 | 
	
	
		
			
				|  | @@ -2627,6 +2649,7 @@ void tnsLoadSystemFontMono(char* mono){
 | 
	
		
			
				|  |  |          if (FT_Load_Char(f->ftfacemono, 'a', FT_LOAD_TARGET_NORMAL | FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP)||
 | 
	
		
			
				|  |  |              FT_Get_Glyph(f->ftfacemono->glyph, &glyph)){ SEND_PANIC_ERROR("Monospace font doesn't contain character 'a'"); }
 | 
	
		
			
				|  |  |          f->MonoAdvance=f->ftfacemono->glyph->advance.x/64.0;
 | 
	
		
			
				|  |  | +        if(glyph) FT_Done_Glyph(glyph);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  };
 | 
	
		
			
				|  |  |  void tnsLoadSystemFont(int num_fonts, ...){
 | 
	
	
		
			
				|  | @@ -2844,6 +2867,7 @@ tnsFontSingleCharacter *tfntFetchCharTextureIDW(uint32_t ch, int UseMono){
 | 
	
		
			
				|  |  |      glTexSubImage2D(GL_TEXTURE_2D, 0, fsc->bufferx, fsc->buffery, w, h, GL_RED, GL_UNSIGNED_BYTE, buf);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      FreeMem(buf);
 | 
	
		
			
				|  |  | +    FT_Done_Glyph(glyph);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      fsc->Generated = 1;
 | 
	
		
			
				|  |  |      return fsc;
 |