⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fontinfo.cpp

📁 linux下的一款播放器
💻 CPP
📖 第 1 页 / 共 4 页
字号:
				    ch - SBCS_FIRST_NON_CONTROL_CHAR])));			}		    }		    else if(isItalicized)		    {			break; //XXXEH- replace with table look-up.		    }		    else		    {			return INT16(float(fontDerivativeScaleFactor *				double((INT32)				arialFontWidths24PointRegular[				ch - SBCS_FIRST_NON_CONTROL_CHAR])));		    }		}}while(0);				//XXXEH- need lookup table!		float foo;		//Floating point error in release build forces the first part		// of this if to have to be added (release build was		// calculating:		// float(24) / (24.0) = 1.000000001		// (when it should be simply 1.0).		if(24 == ulFontPtSize  &&  1.0 == fontDerivativeScaleFactor)		{		    foo = float(UINT32((UINT16)arialFontWidths24PointRegular[			ch - SBCS_FIRST_NON_CONTROL_CHAR]));		}		else		{		    foo = 			float((fontDerivativeScaleFactor *			double(float(ulFontPtSize *			UINT32((UINT16)arialFontWidths24PointRegular[			ch - SBCS_FIRST_NON_CONTROL_CHAR]))) /			double(24.0)));		}		if(foo > INT16(foo))		{		    foo++;		}		return (INT16(foo));	    }	}	return INT16(ulFontPtSize/2);    }    else if(ulFontCharsetIndex & HX_DBCS_CHARSET)    {	if(ch > 0x00FF) //then is two-byte char:	{	    return INT16(ulFontPtSize);	}	return INT16(ulFontPtSize/2);    }    else if(ulFontCharsetIndex & HX_UNICODE_CHARSET)    {	return INT16(ulFontPtSize);    }    return FONTINFO_ERROR_UNKNOWN_CHARSET;}/////////////////////////////////////////////////////////////////////////////////  This function returns the "width" in pixels of the string pStr, given//  the font face, font charset, font point size, and whether or not the//  character is bold &/or italicized:////  WARNING: the value returned may be an error (which is a negative number)//  so you must check the return val before using it!  A negative number is//  the negative of the width found up to the point of error, so zero return//  means error occurred before any char widths were calculated.//INT16 GetStringWidthInPixels(_CHAR* pStr, ULONG32 len,	ULONG32 ulFontFaceIndex, ULONG32 ulFontPtSize, BOOL isBold,	BOOL isItalicized, ULONG32 ulFontCharsetIndex){    INT16 totalWidth = 0L;    if(!pStr  ||  !len)    {	return totalWidth;    }        ULONG32 ulIndx;    for(ulIndx=0; ulIndx<len; ulIndx++)    {	if(ulFontCharsetIndex & HX_DBCS_CHARSET)	{	    if((UCHAR)pStr[ulIndx]>= DBCS_MIN_LEAD_BYTE_VAL)	    {		//Is a 2-byte character, so deal with it:		if(len-1==ulIndx)//shouldn't happen! Lead byte w/o trail byte		{		    HX_ASSERT(len-1==ulIndx); //Lead byte w/o trail byte.		    return -totalWidth;		}		totalWidth += GetCharacterWidth(		    (pStr[ulIndx]<<8 | pStr[ulIndx+1]), //send two byte char.		    ulFontFaceIndex, ulFontPtSize, isBold, isItalicized,		    ulFontCharsetIndex);		ulIndx++;		continue;	    }	    //else drop on through and do the single-byte call below...	}	else if(ulFontCharsetIndex & HX_UNICODE_CHARSET)	{	    //Is a 2-byte character, so deal with it:	    if(len-1==ulIndx)//shouldn't happen! Lead byte w/o trail byte	    {		HX_ASSERT(len-1==ulIndx); //Lead byte w/o trail byte.		return -totalWidth;	    }	    totalWidth += GetCharacterWidth(		(pStr[ulIndx]<<8 | pStr[ulIndx+1]), //send two byte char.		ulFontFaceIndex, ulFontPtSize, isBold, isItalicized,		ulFontCharsetIndex);	    ulIndx++;	    continue;	}	totalWidth += GetCharacterWidth(pStr[ulIndx], ulFontFaceIndex,		ulFontPtSize, isBold, isItalicized, ulFontCharsetIndex);    }    return totalWidth;}/////////////////////////////////////////////////////////////////////////////////  This function returns the string associated with the point size, e.g.,//  a point size of 16 (which is FONT_SIZE_0) returns "+0":////  Note: pRetBuf must be capable of holding 3 chars + the NULL-terminator;//  retBufSize is the number of bytes pRetBuf was allocated.//void getFontPointSizeStringFromPtSize(ULONG32 ulPtSize, char* pRetBuf,	ULONG32 retBufSize){    if(retBufSize>0)    {	pRetBuf[0]='\0';    }    if(retBufSize < 4)    {	return;    }    switch(ulPtSize)    {	case FONT_SIZE_MINUS2:	    strcpy(pRetBuf,"-2"); /* Flawfinder: ignore */	    break;	case FONT_SIZE_MINUS1:	    strcpy(pRetBuf,"-1"); /* Flawfinder: ignore */	    break;	case FONT_SIZE_0:	    strcpy(pRetBuf,"+0"); /* Flawfinder: ignore */	    break;	case FONT_SIZE_PLUS1:	    strcpy(pRetBuf,"+1"); /* Flawfinder: ignore */	    break;	case FONT_SIZE_PLUS2:	    strcpy(pRetBuf,"+2"); /* Flawfinder: ignore */	    break;	case FONT_SIZE_PLUS3:	    strcpy(pRetBuf,"+3"); /* Flawfinder: ignore */	    break;	case FONT_SIZE_PLUS4:	    strcpy(pRetBuf,"+4"); /* Flawfinder: ignore */	    break;	default:	    strcpy(pRetBuf,"+0"); /* Flawfinder: ignore */	    break;    }}//Added this function as this code is now being called in// more than one place://///////////////////////////////////////////////////////////////////////////////  This function returns the string associated with the charset, e.g.,//  a charset value of CHARSET__us_ascii returns "us-ascii":////  Note: pRetBuf must be capable of holding 31 chars + the NULL-terminator;//  retBufSize is the number of bytes pRetBuf was allocated.//void getFontCharsetStringFromCharsetVal(ULONG32 ulCharsetVal, char* pRetBuf,	ULONG32 retBufSize){    if(retBufSize>0)    {	pRetBuf[0]='\0';    }    if(retBufSize < 32)    {	return;    }    switch(ulCharsetVal)    {	case CHARSET__us_ascii:	    strcpy(pRetBuf,"us-ascii"); /* Flawfinder: ignore */	    break;	case CHARSET__iso_8859_1:	    strcpy(pRetBuf,"iso-8859-1"); /* Flawfinder: ignore */	    break;	case CHARSET__x_mac_roman:	    strcpy(pRetBuf,"mac-roman"); /* Flawfinder: ignore */	    break;	case CHARSET__iso_2022_jp:	    strcpy(pRetBuf,"iso-2022-jp"); /* Flawfinder: ignore */	    break;	case CHARSET__x_sjis:	    strcpy(pRetBuf,"x-sjis"); /* Flawfinder: ignore */	    break;	case CHARSET__x_euc_jap:	    strcpy(pRetBuf,"x-euc-jap"); /* Flawfinder: ignore */	    break;	case CHARSET__euc_kr:	    strcpy(pRetBuf,"euc-kr"); /* Flawfinder: ignore */	    break;	case CHARSET__iso_2022_kr:	    strcpy(pRetBuf,"iso-2022-kr"); /* Flawfinder: ignore */	    break;	case CHARSET__gb2312:	    strcpy(pRetBuf,"gb2312"); /* Flawfinder: ignore */	    break;	case CHARSET__big5:	    strcpy(pRetBuf,"big5"); /* Flawfinder: ignore */	    break;	//XXXEH- need to support all the other charsets...	// (see fontdefs.h).	default:	    strcpy(pRetBuf,"us-ascii"); /* Flawfinder: ignore */	    break;    }}//Added this function as this code is now being called in// more than one place://///////////////////////////////////////////////////////////////////////////////  This function returns the string associated with the font face, e.g.,//  a font face index of 20 (TIMES_FONT_FACE_STR) returns "times":////  Note: pRetBuf must be capable of holding 31 chars + the NULL-terminator;//  retBufSize is the number of bytes pRetBuf was allocated.//void getFontFaceStringFromFaceIndex(ULONG32 ulFontFaceIndex, char* pRetBuf,	ULONG32 retBufSize,	//The following are necessary for backwards-compatibility; we don't	// want to support fonts that can't play on older players, so, if	// content version is older than when the font faces were added,	// we have to ignore those font faces:	ULONG32 ulMajorContentVersion, ULONG32 ulMinorContentVersion){    if(retBufSize>0)    {	pRetBuf[0]='\0';    }    if(retBufSize < 32)    {	return;    }    BOOL bActiveContentVersionIncludesKorean = FALSE;    //XXXEH: docs need updating: version="1.4" or higher must    // be set in the <window> tag of the rt file in order for    // Korean to be rendered:    if(ulMajorContentVersion >	    REAL_TEXT_KOREAN_FONT_HANDLING_CONTENT_MAJOR_VERSION	    ||	    (ulMajorContentVersion ==	    REAL_TEXT_KOREAN_FONT_HANDLING_CONTENT_MAJOR_VERSION	    &&	    ulMinorContentVersion >=	    REAL_TEXT_KOREAN_FONT_HANDLING_CONTENT_MINOR_VERSION)	    )    {	bActiveContentVersionIncludesKorean = TRUE;    }    switch(ulFontFaceIndex)    {	case TIMES_FONT_FACE_INDX:	    strcpy(pRetBuf, TIMES_FONT_FACE_STR); /* Flawfinder: ignore */	    break;	case COURIERTT_FONT_FACE_INDX:	    strcpy(pRetBuf, COURIERTT_FONT_FACE_STR2); /* Flawfinder: ignore */	    break;	case SYSTEM_FONT_FACE_INDX:	    strcpy(pRetBuf, SYSTEM_FONT_FACE_STR); /* Flawfinder: ignore */	    break;	case ARIAL_FONT_FACE_INDX:	    strcpy(pRetBuf, ARIAL_FONT_FACE_STR); /* Flawfinder: ignore */	    break;        case ARIAL_BLACK_FONT_FACE_INDX:	    strcpy(pRetBuf, ARIAL_BLACK_FONT_FACE_STR); /* Flawfinder: ignore */	    break;	case ARIAL_NARROW_FONT_FACE_INDX:	    strcpy(pRetBuf, ARIAL_NARROW_FONT_FACE_STR); /* Flawfinder: ignore */	    break;	case ARIAL_ROUNDED_MT_BOLD_FONT_FACE_INDX:	    strcpy(pRetBuf, ARIAL_ROUNDED_MT_BOLD_FONT_FACE_STR); /* Flawfinder: ignore */	    break;	case ALGERIAN_FONT_FACE_INDX:	    strcpy(pRetBuf, ALGERIAN_FONT_FACE_STR); /* Flawfinder: ignore */	    break;	case BOOK_ANTIQUA_FONT_FACE_INDX:	    strcpy(pRetBuf, BOOK_ANTIQUA_FONT_FACE_STR); /* Flawfinder: ignore */	    break;	case BOOKMAN_OLD_STYLE_FONT_FACE_INDX:	    strcpy(pRetBuf, BOOKMAN_OLD_STYLE_FONT_FACE_STR); /* Flawfinder: ignore */	    break;	case BRAGGADOCIO_FONT_FACE_INDX:	    strcpy(pRetBuf, BRAGGADOCIO_FONT_FACE_STR); /* Flawfinder: ignore */	    break;	case BRITANNIC_BOLD_FONT_FACE_INDX:	    strcpy(pRetBuf, BRITANNIC_BOLD_FONT_FACE_STR); /* Flawfinder: ignore */	    break;	case BRUSH_SCRIPT_FONT_FACE_INDX:	    strcpy(pRetBuf, BRUSH_SCRIPT_FONT_FACE_STR); /* Flawfinder: ignore */	    break;	case CENTURY_GOTHIC_FONT_FACE_INDX:	    strcpy(pRetBuf, CENTURY_GOTHIC_FONT_FACE_STR); /* Flawfinder: ignore */	    break;	case CENTURY_SCHOOLBOOK_FONT_FACE_INDX:	    strcpy(pRetBuf, CENTURY_SCHOOLBOOK_FONT_FACE_STR); /* Flawfinder: ignore */	    break;	case COLONNA_MT_FONT_FACE_INDX:	    strcpy(pRetBuf, COLONNA_MT_FONT_FACE_STR); /* Flawfinder: ignore */	    break;	case COMIC_SANS_MS_FONT_FACE_INDX:	    strcpy(pRetBuf, COMIC_SANS_MS_FONT_FACE_STR); /* Flawfinder: ignore */	    break;	case DESDEMONA_FONT_FACE_INDX:	    strcpy(pRetBuf, DESDEMONA_FONT_FACE_STR); /* Flawfinder: ignore */	    break;	case FOOTLIGHT_MT_LIGHT_FONT_FACE_INDX:	    strcpy(pRetBuf, FOOTLIGHT_MT_LIGHT_FONT_FACE_STR); /* Flawfinder: ignore */	    break;	case GARAMOND_FONT_FACE_INDX:	    strcpy(pRetBuf, GARAMOND_FONT_FACE_STR); /* Flawfinder: ignore */	    break;	case HAETTENSCHWEILER_FONT_FACE_INDX:	    strcpy(pRetBuf, HAETTENSCHWEILER_FONT_FACE_STR); /* Flawfinder: ignore */	    break;	case HELVETICA_FONT_FACE_INDX:	    strcpy(pRetBuf, HELVETICA_FONT_FACE_STR); /* Flawfinder: ignore */	    break;	case IMPACT_FONT_FACE_INDX:	    strcpy(pRetBuf, IMPACT_FONT_FACE_STR); /* Flawfinder: ignore */	    break;	case KINO_MT_FONT_FACE_INDX:	    strcpy(pRetBuf, KINO_MT_FONT_FACE_STR); /* Flawfinder: ignore */	    break;	case MATURA_MT_SCRIPT_CAPITALS_FONT_FACE_INDX:	    strcpy(pRetBuf, MATURA_MT_SCRIPT_CAPITALS_FONT_FACE_STR); /* Flawfinder: ignore */	    break;	case MODERN_FONT_FACE_INDX:	    strcpy(pRetBuf, MODERN_FONT_FACE_STR); /* Flawfinder: ignore */	    break;	case MS_DIALOG_FONT_FACE_INDX:	    strcpy(pRetBuf, MS_DIALOG_FONT_FACE_STR); /* Flawfinder: ignore */	    break;	case MS_DIALOG_LIGHT_FONT_FACE_INDX:	    strcpy(pRetBuf, MS_DIALOG_LIGHT_FONT_FACE_STR); /* Flawfinder: ignore */	    break;	case MS_LINEDRAW_FONT_FACE_INDX:	    strcpy(pRetBuf, MS_LINEDRAW_FONT_FACE_STR); /* Flawfinder: ignore */	    break;	case MS_SANS_SERIF_FONT_FACE_INDX:	    strcpy(pRetBuf, MS_SANS_SERIF_FONT_FACE_STR); /* Flawfinder: ignore */	    break;	case MS_SERIF_FONT_FACE_INDX:	    strcpy(pRetBuf, MS_SERIF_FONT_FACE_STR); /* Flawfinder: ignore */	    break;	case MS_SYSTEMEX_FONT_FACE_INDX:	    strcpy(pRetBuf, MS_SYSTEMEX_FONT_FACE_STR); /* Flawfinder: ignore */	    break;	case PLAYBILL_FONT_FACE_INDX:	    strcpy(pRetBuf, PLAYBILL_FONT_FACE_STR); /* Flawfinder: ignore */	    break;	case SMALL_FONTS_FONT_FACE_INDX:	    strcpy(pRetBuf, SMALL_FONTS_FONT_FACE_STR); /* Flawfinder: ignore */	    break;	case VERDANA_FONT_FACE_INDX:	    strcpy(pRetBuf, VERDANA_FONT_FACE_STR); /* Flawfinder: ignore */	    break;	case WIDE_LATIN_FONT_FACE_INDX:	    strcpy(pRetBuf, WIDE_LATIN_FONT_FACE_STR); /* Flawfinder: ignore */	    break;	//DBCS and UNICODE fonts:	case OSAKA_FONT_FACE_INDX:	    strcpy(pRetBuf, OSAKA_FONT_FACE_STR); /* Flawfinder: ignore */	    break;	case SIMPLECHINESE_FONT_FACE_INDX:	    strcpy(pRetBuf, SIMPLECHINESE_FONT_FACE_STR); /* Flawfinder: ignore */	    break;	case TRADITIONALCHINESE_FONT_FACE_INDX:	    strcpy(pRetBuf, TRADITIONALCHINESE_FONT_FACE_STR); /* Flawfinder: ignore */	    break;	case SEOUL_FONT_FACE_INDX:	    strcpy(pRetBuf, /* Flawfinder: ignore */		    bActiveContentVersionIncludesKorean?		    SEOUL_FONT_FACE_STR : DEFAULT_FONT_STR);	    break;	case BATANG_FONT_FACE_INDX:	    strcpy(pRetBuf, /* Flawfinder: ignore */		    bActiveContentVersionIncludesKorean?		    BATANG_FONT_FACE_STR : DEFAULT_FONT_STR);	    break;	case BATANGCHE_FONT_FACE_INDX:	    strcpy(pRetBuf, /* Flawfinder: ignore */		    bActiveContentVersionIncludesKorean?		    BATANGCHE_FONT_FACE_STR : DEFAULT_FONT_STR);	    break;	case GULIM_FONT_FACE_INDX:	    strcpy(pRetBuf, /* Flawfinder: ignore */		    bActiveContentVersionIncludesKorean?		    GULIM_FONT_FACE_STR : DEFAULT_FONT_STR);	    break;	case GULIMCHE_FONT_FACE_INDX:	    strcpy(pRetBuf, /* Flawfinder: ignore */		    bActiveContentVersionIncludesKorean?		    GULIMCHE_FONT_FACE_STR : DEFAULT_FONT_STR);	    break;	case GOTHIC_FONT_FACE_INDX:	    strcpy(pRetBuf, /* Flawfinder: ignore */		    bActiveContentVersionIncludesKorean?		    GOTHIC_FONT_FACE_STR : DEFAULT_FONT_STR);	    break;	case APPLEGOTHIC_FONT_FACE_INDX:	    strcpy(pRetBuf, /* Flawfinder: ignore */		    bActiveContentVersionIncludesKorean?		    APPLEGOTHIC_FONT_FACE_STR : DEFAULT_FONT_STR);	    break;	default:	//XXXEH- handle more fonts here!?!?	    strcpy(pRetBuf, DEFAULT_FONT_STR); /* Flawfinder: ignore */	    break;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -