[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Margin kerning
From: |
Ludovic Courtès |
Subject: |
Re: Margin kerning |
Date: |
Tue, 28 Jun 2005 14:58:46 +0200 |
User-agent: |
Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux) |
Hi,
Michael Piotrowski <address@hidden> writes:
> It seems, however, that it interacts negatively with @OptimizePages;
> if it is set to Yes, Lout dumps core in the second run--at least with
> the one document on which I've tested it.
Good catch! I must confess that I hadn't tested it...
This comes from the fact that `Promote ()' (in z22.c) creates word
objects that contain the string "w" and whose font number is not a valid
font number (zero). This is fixed by having the margin kerning code
check a word's font number is valid or not (in `FillObject ()'). The
annoying thing is that this verification is very specific to the "w"
objects: "real" words have a valid font attached to them.
BTW, Jeff, what are those "w" objects about?
Additionally, I augmented `MakeWord ()' so that it explicitly
initializes all the fields of a word, although this is not strictly
necessary.
Let me know if it's ok with the following patch.
Thanks!
Ludovic.
--- orig/z07.c
+++ mod/z07.c
@@ -136,6 +136,17 @@
{ OBJECT res;
NewWord(res, typ, StringLength(str), pos);
StringCopy(string(res), str);
+
+ word_font(res) = 0;
+ word_colour(res) = 0;
+ word_texture(res) = 0;
+ word_outline(res) = 0;
+ word_language(res) = 0;
+ word_baselinemark(res) = 0;
+ word_ligatures(res) = 0;
+ word_hyph(res) = 0;
+ underline(res) = 0;
+
FposCopy(fpos(res), *pos);
debug4(DOS, DDD, "MakeWord(%s, %s, %s) returning %s",
Image(typ), str, EchoFilePos(pos), EchoObject(res));
--- orig/z14.c
+++ mod/z14.c
@@ -777,10 +777,10 @@
font = word_font(first_on_line);
word_content = string(first_on_line);
- if ((word_content[0]) && (SmallGlyphHeight(font, word_content[0])))
+ if ((font > 0) &&
+ (word_content[0]) && (SmallGlyphHeight(font, word_content[0])))
{ OBJECT z;
- MAPPING m;
- FULL_CHAR *unacc;
+ FULL_CHAR *unacc = NULL;
FULL_CHAR first_word[2];
FULL_LENGTH gwidth;
@@ -788,8 +788,12 @@
"(beginning of line)", word_content[0]);
/* Get font information. */
- m = font_mapping(finfo[font].font_table);
- unacc = MapTable[m]->map[MAP_UNACCENTED];
+ if (finfo[font].font_table)
+ {
+ MAPPING m;
+ m = font_mapping(finfo[font].font_table);
+ unacc = MapTable[m]->map[MAP_UNACCENTED];
+ }
/* Add the first character. */
first_word[0] = word_content[0];
@@ -818,7 +822,7 @@
/* Add a zero-width gap object. */
New(z, GAP_OBJ);
vspace(z) = 0;
- if (word_content[1])
+ if ((word_content[1]) && (unacc))
hspace(z) = FontKernLength(font, unacc,
word_content[0], word_content[1]);
else
@@ -878,8 +882,7 @@
if( mode(gap(lgap)) == ADD_HYPH )
{ OBJECT z, tmp;
FONT_NUM font;
- MAPPING m;
- FULL_CHAR *unacc, *word_content;
+ FULL_CHAR *unacc = NULL, *word_content;
unsigned word_len;
/* find word hyphen attaches to, since need its underline and font */
@@ -891,16 +894,24 @@
/* get font information */
font = word_font(tmp);
- m = font_mapping(finfo[font].font_table);
- unacc = MapTable[m]->map[MAP_UNACCENTED];
+ if (finfo[font].font_table)
+ {
+ MAPPING m;
+ m = font_mapping(finfo[font].font_table);
+ unacc = MapTable[m]->map[MAP_UNACCENTED];
+ }
/* add zero-width gap object */
New(z, GAP_OBJ);
debug0(DOF, DD, " adding hyphen");
debug0(DOF, DD, "");
vspace(z) = 0;
- hspace(z) = FontKernLength(word_font(tmp), unacc,
- word_content[word_len - 1], CH_HYPHEN);
+ if (unacc)
+ hspace(z) = FontKernLength(font, unacc,
+ word_content[word_len - 1], CH_HYPHEN);
+ else
+ hspace(z) = 0;
+
underline(z) = underline(tmp);
SetGap(gap(z), TRUE, FALSE, TRUE, FIXED_UNIT, EDGE_MODE, 0);
Link(x, z);
@@ -945,25 +956,28 @@
word_content = string(last_on_line);
word_len = strlen((char *)word_content);
- if (*word_content)
+ if((font > 0) && (*word_content))
{
last_char = word_content[word_len - 1];
if(SmallGlyphHeight(font, last_char))
{ OBJECT z;
- MAPPING m;
- FULL_CHAR *unacc;
+ FULL_CHAR *unacc = NULL;
/* Get font information. */
- m = font_mapping(finfo[font].font_table);
- unacc = MapTable[m]->map[MAP_UNACCENTED];
+ if (finfo[font].font_table)
+ {
+ MAPPING m;
+ m = font_mapping(finfo[font].font_table);
+ unacc = MapTable[m]->map[MAP_UNACCENTED];
+ }
/* Add a zero-width gap object. */
New(z, GAP_OBJ);
debug1(DOF, DD, " adding margin-kerned character `%c' "
"(end of line)", last_char);
vspace(z) = 0;
- if(word_len > 1)
+ if((word_len > 1) && (unacc))
hspace(z) = FontKernLength(font, unacc,
word_content[word_len - 2],
last_char);
--- orig/z37.c
+++ mod/z37.c
@@ -2001,8 +2001,10 @@
{
struct metrics *fnt;
+ assert ((fnum >= 1) && (fnum <= font_count), "FontGlyphHeight");
+
fnt = finfo[fnum].size_table;
- return (fnt[chr].up - fnt[chr].down);
+ return (fnt ? fnt[chr].up - fnt[chr].down : 0);
}
/*@::FontGlyphWidth()@*******************************************************/
@@ -2018,6 +2020,8 @@
{
struct metrics *fnt;
+ assert ((fnum >= 1) && (fnum <= font_count), "FontGlyphWidth");
+
fnt = finfo[fnum].size_table;
- return (fnt[chr].right - fnt[chr].left);
+ return (fnt ? fnt[chr].right - fnt[chr].left : 0);
}
Re: Margin kerning, Jeff Kingston, 2005/06/28