2000-03-08 19:38:31 -08:00
|
|
|
/*
|
2006-01-04 01:22:41 -08:00
|
|
|
* Copyright (C) 1997-2006, Michael Jennings
|
1999-09-21 19:34:13 -07:00
|
|
|
*
|
2000-03-08 19:38:31 -08:00
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to
|
|
|
|
* deal in the Software without restriction, including without limitation the
|
|
|
|
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
|
|
* sell copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
1999-09-21 19:34:13 -07:00
|
|
|
*
|
2000-03-08 19:38:31 -08:00
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies of the Software, its documentation and marketing & publicity
|
|
|
|
* materials, and acknowledgment shall be given in the documentation, materials
|
|
|
|
* and software packages that this Software was used.
|
1999-09-21 19:34:13 -07:00
|
|
|
*
|
2000-03-08 19:38:31 -08:00
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
|
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
1999-09-21 19:34:13 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _FONT_H_
|
|
|
|
#define _FONT_H_
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <X11/Xfuncproto.h>
|
|
|
|
#include <X11/Intrinsic.h> /* Xlib, Xutil, Xresource, Xfuncproto */
|
|
|
|
|
|
|
|
/************ Macros and Definitions ************/
|
Fri Nov 19 23:05:31 PST 1999 Michael Jennings <mej@eterm.org>
Once again, I've rendered old themes obselete. :-)
I added a new config file attribute and command-line parameter. The
option is --default-font-index, but I wouldn't necessarily use it.
The config file attribute makes more sense. :-)
Anyway, your themes will now need to have a line like this:
font default <index>
in the attributes section. This tells Eterm which font it should use
on startup. (<index> is a number between 0 and the highest-numbered
font you define.) You can now have up to 256 fonts. Font 0 is no
longer necessarily the default font; it is the smallest font. And the
larger the font index, the larger the font should be. (Of course,
this assumes you want Ctrl-> and Ctrl-< to increase/decrease your font
size. In reality, you can have your fonts in any order, and those
keys will cycle through them in order.)
Before, font 0 was always the default, and you didn't have much
freedom in rearranging your fonts. Plus, you were limited to 5. Not
any more. :-) The new system is much more straight-forward, logical,
and powerful.
So please be sure to update your themes by hand, or remove your theme
directory before installing this new version. If your theme lacks
the "font default" line, your Eterms will start with the wrong font.
:-]
SVN revision: 1344
1999-11-19 21:17:29 -08:00
|
|
|
#define FONT_TYPE_X (0x01)
|
|
|
|
#define FONT_TYPE_TTF (0x02)
|
|
|
|
#define FONT_TYPE_FNLIB (0x03)
|
1999-09-21 19:34:13 -07:00
|
|
|
|
|
|
|
#define font_cache_add_ref(font) ((font)->ref_cnt++)
|
|
|
|
|
Fri Nov 19 23:05:31 PST 1999 Michael Jennings <mej@eterm.org>
Once again, I've rendered old themes obselete. :-)
I added a new config file attribute and command-line parameter. The
option is --default-font-index, but I wouldn't necessarily use it.
The config file attribute makes more sense. :-)
Anyway, your themes will now need to have a line like this:
font default <index>
in the attributes section. This tells Eterm which font it should use
on startup. (<index> is a number between 0 and the highest-numbered
font you define.) You can now have up to 256 fonts. Font 0 is no
longer necessarily the default font; it is the smallest font. And the
larger the font index, the larger the font should be. (Of course,
this assumes you want Ctrl-> and Ctrl-< to increase/decrease your font
size. In reality, you can have your fonts in any order, and those
keys will cycle through them in order.)
Before, font 0 was always the default, and you didn't have much
freedom in rearranging your fonts. Plus, you were limited to 5. Not
any more. :-) The new system is much more straight-forward, logical,
and powerful.
So please be sure to update your themes by hand, or remove your theme
directory before installing this new version. If your theme lacks
the "font default" line, your Eterms will start with the wrong font.
:-]
SVN revision: 1344
1999-11-19 21:17:29 -08:00
|
|
|
#define NFONTS 5
|
|
|
|
#define FONT_CMD '#'
|
|
|
|
#define BIGGER_FONT "#+"
|
|
|
|
#define SMALLER_FONT "#-"
|
|
|
|
|
Fri May 26 20:43:03 PDT 2000 Michael Jennings <mej@eterm.org>
Okay, there are a few changes here. First off, I made multi-byte font
support the default now, as long as you have ISO 10646 fonts. In
order to do this, I made the default encoding type "Latin1" so as not
to interfere with 8-bit ISO 8859-1 characters. This means that if you
relied on the default multi-byte encoding method to be SJIS, you'll
need to update your theme files.
I also set it up so that Eterm will ignore SIGHUP, at least until I do
something with it (like reloading the theme or something).
I fixed the proportional font size algorithm. If there is more than
a 3-pixel variance between the minimum and maximum sizes for glyphs in
a proportional font, Eterm will set the size to 2 standard deviations
above the average width. This is so that they won't look so spread
out and ugly, but it still doesn't look perfect. Not much I can do on
that front...terminals must have fixed-width columns.
And then there's the biggie. I put in the ability to configure the
now-infamous font effects. I left a black drop shadow in as the
default, but you can now customize it via the --font-fx option or in
the config file using "font effects <stuff>" in the attributes
context. You can even use "fx" instead of "effects" for short.
So what goes in the <stuff> part? Well, you have several options.
To use a single-color outline, say "outline <color>". Likewise, a
single-color drop shadow is "shadow [corner] <color>"; "bottom_right"
is the default corner if you don't specify one. For a 3-D embossed
look, "emboss <dark_color> <light_color>". The opposite, a carved-
out look, can be had with "carved <dark_color> <light_color>". (Of
course, with those last two, the 3-D look will only work if you
choose the colors wisely.)
Those are all the shortcuts. The long way is to specify a series of
corner/color pairs, like "tl blue" for top-left blue, or
"bottom_right green". You can abbreviate using "tl," "tr," "bl," or
"br," or you can spell out "top_left," "top_right," "bottom_left," or
"bottom_right." If you omit a corner name, the first one defaults to
top-left, the second to top-right, and so on as listed above.
SVN revision: 2714
2000-05-26 20:41:22 -07:00
|
|
|
/* These are subscripts for the arrays in a fontshadow_t */
|
|
|
|
#define SHADOW_TOP_LEFT 0
|
|
|
|
#define SHADOW_TOP_RIGHT 1
|
|
|
|
#define SHADOW_BOTTOM_LEFT 2
|
|
|
|
#define SHADOW_BOTTOM_RIGHT 3
|
|
|
|
|
2000-09-01 21:12:16 -07:00
|
|
|
/* The macros are used to advance to the next/previous font as with Ctrl-> and Ctrl-< */
|
Fri Nov 19 23:05:31 PST 1999 Michael Jennings <mej@eterm.org>
Once again, I've rendered old themes obselete. :-)
I added a new config file attribute and command-line parameter. The
option is --default-font-index, but I wouldn't necessarily use it.
The config file attribute makes more sense. :-)
Anyway, your themes will now need to have a line like this:
font default <index>
in the attributes section. This tells Eterm which font it should use
on startup. (<index> is a number between 0 and the highest-numbered
font you define.) You can now have up to 256 fonts. Font 0 is no
longer necessarily the default font; it is the smallest font. And the
larger the font index, the larger the font should be. (Of course,
this assumes you want Ctrl-> and Ctrl-< to increase/decrease your font
size. In reality, you can have your fonts in any order, and those
keys will cycle through them in order.)
Before, font 0 was always the default, and you didn't have much
freedom in rearranging your fonts. Plus, you were limited to 5. Not
any more. :-) The new system is much more straight-forward, logical,
and powerful.
So please be sure to update your themes by hand, or remove your theme
directory before installing this new version. If your theme lacks
the "font default" line, your Eterms will start with the wrong font.
:-]
SVN revision: 1344
1999-11-19 21:17:29 -08:00
|
|
|
#define NEXT_FONT(i) do { if (font_idx + ((i)?(i):1) >= font_cnt) {font_idx = font_cnt - 1;} else {font_idx += ((i)?(i):1);} \
|
|
|
|
while (!etfonts[font_idx]) {if (font_idx == font_cnt) {font_idx--; break;} font_idx++;} } while (0)
|
|
|
|
#define PREV_FONT(i) do { if (font_idx - ((i)?(i):1) < 0) {font_idx = 0;} else {font_idx -= ((i)?(i):1);} \
|
|
|
|
while (!etfonts[font_idx]) {if (font_idx == 0) break; font_idx--;} } while (0)
|
|
|
|
#define DUMP_FONTS() do {unsigned char i; D_FONT(("DUMP_FONTS(): Font count is %u\n", (unsigned int) font_cnt)); \
|
|
|
|
for (i = 0; i < font_cnt; i++) {D_FONT(("DUMP_FONTS(): Font %u == \"%s\"\n", (unsigned int) i, NONULL(etfonts[i])));}} while (0)
|
1999-09-21 19:34:13 -07:00
|
|
|
|
|
|
|
/************ Structures ************/
|
Fri Nov 19 23:05:31 PST 1999 Michael Jennings <mej@eterm.org>
Once again, I've rendered old themes obselete. :-)
I added a new config file attribute and command-line parameter. The
option is --default-font-index, but I wouldn't necessarily use it.
The config file attribute makes more sense. :-)
Anyway, your themes will now need to have a line like this:
font default <index>
in the attributes section. This tells Eterm which font it should use
on startup. (<index> is a number between 0 and the highest-numbered
font you define.) You can now have up to 256 fonts. Font 0 is no
longer necessarily the default font; it is the smallest font. And the
larger the font index, the larger the font should be. (Of course,
this assumes you want Ctrl-> and Ctrl-< to increase/decrease your font
size. In reality, you can have your fonts in any order, and those
keys will cycle through them in order.)
Before, font 0 was always the default, and you didn't have much
freedom in rearranging your fonts. Plus, you were limited to 5. Not
any more. :-) The new system is much more straight-forward, logical,
and powerful.
So please be sure to update your themes by hand, or remove your theme
directory before installing this new version. If your theme lacks
the "font default" line, your Eterms will start with the wrong font.
:-]
SVN revision: 1344
1999-11-19 21:17:29 -08:00
|
|
|
typedef struct cachefont_struct {
|
2000-09-01 21:12:16 -07:00
|
|
|
char *name; /* Font name in canonical format */
|
|
|
|
unsigned char type; /* Font type (FONT_TYPE_* from above */
|
|
|
|
unsigned char ref_cnt; /* Reference count */
|
1999-09-21 19:34:13 -07:00
|
|
|
union {
|
2000-09-01 21:12:16 -07:00
|
|
|
/* This union will eventually have members for TTF/Fnlib fonts */
|
1999-09-21 19:34:13 -07:00
|
|
|
XFontStruct *xfontinfo;
|
|
|
|
} fontinfo;
|
Fri Nov 19 23:05:31 PST 1999 Michael Jennings <mej@eterm.org>
Once again, I've rendered old themes obselete. :-)
I added a new config file attribute and command-line parameter. The
option is --default-font-index, but I wouldn't necessarily use it.
The config file attribute makes more sense. :-)
Anyway, your themes will now need to have a line like this:
font default <index>
in the attributes section. This tells Eterm which font it should use
on startup. (<index> is a number between 0 and the highest-numbered
font you define.) You can now have up to 256 fonts. Font 0 is no
longer necessarily the default font; it is the smallest font. And the
larger the font index, the larger the font should be. (Of course,
this assumes you want Ctrl-> and Ctrl-< to increase/decrease your font
size. In reality, you can have your fonts in any order, and those
keys will cycle through them in order.)
Before, font 0 was always the default, and you didn't have much
freedom in rearranging your fonts. Plus, you were limited to 5. Not
any more. :-) The new system is much more straight-forward, logical,
and powerful.
So please be sure to update your themes by hand, or remove your theme
directory before installing this new version. If your theme lacks
the "font default" line, your Eterms will start with the wrong font.
:-]
SVN revision: 1344
1999-11-19 21:17:29 -08:00
|
|
|
struct cachefont_struct *next;
|
|
|
|
} cachefont_t;
|
|
|
|
|
Fri May 26 20:43:03 PDT 2000 Michael Jennings <mej@eterm.org>
Okay, there are a few changes here. First off, I made multi-byte font
support the default now, as long as you have ISO 10646 fonts. In
order to do this, I made the default encoding type "Latin1" so as not
to interfere with 8-bit ISO 8859-1 characters. This means that if you
relied on the default multi-byte encoding method to be SJIS, you'll
need to update your theme files.
I also set it up so that Eterm will ignore SIGHUP, at least until I do
something with it (like reloading the theme or something).
I fixed the proportional font size algorithm. If there is more than
a 3-pixel variance between the minimum and maximum sizes for glyphs in
a proportional font, Eterm will set the size to 2 standard deviations
above the average width. This is so that they won't look so spread
out and ugly, but it still doesn't look perfect. Not much I can do on
that front...terminals must have fixed-width columns.
And then there's the biggie. I put in the ability to configure the
now-infamous font effects. I left a black drop shadow in as the
default, but you can now customize it via the --font-fx option or in
the config file using "font effects <stuff>" in the attributes
context. You can even use "fx" instead of "effects" for short.
So what goes in the <stuff> part? Well, you have several options.
To use a single-color outline, say "outline <color>". Likewise, a
single-color drop shadow is "shadow [corner] <color>"; "bottom_right"
is the default corner if you don't specify one. For a 3-D embossed
look, "emboss <dark_color> <light_color>". The opposite, a carved-
out look, can be had with "carved <dark_color> <light_color>". (Of
course, with those last two, the 3-D look will only work if you
choose the colors wisely.)
Those are all the shortcuts. The long way is to specify a series of
corner/color pairs, like "tl blue" for top-left blue, or
"bottom_right green". You can abbreviate using "tl," "tr," "bl," or
"br," or you can spell out "top_left," "top_right," "bottom_left," or
"bottom_right." If you omit a corner name, the first one defaults to
top-left, the second to top-right, and so on as listed above.
SVN revision: 2714
2000-05-26 20:41:22 -07:00
|
|
|
typedef struct fontshadow_struct {
|
|
|
|
Pixel color[4];
|
|
|
|
unsigned char shadow[4];
|
|
|
|
unsigned char do_shadow;
|
|
|
|
} fontshadow_t;
|
|
|
|
|
1999-09-21 19:34:13 -07:00
|
|
|
/************ Variables ************/
|
2001-09-06 15:26:20 -07:00
|
|
|
extern unsigned char font_idx, font_cnt, font_chg;
|
|
|
|
extern int def_font_idx;
|
1999-09-21 19:34:13 -07:00
|
|
|
extern const char *def_fontName[];
|
1999-09-28 12:38:43 -07:00
|
|
|
extern char *rs_font[NFONTS];
|
1999-12-02 18:31:33 -08:00
|
|
|
extern char **etfonts, **etmfonts;
|
Fri May 26 20:43:03 PDT 2000 Michael Jennings <mej@eterm.org>
Okay, there are a few changes here. First off, I made multi-byte font
support the default now, as long as you have ISO 10646 fonts. In
order to do this, I made the default encoding type "Latin1" so as not
to interfere with 8-bit ISO 8859-1 characters. This means that if you
relied on the default multi-byte encoding method to be SJIS, you'll
need to update your theme files.
I also set it up so that Eterm will ignore SIGHUP, at least until I do
something with it (like reloading the theme or something).
I fixed the proportional font size algorithm. If there is more than
a 3-pixel variance between the minimum and maximum sizes for glyphs in
a proportional font, Eterm will set the size to 2 standard deviations
above the average width. This is so that they won't look so spread
out and ugly, but it still doesn't look perfect. Not much I can do on
that front...terminals must have fixed-width columns.
And then there's the biggie. I put in the ability to configure the
now-infamous font effects. I left a black drop shadow in as the
default, but you can now customize it via the --font-fx option or in
the config file using "font effects <stuff>" in the attributes
context. You can even use "fx" instead of "effects" for short.
So what goes in the <stuff> part? Well, you have several options.
To use a single-color outline, say "outline <color>". Likewise, a
single-color drop shadow is "shadow [corner] <color>"; "bottom_right"
is the default corner if you don't specify one. For a 3-D embossed
look, "emboss <dark_color> <light_color>". The opposite, a carved-
out look, can be had with "carved <dark_color> <light_color>". (Of
course, with those last two, the 3-D look will only work if you
choose the colors wisely.)
Those are all the shortcuts. The long way is to specify a series of
corner/color pairs, like "tl blue" for top-left blue, or
"bottom_right green". You can abbreviate using "tl," "tr," "bl," or
"br," or you can spell out "top_left," "top_right," "bottom_left," or
"bottom_right." If you omit a corner name, the first one defaults to
top-left, the second to top-right, and so on as listed above.
SVN revision: 2714
2000-05-26 20:41:22 -07:00
|
|
|
extern fontshadow_t fshadow;
|
1999-09-21 19:34:13 -07:00
|
|
|
# ifdef MULTI_CHARSET
|
|
|
|
extern const char *def_mfontName[];
|
1999-09-28 12:38:43 -07:00
|
|
|
extern char *rs_mfont[NFONTS];
|
1999-09-21 19:34:13 -07:00
|
|
|
# endif
|
|
|
|
|
|
|
|
/************ Function Prototypes ************/
|
|
|
|
_XFUNCPROTOBEGIN
|
|
|
|
|
Fri Nov 19 23:05:31 PST 1999 Michael Jennings <mej@eterm.org>
Once again, I've rendered old themes obselete. :-)
I added a new config file attribute and command-line parameter. The
option is --default-font-index, but I wouldn't necessarily use it.
The config file attribute makes more sense. :-)
Anyway, your themes will now need to have a line like this:
font default <index>
in the attributes section. This tells Eterm which font it should use
on startup. (<index> is a number between 0 and the highest-numbered
font you define.) You can now have up to 256 fonts. Font 0 is no
longer necessarily the default font; it is the smallest font. And the
larger the font index, the larger the font should be. (Of course,
this assumes you want Ctrl-> and Ctrl-< to increase/decrease your font
size. In reality, you can have your fonts in any order, and those
keys will cycle through them in order.)
Before, font 0 was always the default, and you didn't have much
freedom in rearranging your fonts. Plus, you were limited to 5. Not
any more. :-) The new system is much more straight-forward, logical,
and powerful.
So please be sure to update your themes by hand, or remove your theme
directory before installing this new version. If your theme lacks
the "font default" line, your Eterms will start with the wrong font.
:-]
SVN revision: 1344
1999-11-19 21:17:29 -08:00
|
|
|
extern void eterm_font_add(char ***plist, const char *fontname, unsigned char idx);
|
|
|
|
extern void eterm_font_delete(char **flist, unsigned char idx);
|
2000-09-01 21:12:16 -07:00
|
|
|
extern void eterm_font_list_clear(void);
|
|
|
|
extern void font_cache_clear(void);
|
1999-09-21 19:34:13 -07:00
|
|
|
extern void *load_font(const char *, const char *, unsigned char);
|
|
|
|
extern void free_font(const void *);
|
|
|
|
extern void change_font(int, const char *);
|
2002-04-24 19:28:57 -07:00
|
|
|
extern const char *get_font_name(void *);
|
Fri May 26 20:43:03 PDT 2000 Michael Jennings <mej@eterm.org>
Okay, there are a few changes here. First off, I made multi-byte font
support the default now, as long as you have ISO 10646 fonts. In
order to do this, I made the default encoding type "Latin1" so as not
to interfere with 8-bit ISO 8859-1 characters. This means that if you
relied on the default multi-byte encoding method to be SJIS, you'll
need to update your theme files.
I also set it up so that Eterm will ignore SIGHUP, at least until I do
something with it (like reloading the theme or something).
I fixed the proportional font size algorithm. If there is more than
a 3-pixel variance between the minimum and maximum sizes for glyphs in
a proportional font, Eterm will set the size to 2 standard deviations
above the average width. This is so that they won't look so spread
out and ugly, but it still doesn't look perfect. Not much I can do on
that front...terminals must have fixed-width columns.
And then there's the biggie. I put in the ability to configure the
now-infamous font effects. I left a black drop shadow in as the
default, but you can now customize it via the --font-fx option or in
the config file using "font effects <stuff>" in the attributes
context. You can even use "fx" instead of "effects" for short.
So what goes in the <stuff> part? Well, you have several options.
To use a single-color outline, say "outline <color>". Likewise, a
single-color drop shadow is "shadow [corner] <color>"; "bottom_right"
is the default corner if you don't specify one. For a 3-D embossed
look, "emboss <dark_color> <light_color>". The opposite, a carved-
out look, can be had with "carved <dark_color> <light_color>". (Of
course, with those last two, the 3-D look will only work if you
choose the colors wisely.)
Those are all the shortcuts. The long way is to specify a series of
corner/color pairs, like "tl blue" for top-left blue, or
"bottom_right green". You can abbreviate using "tl," "tr," "bl," or
"br," or you can spell out "top_left," "top_right," "bottom_left," or
"bottom_right." If you omit a corner name, the first one defaults to
top-left, the second to top-right, and so on as listed above.
SVN revision: 2714
2000-05-26 20:41:22 -07:00
|
|
|
extern void set_shadow_color_by_name(unsigned char, const char *);
|
|
|
|
extern void set_shadow_color_by_pixel(unsigned char, Pixel);
|
2005-04-25 12:37:23 -07:00
|
|
|
extern unsigned char parse_font_fx(char *line);
|
1999-09-21 19:34:13 -07:00
|
|
|
|
|
|
|
_XFUNCPROTOEND
|
|
|
|
|
|
|
|
#endif /* _FONT_H_ */
|