4 /* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2001, 2002, 2004, 2005
5 Free Software Foundation, Inc.
6 Written by James Clark (jjc@jclark.com)
8 This file is part of groff.
10 groff is free software; you can redistribute it and/or modify it under
11 the terms of the GNU General Public License as published by the Free
12 Software Foundation; either version 2, or (at your option) any later
15 groff is distributed in the hope that it will be useful, but WITHOUT ANY
16 WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 You should have received a copy of the GNU General Public License along
21 with groff; see the file COPYING. If not, write to the Free Software
22 Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
32 static size_range
*size_table
;
37 font_size(int points
);
39 int to_scaled_points();
41 int operator==(font_size
);
42 int operator!=(font_size
);
43 static void init_size_table(int *sizes
);
46 inline font_size::font_size() : p(0)
50 inline int font_size::operator==(font_size fs
)
55 inline int font_size::operator!=(font_size fs
)
60 inline int font_size::to_scaled_points()
65 inline int font_size::to_points()
72 hunits
env_digit_width(environment
*);
73 hunits
env_space_width(environment
*);
74 hunits
env_sentence_space_width(environment
*);
75 hunits
env_narrow_space_width(environment
*);
76 hunits
env_half_narrow_space_width(environment
*);
80 enum tab_type
{ TAB_NONE
, TAB_LEFT
, TAB_CENTER
, TAB_RIGHT
};
87 tab_stops(hunits distance
, tab_type type
);
88 tab_stops(const tab_stops
&);
90 void operator=(const tab_stops
&);
91 tab_type
distance_to_next_tab(hunits pos
, hunits
*distance
);
92 tab_type
distance_to_next_tab(hunits curpos
, hunits
*distance
, hunits
*leftpos
);
94 void add_tab(hunits pos
, tab_type type
, int repeated
);
95 const char *to_string();
98 const unsigned MARGIN_CHARACTER_ON
= 1;
99 const unsigned MARGIN_CHARACTER_NEXT
= 2;
105 class pending_output_line
;
107 // declarations to avoid friend name injection problems
115 void right_justify();
116 void vertical_spacing();
117 void post_vertical_spacing();
121 void temporary_indent();
122 void do_underline(int);
123 void do_input_trap(int);
125 void margin_character();
128 void leader_character();
129 void tab_character();
130 void hyphenate_request();
132 void hyphen_line_max_request();
133 void hyphenation_space_request();
134 void hyphenation_margin_request();
140 void line_tabs_request();
143 void widow_control_request();
144 #endif /* WIDOW_CONTROL */
146 void do_divert(int append
, int boxing
);
149 int dummy
; // dummy environment used for \w
150 hunits prev_line_length
;
152 hunits prev_title_length
;
157 int prev_requested_size
;
162 font_family
*prev_family
;
164 int space_size
; // in 36ths of an em
165 int sentence_space_size
; // same but for spaces at the end of sentences
169 int prev_line_interrupted
;
171 int right_justify_lines
;
172 vunits prev_vertical_spacing
;
173 vunits vertical_spacing
;
174 vunits prev_post_vertical_spacing
;
175 vunits post_vertical_spacing
;
176 int prev_line_spacing
;
180 hunits temporary_indent
;
181 int have_temporary_indent
;
183 hunits target_text_length
;
184 int pre_underline_fontno
;
186 int underline_spaces
;
188 int input_trap_count
;
189 int continued_input_trap
;
190 node
*line
; // in reverse order
191 hunits prev_text_length
;
194 hunits input_line_start
;
199 tab_type current_tab
;
202 charinfo
*leader_char
;
203 int current_field
; // is there a current field?
204 hunits field_distance
;
205 hunits pre_field_width
;
207 int tab_field_spaces
;
208 int tab_precedes_field
;
210 int spread_flag
; // set by \p
211 unsigned margin_character_flags
;
212 node
*margin_character_node
;
213 hunits margin_character_distance
;
214 node
*numbering_nodes
;
215 hunits line_number_digit_width
;
216 int number_text_separation
; // in digit spaces
217 int line_number_indent
; // in digit spaces
218 int line_number_multiple
;
220 unsigned hyphenation_flags
;
221 int hyphen_line_count
;
223 hunits hyphenation_space
;
224 hunits hyphenation_margin
;
225 int composite
; // used for construction of composite char?
226 pending_output_line
*pending_lines
;
229 #endif /* WIDOW_CONTROL */
231 color
*prev_glyph_color
;
233 color
*prev_fill_color
;
235 tab_type
distance_to_next_tab(hunits
*);
236 tab_type
distance_to_next_tab(hunits
*distance
, hunits
*leftpos
);
238 void output_line(node
*, hunits
, int);
239 void output(node
*nd
, int retain_size
, vunits vs
, vunits post_vs
,
240 hunits width
, int was_centered
);
241 void output_title(node
*nd
, int retain_size
, vunits vs
, vunits post_vs
,
244 void mark_last_line();
245 #endif /* WIDOW_CONTROL */
246 breakpoint
*choose_breakpoint();
247 void hyphenate_line(int start_here
= 0);
249 void wrap_up_field();
251 node
*make_tab_node(hunits d
, node
*next
= 0);
252 node
*get_prev_char();
256 int suppress_next_eol
;
260 unsigned char control_char
;
261 unsigned char no_break_control_char
;
262 charinfo
*hyphen_indicator_char
;
265 environment(const environment
*); // for temporary environment
267 statem
*construct_state(int only_eol
);
268 void copy(const environment
*);
269 int is_dummy() { return dummy
; }
271 int is_composite() { return composite
; }
272 void set_composite() { composite
= 1; }
273 vunits
get_vertical_spacing(); // .v
274 vunits
get_post_vertical_spacing(); // .pvs
275 int get_line_spacing(); // .L
276 vunits
total_post_vertical_spacing();
277 int get_point_size() { return size
.to_scaled_points(); }
278 font_size
get_font_size() { return size
; }
279 int get_size() { return size
.to_units(); }
280 int get_requested_point_size() { return requested_size
; }
281 int get_char_height() { return char_height
; }
282 int get_char_slant() { return char_slant
; }
283 hunits
get_digit_width();
284 int get_font() { return fontno
; }; // .f
285 font_family
*get_family() { return family
; }
286 int get_bold(); // .b
287 int get_adjust_mode(); // .j
288 int get_fill(); // .u
289 hunits
get_indent(); // .i
290 hunits
get_temporary_indent();
291 hunits
get_line_length(); // .l
292 hunits
get_saved_line_length(); // .ll
293 hunits
get_saved_indent(); // .in
294 hunits
get_title_length();
295 hunits
get_prev_char_width(); // .w
296 hunits
get_prev_char_skew();
297 vunits
get_prev_char_height();
298 vunits
get_prev_char_depth();
299 hunits
get_text_length(); // .k
300 hunits
get_prev_text_length(); // .n
301 hunits
get_space_width() { return env_space_width(this); }
302 int get_space_size() { return space_size
; } // in ems/36
303 int get_sentence_space_size() { return sentence_space_size
; }
304 hunits
get_narrow_space_width() { return env_narrow_space_width(this); }
305 hunits
get_half_narrow_space_width()
306 { return env_half_narrow_space_width(this); }
307 hunits
get_input_line_position();
308 const char *get_tabs();
310 int get_hyphenation_flags();
311 int get_hyphen_line_max();
312 int get_hyphen_line_count();
313 hunits
get_hyphenation_space();
314 hunits
get_hyphenation_margin();
315 int get_center_lines();
316 int get_right_justify_lines();
317 int get_prev_line_interrupted() { return prev_line_interrupted
; }
318 color
*get_fill_color();
319 color
*get_glyph_color();
320 color
*get_prev_glyph_color();
321 color
*get_prev_fill_color();
322 void set_glyph_color(color
*c
);
323 void set_fill_color(color
*c
);
324 node
*make_char_node(charinfo
*);
325 node
*extract_output_line();
326 void width_registers();
329 void set_font(symbol
);
330 void set_family(symbol
);
332 void set_char_height(int);
333 void set_char_slant(int);
334 void set_input_line_position(hunits
); // used by \n(hp
336 void spread() { spread_flag
= 1; }
337 void possibly_break_line(int start_here
= 0, int forced
= 0);
338 void do_break(int spread
= 0); // .br
340 node
*make_tag(const char *name
, int i
);
342 void handle_tab(int is_leader
= 0); // do a tab or leader
343 void add_node(node
*);
344 void add_char(charinfo
*);
345 void add_hyphen_indicator();
346 void add_italic_correction();
348 void space(hunits
, hunits
);
349 void space_newline();
350 const char *get_glyph_color_string();
351 const char *get_fill_color_string();
352 const char *get_font_family_string();
353 const char *get_font_name_string();
354 const char *get_style_name_string();
355 const char *get_name_string();
356 const char *get_point_size_string();
357 const char *get_requested_point_size_string();
358 void output_pending_lines();
359 void construct_format_state(node
*n
, int was_centered
, int fill
);
360 void construct_new_line_state(node
*n
);
361 void dump_troff_state();
363 friend void title_length();
364 friend void space_size();
366 friend void no_fill();
367 friend void adjust();
368 friend void no_adjust();
369 friend void center();
370 friend void right_justify();
371 friend void vertical_spacing();
372 friend void post_vertical_spacing();
373 friend void line_spacing();
374 friend void line_length();
375 friend void indent();
376 friend void temporary_indent();
377 friend void do_underline(int);
378 friend void do_input_trap(int);
379 friend void set_tabs();
380 friend void margin_character();
381 friend void no_number();
382 friend void number_lines();
383 friend void leader_character();
384 friend void tab_character();
385 friend void hyphenate_request();
386 friend void no_hyphenate();
387 friend void hyphen_line_max_request();
388 friend void hyphenation_space_request();
389 friend void hyphenation_margin_request();
390 friend void line_width();
392 friend void tabs_save();
393 friend void tabs_restore();
395 friend void line_tabs_request();
398 friend void widow_control_request();
399 #endif /* WIDOW_CONTROL */
401 friend void do_divert(int append
, int boxing
);
404 extern environment
*curenv
;
405 extern void pop_env();
406 extern void push_env(int);
408 void init_environments();
409 void read_hyphen_file(const char *name
);
411 extern double spread_limit
;
413 extern int break_flag
;
414 extern symbol default_family
;
415 extern int translate_space_to_dummy
;
417 extern unsigned char hpf_code_table
[];