2000-03-08 19:38:31 -08:00
|
|
|
/*
|
2009-01-06 01:08:48 -08:00
|
|
|
* Copyright (C) 1997-2009, 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
|
|
|
*/
|
|
|
|
|
|
|
|
static const char cvs_ident[] = "$Id$";
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "feature.h"
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <limits.h>
|
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
|
|
|
#include <math.h>
|
1999-09-21 19:34:13 -07:00
|
|
|
|
|
|
|
#include "command.h"
|
|
|
|
#include "font.h"
|
1999-10-07 15:18:14 -07:00
|
|
|
#include "startup.h"
|
1999-09-21 19:34:13 -07:00
|
|
|
#include "options.h"
|
|
|
|
#include "screen.h"
|
|
|
|
#include "term.h"
|
|
|
|
#include "windows.h"
|
|
|
|
|
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
|
|
|
char **etfonts = NULL;
|
2001-09-06 15:26:20 -07:00
|
|
|
unsigned char font_idx = DEF_FONT_IDX, font_cnt = 0;
|
|
|
|
int def_font_idx = DEF_FONT_IDX;
|
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
|
|
|
char *rs_font[NFONTS];
|
2002-06-02 17:24:22 -07:00
|
|
|
|
1999-09-21 19:34:13 -07:00
|
|
|
#ifdef MULTI_CHARSET
|
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
|
|
|
char *rs_mfont[NFONTS];
|
1999-12-02 18:31:33 -08:00
|
|
|
char **etmfonts = NULL;
|
2002-05-04 07:25:30 -07:00
|
|
|
const char *def_mfontName[] = { MFONT0, MFONT1, MFONT2, MFONT3, MFONT4 };
|
1999-09-21 19:34:13 -07:00
|
|
|
#endif
|
2002-05-04 07:25:30 -07:00
|
|
|
const char *def_fontName[] = { FONT0, FONT1, FONT2, FONT3, FONT4 };
|
1999-12-20 11:08:00 -08:00
|
|
|
unsigned char font_chg = 0;
|
2002-05-04 07:25:30 -07:00
|
|
|
fontshadow_t fshadow = { {0, 0, 0, 0}, {0, 0, 0, 1}, 1 };
|
1999-09-21 19:34:13 -07:00
|
|
|
|
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
|
|
|
static cachefont_t *font_cache = NULL, *cur_font = NULL;
|
1999-09-21 19:34:13 -07:00
|
|
|
static void font_cache_add(const char *name, unsigned char type, void *info);
|
|
|
|
static void font_cache_del(const void *info);
|
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
|
|
|
static cachefont_t *font_cache_find(const char *name, unsigned char type);
|
1999-09-22 15:15:46 -07:00
|
|
|
static void *font_cache_find_info(const char *name, unsigned char type);
|
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
|
|
|
static unsigned char get_corner(const char *corner);
|
1999-09-21 19:34:13 -07:00
|
|
|
|
2000-09-01 21:12:16 -07:00
|
|
|
/* The eterm_font_(add|delete) functions keep track of the names of the terminal fonts
|
|
|
|
as defined in the attributes/multicharset contexts. They do NOT call the cache
|
|
|
|
routines. The caller is responsible for adding/removing fonts to/from the cache. */
|
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
|
|
|
void
|
2002-05-04 07:25:30 -07:00
|
|
|
eterm_font_add(char ***plist, const char *fontname, unsigned char idx)
|
|
|
|
{
|
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
|
|
|
|
2002-05-04 07:25:30 -07:00
|
|
|
char **flist;
|
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
|
|
|
|
2002-05-04 07:25:30 -07:00
|
|
|
D_FONT(("Adding \"%s\" at %u (%8p)\n", NONULL(fontname), (unsigned int) idx, plist));
|
|
|
|
ASSERT(plist != NULL); /* plist is the address of either etfonts or etmfonts */
|
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
|
|
|
|
2002-05-04 07:25:30 -07:00
|
|
|
/* If we're adding the font at an index we don't have yet, we must resize to fit it. */
|
|
|
|
if (idx >= font_cnt) {
|
|
|
|
unsigned char new_size = sizeof(char *) * (idx + 1);
|
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
|
|
|
|
2002-05-04 07:25:30 -07:00
|
|
|
/* The below looks messy with all the cpp stuff, but it really just malloc's/realloc's
|
|
|
|
both etfonts and etmfonts at the same time to the same size, zeros all the new
|
|
|
|
memory space using MEMSET(), and then prints some goop. */
|
|
|
|
if (etfonts) {
|
|
|
|
etfonts = (char **) REALLOC(etfonts, new_size);
|
|
|
|
MEMSET(etfonts + font_cnt, 0, sizeof(char *) * (idx - font_cnt + 1));
|
1999-12-10 18:06:33 -08:00
|
|
|
#ifdef MULTI_CHARSET
|
2002-05-04 07:25:30 -07:00
|
|
|
etmfonts = (char **) REALLOC(etmfonts, new_size);
|
|
|
|
MEMSET(etmfonts + font_cnt, 0, sizeof(char *) * (idx - font_cnt + 1));
|
|
|
|
D_FONT((" -> Reallocated font lists: %u bytes at %8p/%8p\n", new_size, etfonts, etmfonts));
|
1999-12-13 03:53:54 -08:00
|
|
|
#else
|
2002-05-04 07:25:30 -07:00
|
|
|
D_FONT((" -> Reallocated font list: %u bytes at %8p\n", new_size, etfonts));
|
1999-12-13 03:53:54 -08:00
|
|
|
#endif
|
2002-05-04 07:25:30 -07:00
|
|
|
} else {
|
|
|
|
etfonts = (char **) MALLOC(new_size);
|
|
|
|
MEMSET(etfonts, 0, new_size);
|
1999-12-10 18:06:33 -08:00
|
|
|
#ifdef MULTI_CHARSET
|
2002-05-04 07:25:30 -07:00
|
|
|
etmfonts = (char **) MALLOC(new_size);
|
|
|
|
MEMSET(etmfonts, 0, new_size);
|
|
|
|
D_FONT((" -> Allocated font lists: %u bytes at %8p/%8p\n", new_size, etfonts, etmfonts));
|
1999-12-13 03:53:54 -08:00
|
|
|
#else
|
2002-05-04 07:25:30 -07:00
|
|
|
D_FONT((" -> Allocating font list: %u bytes at %8p\n", new_size, etfonts));
|
1999-12-13 03:53:54 -08:00
|
|
|
#endif
|
2002-05-04 07:25:30 -07:00
|
|
|
}
|
2000-09-01 21:12:16 -07:00
|
|
|
|
2002-05-04 07:25:30 -07:00
|
|
|
font_cnt = idx + 1; /* Update the font count. */
|
1999-12-10 18:06:33 -08:00
|
|
|
#ifdef MULTI_CHARSET
|
2002-05-04 07:25:30 -07:00
|
|
|
flist = ((plist == &etfonts) ? (etfonts) : (etmfonts));
|
1999-12-10 18:06:33 -08:00
|
|
|
#else
|
2002-05-04 07:25:30 -07:00
|
|
|
flist = etfonts;
|
1999-12-10 18:06:33 -08:00
|
|
|
#endif
|
2002-05-04 07:25:30 -07:00
|
|
|
} else {
|
|
|
|
flist = *plist;
|
|
|
|
if (flist[idx]) {
|
|
|
|
if ((flist[idx] == fontname) || (!strcasecmp(flist[idx], fontname))) {
|
|
|
|
return; /* We've already got the right font. */
|
|
|
|
}
|
|
|
|
FREE(flist[idx]); /* We're replacing an old font. Get rid of the old name. */
|
|
|
|
}
|
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
|
|
|
}
|
2002-05-04 07:25:30 -07:00
|
|
|
flist[idx] = STRDUP(fontname);
|
|
|
|
DUMP_FONTS();
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-05-04 07:25:30 -07:00
|
|
|
eterm_font_delete(char **flist, unsigned char idx)
|
|
|
|
{
|
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
|
|
|
|
2002-05-04 07:25:30 -07:00
|
|
|
ASSERT(idx < font_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
|
|
|
|
2002-05-04 07:25:30 -07:00
|
|
|
if (flist[idx]) {
|
|
|
|
FREE(flist[idx]);
|
|
|
|
}
|
|
|
|
flist[idx] = NULL;
|
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
|
|
|
}
|
|
|
|
|
2000-09-01 21:12:16 -07:00
|
|
|
void
|
|
|
|
eterm_font_list_clear(void)
|
|
|
|
{
|
2002-05-04 07:25:30 -07:00
|
|
|
unsigned char idx;
|
2000-09-01 21:12:16 -07:00
|
|
|
|
2002-05-04 07:25:30 -07:00
|
|
|
for (idx = 0; idx < font_cnt; idx++) {
|
|
|
|
eterm_font_delete(etfonts, idx);
|
2000-09-01 21:12:16 -07:00
|
|
|
#ifdef MULTI_CHARSET
|
2002-05-04 07:25:30 -07:00
|
|
|
eterm_font_delete(etmfonts, idx);
|
2000-09-01 21:12:16 -07:00
|
|
|
#endif
|
2002-05-04 07:25:30 -07:00
|
|
|
}
|
|
|
|
FREE(etfonts);
|
2000-09-01 21:12:16 -07:00
|
|
|
#ifdef MULTI_CHARSET
|
2002-05-04 07:25:30 -07:00
|
|
|
FREE(etmfonts);
|
2000-09-01 21:12:16 -07:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* These font caching routines keep track of all the various fonts we allocate
|
|
|
|
in the X server so that we only allocate each font once. Saves memory. */
|
1999-09-21 19:34:13 -07:00
|
|
|
static void
|
2002-05-04 07:25:30 -07:00
|
|
|
font_cache_add(const char *name, unsigned char type, void *info)
|
|
|
|
{
|
|
|
|
|
|
|
|
cachefont_t *font;
|
|
|
|
|
|
|
|
D_FONT(("font_cache_add(%s, %d, %8p) called.\n", NONULL(name), type, info));
|
|
|
|
|
|
|
|
/* Allocate the cache info for the font and store the data */
|
|
|
|
font = (cachefont_t *) MALLOC(sizeof(cachefont_t));
|
|
|
|
font->name = STRDUP(name);
|
|
|
|
font->type = type;
|
|
|
|
font->ref_cnt = 1;
|
|
|
|
switch (type) {
|
2005-04-18 18:57:24 -07:00
|
|
|
case FONT_TYPE_X:
|
|
|
|
font->fontinfo.xfontinfo = (XFontStruct *) info;
|
|
|
|
break;
|
|
|
|
case FONT_TYPE_TTF:
|
|
|
|
break;
|
|
|
|
case FONT_TYPE_FNLIB:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2002-05-04 07:25:30 -07:00
|
|
|
}
|
|
|
|
D_FONT((" -> Created new cachefont_t struct at %p: \"%s\", %d, %p\n", font, font->name, font->type, font->fontinfo.xfontinfo));
|
|
|
|
|
|
|
|
/* Actually add the struct to the end of our cache linked list. */
|
|
|
|
if (font_cache == NULL) {
|
|
|
|
font_cache = cur_font = font;
|
|
|
|
font->next = NULL;
|
|
|
|
D_FONT((" -> Stored as first font in cache. font_cache == cur_font == font == %p\n", font_cache));
|
|
|
|
D_FONT((" -> font_cache->next == cur_font->next == font->next == %p\n", font_cache->next));
|
|
|
|
} else {
|
|
|
|
D_FONT((" -> font_cache->next == %p, cur_font->next == %p\n", font_cache->next, cur_font->next));
|
|
|
|
cur_font->next = font;
|
|
|
|
font->next = NULL;
|
|
|
|
cur_font = font;
|
|
|
|
D_FONT((" -> Stored font in cache. font_cache == %p, cur_font == %p\n", font_cache, cur_font));
|
|
|
|
D_FONT((" -> font_cache->next == %p, cur_font->next == %p\n", font_cache->next, cur_font->next));
|
|
|
|
}
|
1999-09-21 19:34:13 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-05-04 07:25:30 -07:00
|
|
|
font_cache_del(const void *info)
|
|
|
|
{
|
|
|
|
|
|
|
|
cachefont_t *current, *tmp;
|
|
|
|
|
|
|
|
D_FONT(("font_cache_del(%8p) called.\n", info));
|
|
|
|
|
|
|
|
if (font_cache == NULL) {
|
|
|
|
return; /* No fonts in the cache. Theoretically this should never happen, but... */
|
1999-09-21 19:34:13 -07:00
|
|
|
}
|
2002-05-04 07:25:30 -07:00
|
|
|
|
|
|
|
/* Check the very first entry for a match. It's a special case. */
|
|
|
|
if (((font_cache->type == FONT_TYPE_X) && (font_cache->fontinfo.xfontinfo == (XFontStruct *) info))) {
|
|
|
|
D_FONT((" -> Match found at font_cache (%8p). Font name is \"%s\"\n", font_cache, NONULL(font_cache->name)));
|
|
|
|
/* We've got a match. Decrement the reference count, and if it goes to 0, remove it from the cache. */
|
|
|
|
if (--(font_cache->ref_cnt) == 0) {
|
|
|
|
D_FONT((" -> Reference count is now 0. Deleting from cache.\n"));
|
|
|
|
current = font_cache;
|
|
|
|
font_cache = current->next;
|
|
|
|
XFreeFont(Xdisplay, (XFontStruct *) info);
|
|
|
|
FREE(current->name);
|
|
|
|
FREE(current);
|
1999-09-21 19:34:13 -07:00
|
|
|
} else {
|
2002-05-04 07:25:30 -07:00
|
|
|
D_FONT((" -> Reference count is %d. Returning.\n", font_cache->ref_cnt));
|
1999-09-21 19:34:13 -07:00
|
|
|
}
|
|
|
|
return;
|
2000-09-01 21:12:16 -07:00
|
|
|
#if UNUSED_BLOCK
|
2002-05-04 07:25:30 -07:00
|
|
|
} else if ((font_cache->type == FONT_TYPE_TTF) && (0)) {
|
|
|
|
} else if ((font_cache->type == FONT_TYPE_FNLIB) && (0)) {
|
2000-09-01 21:12:16 -07:00
|
|
|
#endif
|
2002-05-04 07:25:30 -07:00
|
|
|
} else {
|
|
|
|
/* Search for a match. We test current->next, not current, so that we can
|
|
|
|
update the "next" pointer of the font prior to the one we're actually deleting. */
|
|
|
|
for (current = font_cache; current->next; current = current->next) {
|
|
|
|
if (((current->next->type == FONT_TYPE_X) && (current->next->fontinfo.xfontinfo == (XFontStruct *) info))) {
|
2005-04-18 18:57:24 -07:00
|
|
|
D_FONT((" -> Match found at current->next (%8p, current == %8p). Font name is \"%s\"\n", current->next, current,
|
|
|
|
NONULL(current->next->name)));
|
2002-05-04 07:25:30 -07:00
|
|
|
if (--(current->next->ref_cnt) == 0) {
|
|
|
|
D_FONT((" -> Reference count is now 0. Deleting from cache.\n"));
|
|
|
|
tmp = current->next;
|
|
|
|
current->next = current->next->next;
|
|
|
|
XFreeFont(Xdisplay, (XFontStruct *) info);
|
|
|
|
if (cur_font == tmp) {
|
2002-06-08 08:44:08 -07:00
|
|
|
cur_font = current; /* If we're nuking the last entry in the cache, point cur_font to the *new* last entry. */
|
2002-05-04 07:25:30 -07:00
|
|
|
}
|
|
|
|
FREE(tmp->name);
|
|
|
|
FREE(tmp);
|
|
|
|
} else {
|
|
|
|
D_FONT((" -> Reference count is %d. Returning.\n", font_cache->ref_cnt));
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
#if UNUSED_BLOCK
|
|
|
|
} else if ((current->next->type == FONT_TYPE_TTF) && (0)) {
|
|
|
|
} else if ((current->next->type == FONT_TYPE_FNLIB) && (0)) {
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
1999-09-21 19:34:13 -07:00
|
|
|
}
|
2002-05-04 07:25:30 -07:00
|
|
|
/* If we get here, there was no match. No big deal. */
|
2000-09-01 21:12:16 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
font_cache_clear(void)
|
|
|
|
{
|
2002-05-04 07:25:30 -07:00
|
|
|
cachefont_t *current, *tmp;
|
|
|
|
|
|
|
|
D_FONT(("Clearing the font cache.\n"));
|
|
|
|
for (current = font_cache; current;) {
|
|
|
|
D_FONT((" -> Deleting \"%s\" from cache.\n", current->name));
|
|
|
|
tmp = current;
|
|
|
|
current = current->next;
|
|
|
|
if (tmp->type == FONT_TYPE_X) {
|
|
|
|
XFreeFont(Xdisplay, (XFontStruct *) tmp->fontinfo.xfontinfo);
|
|
|
|
FREE(tmp->name);
|
|
|
|
FREE(tmp);
|
2000-09-01 21:12:16 -07:00
|
|
|
#if UNUSED_BLOCK
|
2002-05-04 07:25:30 -07:00
|
|
|
} else if (current->next->type == FONT_TYPE_TTF) {
|
|
|
|
} else if (current->next->type == FONT_TYPE_FNLIB) {
|
2000-09-01 21:12:16 -07:00
|
|
|
#endif
|
2002-05-04 07:25:30 -07:00
|
|
|
}
|
2000-09-01 21:12:16 -07:00
|
|
|
}
|
2002-05-04 07:25:30 -07:00
|
|
|
font_cache = cur_font = NULL;
|
1999-09-21 19:34:13 -07:00
|
|
|
}
|
|
|
|
|
2002-05-04 07:25:30 -07:00
|
|
|
static cachefont_t *font_cache_find(const char *name, unsigned char type)
|
|
|
|
{
|
1999-09-21 19:34:13 -07:00
|
|
|
|
2002-05-04 07:25:30 -07:00
|
|
|
cachefont_t *current;
|
1999-09-21 19:34:13 -07:00
|
|
|
|
2002-05-04 07:25:30 -07:00
|
|
|
ASSERT_RVAL(name != NULL, NULL);
|
1999-09-21 19:34:13 -07:00
|
|
|
|
2002-05-04 07:25:30 -07:00
|
|
|
D_FONT(("font_cache_find(%s, %d) called.\n", NONULL(name), type));
|
1999-09-21 19:34:13 -07:00
|
|
|
|
2002-05-04 07:25:30 -07:00
|
|
|
/* Find a matching name/type in the cache. Just a search; no reference counting happens here. */
|
|
|
|
for (current = font_cache; current; current = current->next) {
|
|
|
|
D_FONT((" -> Checking current (%8p), type == %d, name == %s\n", current, current->type, NONULL(current->name)));
|
|
|
|
if ((current->type == type) && !strcasecmp(current->name, name)) {
|
|
|
|
D_FONT((" -> Match!\n"));
|
|
|
|
return (current);
|
|
|
|
}
|
1999-09-21 19:34:13 -07:00
|
|
|
}
|
2002-05-04 07:25:30 -07:00
|
|
|
D_FONT(("No matches found. =(\n"));
|
|
|
|
return ((cachefont_t *) NULL);
|
1999-09-21 19:34:13 -07:00
|
|
|
}
|
1999-09-22 15:15:46 -07:00
|
|
|
|
|
|
|
static void *
|
2002-05-04 07:25:30 -07:00
|
|
|
font_cache_find_info(const char *name, unsigned char type)
|
|
|
|
{
|
1999-09-22 15:15:46 -07:00
|
|
|
|
2002-05-04 07:25:30 -07:00
|
|
|
cachefont_t *current;
|
|
|
|
|
|
|
|
REQUIRE_RVAL(name != NULL, NULL);
|
|
|
|
|
|
|
|
D_FONT(("font_cache_find_info(%s, %d) called.\n", NONULL(name), type));
|
|
|
|
|
|
|
|
/* This is also a simple search, but it returns the fontinfo rather than the cache entry. */
|
|
|
|
for (current = font_cache; current; current = current->next) {
|
|
|
|
D_FONT((" -> Checking current (%8p), type == %d, name == %s\n", current, current->type, NONULL(current->name)));
|
|
|
|
if ((current->type == type) && !strcasecmp(current->name, name)) {
|
|
|
|
D_FONT((" -> Match!\n"));
|
|
|
|
switch (type) {
|
2005-04-18 18:57:24 -07:00
|
|
|
case FONT_TYPE_X:
|
|
|
|
return ((void *) current->fontinfo.xfontinfo);
|
|
|
|
break;
|
|
|
|
case FONT_TYPE_TTF:
|
|
|
|
return (NULL);
|
|
|
|
break;
|
|
|
|
case FONT_TYPE_FNLIB:
|
|
|
|
return (NULL);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return (NULL);
|
|
|
|
break;
|
2002-05-04 07:25:30 -07:00
|
|
|
}
|
|
|
|
}
|
1999-09-22 15:15:46 -07:00
|
|
|
}
|
2002-05-04 07:25:30 -07:00
|
|
|
D_FONT(("No matches found. =(\n"));
|
|
|
|
return (NULL);
|
1999-09-22 15:15:46 -07:00
|
|
|
}
|
|
|
|
|
2002-04-24 19:28:57 -07:00
|
|
|
const char *
|
|
|
|
get_font_name(void *info)
|
|
|
|
{
|
2002-05-04 07:25:30 -07:00
|
|
|
cachefont_t *current;
|
2002-04-24 19:28:57 -07:00
|
|
|
|
2002-05-04 07:25:30 -07:00
|
|
|
REQUIRE_RVAL(info != NULL, NULL);
|
2002-04-24 19:28:57 -07:00
|
|
|
|
2002-05-04 07:25:30 -07:00
|
|
|
D_FONT(("get_font_name(%8p) called.\n", info));
|
2002-04-24 19:28:57 -07:00
|
|
|
|
2002-05-04 07:25:30 -07:00
|
|
|
/* This is also a simple search, but it returns the fontinfo rather than the cache entry. */
|
|
|
|
for (current = font_cache; current; current = current->next) {
|
|
|
|
D_FONT((" -> Checking current (%8p), type == %d, name == %s\n", current, current->type, NONULL(current->name)));
|
|
|
|
if ((current->type == FONT_TYPE_X) && (((void *) current->fontinfo.xfontinfo) == info)) {
|
|
|
|
D_FONT((" -> Match!\n"));
|
|
|
|
return current->name;
|
2002-04-24 19:28:57 -07:00
|
|
|
#if UNUSED_BLOCK
|
2002-05-04 07:25:30 -07:00
|
|
|
} else if ((current->type == FONT_TYPE_TTF) && (0)) {
|
|
|
|
} else if ((current->type == FONT_TYPE_FNLIB) && (0)) {
|
2002-04-24 19:28:57 -07:00
|
|
|
#endif
|
2002-05-04 07:25:30 -07:00
|
|
|
}
|
2002-04-24 19:28:57 -07:00
|
|
|
}
|
2002-05-04 07:25:30 -07:00
|
|
|
D_FONT(("No matches found. =(\n"));
|
|
|
|
return (NULL);
|
2002-04-24 19:28:57 -07:00
|
|
|
}
|
|
|
|
|
2000-09-01 21:12:16 -07:00
|
|
|
/* load_font() is the function that should be used to allocate fonts. */
|
1999-09-21 19:34:13 -07:00
|
|
|
void *
|
|
|
|
load_font(const char *name, const char *fallback, unsigned char type)
|
|
|
|
{
|
|
|
|
|
2002-05-04 07:25:30 -07:00
|
|
|
cachefont_t *font;
|
|
|
|
XFontStruct *xfont;
|
1999-09-21 19:34:13 -07:00
|
|
|
|
2002-05-04 07:25:30 -07:00
|
|
|
D_FONT(("load_font(%s, %s, %d) called.\n", NONULL(name), NONULL(fallback), type));
|
1999-09-22 15:15:46 -07:00
|
|
|
|
2002-05-04 07:25:30 -07:00
|
|
|
/* Default type is X font. */
|
|
|
|
if (type == 0) {
|
|
|
|
type = FONT_TYPE_X;
|
|
|
|
}
|
2000-09-01 21:12:16 -07:00
|
|
|
|
2002-05-04 07:25:30 -07:00
|
|
|
/* Specify some sane fallbacks */
|
|
|
|
if (name == NULL) {
|
|
|
|
if (fallback) {
|
|
|
|
name = fallback;
|
|
|
|
fallback = "fixed";
|
|
|
|
} else {
|
|
|
|
name = "fixed";
|
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
|
|
|
#ifdef MULTI_CHARSET
|
2002-05-04 07:25:30 -07:00
|
|
|
fallback = "-misc-fixed-medium-r-normal--13-120-75-75-c-60-iso10646-1";
|
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
|
|
|
#else
|
2002-05-04 07:25:30 -07:00
|
|
|
fallback = "-misc-fixed-medium-r-normal--13-120-75-75-c-60-iso8859-1";
|
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
|
|
|
#endif
|
2002-05-04 07:25:30 -07:00
|
|
|
}
|
|
|
|
} else if (fallback == NULL) {
|
|
|
|
fallback = "fixed";
|
1999-09-21 19:34:13 -07:00
|
|
|
}
|
2002-05-04 07:25:30 -07:00
|
|
|
D_FONT((" -> Using name == \"%s\" and fallback == \"%s\"\n", name, fallback));
|
|
|
|
|
|
|
|
/* Look for the font name in the cache. If it's there, add one to the
|
|
|
|
reference count and return the existing fontinfo pointer to the caller. */
|
|
|
|
if ((font = font_cache_find(name, type)) != NULL) {
|
|
|
|
font_cache_add_ref(font);
|
|
|
|
D_FONT((" -> Font found in cache. Incrementing reference count to %d and returning existing data.\n", font->ref_cnt));
|
|
|
|
switch (type) {
|
2005-04-18 18:57:24 -07:00
|
|
|
case FONT_TYPE_X:
|
|
|
|
return ((void *) font->fontinfo.xfontinfo);
|
|
|
|
break;
|
|
|
|
case FONT_TYPE_TTF:
|
|
|
|
return (NULL);
|
|
|
|
break;
|
|
|
|
case FONT_TYPE_FNLIB:
|
|
|
|
return (NULL);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return (NULL);
|
|
|
|
break;
|
2002-05-04 07:25:30 -07:00
|
|
|
}
|
1999-09-21 19:34:13 -07:00
|
|
|
}
|
2002-05-04 07:25:30 -07:00
|
|
|
|
|
|
|
/* No match in the cache, so we'll have to add it. */
|
|
|
|
if (type == FONT_TYPE_X) {
|
|
|
|
if ((xfont = XLoadQueryFont(Xdisplay, name)) == NULL) {
|
2006-02-13 11:52:45 -08:00
|
|
|
libast_print_error("Unable to load font \"%s\". Falling back on \"%s\"\n", name, fallback);
|
2002-05-04 07:25:30 -07:00
|
|
|
if ((xfont = XLoadQueryFont(Xdisplay, fallback)) == NULL) {
|
2006-02-13 11:52:45 -08:00
|
|
|
libast_fatal_error("Couldn't load the fallback font either. Giving up.\n");
|
2002-05-04 07:25:30 -07:00
|
|
|
} else {
|
|
|
|
font_cache_add(fallback, type, (void *) xfont);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
font_cache_add(name, type, (void *) xfont);
|
|
|
|
}
|
|
|
|
return ((void *) xfont);
|
2000-09-01 21:12:16 -07:00
|
|
|
#if UNUSED_BLOCK
|
2002-05-04 07:25:30 -07:00
|
|
|
} else if (type == FONT_TYPE_TTF) {
|
|
|
|
return (NULL);
|
|
|
|
} else if (type == FONT_TYPE_FNLIB) {
|
|
|
|
return (NULL);
|
2000-09-01 21:12:16 -07:00
|
|
|
#endif
|
2002-05-04 07:25:30 -07:00
|
|
|
}
|
|
|
|
ASSERT_NOTREACHED_RVAL(NULL);
|
1999-09-21 19:34:13 -07:00
|
|
|
}
|
|
|
|
|
2000-09-01 21:12:16 -07:00
|
|
|
/* free_font() is the external function for deallocating fonts. */
|
1999-09-21 19:34:13 -07:00
|
|
|
void
|
|
|
|
free_font(const void *info)
|
|
|
|
{
|
2002-05-04 07:25:30 -07:00
|
|
|
ASSERT(info != NULL);
|
|
|
|
font_cache_del(info);
|
1999-09-21 19:34:13 -07:00
|
|
|
}
|
|
|
|
|
2000-09-01 21:12:16 -07:00
|
|
|
/* change_font() handles the font changing escape sequences. It's also called to
|
|
|
|
initialize the terminal fonts (loading and setting up size hints/info).*/
|
1999-09-21 19:34:13 -07:00
|
|
|
void
|
|
|
|
change_font(int init, const char *fontname)
|
|
|
|
{
|
|
|
|
#ifndef NO_BOLDFONT
|
2002-05-04 07:25:30 -07:00
|
|
|
static XFontStruct *boldFont = NULL;
|
1999-09-21 19:34:13 -07:00
|
|
|
#endif
|
2002-05-04 07:25:30 -07:00
|
|
|
short idx = 0, old_idx = font_idx;
|
|
|
|
int fh, fw = 0;
|
1999-09-21 19:34:13 -07:00
|
|
|
|
2005-04-18 18:57:24 -07:00
|
|
|
D_FONT(("change_font(%d, \"%s\"): def_font_idx == %u, font_idx == %u\n", init, NONULL(fontname), (unsigned int) def_font_idx,
|
|
|
|
(unsigned int) font_idx));
|
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
|
|
|
|
2002-05-04 07:25:30 -07:00
|
|
|
if (init) {
|
|
|
|
ASSERT(etfonts != NULL);
|
2002-11-21 11:06:43 -08:00
|
|
|
if ((def_font_idx >= font_cnt) || (etfonts[def_font_idx] == NULL)) {
|
|
|
|
def_font_idx = font_idx;
|
|
|
|
} else {
|
|
|
|
font_idx = def_font_idx;
|
|
|
|
}
|
2002-05-04 07:25:30 -07:00
|
|
|
ASSERT(etfonts[font_idx] != NULL);
|
1999-12-02 18:31:33 -08:00
|
|
|
#ifdef MULTI_CHARSET
|
2002-05-04 07:25:30 -07:00
|
|
|
ASSERT(etmfonts != NULL);
|
|
|
|
ASSERT(etmfonts[font_idx] != NULL);
|
|
|
|
#endif
|
|
|
|
} else {
|
|
|
|
ASSERT(fontname != NULL);
|
|
|
|
|
|
|
|
switch (*fontname) {
|
2005-04-18 18:57:24 -07:00
|
|
|
/* Empty font name. Reset to default. */
|
|
|
|
case '\0':
|
|
|
|
font_idx = def_font_idx;
|
|
|
|
fontname = NULL;
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* A font escape sequence. See which one it is. */
|
|
|
|
case FONT_CMD:
|
|
|
|
idx = atoi(++fontname);
|
|
|
|
switch (*fontname) {
|
|
|
|
case '+':
|
|
|
|
NEXT_FONT(idx);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '-':
|
|
|
|
PREV_FONT(idx);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
if (*fontname != '\0' && !isdigit(*fontname))
|
|
|
|
return; /* It's not a number. Punt. */
|
|
|
|
/* Set current font to font N */
|
|
|
|
BOUND(idx, 0, (font_cnt - 1));
|
|
|
|
font_idx = idx;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* NULL out the fontname so we don't try to load it */
|
|
|
|
fontname = NULL;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
/* Change to the named font. See if we already have it, and if so, just set the index. */
|
|
|
|
for (idx = 0; idx < font_cnt; idx++) {
|
|
|
|
if (!strcasecmp(etfonts[idx], fontname)) {
|
|
|
|
font_idx = idx;
|
|
|
|
fontname = NULL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2002-05-04 07:25:30 -07:00
|
|
|
}
|
2000-09-01 21:12:16 -07:00
|
|
|
|
2002-05-04 07:25:30 -07:00
|
|
|
/* If we get here with a non-NULL fontname, we have to load a new font. Rats. */
|
|
|
|
if (fontname != NULL) {
|
|
|
|
eterm_font_add(&etfonts, fontname, font_idx);
|
|
|
|
} else if (font_idx == old_idx) {
|
|
|
|
/* Sigh. What a waste of time, changing to the same font. */
|
|
|
|
D_FONT((" -> Change to the same font index (%d) we had before? I don't think so.\n", font_idx));
|
|
|
|
return;
|
|
|
|
}
|
1999-09-22 15:15:46 -07:00
|
|
|
}
|
2002-05-04 07:25:30 -07:00
|
|
|
D_FONT((" -> Changing to font index %u (\"%s\")\n", (unsigned int) font_idx, NONULL(etfonts[font_idx])));
|
|
|
|
if (TermWin.font) {
|
|
|
|
/* If we have a terminal font, but it's not our new current font, free it and load the new one. */
|
|
|
|
if (font_cache_find_info(etfonts[font_idx], FONT_TYPE_X) != TermWin.font) {
|
|
|
|
free_font(TermWin.font);
|
|
|
|
TermWin.font = load_font(etfonts[font_idx], "fixed", FONT_TYPE_X);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* Load the new font. */
|
|
|
|
TermWin.font = load_font(etfonts[font_idx], "fixed", FONT_TYPE_X);
|
1999-09-22 15:15:46 -07:00
|
|
|
}
|
1999-09-21 19:34:13 -07:00
|
|
|
|
|
|
|
#ifndef NO_BOLDFONT
|
2002-05-04 07:25:30 -07:00
|
|
|
if (init && rs_boldFont != NULL) {
|
|
|
|
/* If we're initializing, load the bold font too. */
|
|
|
|
boldFont = load_font(rs_boldFont, "-misc-fixed-bold-r-semicondensed--13-120-75-75-c-60-iso8859-1", FONT_TYPE_X);
|
|
|
|
}
|
1999-09-21 19:34:13 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef MULTI_CHARSET
|
2002-05-04 07:25:30 -07:00
|
|
|
if (TermWin.mfont) {
|
|
|
|
/* Ditto the above, but for the multi-byte fonts. */
|
|
|
|
if (font_cache_find_info(etmfonts[font_idx], FONT_TYPE_X) != TermWin.mfont) {
|
|
|
|
free_font(TermWin.mfont);
|
|
|
|
TermWin.mfont = load_font(etmfonts[font_idx], "k14", FONT_TYPE_X);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
TermWin.mfont = load_font(etmfonts[font_idx], "k14", FONT_TYPE_X);
|
1999-09-22 15:15:46 -07:00
|
|
|
}
|
1999-09-21 19:34:13 -07:00
|
|
|
# ifdef USE_XIM
|
2002-05-04 07:25:30 -07:00
|
|
|
/* Changing fonts requires updating the FontSet */
|
|
|
|
if (xim_input_context) {
|
|
|
|
if (TermWin.fontset) {
|
|
|
|
XFreeFontSet(Xdisplay, TermWin.fontset);
|
|
|
|
}
|
|
|
|
TermWin.fontset = create_fontset(etfonts[font_idx], etmfonts[font_idx]);
|
|
|
|
xim_set_fontset();
|
1999-09-21 19:34:13 -07:00
|
|
|
}
|
|
|
|
# endif
|
|
|
|
#endif /* MULTI_CHARSET */
|
|
|
|
|
2002-05-04 07:25:30 -07:00
|
|
|
if (!init) {
|
|
|
|
/* Unless we're initializing, set the font ID in the GC to our new font. */
|
|
|
|
XSetFont(Xdisplay, TermWin.gc, TermWin.font->fid);
|
|
|
|
}
|
1999-09-21 19:34:13 -07:00
|
|
|
|
2002-05-04 07:25:30 -07:00
|
|
|
/* Check the font dimensions to update our TermWin info */
|
|
|
|
fw = TermWin.font->min_bounds.width;
|
2000-06-26 09:33:23 -07:00
|
|
|
#ifdef MULTI_CHARSET
|
2002-05-04 07:25:30 -07:00
|
|
|
fh = (MAX((encoding_method == LATIN1 ? 0 : TermWin.mfont->ascent), TermWin.font->ascent)
|
|
|
|
+ MAX((encoding_method == LATIN1 ? 0 : TermWin.mfont->descent), TermWin.font->descent)
|
|
|
|
+ rs_line_space);
|
2000-06-26 09:33:23 -07:00
|
|
|
#else
|
2002-05-04 07:25:30 -07:00
|
|
|
fh = TermWin.font->ascent + TermWin.font->descent + rs_line_space;
|
2000-06-26 09:33:23 -07:00
|
|
|
#endif
|
1999-09-22 15:15:46 -07:00
|
|
|
|
2002-05-04 07:25:30 -07:00
|
|
|
D_FONT(("Font information: Ascent == %hd, Descent == %hd, width min/max %d/%d\n", TermWin.font->ascent, TermWin.font->descent,
|
|
|
|
TermWin.font->min_bounds.width, TermWin.font->max_bounds.width));
|
|
|
|
if (TermWin.font->min_bounds.width == TermWin.font->max_bounds.width)
|
|
|
|
TermWin.fprop = 0; /* Mono-spaced (fixed width) font */
|
|
|
|
else
|
|
|
|
TermWin.fprop = 1; /* Proportional font */
|
|
|
|
|
|
|
|
/* For proportional fonts with large size variations, do some math-fu to try and help the appearance */
|
2005-04-18 18:57:24 -07:00
|
|
|
if (TermWin.fprop && (BITFIELD_IS_SET(vt_options, VT_OPTIONS_PROPORTIONAL)) && TermWin.font->per_char
|
|
|
|
&& (TermWin.font->max_bounds.width - TermWin.font->min_bounds.width >= 3)) {
|
2002-05-04 07:25:30 -07:00
|
|
|
int cw, n = 0, sum = 0, sumsq = 0, min_w, max_w;
|
|
|
|
unsigned int i;
|
|
|
|
double dev;
|
|
|
|
|
|
|
|
min_w = fw;
|
|
|
|
LOWER_BOUND(min_w, 1);
|
|
|
|
max_w = TermWin.font->max_bounds.width;
|
|
|
|
UPPER_BOUND(max_w, 1024);
|
|
|
|
for (i = TermWin.font->min_char_or_byte2; i <= TermWin.font->max_char_or_byte2; i++) {
|
|
|
|
cw = TermWin.font->per_char[i].width;
|
|
|
|
if (cw >= min_w && cw <= max_w) {
|
|
|
|
sum += cw;
|
|
|
|
sumsq += (cw * cw);
|
|
|
|
n++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (n) {
|
|
|
|
dev = sqrt((sumsq - (sum * sum) / n) / n);
|
|
|
|
/* Final font width is the average width plus 2 standard
|
|
|
|
deviations, but no larger than the font's max width */
|
|
|
|
fw = ((sum / n) + (((int) dev) << 1));
|
2005-04-18 18:57:24 -07:00
|
|
|
D_FONT(("Proportional font optimizations: Average width %d, standard deviation %3.2f, new width %d\n", (sum / n), dev,
|
|
|
|
fw));
|
2002-05-04 07:25:30 -07:00
|
|
|
UPPER_BOUND(fw, max_w);
|
|
|
|
} else {
|
|
|
|
LOWER_BOUND(fw, TermWin.font->max_bounds.width);
|
|
|
|
}
|
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
|
|
|
} else {
|
2002-05-04 07:25:30 -07:00
|
|
|
LOWER_BOUND(fw, TermWin.font->max_bounds.width);
|
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
|
|
|
}
|
2000-03-03 20:25:23 -08:00
|
|
|
|
2002-05-04 07:25:30 -07:00
|
|
|
/* If the sizes haven't changed, we don't have to update the hints */
|
|
|
|
if (fw == TermWin.fwidth && fh == TermWin.fheight) {
|
|
|
|
/* but we _do_ need to redraw to show the new font */
|
|
|
|
scr_touch();
|
|
|
|
return;
|
|
|
|
}
|
1999-09-22 15:15:46 -07:00
|
|
|
|
2002-05-04 07:25:30 -07:00
|
|
|
TermWin.fwidth = fw;
|
|
|
|
TermWin.fheight = fh;
|
1999-09-21 19:34:13 -07:00
|
|
|
|
2002-05-04 07:25:30 -07:00
|
|
|
/* Check the bold font size and make sure it matches the normal font */
|
1999-09-21 19:34:13 -07:00
|
|
|
#ifndef NO_BOLDFONT
|
2002-05-04 07:25:30 -07:00
|
|
|
TermWin.boldFont = NULL; /* FIXME: Memory leak? Not that anyone uses bold fonts.... */
|
|
|
|
if (boldFont != NULL) {
|
|
|
|
|
|
|
|
fw = boldFont->min_bounds.width;
|
|
|
|
fh = boldFont->ascent + boldFont->descent + rs_line_space;
|
2002-06-08 08:44:08 -07:00
|
|
|
if (TermWin.fprop == 0) { /* bold font must also be monospaced */
|
2002-05-04 07:25:30 -07:00
|
|
|
if (fw != boldFont->max_bounds.width)
|
|
|
|
fw = -1;
|
|
|
|
} else {
|
|
|
|
LOWER_BOUND(fw, boldFont->max_bounds.width);
|
|
|
|
}
|
1999-09-21 19:34:13 -07:00
|
|
|
|
2002-05-04 07:25:30 -07:00
|
|
|
if (fw == TermWin.fwidth && fh == TermWin.fheight) {
|
|
|
|
TermWin.boldFont = boldFont;
|
|
|
|
}
|
1999-09-22 15:15:46 -07:00
|
|
|
}
|
1999-09-21 19:34:13 -07:00
|
|
|
#endif /* NO_BOLDFONT */
|
|
|
|
|
2002-05-04 07:25:30 -07:00
|
|
|
set_colorfgbg();
|
1999-09-21 19:34:13 -07:00
|
|
|
|
2002-06-13 22:59:07 -07:00
|
|
|
#ifdef ESCREEN
|
2002-10-07 19:18:09 -07:00
|
|
|
D_FONT((" -> Escreen mode is %s\n", ((NS_MAGIC_LINE(TermWin.screen_mode)) ? ("on") : ("off"))));
|
2002-06-13 22:59:07 -07:00
|
|
|
#endif
|
2002-10-07 19:18:09 -07:00
|
|
|
|
|
|
|
TERM_WINDOW_SET_WIDTH();
|
|
|
|
TERM_WINDOW_SET_HEIGHT();
|
|
|
|
|
|
|
|
D_FONT((" -> New font width/height = %ldx%ld, making the terminal size %ldx%ld\n",
|
|
|
|
TermWin.fwidth, TermWin.fheight, TERM_WINDOW_GET_WIDTH(), TERM_WINDOW_GET_HEIGHT()));
|
1999-09-21 19:34:13 -07:00
|
|
|
|
2002-05-04 07:25:30 -07:00
|
|
|
/* If we're initializing, *we* do the size hints. If not, resize the parent window. */
|
|
|
|
if (init) {
|
|
|
|
szHint.width_inc = TermWin.fwidth;
|
|
|
|
szHint.height_inc = TermWin.fheight;
|
1999-09-21 19:34:13 -07:00
|
|
|
|
2002-05-04 07:25:30 -07:00
|
|
|
szHint.min_width = szHint.base_width + szHint.width_inc;
|
|
|
|
szHint.min_height = szHint.base_height + szHint.height_inc;
|
1999-09-21 19:34:13 -07:00
|
|
|
|
2002-10-07 19:18:09 -07:00
|
|
|
szHint.width = szHint.base_width + TERM_WINDOW_GET_WIDTH();
|
|
|
|
szHint.height = szHint.base_height + TERM_WINDOW_GET_HEIGHT();
|
1999-09-21 19:34:13 -07:00
|
|
|
|
2002-05-04 07:25:30 -07:00
|
|
|
szHint.flags = PMinSize | PResizeInc | PBaseSize;
|
|
|
|
} else {
|
|
|
|
parent_resize();
|
|
|
|
font_chg++;
|
|
|
|
}
|
|
|
|
return;
|
1999-09-21 19:34:13 -07:00
|
|
|
}
|
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
|
|
|
|
|
|
|
static unsigned char
|
|
|
|
get_corner(const char *corner)
|
|
|
|
{
|
2002-05-04 07:25:30 -07:00
|
|
|
if (!BEG_STRCASECMP(corner, "tl ") || !BEG_STRCASECMP(corner, "top_left")) {
|
|
|
|
return SHADOW_TOP_LEFT;
|
|
|
|
} else if (!BEG_STRCASECMP(corner, "tr ") || !BEG_STRCASECMP(corner, "top_right")) {
|
|
|
|
return SHADOW_TOP_RIGHT;
|
|
|
|
} else if (!BEG_STRCASECMP(corner, "bl ") || !BEG_STRCASECMP(corner, "bottom_left")) {
|
|
|
|
return SHADOW_BOTTOM_LEFT;
|
|
|
|
} else if (!BEG_STRCASECMP(corner, "br ") || !BEG_STRCASECMP(corner, "bottom_right")) {
|
|
|
|
return SHADOW_BOTTOM_RIGHT;
|
|
|
|
} else {
|
|
|
|
return 255;
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
set_shadow_color_by_name(unsigned char which, const char *color_name)
|
|
|
|
{
|
2002-05-04 07:25:30 -07:00
|
|
|
Pixel p;
|
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
|
|
|
|
2002-05-04 07:25:30 -07:00
|
|
|
ASSERT(which <= 4);
|
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
|
|
|
|
2002-05-04 07:25:30 -07:00
|
|
|
p = get_color_by_name(color_name, "#000000");
|
|
|
|
fshadow.color[which] = p;
|
|
|
|
fshadow.shadow[which] = fshadow.do_shadow = 1;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
set_shadow_color_by_pixel(unsigned char which, Pixel p)
|
|
|
|
{
|
2002-05-04 07:25:30 -07:00
|
|
|
ASSERT(which <= 4);
|
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
|
|
|
|
2002-05-04 07:25:30 -07:00
|
|
|
fshadow.color[which] = p;
|
|
|
|
fshadow.shadow[which] = fshadow.do_shadow = 1;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
/* Possible syntax for the font effects line:
|
|
|
|
font fx <topleft_color> <topright_color> <bottomleft_color> <bottomright_color>
|
|
|
|
font fx outline <color>
|
|
|
|
font fx shadow <color>
|
|
|
|
font fx emboss <dark_color> <light_color>
|
|
|
|
font fx carved <dark_color> <light_color>
|
|
|
|
^^^^^^^
|
|
|
|
|
|
|
|
|
\- This part is not included in the contents of the line variable.
|
|
|
|
*/
|
|
|
|
unsigned char
|
2005-04-25 12:37:23 -07:00
|
|
|
parse_font_fx(char *line)
|
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
|
|
|
{
|
2002-05-04 07:25:30 -07:00
|
|
|
char *color, *corner;
|
|
|
|
unsigned char which, n;
|
|
|
|
Pixel p;
|
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
|
|
|
|
2002-10-04 18:19:41 -07:00
|
|
|
ASSERT_RVAL(line != NULL, 0);
|
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
|
|
|
|
2006-02-13 11:52:45 -08:00
|
|
|
n = spiftool_num_words(line);
|
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
|
|
|
|
2002-05-04 07:25:30 -07:00
|
|
|
if (!BEG_STRCASECMP(line, "none")) {
|
|
|
|
MEMSET(&fshadow, 0, sizeof(fontshadow_t));
|
|
|
|
} else if (!BEG_STRCASECMP(line, "outline")) {
|
|
|
|
if (n != 2) {
|
|
|
|
return 0;
|
|
|
|
}
|
2006-02-13 11:52:45 -08:00
|
|
|
color = spiftool_get_word(2, line);
|
2002-05-04 07:25:30 -07:00
|
|
|
p = get_color_by_name(color, "black");
|
|
|
|
FREE(color);
|
|
|
|
for (which = 0; which < 4; which++) {
|
|
|
|
set_shadow_color_by_pixel(which, p);
|
|
|
|
}
|
|
|
|
} else if (!BEG_STRCASECMP(line, "shadow")) {
|
|
|
|
if (n == 2) {
|
|
|
|
which = SHADOW_BOTTOM_RIGHT;
|
2006-02-13 11:52:45 -08:00
|
|
|
color = spiftool_get_word(2, line);
|
2002-05-04 07:25:30 -07:00
|
|
|
} else if (n == 3) {
|
2006-02-13 11:52:45 -08:00
|
|
|
color = spiftool_get_word(3, line);
|
|
|
|
corner = spiftool_get_pword(2, line);
|
2002-05-04 07:25:30 -07:00
|
|
|
which = get_corner(corner);
|
|
|
|
if (which >= 4) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
set_shadow_color_by_name(which, color);
|
|
|
|
FREE(color);
|
|
|
|
} else if (!BEG_STRCASECMP(line, "emboss")) {
|
|
|
|
if (n != 3) {
|
|
|
|
return 0;
|
|
|
|
}
|
2006-02-13 11:52:45 -08:00
|
|
|
color = spiftool_get_word(2, line);
|
2002-05-04 07:25:30 -07:00
|
|
|
p = get_color_by_name(color, "black");
|
|
|
|
set_shadow_color_by_pixel(SHADOW_BOTTOM_RIGHT, p);
|
|
|
|
FREE(color);
|
|
|
|
|
2006-02-13 11:52:45 -08:00
|
|
|
color = spiftool_get_word(3, line);
|
2002-05-04 07:25:30 -07:00
|
|
|
p = get_color_by_name(color, "white");
|
|
|
|
set_shadow_color_by_pixel(SHADOW_TOP_LEFT, p);
|
|
|
|
FREE(color);
|
|
|
|
} else if (!BEG_STRCASECMP(line, "carved")) {
|
|
|
|
if (n != 3) {
|
|
|
|
return 0;
|
|
|
|
}
|
2006-02-13 11:52:45 -08:00
|
|
|
color = spiftool_get_word(2, line);
|
2002-05-04 07:25:30 -07:00
|
|
|
p = get_color_by_name(color, "black");
|
|
|
|
set_shadow_color_by_pixel(SHADOW_TOP_LEFT, p);
|
|
|
|
FREE(color);
|
|
|
|
|
2006-02-13 11:52:45 -08:00
|
|
|
color = spiftool_get_word(3, line);
|
2002-05-04 07:25:30 -07:00
|
|
|
p = get_color_by_name(color, "white");
|
|
|
|
set_shadow_color_by_pixel(SHADOW_BOTTOM_RIGHT, p);
|
|
|
|
FREE(color);
|
|
|
|
} else {
|
|
|
|
unsigned char i;
|
|
|
|
|
|
|
|
for (i = 0; i < 4; i++) {
|
|
|
|
which = get_corner(line);
|
|
|
|
if (which >= 4) {
|
|
|
|
which = i;
|
2006-02-13 11:52:45 -08:00
|
|
|
color = spiftool_get_word(1, line);
|
|
|
|
line = spiftool_get_pword(2, line);
|
2002-05-04 07:25:30 -07:00
|
|
|
} else {
|
2006-02-13 11:52:45 -08:00
|
|
|
color = spiftool_get_word(2, line);
|
|
|
|
line = spiftool_get_pword(3, line);
|
2002-05-04 07:25:30 -07:00
|
|
|
}
|
|
|
|
set_shadow_color_by_name(which, color);
|
|
|
|
FREE(color);
|
|
|
|
if (line == NULL) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
}
|
2002-05-04 07:25:30 -07:00
|
|
|
return 1;
|
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
|
|
|
}
|