00001
00005 #ifndef TOSPACE_H
00006 #define TOSPACE_H
00007
00008 #include "blobbox.h"
00009 #include "gap_map.h"
00010 #include "statistc.h"
00011 #include "notdll.h"
00012
00243 extern BOOL_VAR_H (tosp_old_to_method, FALSE, "Space stats use prechopping?");
00244 extern BOOL_VAR_H (tosp_only_use_prop_rows, TRUE,
00245 "Block stats to use fixed pitch rows?");
00246 extern BOOL_VAR_H (tosp_use_pre_chopping, FALSE,
00247 "Space stats use prechopping?");
00248 extern BOOL_VAR_H (tosp_old_to_bug_fix, FALSE,
00249 "Fix suspected bug in old code");
00250 extern BOOL_VAR_H (tosp_block_use_cert_spaces, TRUE,
00251 "Only stat OBVIOUS spaces");
00252 extern BOOL_VAR_H (tosp_row_use_cert_spaces, TRUE,
00253 "Only stat OBVIOUS spaces");
00254 extern BOOL_VAR_H (tosp_narrow_blobs_not_cert, TRUE,
00255 "Only stat OBVIOUS spaces");
00256 extern BOOL_VAR_H (tosp_row_use_cert_spaces1, TRUE,
00257 "Only stat OBVIOUS spaces");
00258 extern BOOL_VAR_H (tosp_recovery_isolated_row_stats, TRUE,
00259 "Use row alone when inadequate cert spaces");
00260 extern BOOL_VAR_H (tosp_only_small_gaps_for_kern, FALSE, "Better guess");
00261 extern BOOL_VAR_H (tosp_all_flips_fuzzy, FALSE, "Pass ANY flip to context?");
00262 extern BOOL_VAR_H (tosp_fuzzy_limit_all, TRUE,
00263 "Dont restrict kn->sp fuzzy limit to tables");
00264 extern BOOL_VAR_H (tosp_stats_use_xht_gaps, TRUE,
00265 "Use within xht gap for wd breaks");
00266 extern BOOL_VAR_H (tosp_use_xht_gaps, TRUE,
00267 "Use within xht gap for wd breaks");
00268 extern BOOL_VAR_H (tosp_only_use_xht_gaps, FALSE,
00269 "Only use within xht gap for wd breaks");
00270 extern BOOL_VAR_H (tosp_rule_9_test_punct, FALSE,
00271 "Dont chng kn to space next to punct");
00272 extern BOOL_VAR_H (tosp_flip_fuzz_kn_to_sp, TRUE, "Default flip");
00273 extern BOOL_VAR_H (tosp_flip_fuzz_sp_to_kn, TRUE, "Default flip");
00274 extern BOOL_VAR_H (tosp_improve_thresh, FALSE,
00275 "Enable improvement heuristic");
00276 extern INT_VAR_H (tosp_debug_level, 0, "Debug data");
00277 extern INT_VAR_H (tosp_enough_space_samples_for_median, 3,
00278 "or should we use mean");
00279 extern INT_VAR_H (tosp_redo_kern_limit, 10,
00280 "No.samples reqd to reestimate for row");
00281 extern INT_VAR_H (tosp_few_samples, 40,
00282 "No.gaps reqd with 1 large gap to treat as a table");
00283 extern INT_VAR_H (tosp_short_row, 20,
00284 "No.gaps reqd with few cert spaces to use certs");
00285 extern INT_VAR_H (tosp_sanity_method, 1, "How to avoid being silly");
00286 extern double_VAR_H (tosp_threshold_bias1, 0,
00287 "how far between kern and space?");
00288 extern double_VAR_H (tosp_threshold_bias2, 0,
00289 "how far between kern and space?");
00290 extern double_VAR_H (tosp_narrow_fraction, 0.3,
00291 "Fract of xheight for narrow");
00292 extern double_VAR_H (tosp_narrow_aspect_ratio, 0.48,
00293 "narrow if w/h less than this");
00294 extern double_VAR_H (tosp_wide_fraction, 0.52, "Fract of xheight for wide");
00295 extern double_VAR_H (tosp_wide_aspect_ratio, 0.0,
00296 "wide if w/h less than this");
00297 extern double_VAR_H (tosp_fuzzy_space_factor, 0.6,
00298 "Fract of xheight for fuzz sp");
00299 extern double_VAR_H (tosp_fuzzy_space_factor1, 0.5,
00300 "Fract of xheight for fuzz sp");
00301 extern double_VAR_H (tosp_fuzzy_space_factor2, 0.72,
00302 "Fract of xheight for fuzz sp");
00303 extern double_VAR_H (tosp_gap_factor, 0.83, "gap ratio to flip sp->kern");
00304 extern double_VAR_H (tosp_kern_gap_factor1, 2.0,
00305 "gap ratio to flip kern->sp");
00306 extern double_VAR_H (tosp_kern_gap_factor2, 1.3,
00307 "gap ratio to flip kern->sp");
00308 extern double_VAR_H (tosp_kern_gap_factor3, 2.5,
00309 "gap ratio to flip kern->sp");
00310 extern double_VAR_H (tosp_ignore_big_gaps, -1, "xht multiplier");
00311 extern double_VAR_H (tosp_ignore_very_big_gaps, 3.5, "xht multiplier");
00312 extern double_VAR_H (tosp_rep_space, 1.6, "rep gap multiplier for space");
00313 extern double_VAR_H (tosp_enough_small_gaps, 0.65,
00314 "Fract of kerns reqd for isolated row stats");
00315 extern double_VAR_H (tosp_table_kn_sp_ratio, 2.25,
00316 "Min difference of kn & sp in table");
00317 extern double_VAR_H (tosp_table_xht_sp_ratio, 0.33,
00318 "Expect spaces bigger than this");
00319 extern double_VAR_H (tosp_table_fuzzy_kn_sp_ratio, 3.0,
00320 "Fuzzy if less than this");
00321 extern double_VAR_H (tosp_fuzzy_kn_fraction, 0.5, "New fuzzy kn alg");
00322 extern double_VAR_H (tosp_fuzzy_sp_fraction, 0.5, "New fuzzy sp alg");
00323 extern double_VAR_H (tosp_min_sane_kn_sp, 1.5,
00324 "Dont trust spaces less than this time kn");
00325 extern double_VAR_H (tosp_init_guess_kn_mult, 2.2,
00326 "Thresh guess - mult kn by this");
00327 extern double_VAR_H (tosp_init_guess_xht_mult, 0.28,
00328 "Thresh guess - mult xht by this");
00329 extern double_VAR_H (tosp_max_sane_kn_thresh, 5.0,
00330 "Multiplier on kn to limit thresh");
00331 extern double_VAR_H (tosp_flip_caution, 0.0,
00332 "Dont autoflip kn to sp when large separation");
00333 extern double_VAR_H (tosp_large_kerning, 0.19,
00334 "Limit use of xht gap with large kns");
00335 extern double_VAR_H (tosp_dont_fool_with_small_kerns, -1,
00336 "Limit use of xht gap with odd small kns");
00337 extern double_VAR_H (tosp_near_lh_edge, 0,
00338 "Dont reduce box if the top left is non blank");
00339 extern double_VAR_H (tosp_silly_kn_sp_gap, 0.2,
00340 "Dont let sp minus kn get too small");
00341 extern double_VAR_H (tosp_pass_wide_fuzz_sp_to_context, 0.75,
00342 "How wide fuzzies need context");
00345 void to_spacing(
00346 ICOORD page_tr,
00347 TO_BLOCK_LIST *blocks
00348 );
00349
00350 void block_spacing_stats(TO_BLOCK *block,
00351 GAPMAP *gapmap,
00352 BOOL8 &old_text_ord_proportional,
00353 INT16 &block_space_gap_width,
00354 INT16 &block_non_space_gap_width
00355 );
00356
00357 void row_spacing_stats(TO_ROW *row,
00358 GAPMAP *gapmap,
00359 INT16 block_idx,
00360 INT16 row_idx,
00361 INT16 block_space_gap_width,
00362 INT16 block_non_space_gap_width
00363 );
00364
00365 void old_to_method(TO_ROW *row,
00366 STATS *all_gap_stats,
00367 STATS *space_gap_stats,
00368 STATS *small_gap_stats,
00369 INT16 block_space_gap_width,
00370 INT16 block_non_space_gap_width
00371 );
00372 BOOL8 isolated_row_stats(TO_ROW *row,
00373 GAPMAP *gapmap,
00374 STATS *all_gap_stats,
00375 BOOL8 suspected_table,
00376 INT16 block_idx,
00377 INT16 row_idx);
00378 INT16 stats_count_under(STATS *stats, INT16 threshold);
00379 void improve_row_threshold(TO_ROW *row, STATS *all_gap_stats);
00380 ROW *make_prop_words(
00381 TO_ROW *row,
00382 FCOORD rotation
00383 );
00384 BOOL8 make_a_word_break(
00385 TO_ROW *row,
00386 BOX blob_box,
00387 INT16 prev_gap,
00388 BOX prev_blob_box,
00389 INT16 real_current_gap,
00390 INT16 within_xht_current_gap,
00391 BOX next_blob_box,
00392 INT16 next_gap,
00393 UINT8 &blanks,
00394 BOOL8 &fuzzy_sp,
00395 BOOL8 &fuzzy_non);
00396 BOOL8 narrow_blob(TO_ROW *row, BOX blob_box);
00397 BOOL8 wide_blob(TO_ROW *row, BOX blob_box);
00398 BOOL8 suspected_punct_blob(TO_ROW *row, BOX box);
00399
00400 void peek_at_next_gap(TO_ROW *row,
00401 BLOBNBOX_IT box_it,
00402 BOX &next_blob_box,
00403 INT16 &next_gap,
00404 INT16 &next_within_xht_gap);
00405 void mark_gap(
00406 BOX blob,
00407 INT16 rule,
00408 INT16 prev_gap,
00409 INT16 prev_blob_width,
00410 INT16 current_gap,
00411 INT16 next_blob_width,
00412 INT16 next_gap);
00413 float find_mean_blob_spacing(WERD *word);
00414 BOOL8 ignore_big_gap(TO_ROW *row,
00415 INT32 row_length,
00416 GAPMAP *gapmap,
00417 INT16 left,
00418 INT16 right);
00419 BOX reduced_box_next(
00420 TO_ROW *row,
00421 BLOBNBOX_IT *it
00422 );
00423 BOX reduced_box_for_blob(BLOBNBOX *blob, TO_ROW *row, INT16 *left_above_xht);
00424 #endif