| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475 |
- /*
- ** Command & Conquer Generals Zero Hour(tm)
- ** Copyright 2025 Electronic Arts Inc.
- **
- ** This program is free software: you can redistribute it and/or modify
- ** it under the terms of the GNU General Public License as published by
- ** the Free Software Foundation, either version 3 of the License, or
- ** (at your option) any later version.
- **
- ** This program is distributed in the hope that it will be useful,
- ** but WITHOUT ANY WARRANTY; without even the implied warranty of
- ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ** GNU General Public License for more details.
- **
- ** You should have received a copy of the GNU General Public License
- ** along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- /************************************************************************************************
- *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
- ************************************************************************************************
- * *
- * Project Name: Setup *
- * *
- * Archive: TTFont.cpp *
- * *
- * Author: Maria del Mar McCready Legg *
- * *
- * Modtime: 8/24/99 3:44pm *
- * *
- * Revision: 01 *
- * *
- *----------------------------------------------------------------------------------------------*
- * Functions: *
- * TTFontClass::TTFontClass -- Constructor for a font class object. *
- * TTFontClass::Char_Pixel_Width -- Fetch the pixel width of the character specified. *
- * TTFontClass::Find_Text_VLength -- Finds length of text in pixels *
- * TTFontClass::Get_Height -- Fetch the normalized height of the nominal font character. *
- * TTFontClass::Get_Width -- Get normalized width of the nominal font character. *
- * TTFontClass::Print -- Print text to the surface specified. *
- * TTFontClass::Raw_Height -- Fetch the height of the font. *
- * TTFontClass::Raw_Width -- Fetch the raw width of a character. *
- * TTFontClass::Set_XSpacing -- Set the X spacing override value. *
- * TTFontClass::Set_YSpacing -- Set the vertical (Y) spacing override value. *
- * TTFontClass::String_Pixel_Width -- Determines the width of the string in pixels. *
- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
-
- #define STRICT
- #include <windows.h>
- #include <windowsx.h>
- #include <assert.h>
- #include <ctype.h>
- #include <stdlib.h>
- #include "args.h"
- #include "autorun.h"
- #include "rect.h"
- #include "wnd_file.h"
- #include "ttfont.h"
- #include "jsupport.h" // [OYO]
- #include "locale_api.h"
- #define FONTINFOMAXHEIGHT 4
- #define FONTINFOMAXWIDTH 5
- #define FUDGEDIV 16
- //-------------------------------------------------------------------------
- // Text Fonts.
- //-------------------------------------------------------------------------
- TTFontClass *TTButtonFontPtr = NULL;
- TTFontClass *TTButtonFontPtrSmall = NULL;
- TTFontClass *TTTextFontPtr = NULL;
- TTFontClass *TTTextFontPtr640 = NULL;
- TTFontClass *TTTextFontPtr800 = NULL;
- TTFontClass *TTLicenseFontPtr = NULL;
-
- FontManagerClass * FontManager = NULL;
- //unsigned long TEXT_COLOR = RGB( 247, 171, 11 );
- //unsigned long SHADOW_COLOR = RGB( 40, 8, 8 );
- unsigned long TEXT_COLOR = RGB( 255, 204, 51 );
- unsigned long SHADOW_COLOR = RGB( 40, 8, 8 );
- unsigned long TEXT_NORMAL_COLOR = RGB( 255, 204, 51 );
- unsigned long TEXT_NORMAL_SHADOW_COLOR = RGB( 40, 8, 8 );
- unsigned long TEXT_FOCUSED_COLOR = RGB( 255, 204, 51 );
- unsigned long TEXT_FOCUSED_SHADOW_COLOR = RGB( 40, 8, 8 );
- unsigned long TEXT_PRESSED_COLOR = RGB( 194, 79, 32 );
- unsigned long TEXT_PRESSED_SHADOW_COLOR = RGB( 70, 55, 49 );
- unsigned long BLACK_COLOR = RGB( 0, 0, 0 );
- unsigned long WHITE_COLOR = RGB( 255, 255, 255 );
- unsigned long RED_COLOR = RGB( 255, 0, 0 );
- unsigned long ORANGE_COLOR = RGB( 199, 91, 0 );
- unsigned long YELLOW_COLOR = RGB( 255, 247, 0 );
- unsigned long GREEN_COLOR = RGB( 0, 255, 0 );
- unsigned long BLUE_COLOR = RGB( 0, 0, 255 );
- unsigned long INDIGO_COLOR = RGB( 90, 2, 253 );
- unsigned long VIOLET_COLOR = RGB( 128, 0, 255 );
- /************************************************************************************
- * TTFontClass::TTFontClass -- Constructor for a font class object. *
- * *
- * This constructs a font object as it is based upon the true type windows fonts. *
- * *
- * INPUT: char *filename -- True Type Windows font file to open. *
- * char *facename -- It's face name. *
- * int height -- The height requested. *
- * *
- * OUTPUT: none *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 08/24/1999 MML : Created. *
- *==================================================================================*/
- TTFontClass::TTFontClass(
- HDC hdc,
- char *filename,
- char *facename,
- int height,
- int weight,
- BYTE charset,
- int width,
- int escapement,
- int orientation,
- BYTE italic,
- BYTE underline,
- BYTE strikeout,
- BYTE outputPrecision,
- BYTE clipPrecision,
- BYTE quality,
- BYTE pitchAndFamily )
- {
- HGDIOBJ old_object;
- TEXTMETRIC tm;
- char real_facename[MAX_PATH];
- //--------------------------------------------------------------------------
- // Get or Set a Font filename.
- //--------------------------------------------------------------------------
- if (( filename == NULL ) || ( filename[0] == '\0' )) {
- strcpy( szFilename, "Arial.ttf" );
- } else {
- strcpy( szFilename, filename );
- }
- //--------------------------------------------------------------------------
- // Get or Set a Font facename.
- //--------------------------------------------------------------------------
- if (( facename == NULL ) || ( facename[0] == '\0' )) {
- strcpy( szFacename, "Arial" );
- } else {
- strcpy( szFacename, facename );
- }
- real_facename[0] = '\0';
- Msg( __LINE__, __FILE__, "TTFontClass -- filename=%s, facename=%s, height=%d.", filename, facename, height );
- //--------------------------------------------------------------------------
- // Make sure the font file is "Registered". Then create the font.
- //--------------------------------------------------------------------------
- AddFontResource( szFilename );
- Font = CreateFont(
- height,
- width,
- escapement,
- orientation,
- weight,
- italic,
- underline,
- strikeout,
- charset,
- outputPrecision,
- clipPrecision,
- quality,
- pitchAndFamily,
- szFacename );
- if ( hdc && ( Font != NULL )) {
- //----------------------------------------------------------------------
- // The GetTextFace function lets a program determine the face name of
- // THE font currently selected in the device context:
- //----------------------------------------------------------------------
- old_object = SelectObject( hdc, Font );
- GetTextFace( hdc, ( sizeof( real_facename ) / sizeof( TCHAR )), real_facename );
- if( _stricmp( real_facename, szFacename ) != 0 ) {
- strcpy( szFilename, "Arial.ttf" );
- strcpy( szFacename, "Arial" );
- SelectObject( hdc, old_object );
- DeleteObject( Font );
- Font = NULL;
- Font = CreateFont(
- height, // height of font
- width, // average character width
- escapement, // angle of escapement
- orientation, // base-line orientation angle
- weight, // font weight
- italic, // italic attribute option
- underline, // underline attribute option
- strikeout, // strikeout attribute option
- charset, // character set identifier
- outputPrecision, // output precision
- clipPrecision, // clipping precision
- quality, // output quality
- pitchAndFamily, // pitch and family
- szFacename ); // typeface name
- real_facename[0] = '\0';
- old_object = SelectObject( hdc, Font );
- GetTextFace( hdc, ( sizeof( real_facename ) / sizeof( TCHAR )), real_facename );
- }
- }
- //--------------------------------------------------------------------------
- // Save off the height.
- //--------------------------------------------------------------------------
- Height = height;
- if ( hdc ) {
- //-----------------------------------------------------------------------
- // Get info from the font in BackBuffer's DC.
- //-----------------------------------------------------------------------
- old_object = SelectObject( hdc, Font );
- GetTextMetrics( hdc, &tm );
- FontXSpacing = GetTextCharacterExtra( hdc );
- Ascent = tm.tmAscent;
- Descent = tm.tmDescent;
- InternalLeading = tm.tmInternalLeading;
- ExternalLeading = tm.tmExternalLeading;
- AveCharWidth = tm.tmAveCharWidth;
- MaxCharWidth = tm.tmMaxCharWidth;
- Overhang = tm.tmOverhang;
- Italic = tm.tmItalic;
- Underlined = tm.tmUnderlined;
- StruckOut = tm.tmStruckOut;
- CharSet = tm.tmCharSet; // [OYO] It is important to support Double Byte Chars
- SelectObject( hdc, old_object );
- } else {
- //-----------------------------------------------------------------------
- // Set default values.
- //-----------------------------------------------------------------------
- Ascent = 0;
- Descent = 0;
- InternalLeading = 0;
- ExternalLeading = 0;
- AveCharWidth = 0;
- MaxCharWidth = 0;
- Overhang = 0;
- Italic = 0;
- Underlined = 0;
- StruckOut = 0;
- CharSet = 0; // [OYO]
- FontXSpacing = 0;
- }
- }
- /***********************************************************************************************
- * TTFontClass::Char_Pixel_Width -- Fetch the pixel width of the character specified. *
- * *
- * This will return with the pixel width of the character specified. *
- * *
- * INPUT: c -- The character to determine the pixel width for. *
- * *
- * OUTPUT: Returns with the pixel width of the character. *
- * *
- * WARNINGS: The return width is the screen real estate width which may differ from the *
- * actual pixels of the character. This difference is controlled by the font *
- * X spacing. *
- * *
- * HISTORY: *
- * 05/26/1997 JLB : Created. *
- *=============================================================================================*/
- int TTFontClass::Char_Pixel_Width( HDC hdc, UINT c ) const
- {
- HGDIOBJ old_object;
- ABC abc;
- abc.abcA = 0;
- abc.abcB = 0;
- abc.abcC = 0;
- if ( hdc ) {
- old_object = SelectObject( hdc, Font );
- GetCharABCWidths( hdc, c, c, &abc );
- SelectObject( hdc, old_object );
- }
- return( abc.abcA + abc.abcB + abc.abcC );
- }
- /************************************************************************************************
- * TTFontClass::Char_Pixel_Width -- Fetch the pixel width of the character specified.
- *
- * This will return with the pixel width of the character specified.
- *
- * INPUT: HDC hdc -- must be passed in from calling function.
- * char const * string -- the pointer to the character in the string.
- * int *num_bytes -- return number of bytes this character has: 1 or 2.
- *
- * OUTPUT: Returns with the pixel width of the character.
- *
- * WARNINGS: The return width is the screen real estate width which may differ from the
- * actual pixels of the character. This difference is controlled by the font
- * X spacing.
- *
- * NOTE: This is function determines if the character is a double-byte or single-byte
- * character, then calls the standard Char_Pixel_Width.
- *
- * HISTORY:
- * 05/26/1997 JLB : Created.
- *==============================================================================================*/
- //
- // [OYO] Supports DBCS ( multi-byte characters ).
- //
- int TTFontClass::Char_Pixel_Width ( HDC hdc, char const * string, int *num_bytes ) const
- {
- char const *letter = string;
- int length = 0;
- UINT c;
- //--------------------------------------------------------------------------
- // These values must be passed in.
- //--------------------------------------------------------------------------
- if ( string == NULL || *string == '\0' || hdc == NULL ) {
- return( 0 );
- }
- //--------------------------------------------------------------------------
- // If this value is passed in, the set the default value (1=single).
- //--------------------------------------------------------------------------
- if ( num_bytes!= NULL ) {
- *num_bytes = 1;
- }
- //--------------------------------------------------------------------------
- // Get the pixel width of the character. If it is a double-byte character,
- // then num_bytes will come back as '2'.
- //--------------------------------------------------------------------------
- if( IsFontDBCS() && IsDBCSLeadByte( *letter )){
- c = Get_Double_Byte_Char( letter, num_bytes );
- length += Char_Pixel_Width( hdc, c ); // pixel length of double-byte character.
- } else {
- length += Char_Pixel_Width( hdc, *letter ); // pixel length of single-byte character.
- }
- return( length );
- }
- /************************************************************************************************
- * TTFontClass::String_Pixel_Width -- Determines the width of the string in pixels. *
- * *
- * This routine is used to determine how many pixels wide the string will be if it were *
- * printed. *
- * *
- * INPUT: string -- The string to convert into its pixel width. *
- * *
- * OUTPUT: Returns with the number of pixels the string would span if it were printed. *
- * *
- * WARNINGS: This routine does not take into account clipping. *
- * *
- * HISTORY: *
- * 05/26/1997 JLB : Created. *
- *==============================================================================================*/
- int TTFontClass::String_Pixel_Width( HDC hdc, char const * string ) const
- {
- if ( string == NULL ) {
- return(0);
- }
- int largest = 0; // Largest recorded width of the string.
- int width = 0;
- HGDIOBJ old_object;
- int length;
- SIZE size;
- bool make_dc = FALSE;
- HDC localDC = hdc;
- size.cx = 0;
- if ( localDC == NULL ) {
- return( size.cx );
- }
- if ( localDC ) {
- length = strlen( string );
- old_object = SelectObject( localDC, Font );
- GetTextExtentPoint32( localDC, string, length, &size );
- SelectObject( localDC, old_object );
- }
- return( size.cx );
- }
- /****************************************************************************
- *
- * NAME
- * String_Pixel_Bounds(String, Bounds)
- *
- * DESCRIPTION
- * Calculate the bounding box for the specified string.
- *
- * INPUTS
- * String - String to calculate bounds for
- * Bounds - Rect to fill with bounds
- *
- * RESULT
- * NONE
- *
- ****************************************************************************/
- //
- // [OYO] Supports DBCS ( multi-byte characters ).
- //
- void TTFontClass::String_Pixel_Bounds( HDC hdc, const char* string, Rect& bounds ) const
- {
- int width;
- int height;
- bounds.Width = 0;
- bounds.Height = 0;
- if ( string == NULL ) {
- return;
- }
- if ( hdc == NULL ) {
- return;
- }
- width = 0;
- height = Get_Height();
- while ( *string != 0 ) {
- if (( *string == '\r' ) || ( *string == '\n' )) {
- string++;
- height += Get_Height();
- bounds.Width = max( bounds.Width, width );
- width = 0;
- } else if( IsFontDBCS()){
- #if(0)
- //--------------------------------------------------------------------
- // Using one of those _tc functions:
- // Get a character, get the width of that character, then
- // move the pointer to the next character.
- //--------------------------------------------------------------------
- UINT c = Get_Double_Byte_Char( string );
- width += Char_Pixel_Width( hdc, c );
- string = _tcsinc( string );
- #else
- //--------------------------------------------------------------------
- // MBCS way: Get a byte. If byte is a "Lead" byte, get the second half,
- // combine them into one character, then get the width of that character.
- //--------------------------------------------------------------------
- UINT c = *(BYTE*)string++;
- if( IsDBCSLeadByte( c )&& *string ) {
- c = ( c << 8 ) | *(BYTE *)string++;
- }
- width += Char_Pixel_Width( hdc, c );
- #endif
- } else {
- width += Char_Pixel_Width( hdc, *string++ );
- }
- }
- bounds.Width = max( bounds.Width, width );
- bounds.Height = height;
- }
- /***********************************************************************************************
- * TTFontClass::Get_Double_Byte_Char -- Get the first character even if DBSC.
- *
- * INPUT: char * -- string to look at.
- *
- * OUTPUT: Returns with the normalized width of the character in the font.
- *
- * WARNINGS: I added this function based on code provided by Ikeda-san.
- *
- * HISTORY:
- * 06/05/2000 MML : Created.
- *=============================================================================================*/
- //
- // [OYO] Supports DBCS ( multi-byte characters ).
- //
- UINT TTFontClass::Get_Double_Byte_Char ( const char *string, int *num_bytes ) const
- {
- if ( string == NULL || *string == '\0' ) {
- return( 0 );
- }
- const char *ptr = string;
- UINT c = *(BYTE *)ptr++;
- if ( num_bytes != NULL ) {
- *num_bytes = 1;
- }
- //--------------------------------------------------------------------------
- // The IsDBCSLeadByte function determines whether a character is a
- // lead byte — that is, the first byte of a character in a double-byte
- // character set (DBCS).
- //
- // BOOL IsDBCSLeadByte( BYTE TestChar /* character to test */ );
- //
- // TestChar -- Specifies the character to be tested.
- //
- // Return Values
- // If the character is a lead byte, the return value is nonzero.
- // If the character is not a lead byte, the return value is zero.
- // To get extended error information, call GetLastError.
- // Remarks
- // Lead bytes are unique to double-byte character sets.
- // A lead byte introduces a double-byte character. Lead bytes
- // occupy a specific range of byte values. The IsDBCSLeadByte
- // function uses the ANSI code page to check lead-byte ranges.
- // To specify a different code page, use the IsDBCSLeadByteEx function.
- //
- // Declared in winnls.h.
- //--------------------------------------------------------------------------
- if( IsDBCSLeadByte( c )&& *ptr ) { // [OYO]
- c = ( c << 8 ) | *(BYTE *)ptr++;
- if ( num_bytes != NULL ) {
- *num_bytes = 2;
- }
- }
- return( c );
- }
- /***********************************************************************************************
- * TTFontClass::Get_Width -- Get normalized width of the nominal font character. *
- * *
- * This routine is used to fetch the width of the widest character in the font but the *
- * width has been biased according to any X spacing override present. *
- * *
- * INPUT: none *
- * *
- * OUTPUT: Returns with the normalized width of the widest character in the font. *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 05/26/1997 JLB : Created. *
- *=============================================================================================*/
- int TTFontClass::Get_Width( void ) const
- {
- return( MaxCharWidth - Overhang );
- }
- /***********************************************************************************************
- * TTFontClass::Get_Height -- Fetch the normalized height of the nominal font character. *
- * *
- * This will return the height of the font but the returned height will be adjusted by any *
- * Y spacing override present. *
- * *
- * INPUT: none *
- * *
- * OUTPUT: Returns with the height of the font normalized by any spacing overrides. *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 05/26/1997 JLB : Created. *
- *=============================================================================================*/
- int TTFontClass::Get_Height( void ) const
- {
- return( Height );
- }
- /***********************************************************************************************
- * TTFontClass::Set_XSpacing -- Set the X spacing override value. *
- * *
- * Use this routine to control the horizontal spacing override for this font. If the value *
- * is negative, the font becomes compressed. If the value is positive, then the font *
- * becomes expanded. *
- * *
- * INPUT: x -- The X spacing override to use for this font. *
- * *
- * OUTPUT: Returns with the old X spacing override value. *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 05/26/1997 JLB : Created. *
- *=============================================================================================*/
- int TTFontClass::Set_XSpacing( HDC hdc, int x )
- {
- // HGDIOBJ old_object;
- // int answer = 0;
- // if ( hdc ) {
- // old_object = SelectObject( hdc, Font );
- // answer = SetTextCharacterExtra( hdc, x );
- // SelectObject( hdc, old_object );
- // }
- FontXSpacing = x;
- return( x );
- }
- /***********************************************************************************************
- * TTFontClass::Set_YSpacing -- Set the vertical (Y) spacing override value. *
- * *
- * Use this routine to control the "line spacing" of a font. If the Y spacing is negative *
- * then the font becomes closer to the line above it. If value is positive, then more *
- * space occurs between lines. *
- * *
- * INPUT: y -- The Y spacing override to use for this font. *
- * *
- * OUTPUT: Returns with the old Y spacing override value. *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 05/26/1997 JLB : Created. *
- *=============================================================================================*/
- int TTFontClass::Set_YSpacing( int y )
- {
- FontYSpacing = y;
- return(y);
- }
- /***********************************************************************************************
- * TTFontClass::Print -- Print text to the surface specified. WCHAR Version. *
- * *
- * This displays text to the surface specified and with the attributes specified. *
- * *
- * INPUT: string -- The string to display to the surface. *
- * surface -- The surface to display the text upon. *
- * cliprect -- The clipping rectangle that both clips the text and biases the print *
- * location to. *
- * point -- The draw position for the upper left corner of the first character. *
- * convert -- The pixel convert object that is used to draw the correct colors to *
- * the destination surface. *
- * remap -- Auxiliary remap table for font colors. *
- * *
- * OUTPUT: Returns with the point where the next print should begin if it is to smoothly *
- * continue where this print operation left off. *
- * *
- * WARNINGS: There are two separate drawing routines; one for old fonts and one for new fonts. *
- * *
- * HISTORY: *
- * 05/26/1997 JLB : Created. *
- * 06/20/1887 BNA : Modified to handle new fonts. *
- *=============================================================================================*/
- #if(NDEBUG)
- Point2D TTFontClass::Print(
- HDC hdc,
- wchar_t const * string,
- Rect const & cliprect,
- COLORREF forecolor, /* = TEXT_COLOR, */
- COLORREF backcolor, /* = TEXT_SHADOW_COLOR, */
- TextFormatType flag, /* = TPF_DEFAULT, */
- TextShadowType shadow ) /* = TPF_FULLSHADOW */
- {
- char buffer[ _MAX_PATH ];
- int length = wcslen( string );
- memset( buffer, '\0', _MAX_PATH );
- WideCharToMultiByte( CodePage, 0, string, length, buffer, _MAX_PATH, NULL, NULL );
- return( Print( hdc, buffer, cliprect, forecolor, backcolor, flag, shadow ));
- }
- #else
- Point2D TTFontClass::Print(
- HDC hdc,
- wchar_t const * string,
- Rect const & cliprect,
- COLORREF forecolor, /* = TEXT_COLOR, */
- COLORREF backcolor, /* = TEXT_SHADOW_COLOR, */
- TextFormatType flag, /* = TPF_DEFAULT, */
- TextShadowType shadow ) /* = TPF_FULLSHADOW */
- {
- Point2D point( cliprect.X, cliprect.Y );
- RECT rect;
- HGDIOBJ old_object;
- SIZE size;
- int length = 0;
- int result = 0;
- //--------------------------------------------------------------------------
- // If no string, why continue?
- //--------------------------------------------------------------------------
- assert( string != NULL );
- assert( hdc != NULL );
- if (( string == NULL ) || ( string[0] == '\0' )) {
- return( point );
- }
- //--------------------------------------------------------------------------
- // Set up rectangle print regions for the "shadow" and the main color.
- //--------------------------------------------------------------------------
- length = wcslen( string );
- rect.left = cliprect.X;
- rect.top = cliprect.Y;
- rect.right = cliprect.X + cliprect.Width;
- rect.bottom = cliprect.Y + cliprect.Height;
- Msg( __LINE__, __FILE__, "TTFontClass::Print -- string = %s.", string );
- Msg( __LINE__, __FILE__, "TTFontClass::Print -- strlen = %d.", length );
- Msg( __LINE__, __FILE__, "TTFontClass::Print -- rect = [%d, %d, %d, %d].", rect.left, rect.top, rect.right, rect.bottom );
- // Msg( __LINE__, __FILE__, "TTFontClass::Print -- rect2 = [%d, %d, %d, %d].", rect.left, rect.top, rect.right, rect.bottom );
- //--------------------------------------------------------------------------
- // Print the "Shadow" depending on style desired, then the text in the requested color.
- //--------------------------------------------------------------------------
- if ( hdc ) {
- assert( Font != NULL );
- old_object = SelectObject( hdc, Font );
- SetTextCharacterExtra( hdc, FontXSpacing );
- SetTextAlign( hdc, TA_LEFT | TA_TOP );
- SetBkMode( hdc, TRANSPARENT );
- SetTextColor( hdc, forecolor );
- // result = ExtTextOutW(
- // hdc, // handle to DC
- // rect.left, // x-coordinate of reference point
- // rect.top, // y-coordinate of reference point
- // ETO_CLIPPED, // text-output options
- // &rect, // optional dimensions
- // string, // string
- // length, // number of characters in string
- // NULL // array of spacing values
- // );
- // result = TextOutW(
- // hdc, // handle to DC
- // rect.left, // x-coordinate of starting position
- // rect.top, // y-coordinate of starting position
- // string, // character string
- // length // number of characters
- // );
-
- result = DrawTextW(
- hdc,
- string,
- length,
- &rect,
- flag );
-
- GetTextExtentPointW( hdc, string, length, &size );
- SelectObject( hdc, old_object );
- }
- point.X += size.cx;
- return( point );
- }
- #endif
- /***********************************************************************************************
- * TTFontClass::Print -- Print text to the surface specified. CHAR version. *
- * *
- * This displays text to the surface specified and with the attributes specified. *
- * *
- * INPUT: string -- The string to display to the surface. *
- * surface -- The surface to display the text upon. *
- * cliprect -- The clipping rectangle that both clips the text and biases the print *
- * location to. *
- * point -- The draw position for the upper left corner of the first character. *
- * convert -- The pixel convert object that is used to draw the correct colors to *
- * the destination surface. *
- * remap -- Auxiliary remap table for font colors. *
- * *
- * OUTPUT: Returns with the point where the next print should begin if it is to smoothly *
- * continue where this print operation left off. *
- * *
- * WARNINGS: There are two separate drawing routines; one for old fonts and one for new fonts. *
- * *
- * HISTORY: *
- * 05/26/1997 JLB : Created. *
- * 06/20/1887 BNA : Modified to handle new fonts. *
- *=============================================================================================*/
- Point2D TTFontClass::Print(
- HDC hdc,
- char const * string,
- Rect const & cliprect,
- COLORREF forecolor, /* = TEXT_COLOR, */
- COLORREF backcolor, /* = TEXT_SHADOW_COLOR, */
- TextFormatType flag, /* = TPF_DEFAULT, */
- TextShadowType shadow ) /* = TPF_FULLSHADOW */
- {
- Point2D point( cliprect.X, cliprect.Y );
- RECT rect, rect2;
- HGDIOBJ old_object;
- SIZE size;
- int length = 0;
- int result = 0;
- //--------------------------------------------------------------------------
- // If no string, why continue?
- //--------------------------------------------------------------------------
- assert( string != NULL );
- assert( hdc != NULL );
- if (( string == NULL ) || ( string[0] == '\0' )) {
- return( point );
- }
- //--------------------------------------------------------------------------
- // Set up rectangle print regions for the "shadow" and the main color.
- //--------------------------------------------------------------------------
- length = strlen( string );
- rect.left = cliprect.X;
- rect.top = cliprect.Y;
- rect.right = cliprect.X + cliprect.Width;
- rect.bottom = cliprect.Y + cliprect.Height;
- // Shadow
- rect2.left = rect.left - 1;
- rect2.top = rect.top - 1;
- rect2.right = rect.right - 1;
- rect2.bottom= rect.bottom - 1;
- // Msg( __LINE__, __FILE__, "TTFontClass::Print -- strlen = %d.", length );
- // Msg( __LINE__, __FILE__, "TTFontClass::Print -- rect = [%d, %d, %d, %d].", rect.left, rect.top, rect.right, rect.bottom );
- // Msg( __LINE__, __FILE__, "TTFontClass::Print -- rect2 = [%d, %d, %d, %d].", rect.left, rect.top, rect.right, rect.bottom );
- //--------------------------------------------------------------------------
- // Print the "Shadow" depending on style desired, then the text in the requested color.
- //--------------------------------------------------------------------------
- if ( hdc ) {
- assert( Font != NULL );
- old_object = SelectObject( hdc, Font );
- SetTextCharacterExtra( hdc, FontXSpacing );
- SetTextAlign( hdc, TA_LEFT | TA_TOP );
- SetBkMode( hdc, TRANSPARENT );
- SetTextColor( hdc, backcolor );
- if ( shadow == TPF_SHADOW ) {
- // One left, One up.
- result = DrawText( hdc, string, length, &rect2, flag );
- assert( result != 0 );
- // One left.
- rect2.left = rect.left - 1;
- rect2.top = rect.top;
- rect2.right = rect.right - 1;
- rect2.bottom = rect.bottom;
- result = DrawText( hdc, string, length, &rect2, flag );
- assert( result != 0 );
- // One up.
- rect2.left = rect.left;
- rect2.top = rect.top - 1;
- rect2.right = rect.right;
- rect2.bottom = rect.bottom - 1;
- result = DrawText( hdc, string, length, &rect2, flag );
- assert( result != 0 );
- } else if ( shadow == TPF_DOUBLESHADOW ) {
- // One left, One up.
- result = DrawText( hdc, string, length, &rect2, flag );
- assert( result != 0 );
- // One left.
- rect2.left = rect.left - 1;
- rect2.top = rect.top;
- result = DrawText( hdc, string, length, &rect2, flag );
- assert( result != 0 );
- // One up.
- rect2.left = rect.left;
- rect2.top = rect.top - 1;
- result = DrawText( hdc, string, length, &rect2, flag );
- assert( result != 0 );
- // Two left, Two up.
- rect2.left = rect.left - 2;
- rect2.top = rect.top - 2;
- result = DrawText( hdc, string, length, &rect2, flag );
- assert( result != 0 );
- // Two left.
- rect2.left = rect.left - 2;
- rect2.top = rect.top;
- result = DrawText( hdc, string, length, &rect2, flag );
- assert( result != 0 );
- // Two up.
- rect2.left = rect.left;
- rect2.top = rect.top - 2;
- result = DrawText( hdc, string, length, &rect2, flag );
- assert( result != 0 );
- } else if ( shadow == TPF_FULLSHADOW ) {
- // One left, One up.
- result = DrawText( hdc, string, length, &rect2, flag );
- assert( result != 0 );
- // One right, One up.
- rect2.left = rect.left + 1;
- rect2.top = rect.top - 1;
- result = DrawText( hdc, string, length, &rect2, flag );
- assert( result != 0 );
- // One left, One down.
- rect2.left = rect.left - 1;
- rect2.top = rect.top + 1;
- result = DrawText( hdc, string, length, &rect2, flag );
- assert( result != 0 );
- // One right, One down.
- rect2.left = rect.left + 1;
- rect2.top = rect.top + 1;
- result = DrawText( hdc, string, length, &rect2, flag );
- assert( result != 0 );
- // One left.
- rect2.left = rect.left - 1;
- rect2.top = rect.top;
- result = DrawText( hdc, string, length, &rect2, flag );
- assert( result != 0 );
- // One right.
- rect2.left = rect.left + 1;
- rect2.top = rect.top;
- result = DrawText( hdc, string, length, &rect2, flag );
- assert( result != 0 );
- // One up.
- rect2.left = rect.left;
- rect2.top = rect.top - 1;
- result = DrawText( hdc, string, length, &rect2, flag );
- assert( result != 0 );
- // One down.
- rect2.left = rect.left;
- rect2.top = rect.top + 1;
- result = DrawText( hdc, string, length, &rect2, flag );
- assert( result != 0 );
- // Two right.
- rect2.left = rect.left + 2;
- rect2.top = rect.top;
- result = DrawText( hdc, string, length, &rect2, flag );
- assert( result != 0 );
- // Two down.
- rect2.left = rect.left;
- rect2.top = rect.top + 2;
- result = DrawText( hdc, string, length, &rect2, flag );
- assert( result != 0 );
- // Two right, One up.
- rect2.left = rect.left + 2;
- rect2.top = rect.top - 2;
- result = DrawText( hdc, string, length, &rect2, flag );
- assert( result != 0 );
- // Two right, One down.
- rect2.left = rect.left + 2;
- rect2.top = rect.top + 2;
- result = DrawText( hdc, string, length, &rect2, flag );
- assert( result != 0 );
- // Three right.
- rect2.left = rect.left + 3;
- rect2.top = rect.top;
- result = DrawText( hdc, string, length, &rect2, flag );
- assert( result != 0 );
- // Three down.
- rect2.left = rect.left;
- rect2.top = rect.top + 3;
- result = DrawText( hdc, string, length, &rect2, flag );
- assert( result != 0 );
- // Three right, One up.
- rect2.left = rect.left + 3;
- rect2.top = rect.top - 3;
- result = DrawText( hdc, string, length, &rect2, flag );
- assert( result != 0 );
- // Three right, One down.
- rect2.left = rect.left + 3;
- rect2.top = rect.top + 3;
- result = DrawText( hdc, string, length, &rect2, flag );
- assert( result != 0 );
- }
- SetTextColor( hdc, forecolor );
- result = DrawText( hdc, string, length, &rect, flag );
- assert( result != 0 );
- GetTextExtentPoint( hdc, string, length, &size );
- SelectObject( hdc, old_object );
- }
- point.X += size.cx;
- return( point );
- }
- /***************************************************************************
- * TTFontClass::FIND_TEXT_VLENGTH -- Finds length of text in pixels *
- * *
- * INPUT: BYTE *string - the strength to find the vertical length of *
- * int width - the width of the region to fit it in *
- * *
- * OUTPUT: int -- the number of pixels it takes up veritcally. *
- * *
- * HISTORY: *
- * 09/27/1994 PWG : Created. *
- *=========================================================================*/
- //
- // [OYO] Supports DBCS ( multi-byte characters ).
- //
- int TTFontClass::Find_Text_VLength( HDC hdc, char *str, int width )
- {
- int curlen = 0;
- int lastlen = 0;
- int lines = Get_Height();
- char *letter = str;
- bool make_dc = FALSE;
- HDC localDC = hdc;
- if ( *str == '\0' || str == NULL ) {
- return( 0 );
- }
- //--------------------------------------------------------------------------
- // If no DC was passed in, then we need to get one.
- //--------------------------------------------------------------------------
- if ( localDC == NULL ) {
- return( 0 );
- }
- //==========================================================================
- // Process languages EXCEPT Double-byte languages.
- //==========================================================================
- if( !(IS_LANGUAGE_DBCS( LanguageID ))) {
- //-----------------------------------------------------------------------
- // Get the pixel length of the string.
- //-----------------------------------------------------------------------
- curlen = String_Pixel_Width( localDC, str );
- lines = 0;
- //-----------------------------------------------------------------------
- // If the string in longer than the width given, calculate the number of
- // lines needed in pixels (height of string in pixels ).
- //-----------------------------------------------------------------------
- if ( curlen > width ) {
- while( curlen > 0 ) {
- if ( curlen > width ) {
- curlen -= width;
- } else {
- curlen = 0;
- }
- lines += Get_Height();
- }
- } else {
- lines = Get_Height();
- }
- //-----------------------------------------------------------------------
- // Check for any newlines. Add one line per newline.
- //-----------------------------------------------------------------------
- letter = str;
- while ( *letter ) {
- if ( *letter == '\n') {
- lines += Get_Height();
- }
- letter++;
- }
- } else {
- //=======================================================================
- // Process Double-Byte language text.
- //=======================================================================
- int i, n, wspc;
- UINT c;
- int fdbcs = IsFontDBCS();
- lines = 0;
- //-----------------------------------------------------------------------
- // For each word...
- //-----------------------------------------------------------------------
- while ( n = nGetWord( letter, fdbcs )) {
- //--------------------------------------------------------------------
- // For each character in the word...
- //--------------------------------------------------------------------
- for ( c=0, wspc=0, curlen=0, i=0; i < n; i++ ) {
- if ( c ) {
- //--------------------------------------------------------------
- // Double-byte character.
- //--------------------------------------------------------------
- c = ( c<<8 )|(UINT)(BYTE)letter[i];
- curlen += Char_Pixel_Width( localDC, c ) + wspc;
- c = 0;
- wspc = 0;
- } else if( fdbcs && IsDBCSLeadByte((BYTE)letter[i])) {
- //--------------------------------------------------------------
- // First half of a Double-byte character.
- //--------------------------------------------------------------
- c = (UINT)(BYTE)letter[i];
- } else if((BYTE)letter[i] > ' ' ) {
- //--------------------------------------------------------------
- // Single-byte character.
- //--------------------------------------------------------------
- curlen += Char_Pixel_Width( localDC, (UINT)(BYTE)letter[i] ) + wspc;
- wspc = 0;
- } else if( letter[i] == ' ') {
- //--------------------------------------------------------------
- // Space character.
- //--------------------------------------------------------------
- wspc += Char_Pixel_Width( localDC, ' ' );
- }
- } // end-of-for
- //--------------------------------------------------------------------
- //
- //--------------------------------------------------------------------
- if( lastlen + curlen > width ) {
- lines += Get_Height();
- lastlen = 0;
- }
- //--------------------------------------------------------------------
- // !!! If one block length bigger than available width,
- // next line will be overflow. but never endless loop. !!!
- //--------------------------------------------------------------------
- lastlen += curlen + wspc;
- //--------------------------------------------------------------------
- //
- //--------------------------------------------------------------------
- if( letter[i] == '\n' ) {
- lines += Get_Height();
- lastlen = 0;
- }
- letter += n;
- } // end-of-while
- //-----------------------------------------------------------------------
- // Left over, add a line.
- //-----------------------------------------------------------------------
- if( lastlen ) {
- lines += Get_Height();
- }
- }
- //--------------------------------------------------------------------------
- // Return the number of lines.
- //--------------------------------------------------------------------------
- if ( !lines ) {
- lines = Get_Height();
- }
- return( lines );
- }
- /***********************************************************************************************
- * FontManagerClass::FontManagerClass -- Constructor for FontManager class. *
- * *
- * INPUT: none. *
- * *
- * OUTPUT: none *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 03/26/1998 MML : Created. *
- *=============================================================================================*/
- FontManagerClass::FontManagerClass ( HDC hdc )
- {
- //--------------------------------------------------------------------------
- // Open a DC to the BackBuffer.
- //--------------------------------------------------------------------------
- if ( hdc ) {
- char szPath[ MAX_PATH ];
- char szFile[ MAX_PATH ];
- char szFacename[ MAX_PATH ];
- char drive[ _MAX_DRIVE ];
- char dir[ _MAX_DIR ];
- bool b640X480 = false;
- RECT rect; // Desktop Window ( used once ).
- strcpy( szFile, "Arial.ttf" );
- strcpy( szFacename, "Arial" );
- strcpy( szPath, Args->Get_argv(0));
- _splitpath( szPath, drive, dir, NULL, NULL );
- _makepath( szPath, drive, dir, "Setup\\Setup", ".ini" );
- GetPrivateProfileString( "Fonts", "Font", "Arial.tff", szFile, MAX_PATH, szPath );
- GetPrivateProfileString( "Fonts", "Fontname", "Arial", szFacename, MAX_PATH, szPath );
- //---------------------------------------------------------------------
- // Use codepage set by Locomoto class.
- //---------------------------------------------------------------------
- UINT codepage = CodePage; // GetACP();
- GetClientRect( GetDesktopWindow(), &rect );
- if( rect.right <= 640 ) {
- b640X480 = TRUE;
- }
- Msg( __LINE__, __FILE__, "FontManagerClass -- szFile = %s, szFilename = %s.", szFile, szFacename );
- //---------------------------------------------------------------------
- // Create the True Type Fonts.
- //
- // Value Weight
- // ____________________________
- // FW_DONTCARE 0
- // FW_THIN 100
- // FW_EXTRALIGHT 200
- // FW_ULTRALIGHT 200
- // FW_LIGHT 300
- // FW_NORMAL 400
- // FW_REGULAR 400
- // FW_MEDIUM 500
- // FW_SEMIBOLD 600
- // FW_DEMIBOLD 600
- // FW_BOLD 700
- // FW_EXTRABOLD 800
- // FW_ULTRABOLD 800
- // FW_HEAVY 900
- // FW_BLACK 900
- //---------------------------------------------------------------------
- switch( LanguageID ) { // [OYO] Add this line if you wish to support another languages
- //=================================================================
- // JAPANESE
- //=================================================================
- case LANG_JAP: // [OYO] Use MS PGothic for Japanese Win9x
- if( codepage == 932 ) {
- strcpy( szFile, "MSGothic.ttc" );
- strcpy( szFacename, "MS PGothic" );
- TTButtonFontPtr = new TTFontClass( hdc, szFile, szFacename, 20, FW_NORMAL, SHIFTJIS_CHARSET );
- TTButtonFontPtrSmall= new TTFontClass( hdc, szFile, szFacename, 12, FW_NORMAL, SHIFTJIS_CHARSET );
- TTTextFontPtr = new TTFontClass( hdc, szFile, szFacename, 16, FW_MEDIUM, SHIFTJIS_CHARSET );
- TTTextFontPtr640 = new TTFontClass( hdc, szFile, szFacename, 14, FW_MEDIUM, SHIFTJIS_CHARSET );
- TTTextFontPtr800 = new TTFontClass( hdc, szFile, szFacename, 14, FW_MEDIUM, SHIFTJIS_CHARSET );
- TTLicenseFontPtr = new TTFontClass( hdc, szFile, szFacename, 12, FW_NORMAL, SHIFTJIS_CHARSET );
- }
- break;
- //=================================================================
- // KOREAN
- //=================================================================
- case LANG_KOR: // [OYO] Use GulimChe for Korean Win9x
- if ( codepage == 949 ) {
- strcpy( szFile, "Gulim.tff" );
- strcpy( szFacename, "Gulim" );
- TTButtonFontPtr = new TTFontClass( hdc, szFile, szFacename, 20, FW_NORMAL, HANGEUL_CHARSET );
- TTButtonFontPtrSmall= new TTFontClass( hdc, szFile, szFacename, 20, FW_NORMAL, HANGEUL_CHARSET );
- TTTextFontPtr = new TTFontClass( hdc, szFile, szFacename, 16, FW_MEDIUM, HANGEUL_CHARSET );
- TTTextFontPtr640 = new TTFontClass( hdc, szFile, szFacename, 14, FW_MEDIUM, HANGEUL_CHARSET );
- TTTextFontPtr800 = new TTFontClass( hdc, szFile, szFacename, 14, FW_MEDIUM, HANGEUL_CHARSET );
- TTLicenseFontPtr = new TTFontClass( hdc, szFile, szFacename, 12, FW_NORMAL, HANGEUL_CHARSET );
- }
- break;
- //=================================================================
- // CHINESE
- //=================================================================
- case LANG_CHI:
- if ( codepage == 950 ) {
- strcpy( szFile, "mingliu.ttc" );
- strcpy( szFacename, "mingliu" );
- TTButtonFontPtr = new TTFontClass( hdc, szFile, szFacename, 20, FW_NORMAL, CHINESEBIG5_CHARSET );
- TTButtonFontPtrSmall= new TTFontClass( hdc, szFile, szFacename, 14, FW_NORMAL, CHINESEBIG5_CHARSET );
- TTTextFontPtr = new TTFontClass( hdc, szFile, szFacename, 16, FW_MEDIUM, CHINESEBIG5_CHARSET );
- TTTextFontPtr640 = new TTFontClass( hdc, szFile, szFacename, 14, FW_MEDIUM, CHINESEBIG5_CHARSET );
- TTTextFontPtr800 = new TTFontClass( hdc, szFile, szFacename, 14, FW_MEDIUM, CHINESEBIG5_CHARSET );
- TTLicenseFontPtr = new TTFontClass( hdc, szFile, szFacename, 12, FW_NORMAL, CHINESEBIG5_CHARSET );
- }
- break;
- //=================================================================
- // ENGLISH, FRENCH, GERMAN
- //=================================================================
- case LANG_GER:
- case LANG_FRE:
- case LANG_USA:
- default:
- TTButtonFontPtr = new TTFontClass( hdc, szFile, szFacename, 22, FW_SEMIBOLD, ANSI_CHARSET, 0, 0, 0, FALSE );
- if( LANG_FRE == LanguageID ) {
- TTButtonFontPtrSmall= new TTFontClass( hdc, szFile, szFacename, 20, FW_SEMIBOLD, ANSI_CHARSET, 0, 0, 0, FALSE );
- } else {
- TTButtonFontPtrSmall= new TTFontClass( hdc, szFile, szFacename, 22, FW_SEMIBOLD, ANSI_CHARSET, 0, 0, 0, FALSE );
- }
- TTTextFontPtr = new TTFontClass( hdc, szFile, szFacename, 16, FW_SEMIBOLD, ANSI_CHARSET, 0, 0, 0, FALSE );
- TTTextFontPtr640 = new TTFontClass( hdc, szFile, szFacename, 14, FW_SEMIBOLD, ANSI_CHARSET, 0, 0, 0, FALSE );
- TTTextFontPtr800 = new TTFontClass( hdc, szFile, szFacename, 14, FW_SEMIBOLD, ANSI_CHARSET, 0, 0, 0, FALSE );
- TTLicenseFontPtr = new TTFontClass( hdc, szFile, szFacename, 12, FW_MEDIUM, ANSI_CHARSET, 0, 0, 0, FALSE );
- break;
- }
- //----------------------------------------------------------------------
- // If we fell through...
- //----------------------------------------------------------------------
- if( TTButtonFontPtr == NULL || TTTextFontPtr == NULL ) {
- strcpy( szFile, "Arial.tff" );
- strcpy( szFacename, "Arial" );
- if( TTButtonFontPtr == NULL ) {
- TTButtonFontPtr = new TTFontClass( hdc, szFile, szFacename, 22, FW_SEMIBOLD, ANSI_CHARSET, 0, 0, 0, FALSE );
- }
- if( TTButtonFontPtrSmall == NULL ) {
- TTButtonFontPtrSmall= new TTFontClass( hdc, szFile, szFacename, 22, FW_SEMIBOLD, ANSI_CHARSET, 0, 0, 0, FALSE );
- }
- if( TTTextFontPtr == NULL ) {
- TTTextFontPtr = new TTFontClass( hdc, szFile, szFacename, 16, FW_SEMIBOLD, ANSI_CHARSET, 0, 0, 0, FALSE );
- }
- if( TTTextFontPtr640 == NULL ) {
- TTTextFontPtr640 = new TTFontClass( hdc, szFile, szFacename, 14, FW_SEMIBOLD, ANSI_CHARSET, 0, 0, 0, FALSE );
- }
- if( TTTextFontPtr800 == NULL ) {
- TTTextFontPtr800 = new TTFontClass( hdc, szFile, szFacename, 14, FW_SEMIBOLD, ANSI_CHARSET, 0, 0, 0, FALSE );
- }
- if( TTLicenseFontPtr == NULL ) {
- TTLicenseFontPtr = new TTFontClass( hdc, szFile, szFacename, 12, FW_MEDIUM, ANSI_CHARSET, 0, 0, 0, FALSE );
- }
- }
- }
- assert( TTTextFontPtr != NULL );
- assert( TTTextFontPtr640 != NULL );
- assert( TTTextFontPtr800 != NULL );
- assert( TTButtonFontPtr != NULL );
- assert( TTButtonFontPtrSmall != NULL );
- assert( TTLicenseFontPtr != NULL );
- }
- /***********************************************************************************************
- * FontManagerClass::~FontManagerClass -- Destructor for FontManager class. *
- * *
- * INPUT: none. *
- * *
- * OUTPUT: none *
- * *
- * WARNINGS: none *
- * *
- * HISTORY: *
- * 03/26/1998 MML : Created. *
- *=============================================================================================*/
- FontManagerClass::~FontManagerClass ( void )
- {
- if ( TTButtonFontPtr != NULL ) {
- delete TTButtonFontPtr;
- TTButtonFontPtr = NULL;
- }
- if ( TTTextFontPtr != NULL ) {
- delete TTTextFontPtr;
- TTTextFontPtr = NULL;
- }
- }
- /***********************************************************************************************
- * Font_From_TPF -- Convert flags into a font pointer. *
- * *
- * This routine will examine the specified flags and return with a pointer to the font *
- * that the flags represent. *
- * *
- * INPUT: flags -- The flags to convert into a font pointer. *
- * *
- * OUTPUT: Returns with a font pointer that matches the flags. *
- * *
- * WARNINGS: If no match could be found, a default font pointer is returned. *
- * *
- * HISTORY: *
- * 05/26/1997 JLB : Created. *
- *=============================================================================================*/
- TTFontClass * Font_From_TPF ( TextPrintType flags )
- {
- TTFontClass *fontptr= NULL;
-
- switch (flags & 0x000F) {
- case TPF_BUTTON_FONT:
- fontptr = TTButtonFontPtr;
- break;
- case TPF_TEXT_FONT:
- fontptr = TTTextFontPtr;
- break;
- default:
- fontptr = TTTextFontPtr;
- break;
- }
- return( fontptr );
- }
- /************************************************************************************************
- * Is_True_Type_Font -- Convert flags into a font pointer. *
- * *
- * This routine will examine the specified flags and return with a pointer to the font *
- * that the flags represent. *
- * *
- * INPUT: flags -- The flags to convert into a font pointer. *
- * *
- * OUTPUT: Returns with a font pointer that matches the flags. *
- * *
- * WARNINGS: If no match could be found, a default font pointer is returned. *
- * *
- * HISTORY: *
- * 05/26/1997 JLB : Created. *
- *==============================================================================================*/
- bool Is_True_Type_Font( TextPrintType flags )
- {
- if (( flags == TPF_BUTTON_FONT ) || ( flags == TPF_TEXT_FONT )) {
- return TRUE;
- } else {
- return FALSE;
- }
- }
|