2 * Copyright (c) 2014 - 2017 Steffen (Daode) Nurpmeso <steffen@sdaoden.eu>.
4 * Copyright (C) 1989 - 1992, 2000 - 2002, 2004 - 2006
5 * Free Software Foundation, Inc.
6 * Written by James Clark (jjc@jclark.com)
8 * This is free software; you can redistribute it and/or modify it under
9 * the terms of the GNU General Public License as published by the Free
10 * Software Foundation; either version 2, or (at your option) any later
13 * This is distributed in the hope that it will be useful, but WITHOUT ANY
14 * WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 * You should have received a copy of the GNU General Public License along
19 * with groff; see the file COPYING. If not, write to the Free Software
20 * Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA.
26 #include "troff-config.h"
37 static size_range
*size_table
;
44 font_size(int points
);
46 int to_scaled_points();
48 int operator==(font_size
);
49 int operator!=(font_size
);
51 static void init_size_table(int *sizes
);
54 inline font_size::font_size() : p(0)
58 inline int font_size::operator==(font_size fs
)
63 inline int font_size::operator!=(font_size fs
)
68 inline int font_size::to_scaled_points()
73 inline int font_size::to_points()
80 hunits
env_digit_width(environment
*);
81 hunits
env_space_width(environment
*);
82 hunits
env_sentence_space_width(environment
*);
83 hunits
env_narrow_space_width(environment
*);
84 hunits
env_half_narrow_space_width(environment
*);
85 int env_get_zoom(environment
*);
89 enum tab_type
{ TAB_NONE
, TAB_LEFT
, TAB_CENTER
, TAB_RIGHT
};
98 tab_stops(hunits distance
, tab_type type
);
99 tab_stops(const tab_stops
&);
101 void operator=(const tab_stops
&);
102 tab_type
distance_to_next_tab(hunits pos
, hunits
*distance
);
103 tab_type
distance_to_next_tab(hunits curpos
, hunits
*distance
, hunits
*leftpos
);
105 void add_tab(hunits pos
, tab_type type
, int repeated
);
106 const char *to_string();
109 const unsigned MARGIN_CHARACTER_ON
= 1;
110 const unsigned MARGIN_CHARACTER_NEXT
= 2;
116 class pending_output_line
;
118 // declarations to avoid friend name injection problems
126 void right_justify();
127 void vertical_spacing();
128 void post_vertical_spacing();
132 void temporary_indent();
133 void do_underline(int);
134 void do_input_trap(int);
136 void margin_character();
139 void leader_character();
140 void tab_character();
141 void hyphenate_request();
143 void hyphen_line_max_request();
144 void hyphenation_space_request();
145 void hyphenation_margin_request();
151 void line_tabs_request();
154 void widow_control_request();
155 #endif /* WIDOW_CONTROL */
157 void do_divert(int append
, int boxing
);
161 friend void title_length();
162 friend void space_size();
164 friend void no_fill();
165 friend void adjust();
166 friend void no_adjust();
167 friend void center();
168 friend void right_justify();
169 friend void vertical_spacing();
170 friend void post_vertical_spacing();
171 friend void line_spacing();
172 friend void line_length();
173 friend void indent();
174 friend void temporary_indent();
175 friend void do_underline(int);
176 friend void do_input_trap(int);
177 friend void set_tabs();
178 friend void margin_character();
179 friend void no_number();
180 friend void number_lines();
181 friend void leader_character();
182 friend void tab_character();
183 friend void hyphenate_request();
184 friend void no_hyphenate();
185 friend void hyphen_line_max_request();
186 friend void hyphenation_space_request();
187 friend void hyphenation_margin_request();
188 friend void line_width();
190 friend void tabs_save();
191 friend void tabs_restore();
193 friend void line_tabs_request();
196 friend void widow_control_request();
197 #endif /* WIDOW_CONTROL */
198 friend void do_divert(int append
, int boxing
);
200 int dummy
; // dummy environment used for \w
201 hunits prev_line_length
;
203 hunits prev_title_length
;
208 int prev_requested_size
;
213 font_family
*prev_family
;
215 int space_size
; // in 36ths of an em
216 int sentence_space_size
; // same but for spaces at the end of sentences
220 int prev_line_interrupted
;
222 int right_justify_lines
;
223 vunits prev_vertical_spacing
;
224 vunits vertical_spacing
;
225 vunits prev_post_vertical_spacing
;
226 vunits post_vertical_spacing
;
227 int prev_line_spacing
;
231 hunits temporary_indent
;
232 int have_temporary_indent
;
234 hunits target_text_length
;
235 int pre_underline_fontno
;
237 int underline_spaces
;
239 int input_trap_count
;
240 int continued_input_trap
;
241 node
*line
; // in reverse order
242 hunits prev_text_length
;
245 hunits input_line_start
;
250 tab_type current_tab
;
253 charinfo
*leader_char
;
254 int current_field
; // is there a current field?
255 hunits field_distance
;
256 hunits pre_field_width
;
258 int tab_field_spaces
;
259 int tab_precedes_field
;
261 int spread_flag
; // set by \p
262 unsigned margin_character_flags
;
263 node
*margin_character_node
;
264 hunits margin_character_distance
;
265 node
*numbering_nodes
;
266 hunits line_number_digit_width
;
267 int number_text_separation
; // in digit spaces
268 int line_number_indent
; // in digit spaces
269 int line_number_multiple
;
271 unsigned hyphenation_flags
;
272 int hyphen_line_count
;
274 hunits hyphenation_space
;
275 hunits hyphenation_margin
;
276 int composite
; // used for construction of composite char?
277 pending_output_line
*pending_lines
;
280 #endif /* WIDOW_CONTROL */
282 color
*prev_glyph_color
;
284 color
*prev_fill_color
;
286 tab_type
distance_to_next_tab(hunits
*);
287 tab_type
distance_to_next_tab(hunits
*distance
, hunits
*leftpos
);
289 void output_line(node
*, hunits
, int);
290 void output(node
*nd
, int retain_size
, vunits vs
, vunits post_vs
,
291 hunits width
, int was_centered
);
292 void output_title(node
*nd
, int retain_size
, vunits vs
, vunits post_vs
,
295 void mark_last_line();
296 #endif /* WIDOW_CONTROL */
297 breakpoint
*choose_breakpoint();
298 void hyphenate_line(int start_here
= 0);
300 void wrap_up_field();
302 node
*make_tab_node(hunits d
, node
*next
= 0);
303 node
*get_prev_char();
308 int suppress_next_eol
;
312 unsigned char control_char
;
313 unsigned char no_break_control_char
;
314 charinfo
*hyphen_indicator_char
;
317 environment(const environment
*); // for temporary environment
319 statem
*construct_state(int only_eol
);
321 void copy(const environment
*);
322 int is_dummy() { return dummy
; }
324 int is_composite() { return composite
; }
325 void set_composite() { composite
= 1; }
326 vunits
get_vertical_spacing(); // .v
327 vunits
get_post_vertical_spacing(); // .pvs
328 int get_line_spacing(); // .L
329 vunits
total_post_vertical_spacing();
330 int get_point_size() { return size
.to_scaled_points(); }
331 font_size
get_font_size() { return size
; }
332 int get_size() { return size
.to_units(); }
333 int get_requested_point_size() { return requested_size
; }
334 int get_char_height() { return char_height
; }
335 int get_char_slant() { return char_slant
; }
336 hunits
get_digit_width();
337 int get_font() { return fontno
; }; // .f
338 int get_zoom(); // .zoom
339 font_family
*get_family() { return family
; }
340 int get_bold(); // .b
341 int get_adjust_mode(); // .j
342 int get_fill(); // .u
343 hunits
get_indent(); // .i
344 hunits
get_temporary_indent();
345 hunits
get_line_length(); // .l
346 hunits
get_saved_line_length(); // .ll
347 hunits
get_saved_indent(); // .in
348 hunits
get_title_length();
349 hunits
get_prev_char_width(); // .w
350 hunits
get_prev_char_skew();
351 vunits
get_prev_char_height();
352 vunits
get_prev_char_depth();
353 hunits
get_text_length(); // .k
354 hunits
get_prev_text_length(); // .n
355 hunits
get_space_width() { return env_space_width(this); }
356 int get_space_size() { return space_size
; } // in ems/36
357 int get_sentence_space_size() { return sentence_space_size
; }
358 hunits
get_narrow_space_width() { return env_narrow_space_width(this); }
359 hunits
get_half_narrow_space_width()
360 { return env_half_narrow_space_width(this); }
361 hunits
get_input_line_position();
362 const char *get_tabs();
364 int get_hyphenation_flags();
365 int get_hyphen_line_max();
366 int get_hyphen_line_count();
367 hunits
get_hyphenation_space();
368 hunits
get_hyphenation_margin();
369 int get_center_lines();
370 int get_right_justify_lines();
371 int get_prev_line_interrupted() { return prev_line_interrupted
; }
372 color
*get_fill_color();
373 color
*get_glyph_color();
374 color
*get_prev_glyph_color();
375 color
*get_prev_fill_color();
376 void set_glyph_color(color
*c
);
377 void set_fill_color(color
*c
);
378 node
*make_char_node(charinfo
*);
379 node
*extract_output_line();
380 void width_registers();
383 void set_font(symbol
);
384 void set_family(symbol
);
386 void set_char_height(int);
387 void set_char_slant(int);
388 void set_input_line_position(hunits
); // used by \n(hp
390 void spread() { spread_flag
= 1; }
391 void possibly_break_line(int start_here
= 0, int forced
= 0);
392 void do_break(int spread
= 0); // .br
394 node
*make_tag(const char *name
, int i
);
396 void handle_tab(int is_leader
= 0); // do a tab or leader
397 void add_node(node
*);
398 void add_char(charinfo
*);
399 void add_hyphen_indicator();
400 void add_italic_correction();
402 void space(hunits
, hunits
);
403 void space_newline();
404 const char *get_glyph_color_string();
405 const char *get_fill_color_string();
406 const char *get_font_family_string();
407 const char *get_font_name_string();
408 const char *get_style_name_string();
409 const char *get_name_string();
410 const char *get_point_size_string();
411 const char *get_requested_point_size_string();
412 void output_pending_lines();
413 void construct_format_state(node
*n
, int was_centered
, int fill
);
414 void construct_new_line_state(node
*n
);
415 void dump_troff_state();
418 extern environment
*curenv
;
419 extern void pop_env();
420 extern void push_env(int);
422 void init_environments();
423 void read_hyphen_file(const char *name
);
425 extern double spread_limit
;
427 extern int break_flag
;
428 extern symbol default_family
;
429 extern int translate_space_to_dummy
;
431 extern unsigned char hpf_code_table
[];