CnC_Remastered_Collection

Command and Conquer: Red Alert
Log | Files | Refs | README | LICENSE

SET_FONT.CPP (4324B)


      1 //
      2 // Copyright 2020 Electronic Arts Inc.
      3 //
      4 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is free 
      5 // software: you can redistribute it and/or modify it under the terms of 
      6 // the GNU General Public License as published by the Free Software Foundation, 
      7 // either version 3 of the License, or (at your option) any later version.
      8 
      9 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed 
     10 // in the hope that it will be useful, but with permitted additional restrictions 
     11 // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT 
     12 // distributed with this program. You should have received a copy of the 
     13 // GNU General Public License along with permitted additional restrictions 
     14 // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
     15 
     16 /***************************************************************************
     17  **   C O N F I D E N T I A L --- W E S T W O O D   A S S O C I A T E S   **
     18  ***************************************************************************
     19  *                                                                         *
     20  *                 Project Name : Westwood Library                         *
     21  *                                                                         *
     22  *                    File Name : SET_FONT.C                               *
     23  *                                                                         *
     24  *                   Programmer : Joe L. Bostic                            *
     25  *                                                                         *
     26  *                   Start Date : September 6, 1991                        *
     27  *                                                                         *
     28  *                  Last Update : June 29, 1994   [SKB]                    *
     29  *                                                                         *
     30  *-------------------------------------------------------------------------*
     31  * Functions:                                                              *
     32  *   Set_Font -- Changes the default text printing font.                   *
     33  * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
     34 
     35 
     36 #include "font.h"
     37 #include <wwstd.h>
     38 
     39 
     40 
     41 /***************************************************************************
     42  * SET_FONT -- Changes the default text printing font.                     *
     43  *                                                                         *
     44  *    This routine will change the default text printing font for all      *
     45  *    text output.  It handles updating the system where necessary.        *
     46  *                                                                         *
     47  * INPUT:   fontptr  -- Pointer to the font to change to.                  *
     48  *                                                                         *
     49  * OUTPUT:  Returns with a pointer to the previous font.                   *
     50  *                                                                         *
     51  * WARNINGS:   none                                                        *
     52  *                                                                         *
     53  * HISTORY:                                                                *
     54  *   09/06/1991 JLB : Created.                                             *
     55  *   09/17/1991 JLB : Fixed return value bug.                              *
     56  *   01/31/1992 DRD : Modified to use new font format.                     *
     57  *   06/29/1994 SKB : modified for 32 bit library                          *
     58  *=========================================================================*/
     59 void * __cdecl Set_Font(void const *fontptr)
     60 {
     61 	void *oldfont;
     62 	char	const *blockptr;
     63 
     64 	oldfont = (void *) FontPtr;
     65 
     66 	if (fontptr) {
     67 		FontPtr    = (void *) fontptr;
     68 
     69 		/*
     70 		**	Inform the system about the new font.
     71 		*/
     72 
     73 		FontWidthBlockPtr = (char*)fontptr + *(unsigned short *)((char*)fontptr + FONTWIDTHBLOCK);
     74 		blockptr  = (char*)fontptr + *(unsigned short *)((char*)fontptr + FONTINFOBLOCK);
     75 		FontHeight = *(blockptr + FONTINFOMAXHEIGHT);
     76 		FontWidth  = *(blockptr + FONTINFOMAXWIDTH);
     77 		//Draw_Char_Setup();
     78 
     79 #if FALSE
     80 		WindowLines = WinH / FontHeight;
     81 		WindowWidth = WinW << 3;
     82 		WindowColumns = WindowWidth / FontWidth;
     83 #endif
     84 	}
     85 
     86 	return(oldfont);
     87 }