1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-19 04:20:27 +01:00

- Changed fallback font to 'sans serif:pixelsize=12'

- Fixed convertfonts to account for $LANG
- Fixed convertfonts logic a bit and no longer output slant and weight if
  they are the default ones (medium and roman)
- Applied Pascal's fix for GNUstep menus (modified to also include submenus)
  Still this is not the proper fix, as it can't differentiate between
  submenus and other windows at the floating window level. Correct fix needs
  some extra hints to be set by GNUstep on menus.
This commit is contained in:
dan
2004-10-22 22:27:11 +00:00
parent 08e811aae7
commit d08691d5a5
7 changed files with 75 additions and 92 deletions

View File

@@ -10,9 +10,9 @@ _WINGsConfiguration WINGsConfiguration;
#define SYSTEM_FONT "sans:pixelsize=12" #define SYSTEM_FONT "Trebuchet MS,Luxi Sans"
#define BOLD_SYSTEM_FONT "Trebuchet MS,Luxi Sans:bold"
#define BOLD_SYSTEM_FONT "sans:bold:pixelsize=12" #define DEFAULT_FONT_SIZE 12
#define FLOPPY_PATH "/floppy" #define FLOPPY_PATH "/floppy"
@@ -41,48 +41,6 @@ getButtonWithName(const char *name, unsigned defaultButton)
} }
// fix this
static Bool
missingOrInvalidXLFD(char *xlfd)
{
char *ptr = xlfd;
Bool broken = False;
int count = 0;
if (!xlfd)
return True;
while (*ptr) {
if (*ptr=='%') {
ptr++;
if ((*ptr=='d' || *ptr=='i') && count==0) {
count++;
} else {
broken = True;
break;
}
} else if (*ptr==',') {
count = 0;
}
ptr++;
}
if (broken) {
if (xlfd == WINGsConfiguration.systemFont) {
ptr = "system font";
} else if (xlfd == WINGsConfiguration.boldSystemFont) {
ptr = "bold system font";
} else {
ptr = "Unknown System Font";
}
wwarning(_("Invalid %s specification: '%s' (only %%d is allowed and "
"at most once for each font in a fontset)."), ptr, xlfd);
}
return broken;
}
void void
W_ReadConfigurations(void) W_ReadConfigurations(void)
{ {
@@ -139,12 +97,15 @@ W_ReadConfigurations(void)
WMGetUDIntegerForKey(defaults, "DefaultFontSize"); WMGetUDIntegerForKey(defaults, "DefaultFontSize");
} }
if (missingOrInvalidXLFD(WINGsConfiguration.systemFont)) { if (!WINGsConfiguration.systemFont) {
WINGsConfiguration.systemFont = SYSTEM_FONT; WINGsConfiguration.systemFont = SYSTEM_FONT;
} }
if (missingOrInvalidXLFD(WINGsConfiguration.boldSystemFont)) { if (!WINGsConfiguration.boldSystemFont) {
WINGsConfiguration.boldSystemFont = BOLD_SYSTEM_FONT; WINGsConfiguration.boldSystemFont = BOLD_SYSTEM_FONT;
} }
if (WINGsConfiguration.defaultFontSize == 0) {
WINGsConfiguration.defaultFontSize = DEFAULT_FONT_SIZE;
}
if (!WINGsConfiguration.floppyPath) { if (!WINGsConfiguration.floppyPath) {
WINGsConfiguration.floppyPath = FLOPPY_PATH; WINGsConfiguration.floppyPath = FLOPPY_PATH;
} }
@@ -157,9 +118,6 @@ W_ReadConfigurations(void)
if (WINGsConfiguration.mouseWheelDown == 0) { if (WINGsConfiguration.mouseWheelDown == 0) {
WINGsConfiguration.mouseWheelDown = Button5; WINGsConfiguration.mouseWheelDown = Button5;
} }
if (WINGsConfiguration.defaultFontSize == 0) {
WINGsConfiguration.defaultFontSize = 12;
}
} }

View File

@@ -13,7 +13,7 @@
#include <X11/Xlocale.h> #include <X11/Xlocale.h>
#define DEFAULT_FONT "sans-serif:pixelsize=12" #define DEFAULT_FONT "sans serif:pixelsize=12"
#define DEFAULT_SIZE WINGsConfiguration.defaultFontSize #define DEFAULT_SIZE WINGsConfiguration.defaultFontSize
@@ -38,7 +38,7 @@ xlfdToFcPattern(char *xlfd, int size)
wfree(fname); wfree(fname);
if (!pattern) { if (!pattern) {
wwarning(_("invalid font: %s. Using default %s"), xlfd, DEFAULT_FONT); wwarning(_("invalid font: %s. Trying '%s'"), xlfd, DEFAULT_FONT);
pattern = FcNameParse(DEFAULT_FONT); pattern = FcNameParse(DEFAULT_FONT);
} }

View File

@@ -235,7 +235,7 @@ lookup_available_fonts(_Panel *panel)
if (pat) if (pat)
FcPatternDestroy(pat); FcPatternDestroy(pat);
panel->fonts->families[panel->fonts->familyn++].name= wstrdup("sans"); panel->fonts->families[panel->fonts->familyn++].name= wstrdup("sans serif");
family= panel->fonts->families + panel->fonts->familyn-1; family= panel->fonts->families + panel->fonts->familyn-1;
family->styles= wmalloc(sizeof(FontStyle)*2); family->styles= wmalloc(sizeof(FontStyle)*2);
family->stylen= 2; family->stylen= 2;
@@ -453,7 +453,7 @@ selectedOption(WMWidget *w, void *data)
FcDefaultSubstitute(pat); FcDefaultSubstitute(pat);
if (FcPatternGetString(pat, FC_FAMILY, 0, &name) != FcResultMatch) if (FcPatternGetString(pat, FC_FAMILY, 0, &name) != FcResultMatch)
name= "sans"; name= "sans serif";
found= 0; found= 0;
// select family // select family
@@ -672,7 +672,7 @@ createPanel(Panel *p)
} }
} }
else else
WMAddListItem(panel->familyL, "sans"); WMAddListItem(panel->familyL, "sans serif");
WMSetListAction(panel->familyL, selectedFamily, panel); WMSetListAction(panel->familyL, selectedFamily, panel);

View File

@@ -61,8 +61,8 @@ extern Panel *InitAppearance(WMScreen *scr, WMWidget *parent);
#define ICON_TITLE_FONT "sans:pixelsize=9" #define ICON_TITLE_FONT "sans serif:pixelsize=9"
#define ICON_TITLE_VFONT "sans:pixelsize=9:weight=100" #define ICON_TITLE_VFONT "sans serif:pixelsize=9:weight=100"
#define MAX_SECTIONS 16 #define MAX_SECTIONS 16

View File

@@ -339,6 +339,18 @@ setupGNUstepHints(WWindow *wwin, GNUstepWMAttributes *gs_hints)
if (gs_hints->extra_flags & GSNoApplicationIconFlag) { if (gs_hints->extra_flags & GSNoApplicationIconFlag) {
wwin->client_flags.no_appicon = 1; wwin->client_flags.no_appicon = 1;
} }
/* temporary solution to avoid GS menus in our window list.
* it's temporary because it's not the proper way: windows at the
* floating level are also skipped from the window list with this.
* Fix it -Dan */
if (gs_hints->flags & GSWindowLevelAttr) {
if (gs_hints->window_level == WMMainMenuWindowLevel ||
gs_hints->window_level == WMSubmenuWindowLevel) {
wwin->client_flags.skip_window_list = 1;
}
}
} }

View File

@@ -103,6 +103,9 @@ main(int argc, char **argv)
} }
} }
/* we need this in order for MB_CUR_MAX to work */
setlocale(LC_ALL, "");
WMPLSetCaseSensitive(False); WMPLSetCaseSensitive(False);
if (stat(file, &statbuf) < 0) { if (stat(file, &statbuf) < 0) {

View File

@@ -6,7 +6,7 @@
#include "../src/wconfig.h" #include "../src/wconfig.h"
#define DEFAULT_FONT "sans:pixelsize=12" #define DEFAULT_FONT "sans serif:pixelsize=12"
static int static int
countChar(char *str, char c) countChar(char *str, char c)
@@ -54,7 +54,7 @@ getXLFDTokens(char *xlfd)
len--; len--;
if (len <= 0) if (len <= 0)
break; break;
size = strcspn(ptr, "-"); size = strcspn(ptr, "-,");
tokens[i].str = ptr; tokens[i].str = ptr;
tokens[i].len = size; tokens[i].len = size;
ptr += size; ptr += size;
@@ -84,20 +84,44 @@ strToInt(str *token)
} }
static char*
mapWeightToName(str *weight)
{
char *normalNames[] = {"medium", "normal", "regular"};
static char buf[32];
int i;
if (weight->len==0)
return "";
for (i=0; i<sizeof(normalNames)/sizeof(char*); i++) {
if (strlen(normalNames[i])==weight->len &&
strncmp(normalNames[i], weight->str, weight->len))
{
return "";
}
}
snprintf(buf, sizeof(buf), ":%.*s", weight->len, weight->str);
return buf;
}
static char* static char*
mapSlantToName(str *slant) mapSlantToName(str *slant)
{ {
if (slant->len==0 || slant->str[0]=='*') if (slant->len==0)
return "roman"; return "";
switch(slant->str[0]) { switch(slant->str[0]) {
case 'i': case 'i':
return "italic"; return ":italic";
case 'o': case 'o':
return "oblique"; return ":oblique";
case 'r': case 'r':
default: default:
return "roman"; return "";
} }
} }
@@ -106,7 +130,7 @@ char*
xlfdToFc(char *xlfd, char *useFamily, Bool keepXLFD) xlfdToFc(char *xlfd, char *useFamily, Bool keepXLFD)
{ {
str *tokens, *family, *weight, *slant; str *tokens, *family, *weight, *slant;
char *name, buf[512]; char *name, buf[64], *slt;
int size, pixelsize; int size, pixelsize;
tokens = getXLFDTokens(xlfd); tokens = getXLFDTokens(xlfd);
@@ -116,6 +140,8 @@ xlfdToFc(char *xlfd, char *useFamily, Bool keepXLFD)
family = &(tokens[1]); family = &(tokens[1]);
weight = &(tokens[2]); weight = &(tokens[2]);
slant = &(tokens[3]); slant = &(tokens[3]);
pixelsize = strToInt(&tokens[6]);
size = strToInt(&tokens[7]);
if (useFamily) { if (useFamily) {
name = wstrdup(useFamily); name = wstrdup(useFamily);
@@ -123,31 +149,23 @@ xlfdToFc(char *xlfd, char *useFamily, Bool keepXLFD)
if (family->len==0 || family->str[0]=='*') if (family->len==0 || family->str[0]=='*')
return wstrdup(DEFAULT_FONT); return wstrdup(DEFAULT_FONT);
sprintf(buf, "%.*s", family->len, family->str); snprintf(buf, sizeof(buf), "%.*s", family->len, family->str);
name = wstrdup(buf); name = wstrdup(buf);
} }
pixelsize = strToInt(&tokens[6]); if (size>0 && pixelsize<=0) {
size = strToInt(&tokens[7]); snprintf(buf, sizeof(buf), "-%d", size/10);
name = wstrappend(name, buf);
}
name = wstrappend(name, mapWeightToName(weight));
name = wstrappend(name, mapSlantToName(slant));
if (size<=0 && pixelsize<=0) { if (size<=0 && pixelsize<=0) {
name = wstrappend(name, ":pixelsize=12"); name = wstrappend(name, ":pixelsize=12");
} else if (pixelsize>0) { } else if (pixelsize>0) {
/* if pixelsize is present size will be ignored so we skip it */ /* if pixelsize is present size will be ignored so we skip it */
sprintf(buf, ":pixelsize=%d", pixelsize); snprintf(buf, sizeof(buf), ":pixelsize=%d", pixelsize);
name = wstrappend(name, buf);
} else {
sprintf(buf, "-%d", size/10);
name = wstrappend(name, buf);
}
if (weight->len>0 && weight->str[0]!='*') {
sprintf(buf, ":weight=%.*s", weight->len, weight->str);
name = wstrappend(name, buf);
}
if (slant->len>0 && slant->str[0]!='*') {
sprintf(buf, ":slant=%s", mapSlantToName(slant));
name = wstrappend(name, buf); name = wstrappend(name, buf);
} }
@@ -165,19 +183,11 @@ char*
convertFont(char *font, Bool keepXLFD) convertFont(char *font, Bool keepXLFD)
{ {
if (font[0]=='-') { if (font[0]=='-') {
char *res;
char *tmp= wstrdup(font);
if (MB_CUR_MAX < 2) { if (MB_CUR_MAX < 2) {
char *ptr = strchr(tmp, ','); return xlfdToFc(font, NULL, keepXLFD);
if (ptr) *ptr= 0;
res = xlfdToFc(tmp, NULL, keepXLFD);
} else { } else {
res = xlfdToFc(tmp, "sans", keepXLFD); return xlfdToFc(font, "sans serif", keepXLFD);
} }
wfree(tmp);
return res;
} else { } else {
return font; return font;
} }