/** * End the system. */ void system_end(void) { tooltip_dismiss(); object_deinit(); notification_destroy(); popup_destroy_all(); resources_deinit(); toolkit_widget_deinit(); client_socket_deinitialize(); metaserver_clear_data(); effects_deinit(); sound_ambient_clear(); interface_deinit(); sound_deinit(); intro_deinit(); cmd_aliases_deinit(); server_settings_deinit(); texture_deinit(); text_deinit(); hfiles_deinit(); settings_deinit(); keybind_deinit(); image_bmaps_deinit(); anims_deinit(); skills_deinit(); spells_deinit(); clioption_settings_deinit(); server_files_deinit(); image_deinit(); toolkit_deinit(); SDL_Quit(); }
static const char *initFont(font_t *self, const void *data, int ptsize) { int i; /* Init font */ stbtt_fontinfo font; if ( !stbtt_InitFont(&font, data, 0) ) { return "could not load font"; } /* Get height and scale */ int ascent, descent, lineGap; stbtt_GetFontVMetrics(&font, &ascent, &descent, &lineGap); float scale = stbtt_ScaleForMappingEmToPixels(&font, ptsize); self->height = (ascent - descent + lineGap) * scale + 0.5; /* Init image */ int w = 128, h = 128; retry: image_initBlank(&self->image, w, h); /* Load glyphs */ float s = stbtt_ScaleForMappingEmToPixels(&font, 1) / stbtt_ScaleForPixelHeight(&font, 1); int res = stbtt_BakeFontBitmap( data, 0, ptsize * s, self->image.data, w, h, 0, 128, self->glyphs); /* Retry with a larger image buffer if the buffer wasn't large enough */ if (res < 0) { w <<= 1; h <<= 1; image_deinit(&self->image); goto retry; } /* Adjust glyph yoffsets */ int scaledAscent = ascent * scale + 0.5; for (i = 0; i < 128; i++) { self->glyphs[i].yoff += scaledAscent; } /* Init image data and mask */ for (i = 0; i < w * h; i++) { self->image.data[i] = (self->image.data[i] > 127) ? 1 : 0; self->image.mask[i] = (self->image.data[i] == 0) ? 0xff : 0; } /* Return NULL for no error */ return NULL; }
void font_deinit(font_t *self) { image_deinit(&self->image); }