mirror of
https://github.com/gryf/wmaker.git
synced 2026-02-04 23:35:58 +01:00
Started to move towards using xft2 only, for a unified font/locale handling
in WINGs
This commit is contained in:
@@ -12,30 +12,19 @@ Changes since wmaker 0.80.1:
|
||||
WMCreateRGBAColor() and WMSetColorAlpha()
|
||||
- Miscelaneous code cleanups in wtext.c
|
||||
- Added Xft support in WINGs (for drawing antialiased fonts with transparency).
|
||||
- Added a new function: WMCreateAntialiasedFont() to create a font which will
|
||||
be drawn antialiased using Xft (if available, else function returns NULL)
|
||||
- New options in WMGLOBAL: AntialiasedText, AntialiasedSystemFont and
|
||||
AntialiasedBoldSystemFont. Check NEWS for details.
|
||||
- New options in WMGLOBAL: AntialiasedText. Check NEWS for details.
|
||||
- Fixed some improper calls to snprintf in wfont.c
|
||||
- Added double buffering when drawing a WMFrame title with an antialiased font
|
||||
to avoid flickering.
|
||||
- Added double buffering when drawing WMList items to avoid flickering.
|
||||
Double buffering for list also works for user drawn lists. Read NEWS for
|
||||
details and incompatibilities introduced by this change.
|
||||
- Added WMIsAntialiasedFont(WMFont *font) to check if a font is antialiased.
|
||||
- Added WMGetColorAlpha(WMColor *color)
|
||||
- Better outline when drawing balloons.
|
||||
- Added WMCreateFontWithFlags()
|
||||
- Added WMCreateFontWithAttributes()
|
||||
- You can now pass "SystemFont", "BoldSystemFont", "SystemFont-##" or
|
||||
"BoldSystemFont-##", with ## being the font size to any font creating
|
||||
function to create a font with the (bold) system font font specification.
|
||||
- Added WMCreateAntialiasedFontSet() (like WMCreateAntialiasedFont() but for
|
||||
languages with multibyte text). Note however that these specific font
|
||||
creating functions (as well as WMCreateNormalFont() and WMCreateFontSet())
|
||||
are not meant to be called directly except in very special cases.
|
||||
The more generic WMCreateFont() or WMCreateFontWithFlags() should be used.
|
||||
- Multibyte languages can now render antialiased text too (only tested on
|
||||
russian since this is the only multibyte language I can test).
|
||||
- Added WMCopyFontWithChanges(). This is a more generic and powerful function
|
||||
meant to replaces the obsoleted WMEmphasizeFont(), WMNormalizeFont(),
|
||||
WMStrenghtenFont() and the other similar functions. To get the same effect
|
||||
@@ -45,7 +34,7 @@ Changes since wmaker 0.80.1:
|
||||
- Added WMGetWidgetBackgroundColor()
|
||||
- Code cleanup in wtext.c
|
||||
- Fixed a memory leak in wfontpanel.c
|
||||
- Added a check that only %d is used in a font specification in WMGLOBAL and at
|
||||
??- Added a check that only %d is used in a font specification in WMGLOBAL and at
|
||||
most once for each font in a fontset (eliminates a possible security exploit)
|
||||
- Fixed WMGetTextDefaultColor() not to retain the returned color. It returns
|
||||
only a reference to the internal color, which you shouldn't release
|
||||
|
||||
@@ -107,22 +107,6 @@ enum {
|
||||
};
|
||||
|
||||
|
||||
/* Font flags */
|
||||
typedef enum {
|
||||
WFDefaultFont = 0,
|
||||
WFNormalFont = (1<<0),
|
||||
WFFontSet = (1<<1),
|
||||
WFAntialiased = (1<<2),
|
||||
WFNotAntialiased = (1<<3)
|
||||
} WMFontFlags;
|
||||
|
||||
|
||||
/* Use default system font size in system font name */
|
||||
enum {
|
||||
WFDefaultSize = -1
|
||||
};
|
||||
|
||||
|
||||
/* frame title positions */
|
||||
typedef enum {
|
||||
WTPNoTitle,
|
||||
@@ -746,18 +730,11 @@ Bool WMIsAntialiasingEnabled(WMScreen *scrPtr);
|
||||
|
||||
/* ....................................................................... */
|
||||
|
||||
WMFont* WMCreateNormalFont(WMScreen *scrPtr, char *fontName);
|
||||
|
||||
WMFont* WMCreateFontSet(WMScreen *scrPtr, char *fontName);
|
||||
|
||||
WMFont* WMCreateAntialiasedFont(WMScreen *scrPtr, char *fontName);
|
||||
|
||||
WMFont* WMCreateAntialiasedFontSet(WMScreen *scrPtr, char *fontName);
|
||||
|
||||
WMFont* WMCreateFont(WMScreen *scrPtr, char *fontName);
|
||||
|
||||
WMFont* WMCreateFontWithFlags(WMScreen *scrPtr, char *fontName,
|
||||
WMFontFlags flags);
|
||||
//??
|
||||
WMFont* WMCreateFontWithAttributes(WMScreen *scrPtr, char *fontName,
|
||||
WMFontAttributes *attribs);
|
||||
|
||||
WMFont* WMCopyFontWithChanges(WMScreen *scrPtr, WMFont *font,
|
||||
const WMFontAttributes *changes);
|
||||
@@ -770,15 +747,6 @@ char* WMGetFontName(WMFont *font);
|
||||
|
||||
unsigned int WMFontHeight(WMFont *font);
|
||||
|
||||
Bool WMIsAntialiasedFont(WMFont *font);
|
||||
|
||||
/*
|
||||
WMFont* WMUserFontOfSize(WMScreen *scrPtr, int size);
|
||||
|
||||
WMFont* WMUserFixedPitchFontOfSize(WMScreen *scrPtr, int size);
|
||||
*/
|
||||
|
||||
|
||||
void WMSetWidgetDefaultFont(WMScreen *scr, WMFont *font);
|
||||
|
||||
void WMSetWidgetDefaultBoldFont(WMScreen *scr, WMFont *font);
|
||||
@@ -791,8 +759,6 @@ WMFont* WMSystemFontOfSize(WMScreen *scrPtr, int size);
|
||||
|
||||
WMFont* WMBoldSystemFontOfSize(WMScreen *scrPtr, int size);
|
||||
|
||||
XFontSet WMGetFontFontSet(WMFont *font);
|
||||
|
||||
/* ....................................................................... */
|
||||
|
||||
WMPixmap* WMRetainPixmap(WMPixmap *pixmap);
|
||||
|
||||
@@ -24,7 +24,7 @@ extern "C" {
|
||||
|
||||
#define DOUBLE_BUFFER
|
||||
|
||||
|
||||
|
||||
|
||||
#define WC_UserWidget 128
|
||||
|
||||
@@ -48,17 +48,20 @@ typedef struct W_Application {
|
||||
typedef struct W_Font {
|
||||
struct W_Screen *screen;
|
||||
|
||||
union {
|
||||
XFontSet set;
|
||||
XFontStruct *normal;
|
||||
struct _XftFont *xft;
|
||||
} font;
|
||||
#ifdef XFT
|
||||
struct _XftFont *font;
|
||||
#else
|
||||
// pick one
|
||||
//XFontSet font;
|
||||
XFontStruct *font;
|
||||
#endif
|
||||
|
||||
short height;
|
||||
short y;
|
||||
short refCount;
|
||||
char *name;
|
||||
unsigned int notFontSet:1;
|
||||
unsigned int antialiased:1;
|
||||
//unsigned int notFontSet:1;
|
||||
//unsigned int antialiased:1;
|
||||
} W_Font;
|
||||
|
||||
|
||||
@@ -97,7 +100,7 @@ typedef struct W_FocusInfo {
|
||||
struct W_DraggingInfo {
|
||||
Window destinationWindow;
|
||||
Window sourceWindow;
|
||||
|
||||
|
||||
WMPoint location;
|
||||
|
||||
unsigned sourceOperation;
|
||||
@@ -116,7 +119,7 @@ struct W_DraggingInfo {
|
||||
WMSize mouseOffset;
|
||||
unsigned finished:1;
|
||||
};
|
||||
|
||||
|
||||
|
||||
typedef struct W_Screen {
|
||||
Display *display;
|
||||
@@ -139,8 +142,6 @@ typedef struct W_Screen {
|
||||
|
||||
struct _XftDraw *xftdraw; /* shared XftDraw */
|
||||
|
||||
Bool hasXftSupport; /* if it can antialias text */
|
||||
|
||||
/* application related */
|
||||
|
||||
W_FocusInfo *focusInfo;
|
||||
@@ -416,8 +417,6 @@ typedef struct W_EventHandler {
|
||||
typedef struct _WINGsConfiguration {
|
||||
char *systemFont;
|
||||
char *boldSystemFont;
|
||||
char *antialiasedSystemFont;
|
||||
char *antialiasedBoldSystemFont;
|
||||
int defaultFontSize;
|
||||
Bool antialiasedText;
|
||||
Bool useMultiByte;
|
||||
|
||||
@@ -75,10 +75,6 @@ missingOrInvalidXLFD(char *xlfd)
|
||||
ptr = "system font";
|
||||
} else if (xlfd == WINGsConfiguration.boldSystemFont) {
|
||||
ptr = "bold system font";
|
||||
} else if (xlfd == WINGsConfiguration.antialiasedSystemFont) {
|
||||
ptr = "antialiased system font";
|
||||
} else if (xlfd == WINGsConfiguration.antialiasedBoldSystemFont) {
|
||||
ptr = "antialiased bold system font";
|
||||
} else {
|
||||
ptr = "Unknown System Font";
|
||||
}
|
||||
@@ -110,12 +106,6 @@ W_ReadConfigurations(void)
|
||||
WINGsConfiguration.boldSystemFont =
|
||||
WMGetUDStringForKey(defaults, "BoldSystemFont");
|
||||
|
||||
WINGsConfiguration.antialiasedSystemFont =
|
||||
WMGetUDStringForKey(defaults, "AntialiasedSystemFont");
|
||||
|
||||
WINGsConfiguration.antialiasedBoldSystemFont =
|
||||
WMGetUDStringForKey(defaults, "AntialiasedBoldSystemFont");
|
||||
|
||||
#ifdef XFT
|
||||
WINGsConfiguration.antialiasedText =
|
||||
WMGetUDBoolForKey(defaults, "AntialiasedText");
|
||||
@@ -184,12 +174,6 @@ W_ReadConfigurations(void)
|
||||
if (missingOrInvalidXLFD(WINGsConfiguration.boldSystemFont)) {
|
||||
WINGsConfiguration.boldSystemFont = BOLD_SYSTEM_FONT;
|
||||
}
|
||||
if (missingOrInvalidXLFD(WINGsConfiguration.antialiasedSystemFont)) {
|
||||
WINGsConfiguration.antialiasedSystemFont = XFTSYSTEM_FONT;
|
||||
}
|
||||
if (missingOrInvalidXLFD(WINGsConfiguration.antialiasedBoldSystemFont)) {
|
||||
WINGsConfiguration.antialiasedBoldSystemFont = XFTBOLD_SYSTEM_FONT;
|
||||
}
|
||||
if (!WINGsConfiguration.floppyPath) {
|
||||
WINGsConfiguration.floppyPath = FLOPPY_PATH;
|
||||
}
|
||||
|
||||
@@ -3,16 +3,18 @@
|
||||
|
||||
#ifdef XFT
|
||||
# include <X11/Xft/Xft.h>
|
||||
# ifdef HAVE_WCHAR_H
|
||||
# include <wchar.h>
|
||||
# endif
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#include "WINGsP.h"
|
||||
|
||||
|
||||
#include <wraster.h>
|
||||
#include <assert.h>
|
||||
#include <X11/Xlocale.h>
|
||||
|
||||
#include <wchar.h>
|
||||
|
||||
|
||||
static char *makeFontSetOfSize(char *fontset, int size);
|
||||
@@ -276,9 +278,6 @@ WMCreateAntialiasedFont(WMScreen *scrPtr, char *fontName)
|
||||
Display *display = scrPtr->display;
|
||||
char *fname, *ptr;
|
||||
|
||||
if (!scrPtr->hasXftSupport)
|
||||
return NULL;
|
||||
|
||||
fontName = xlfdFromFontName(fontName, True);
|
||||
|
||||
if ((ptr = strchr(fontName, ','))) {
|
||||
@@ -355,9 +354,6 @@ WMCreateAntialiasedFontSet(WMScreen *scrPtr, char *fontName)
|
||||
Display *display = scrPtr->display;
|
||||
char *fname, *ptr;
|
||||
|
||||
if (!scrPtr->hasXftSupport)
|
||||
return NULL;
|
||||
|
||||
fontName = xlfdFromFontName(fontName, True);
|
||||
|
||||
if ((ptr = strchr(fontName, ','))) {
|
||||
@@ -521,13 +517,6 @@ WMReleaseFont(WMFont *font)
|
||||
}
|
||||
|
||||
|
||||
Bool
|
||||
WMHasAntialiasingSupport(WMScreen *scrPtr)
|
||||
{
|
||||
return scrPtr->hasXftSupport;
|
||||
}
|
||||
|
||||
|
||||
Bool
|
||||
WMIsAntialiasingEnabled(WMScreen *scrPtr)
|
||||
{
|
||||
|
||||
@@ -629,13 +629,6 @@ WMCreateScreenWithRContext(Display *display, int screen, RContext *context)
|
||||
scrPtr->xftFontSetCache = WMCreateHashTable(WMStringPointerHashCallbacks);
|
||||
|
||||
#ifdef XFT
|
||||
|
||||
# ifdef XFT2
|
||||
scrPtr->hasXftSupport = 1;
|
||||
# else
|
||||
scrPtr->hasXftSupport = XftDefaultHasRender(scrPtr->display);
|
||||
# endif
|
||||
|
||||
scrPtr->xftdraw = XftDrawCreate(scrPtr->display, W_DRAWABLE(scrPtr),
|
||||
scrPtr->visual, scrPtr->colormap);
|
||||
#endif
|
||||
@@ -768,16 +761,7 @@ WMCreateScreenWithRContext(Display *display, int screen, RContext *context)
|
||||
|
||||
scrPtr->useMultiByte = WINGsConfiguration.useMultiByte;
|
||||
|
||||
if (scrPtr->hasXftSupport) {
|
||||
scrPtr->antialiasedText = WINGsConfiguration.antialiasedText;
|
||||
} else {
|
||||
if (WINGsConfiguration.antialiasedText) {
|
||||
wwarning(_("Text antialiasing is enabled in the configuration but"
|
||||
" the X server doesn't have the required capabilities "
|
||||
"(missing RENDER extension). Disabling text antialiasing."));
|
||||
}
|
||||
scrPtr->antialiasedText = False;
|
||||
}
|
||||
scrPtr->antialiasedText = WINGsConfiguration.antialiasedText;
|
||||
|
||||
scrPtr->normalFont = WMSystemFontOfSize(scrPtr,
|
||||
WINGsConfiguration.defaultFontSize);
|
||||
@@ -800,16 +784,16 @@ WMCreateScreenWithRContext(Display *display, int screen, RContext *context)
|
||||
CHECK_BUTTON_ON_HEIGHT, False);
|
||||
|
||||
scrPtr->checkButtonImageOff = makePixmap(scrPtr, CHECK_BUTTON_OFF,
|
||||
CHECK_BUTTON_OFF_WIDTH,
|
||||
CHECK_BUTTON_OFF_HEIGHT, False);
|
||||
CHECK_BUTTON_OFF_WIDTH,
|
||||
CHECK_BUTTON_OFF_HEIGHT, False);
|
||||
|
||||
scrPtr->radioButtonImageOn = makePixmap(scrPtr, RADIO_BUTTON_ON,
|
||||
RADIO_BUTTON_ON_WIDTH,
|
||||
RADIO_BUTTON_ON_HEIGHT, False);
|
||||
|
||||
scrPtr->radioButtonImageOff = makePixmap(scrPtr, RADIO_BUTTON_OFF,
|
||||
RADIO_BUTTON_OFF_WIDTH,
|
||||
RADIO_BUTTON_OFF_HEIGHT, False);
|
||||
RADIO_BUTTON_OFF_WIDTH,
|
||||
RADIO_BUTTON_OFF_HEIGHT, False);
|
||||
|
||||
scrPtr->buttonArrow = makePixmap(scrPtr, BUTTON_ARROW,
|
||||
BUTTON_ARROW_WIDTH, BUTTON_ARROW_HEIGHT,
|
||||
@@ -842,20 +826,20 @@ WMCreateScreenWithRContext(Display *display, int screen, RContext *context)
|
||||
SCROLLER_ARROW_RIGHT_HEIGHT, True);
|
||||
|
||||
scrPtr->hiUpArrow = makePixmap(scrPtr, HI_SCROLLER_ARROW_UP,
|
||||
SCROLLER_ARROW_UP_WIDTH,
|
||||
SCROLLER_ARROW_UP_HEIGHT, True);
|
||||
SCROLLER_ARROW_UP_WIDTH,
|
||||
SCROLLER_ARROW_UP_HEIGHT, True);
|
||||
|
||||
scrPtr->hiDownArrow = makePixmap(scrPtr, HI_SCROLLER_ARROW_DOWN,
|
||||
SCROLLER_ARROW_DOWN_WIDTH,
|
||||
SCROLLER_ARROW_DOWN_HEIGHT, True);
|
||||
SCROLLER_ARROW_DOWN_WIDTH,
|
||||
SCROLLER_ARROW_DOWN_HEIGHT, True);
|
||||
|
||||
scrPtr->hiLeftArrow = makePixmap(scrPtr, HI_SCROLLER_ARROW_LEFT,
|
||||
SCROLLER_ARROW_LEFT_WIDTH,
|
||||
SCROLLER_ARROW_LEFT_HEIGHT, True);
|
||||
SCROLLER_ARROW_LEFT_WIDTH,
|
||||
SCROLLER_ARROW_LEFT_HEIGHT, True);
|
||||
|
||||
scrPtr->hiRightArrow = makePixmap(scrPtr, HI_SCROLLER_ARROW_RIGHT,
|
||||
SCROLLER_ARROW_RIGHT_WIDTH,
|
||||
SCROLLER_ARROW_RIGHT_HEIGHT, True);
|
||||
SCROLLER_ARROW_RIGHT_WIDTH,
|
||||
SCROLLER_ARROW_RIGHT_HEIGHT, True);
|
||||
|
||||
scrPtr->popUpIndicator = makePixmap(scrPtr, POPUP_INDICATOR,
|
||||
POPUP_INDICATOR_WIDTH,
|
||||
@@ -878,7 +862,7 @@ WMCreateScreenWithRContext(Display *display, int screen, RContext *context)
|
||||
{
|
||||
XColor bla;
|
||||
Pixmap blank;
|
||||
|
||||
|
||||
blank = XCreatePixmap(display, scrPtr->stipple, 1, 1, 1);
|
||||
XSetForeground(display, scrPtr->monoGC, 0);
|
||||
XFillRectangle(display, blank, scrPtr->monoGC, 0, 0, 1, 1);
|
||||
|
||||
Reference in New Issue
Block a user