bool FontObject::LoadFontFromTexture(SDL_Renderer* renderer) { UnloadFont(); m_font = TTF_OpenFont(m_fontFile.c_str(), 28); m_fontSurface = TTF_RenderText_Solid(m_font, m_text.c_str(), m_textColor); if(m_fontSurface == NULL) { return false; } else { m_fontTexture = SDL_CreateTextureFromSurface(renderer, m_fontSurface); if(m_fontTexture == NULL) { return false; } else { m_width = m_fontSurface->w; m_height = m_fontSurface->h; } } return true; }
void PlatformSpecificExitingMenus(void) { // just need to release the DD surface // lets leave the rects as valid, so we can // do lazy eval of the font char rects if we want int fadeLevel=65536; while(fadeLevel>=0) { /* fade screen to black */ SetPaletteFadeLevel(fadeLevel); fadeLevel-= 2048; } UnloadFont(&AvpFonts[MENU_FONT_1]); unload_rif(menu_rif);//get rid of File_Chunk menu_rif = INVALID_RIFFHANDLE; BlankScreen(); }
/// @brief Closes the renderer used by the editor /// @return 0 on failure, non-0 for success /// @note Tested int CloseGraphics (void) { Graphics::Main & g = Graphics::Main::Get(); // Unload all pictures; doing so unloads images, as well. while (!g.mPictures.empty()) { UnloadPicture(*g.mPictures.begin()); } // Unload all text images and fonts. while (!g.mTextImages.empty()) { UnloadTextImage(*g.mTextImages.begin()); } while (!g.mFaces.empty()) { Graphics::Face * pFace = g.mFaces.begin()->second; while (!pFace->mSizes.empty()) { UnloadFont(pFace->mSizes.begin()->second); } } // Close TrueType font support. FT_Done_FreeType(g.mFreeType); // Close the video subsystem. if (SDL_WasInit(SDL_INIT_VIDEO)) SDL_QuitSubSystem(SDL_INIT_VIDEO); // Flag the termination g.mInit = false; return 1; }
//---------------------------------------------------------------------------------- // Main entry point //---------------------------------------------------------------------------------- int main(void) { // Initialization (Note windowTitle is unused on Android) //--------------------------------------------------------- InitWindow(screenWidth, screenHeight, "KOALA SEASONS"); // Load global data here (assets that must be available in all screens, i.e. fonts) font = LoadFont("resources/graphics/mainfont.png"); atlas01 = LoadTexture("resources/graphics/atlas01.png"); atlas02 = LoadTexture("resources/graphics/atlas02.png"); #if defined(PLATFORM_WEB) || defined(PLATFORM_RPI) || defined(PLATFORM_ANDROID) colorBlend = LoadShader("resources/shaders/glsl100/base.vs", "resources/shaders/glsl100/blend_color.fs"); #else colorBlend = LoadShader("resources/shaders/glsl330/base.vs", "resources/shaders/glsl330/blend_color.fs"); #endif InitAudioDevice(); // Load sounds data fxJump = LoadSound("resources/audio/jump.ogg"); fxDash = LoadSound("resources/audio/dash.ogg"); fxEatLeaves = LoadSound("resources/audio/eat_leaves.ogg"); fxHitResin = LoadSound("resources/audio/resin_hit.ogg"); fxWind = LoadSound("resources/audio/wind_sound.ogg"); fxDieSnake = LoadSound("resources/audio/snake_die.ogg"); fxDieDingo = LoadSound("resources/audio/dingo_die.ogg"); fxDieOwl = LoadSound("resources/audio/owl_die.ogg"); music = LoadMusicStream("resources/audio/jngl.xm"); PlayMusicStream(music); SetMusicVolume(music, 1.0f); // Define and init first screen // NOTE: currentScreen is defined in screens.h as a global variable currentScreen = TITLE; InitLogoScreen(); //InitOptionsScreen(); InitTitleScreen(); InitGameplayScreen(); InitEndingScreen(); #if defined(PLATFORM_WEB) emscripten_set_main_loop(UpdateDrawFrame, 0, 1); #else SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop while (!WindowShouldClose()) UpdateDrawFrame(); #endif // De-Initialization //-------------------------------------------------------------------------------------- UnloadEndingScreen(); UnloadTitleScreen(); UnloadGameplayScreen(); UnloadLogoScreen(); UnloadTexture(atlas01); UnloadTexture(atlas02); UnloadFont(font); UnloadShader(colorBlend); // Unload color overlay blending shader UnloadSound(fxJump); UnloadSound(fxDash); UnloadSound(fxEatLeaves); UnloadSound(fxHitResin); UnloadSound(fxWind); UnloadSound(fxDieSnake); UnloadSound(fxDieDingo); UnloadSound(fxDieOwl); UnloadMusicStream(music); CloseAudioDevice(); // Close audio device CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- return 0; }
int main(void) { // Initialization //-------------------------------------------------------------------------------------- const int screenWidth = 800; const int screenHeight = 450; InitWindow(screenWidth, screenHeight, "raylib [text] example - sprite fonts usage"); const char msg1[50] = "THIS IS A custom SPRITE FONT..."; const char msg2[50] = "...and this is ANOTHER CUSTOM font..."; const char msg3[50] = "...and a THIRD one! GREAT! :D"; // NOTE: Textures/Fonts MUST be loaded after Window initialization (OpenGL context is required) Font font1 = LoadFont("resources/custom_mecha.png"); // Font loading Font font2 = LoadFont("resources/custom_alagard.png"); // Font loading Font font3 = LoadFont("resources/custom_jupiter_crash.png"); // Font loading Vector2 fontPosition1 = { screenWidth/2 - MeasureTextEx(font1, msg1, font1.baseSize, -3).x/2, screenHeight/2 - font1.baseSize/2 - 80 }; Vector2 fontPosition2 = { screenWidth/2 - MeasureTextEx(font2, msg2, font2.baseSize, -2).x/2, screenHeight/2 - font2.baseSize/2 - 10 }; Vector2 fontPosition3 = { screenWidth/2 - MeasureTextEx(font3, msg3, font3.baseSize, 2).x/2, screenHeight/2 - font3.baseSize/2 + 50 }; SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop while (!WindowShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- // TODO: Update variables here... //---------------------------------------------------------------------------------- // Draw //---------------------------------------------------------------------------------- BeginDrawing(); ClearBackground(RAYWHITE); DrawTextEx(font1, msg1, fontPosition1, font1.baseSize, -3, WHITE); DrawTextEx(font2, msg2, fontPosition2, font2.baseSize, -2, WHITE); DrawTextEx(font3, msg3, fontPosition3, font3.baseSize, 2, WHITE); EndDrawing(); //---------------------------------------------------------------------------------- } // De-Initialization //-------------------------------------------------------------------------------------- UnloadFont(font1); // Font unloading UnloadFont(font2); // Font unloading UnloadFont(font3); // Font unloading CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- return 0; }
static int UnloadFont (lua_State * L) { UnloadFont(lua_touserdata(L, 1)); return 0; }
void ShutdownFonts( ) { UnloadFont( gpLargeFontType1 ); UnloadFont( gpSmallFontType1 ); UnloadFont( gpTinyFontType1 ); UnloadFont( gp12PointFont1 ); UnloadFont( gpClockFont); UnloadFont( gpCompFont); UnloadFont( gpSmallCompFont); UnloadFont( gp10PointRoman); UnloadFont( gp12PointRoman); UnloadFont( gp14PointSansSerif); // UnloadFont( gpMilitaryFont1); UnloadFont( gp10PointArial); UnloadFont( gp10PointArialBold); UnloadFont( gp14PointArial); UnloadFont( gpBlockyFont); UnloadFont( gp12PointArialFixedFont ); #if defined( JA2EDITOR ) && defined( ENGLISH ) UnloadFont( gpHugeFont ); #endif // ATE: Shutdown any win fonts if ( iUseWinFonts ) { ShutdownWinFonts(); } }
//---------------------------------------------------------------------------------- // Main entry point //---------------------------------------------------------------------------------- int main(int argc, char *argv[]) { // Initialization //--------------------------------------------------------- #if defined(PLATFORM_DESKTOP) // TODO: Support for dropped files on the exe // Support command line argument for custom music file if (argc > 1) { // Just supporting an input argument parameter!!! o__O if ((IsFileExtension(argv[1], ".ogg")) || (IsFileExtension(argv[1], ".wav"))) { if (sampleFilename != NULL) free(sampleFilename); sampleFilename = (char *)malloc(256); strcpy(sampleFilename, argv[1]); printf("Custom audio file: %s", sampleFilename); } } #endif #ifndef PLATFORM_ANDROID SetConfigFlags(FLAG_MSAA_4X_HINT); #endif // Note windowTitle is unused on Android InitWindow(screenWidth, screenHeight, "GGJ17 - WAVE COLLECTOR"); // Global data loading (assets that must be available in all screens, i.e. fonts) InitAudioDevice(); font = LoadFont("resources/font.fnt"); music = LoadMusicStream("resources/audio/wave.ogg"); SetMusicVolume(music, 1.0f); // Setup and Init first screen currentScreen = LOGO; InitLogoScreen(); //InitTitleScreen(); //InitGameplayScreen(); //InitEndingScreen(); #if defined(PLATFORM_WEB) emscripten_set_main_loop(UpdateDrawFrame, 0, 1); #else SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop while (!WindowShouldClose()) // Detect window close button or ESC key { UpdateDrawFrame(); } #endif // De-Initialization //-------------------------------------------------------------------------------------- switch (currentScreen) { case LOGO: UnloadLogoScreen(); break; case TITLE: UnloadTitleScreen(); break; case GAMEPLAY: UnloadGameplayScreen(); break; case ENDING: UnloadEndingScreen(); break; default: break; } // Unload all global loaded data (i.e. fonts) here! UnloadFont(font); UnloadMusicStream(music); CloseAudioDevice(); // Close audio context CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- return 0; }