- added BGFont that allows setting the background text font

- made Times New Roman default font for the background text because it should always have support for the locale's language


git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@3560 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
kichik 2004-06-11 15:33:00 +00:00
parent 0799b35cd6
commit b11c65e0f8
9 changed files with 158 additions and 17 deletions

View file

@ -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 [\\<b\\>off\\</b\\>|(topc botc [textcolor|notext])]

View file

@ -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;

View file

@ -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));
}

View file

@ -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

View file

@ -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;

View file

@ -246,6 +246,9 @@ enum {
NB_STRINGS,
NB_LANGTABLES,
NB_CTLCOLORS,
#ifdef NSIS_SUPPORT_BGBG
NB_BGFONT,
#endif
NB_DATA,
BLOCKS_NUM

View file

@ -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()
}

View file

@ -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},

View file

@ -33,6 +33,7 @@ enum
TOK_SHOWDETAILSUNINST,
TOK_DIRSHOW,
TOK_ROOTDIRINST,
TOK_BGFONT,
TOK_BGGRADIENT,
TOK_INSTCOLORS,
TOK_SUBCAPTION,