groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Groff] explicit hyphen and numbers


From: Werner LEMBERG
Subject: Re: [Groff] explicit hyphen and numbers
Date: Fri, 11 Aug 2006 10:07:19 +0200 (CEST)

> For example, I could add a new `.cflags' value to ignore the
> surrounding hyphenation codes.  On the other hand, until now there
> has never been a complaint...

Here is a patch.  As soon as I have CVS access again I'll add it to
the repository.


    Werner


======================================================================


diff -ru -x CVS groff.old/doc/groff.texinfo groff/doc/groff.texinfo
--- groff.old/doc/groff.texinfo 2006-07-22 06:51:50.000000000 +0200
+++ groff/doc/groff.texinfo     2006-08-11 10:05:30.000000000 +0200
@@ -472,7 +472,7 @@
 @title groff
 @subtitle The GNU implementation of @code{troff}
 @subtitle Edition 1.19.3
address@hidden Spring 2006
address@hidden Summer 2006
 @author by Trent address@hidden
 @author and Werner Lemberg (@email{bug-groff@@gnu.org})
 
@@ -2176,7 +2176,7 @@
 
 @item address@hidden
 Set hyphenation flags.  Possible values are address@hidden hyphenate without
-restrictions, address@hidden to not hyphenate the last word on a page,
+restrictions, address@hidden not hyphenate the last word on a page,
 address@hidden not hyphenate the last two characters of a word, and
 address@hidden not hyphenate the first two characters of a word.  These
 values are additive; the default address@hidden
@@ -9362,14 +9362,19 @@
 @item 2
 @cindex hyphenating characters
 @cindex characters, hyphenation
-Lines can be broken before the character (initially no characters have
-this property).
+Lines can be broken before the character (initially no characters have this
+property).  This only works if both the characters before and after have
+non-zero hyphenation codes (as set with the @code{hcode} request).  Use
address@hidden to override this behaviour.
 
 @item 4
 @cindex @code{hy} glyph, and @code{cflags}
 @cindex @code{em} glyph, and @code{cflags}
-Lines can be broken after the character (initially the character
address@hidden and the symbols @samp{\[hy]} and @samp{\[em]} have this 
property).
+Lines can be broken after the character (initially the character @samp{-}
+and the symbols @samp{\[hy]} and @samp{\[em]} have this property).  This
+only works if both the characters before and after have non-zero hyphenation
+codes (as set with the @code{hcode} request).  Use address@hidden to override
+this behaviour.
 
 @item 8
 @cindex overlapping characters
@@ -9405,6 +9410,22 @@
 this is the same as having a zero space factor in @TeX{} (initially
 characters @samp{"')]*} and the symbols @samp{\[dg]} and @samp{\[rq]} have
 this property).
+
address@hidden 64
+Ignore hyphenation code values of the surrounding characters.  Use this in
+combination with values 2 address@hidden (initially no characters have this
+property).  For example, if you need an automatic break point after the
+hyphen in number ranges like `3000-5000', insert
+
address@hidden
+.cflags 68 -
address@hidden
+
address@hidden
+into your document.  Note, however, that this can lead to bad layout if done
+without thinking; in most situations, a better solution instead of changing
+the @code{cflags} value is to insert @code{\:} right after the hyphen at the
+places which really need a break point.
 @end table
 @endDefreq
 
diff -ru -x CVS groff.old/man/groff_diff.man groff/man/groff_diff.man
--- groff.old/man/groff_diff.man        2006-07-12 21:28:37.000000000 +0200
+++ groff/man/groff_diff.man    2006-08-11 08:50:20.000000000 +0200
@@ -3,7 +3,7 @@
 .ig
 groff_diff.man
 
-Last update : 11 Jul 2006
+Last update : 11 Aug 2006
 
 This file is part of groff, the GNU roff type-setting system.
 It is the source of the man-page groff_diff(7).
@@ -1046,6 +1046,7 @@
 this property); a line is not broken at a character with this
 property unless the characters on each side both have non-zero
 hyphenation codes.
+This can be overridden with value 64.
 .
 .IP 4
 Lines can be broken after the character (initially characters
@@ -1053,6 +1054,7 @@
 have this property); a line is not broken at a character with
 this property unless the characters on each side both have non-zero
 hyphenation codes.
+This can be overridden with value 64.
 .
 .IP 8
 The character overlaps horizontally (initially characters
@@ -1072,6 +1074,11 @@
 having a zero space factor in \*[tx] (initially characters
 .B \[dq]')]*\[rs](dg\[rs](rq
 have this property).
+.
+.IP 64
+Ignore hyphenation code values of the surrounding characters.
+Use this in combination with values 2 and\~4 (initially no characters have
+this property).
 .RE
 .
 .TP
diff -ru -x CVS groff.old/NEWS groff/NEWS
--- groff.old/NEWS      2006-07-22 06:50:48.000000000 +0200
+++ groff/NEWS  2006-08-11 09:18:05.000000000 +0200
@@ -47,6 +47,11 @@
   The new number register `.zoom' holds the zoom value of the current font,
   in multiples of 1/1000th.
 
+o The `cflags' request has been extended with a new flag value 64, to be
+  used in combination with values 2 (break before character) and 4 (break
+  after character).  If set, the hyphenation codes of the surrounding
+  characters are ignored.
+
 Pic
 ---
 
diff -ru -x CVS groff.old/src/roff/troff/charinfo.h 
groff/src/roff/troff/charinfo.h
--- groff.old/src/roff/troff/charinfo.h 2006-02-23 21:08:14.000000000 +0100
+++ groff/src/roff/troff/charinfo.h     2006-08-11 08:17:50.000000000 +0200
@@ -44,7 +44,8 @@
     BREAK_AFTER = 4,
     OVERLAPS_HORIZONTALLY = 8,
     OVERLAPS_VERTICALLY = 16,
-    TRANSPARENT = 32
+    TRANSPARENT = 32,
+    IGNORE_HCODES = 64
   };
   enum {
     TRANSLATE_NONE,
@@ -54,7 +55,7 @@
     TRANSLATE_HYPHEN_INDICATOR
   };
   symbol nm;
-  charinfo(symbol s);
+  charinfo(symbol);
   glyph *as_glyph();
   int ends_sentence();
   int overlaps_vertically();
@@ -62,6 +63,7 @@
   int can_break_before();
   int can_break_after();
   int transparent();
+  int ignore_hcodes();
   unsigned char get_hyphenation_code();
   unsigned char get_ascii_code();
   unsigned char get_asciify_code();
@@ -122,6 +124,11 @@
   return flags & TRANSPARENT;
 }
 
+inline int charinfo::ignore_hcodes()
+{
+  return flags & IGNORE_HCODES;
+}
+
 inline int charinfo::numbered()
 {
   return number >= 0;
diff -ru -x CVS groff.old/src/roff/troff/node.cpp groff/src/roff/troff/node.cpp
--- groff.old/src/roff/troff/node.cpp   2006-07-10 15:44:40.000000000 +0200
+++ groff/src/roff/troff/node.cpp       2006-08-11 08:23:08.000000000 +0200
@@ -2839,15 +2839,19 @@
 node *break_char_node::add_self(node *n, hyphen_list **p)
 {
   assert((*p)->hyphenation_code == 0);
-  if ((*p)->breakable && (break_code & 1)) {
-    n = new space_node(H0, col, n);
-    n->freeze_space();
+  if (break_code & 1) {
+    if ((*p)->breakable || break_code & 4) {
+      n = new space_node(H0, col, n);
+      n->freeze_space();
+    }
   }
   next = n;
   n = this;
-  if ((*p)->breakable && (break_code & 2)) {
-    n = new space_node(H0, col, n);
-    n->freeze_space();
+  if (break_code & 2) {
+    if ((*p)->breakable || break_code & 4) {
+      n = new space_node(H0, col, n);
+      n->freeze_space();
+    }
   }
   hyphen_list *pp = *p;
   *p = (*p)->next;
@@ -5073,6 +5077,8 @@
     break_code = 1;
   if (ci->can_break_after())
     break_code |= 2;
+  if (ci->ignore_hcodes())
+    break_code |= 4;
   if (break_code) {
     node *next1 = res->next;
     res->next = 0;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]