diff --git a/Docs/src/attributes.but b/Docs/src/attributes.but index 5774b6df..0f001001 100644 --- a/Docs/src/attributes.but +++ b/Docs/src/attributes.but @@ -24,6 +24,12 @@ Controls whether or not installs are enabled to the root directory of a drive, o Sets whether or not the install window automatically closes when completed. This is overrideable from a section using \R{setautoclose}{SetAutoClose}. +\S2{abgfont} BGFont + +\c [font_face [height [wieght] [/ITALIC] [/UNDERLINE] [/STRIKE]]] + +Specifies the font used to show the text on the background gradient. To set the color use \R{abggradient}{BGGradient}. If no parameters are specified, the default font will be used. The default font is bold and italic Times New Roman. + \S2{abggradient} BGGradient \c [\\off\\|(topc botc [textcolor|notext])] diff --git a/Source/Platform.h b/Source/Platform.h index 49abe501..783b38ed 100644 --- a/Source/Platform.h +++ b/Source/Platform.h @@ -479,6 +479,30 @@ typedef WORD LANGID; #ifndef TRANSPARENT # define TRANSPARENT 1 #endif +#ifndef LF_FACESIZE +# define LF_FACESIZE 32 +#endif +#ifndef FW_NORMAL +# define FW_NORMAL 400 +#endif +#ifndef FW_BOLD +# define FW_BOLD 700 +#endif +#ifndef DEFAULT_CHARSET +# define DEFAULT_CHARSET 1 +#endif +#ifndef OUT_DEFAULT_PRECIS +# define OUT_DEFAULT_PRECIS 0 +#endif +#ifndef CLIP_DEFAULT_PRECIS +# define CLIP_DEFAULT_PRECIS 0 +#endif +#ifndef DEFAULT_QUALITY +# define DEFAULT_QUALITY 0 +#endif +#ifndef DEFAULT_PITCH +# define DEFAULT_PITCH 0 +#endif // file ops @@ -546,6 +570,22 @@ typedef WORD LANGID; // structures #ifndef _WIN32 +typedef struct _LOGFONT { + LONG lfHeight; + LONG lfWidth; + LONG lfEscapement; + LONG lfOrientation; + LONG lfWeight; + BYTE lfItalic; + BYTE lfUnderline; + BYTE lfStrikeOut; + BYTE lfCharSet; + BYTE lfOutPrecision; + BYTE lfClipPrecision; + BYTE lfQuality; + BYTE lfPitchAndFamily; + CHAR lfFaceName[LF_FACESIZE]; +} LOGFONT; # pragma pack(2) typedef struct _IMAGE_DOS_HEADER { WORD e_magic; diff --git a/Source/build.cpp b/Source/build.cpp index 93f0f494..3ec58f4e 100644 --- a/Source/build.cpp +++ b/Source/build.cpp @@ -394,6 +394,22 @@ definedlist.add("NSIS_SUPPORT_LANG_IN_STRINGS"); notify_hwnd=0; #endif + bg_default_font.lfHeight=40; + bg_default_font.lfWidth=0; + bg_default_font.lfEscapement=0; + bg_default_font.lfOrientation=0; + bg_default_font.lfWeight=FW_BOLD; + bg_default_font.lfItalic=TRUE; + bg_default_font.lfUnderline=FALSE; + bg_default_font.lfStrikeOut=FALSE; + bg_default_font.lfCharSet=DEFAULT_CHARSET; + bg_default_font.lfOutPrecision=OUT_DEFAULT_PRECIS; + bg_default_font.lfClipPrecision=CLIP_DEFAULT_PRECIS; + bg_default_font.lfQuality=DEFAULT_QUALITY; + bg_default_font.lfPitchAndFamily=DEFAULT_PITCH; + strncpy(bg_default_font.lfFaceName,"Times New Roman",LF_FACESIZE); + memcpy(&bg_font,&bg_default_font,sizeof(LOGFONT)); + defcodepage_set=false; uDefCodePage=CP_ACP; @@ -2150,6 +2166,14 @@ void CEXEBuild::PreperHeaders(IGrowBuf *hdrbuf) hdrbuf->add(cur_langtables->get(),cur_langtables->getlen()); cur_header->blocks[NB_CTLCOLORS].offset = hdrbuf->getlen(); hdrbuf->add(cur_ctlcolors->get(),cur_ctlcolors->getlen()); +#ifdef NSIS_SUPPORT_BGBG + if (cur_header->bg_color1 != -1) + { + bg_font.lfFaceName[LF_FACESIZE-1]=0; + cur_header->blocks[NB_BGFONT].offset = hdrbuf->getlen(); + hdrbuf->add(&bg_font,sizeof(LOGFONT)); + } +#endif memcpy(hdrbuf->get(),cur_header,sizeof(header)); } diff --git a/Source/build.h b/Source/build.h index 11db2662..1e0eefe9 100644 --- a/Source/build.h +++ b/Source/build.h @@ -341,6 +341,12 @@ class CEXEBuild { bool branding_image_found; WORD branding_image_id; unsigned char *m_unicon_data; + +#ifdef NSIS_SUPPORT_BGBG + LOGFONT bg_font; + LOGFONT bg_default_font; +#endif + #ifdef NSIS_CONFIG_COMPRESSION_SUPPORT int deflateToFile(FILE *fp, char *buf, int len); // len==0 to flush #endif diff --git a/Source/exehead/bgbg.c b/Source/exehead/bgbg.c index 60e228f8..025e8f4e 100644 --- a/Source/exehead/bgbg.c +++ b/Source/exehead/bgbg.c @@ -59,22 +59,7 @@ LRESULT CALLBACK BG_WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) if (header->bg_textcolor != -1) { HFONT oldFont; - HFONT newFont = CreateFont( - 40, - 0, - 0, - 0, - FW_BOLD, - TRUE, - FALSE, - FALSE, - DEFAULT_CHARSET, - OUT_DEFAULT_PRECIS, - CLIP_DEFAULT_PRECIS, - DEFAULT_QUALITY, - DEFAULT_PITCH, - "Garamond" - ); + HFONT newFont = CreateFontIndirect((LOGFONT *) header->blocks[NB_BGFONT].offset); if (newFont) { r.left=16; diff --git a/Source/exehead/fileform.h b/Source/exehead/fileform.h index b699176e..5ba28fed 100644 --- a/Source/exehead/fileform.h +++ b/Source/exehead/fileform.h @@ -246,6 +246,9 @@ enum { NB_STRINGS, NB_LANGTABLES, NB_CTLCOLORS, +#ifdef NSIS_SUPPORT_BGBG + NB_BGFONT, +#endif NB_DATA, BLOCKS_NUM diff --git a/Source/script.cpp b/Source/script.cpp index 31354f01..e0db6315 100644 --- a/Source/script.cpp +++ b/Source/script.cpp @@ -2015,6 +2015,81 @@ int CEXEBuild::doCommand(int which_token, LineParser &line) SCRIPT_MSG("AllowRootDirInstall: %s\n",k?"false":"true"); } return PS_OK; + case TOK_BGFONT: +#ifndef NSIS_SUPPORT_BGBG + ERROR_MSG("Error: BGFont specified but NSIS_SUPPORT_BGBG not defined\n"); + return PS_ERROR; +#else//NSIS_SUPPORT_BGBG + if (line.getnumtokens()==1) + { + memcpy(&bg_font,&bg_default_font,sizeof(LOGFONT)); + SCRIPT_MSG("BGFont: default font\n"); + return PS_OK; + } + + LOGFONT newfont; + newfont.lfHeight=40; + newfont.lfWidth=0; + newfont.lfEscapement=0; + newfont.lfOrientation=0; + newfont.lfWeight=FW_NORMAL; + newfont.lfItalic=FALSE; + newfont.lfUnderline=FALSE; + newfont.lfStrikeOut=FALSE; + newfont.lfCharSet=DEFAULT_CHARSET; + newfont.lfOutPrecision=OUT_DEFAULT_PRECIS; + newfont.lfClipPrecision=CLIP_DEFAULT_PRECIS; + newfont.lfQuality=DEFAULT_QUALITY; + newfont.lfPitchAndFamily=DEFAULT_PITCH; + + strncpy(newfont.lfFaceName,line.gettoken_str(1),LF_FACESIZE); + + SCRIPT_MSG("BGFont: \"%s\"",line.gettoken_str(1)); + { + bool height=false; + bool weight=false; + for (int i = 2; i < line.getnumtokens(); i++) { + char *tok=line.gettoken_str(i); + if (tok[0]=='/') { + if (!strcmpi(tok,"/ITALIC")) { + SCRIPT_MSG(" /ITALIC"); + newfont.lfItalic=TRUE; + } + else if (!strcmpi(tok,"/UNDERLINE")) { + SCRIPT_MSG(" /UNDERLINE"); + newfont.lfUnderline=TRUE; + } + else if (!strcmpi(tok,"/STRIKE")) { + SCRIPT_MSG(" /STRIKE"); + newfont.lfStrikeOut=TRUE; + } + else { + SCRIPT_MSG("\n"); + PRINTHELP(); + } + } + else { + if (!height) { + SCRIPT_MSG(" height=%s",tok); + newfont.lfHeight=line.gettoken_int(i); + height=true; + } + else if (!weight) { + SCRIPT_MSG(" weight=%s",tok); + newfont.lfWeight=line.gettoken_int(i); + weight=true; + } + else { + SCRIPT_MSG("\n"); + PRINTHELP(); + } + } + } + } + SCRIPT_MSG("\n"); + memcpy(&bg_font, &newfont, sizeof(LOGFONT)); + return PS_OK; +#endif//NSIS_SUPPORT_BGBG case TOK_BGGRADIENT: #ifndef NSIS_SUPPORT_BGBG ERROR_MSG("Error: BGGradient specified but NSIS_SUPPORT_BGBG not defined\n"); @@ -2028,7 +2103,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line) } else if (!stricmp(line.gettoken_str(1),"off")) { - build_header.bg_color1=build_header.bg_color2=-1; + build_header.bg_color1=build_header.bg_color2=build_header.bg_textcolor=-1; SCRIPT_MSG("BGGradient: off\n"); if (line.getnumtokens()>2) PRINTHELP() } diff --git a/Source/tokens.cpp b/Source/tokens.cpp index b80f6005..3d3ef9e1 100644 --- a/Source/tokens.cpp +++ b/Source/tokens.cpp @@ -31,6 +31,7 @@ static tokenType tokenlist[TOK__LAST] = {TOK_ADDBRANDINGIMAGE,"AddBrandingImage",2,1,"(top|left|bottom|right) (height|width) [padding]",TP_GLOBAL}, {TOK_ADDSIZE,"AddSize",1,0,"size_to_add_to_section_in_kb",TP_SEC}, {TOK_AUTOCLOSE,"AutoCloseWindow",1,0,"(false|true)",TP_GLOBAL}, +{TOK_BGFONT,"BGFont",0,6,"[font_face [height [wieght] [/ITALIC] [/UNDERLINE] [/STRIKE]]]",TP_GLOBAL}, {TOK_BGGRADIENT,"BGGradient",0,3,"(off | [top_color [bottom_color [text_color]]])",TP_GLOBAL}, {TOK_BRANDINGTEXT,"BrandingText",1,1,"[/TRIM(LEFT|RIGHT|CENTER)] installer_text",TP_GLOBAL}, {TOK_BRINGTOFRONT,"BringToFront",0,0,"",TP_CODE}, diff --git a/Source/tokens.h b/Source/tokens.h index 1ff9abd9..ad3147ae 100644 --- a/Source/tokens.h +++ b/Source/tokens.h @@ -33,6 +33,7 @@ enum TOK_SHOWDETAILSUNINST, TOK_DIRSHOW, TOK_ROOTDIRINST, + TOK_BGFONT, TOK_BGGRADIENT, TOK_INSTCOLORS, TOK_SUBCAPTION,