2007-03-08 04:03:40 +08:00
|
|
|
/**********************************************************************
|
|
|
|
* File: ocrrow.h (Formerly row.h)
|
|
|
|
* Description: Code for the ROW class.
|
2012-02-02 11:06:39 +08:00
|
|
|
* Author: Ray Smith
|
|
|
|
* Created: Tue Oct 08 15:58:04 BST 1991
|
2007-03-08 04:03:40 +08:00
|
|
|
*
|
|
|
|
* (C) Copyright 1991, Hewlett-Packard Ltd.
|
|
|
|
** Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
** you may not use this file except in compliance with the License.
|
|
|
|
** You may obtain a copy of the License at
|
|
|
|
** http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
** Unless required by applicable law or agreed to in writing, software
|
|
|
|
** distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
** See the License for the specific language governing permissions and
|
|
|
|
** limitations under the License.
|
|
|
|
*
|
|
|
|
**********************************************************************/
|
|
|
|
|
|
|
|
#ifndef OCRROW_H
|
|
|
|
#define OCRROW_H
|
|
|
|
|
2012-02-02 11:06:39 +08:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "quspline.h"
|
|
|
|
#include "werd.h"
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
class TO_ROW;
|
|
|
|
|
2012-02-02 11:06:39 +08:00
|
|
|
class PARA;
|
|
|
|
|
2007-03-08 04:03:40 +08:00
|
|
|
class ROW:public ELIST_LINK
|
|
|
|
{
|
2010-11-24 02:34:14 +08:00
|
|
|
friend void tweak_row_baseline(ROW *, double, double);
|
2007-03-08 04:03:40 +08:00
|
|
|
public:
|
2008-04-22 08:41:37 +08:00
|
|
|
ROW() {
|
2007-03-08 04:03:40 +08:00
|
|
|
} //empty constructor
|
|
|
|
ROW( //constructor
|
2008-04-22 08:41:37 +08:00
|
|
|
inT32 spline_size, //no of segments
|
|
|
|
inT32 *xstarts, //segment boundaries
|
2007-03-08 04:03:40 +08:00
|
|
|
double *coeffs, //coefficients //ascender size
|
|
|
|
float x_height,
|
|
|
|
float ascenders,
|
|
|
|
float descenders, //descender size
|
2008-04-22 08:41:37 +08:00
|
|
|
inT16 kern, //char gap
|
|
|
|
inT16 space); //word gap
|
2007-03-08 04:03:40 +08:00
|
|
|
ROW( //constructor
|
|
|
|
TO_ROW *row, //textord row
|
2008-04-22 08:41:37 +08:00
|
|
|
inT16 kern, //char gap
|
|
|
|
inT16 space); //word gap
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
WERD_LIST *word_list() { //get words
|
|
|
|
return &words;
|
|
|
|
}
|
|
|
|
|
|
|
|
float base_line( //compute baseline
|
|
|
|
float xpos) const { //at the position
|
|
|
|
//get spline value
|
|
|
|
return (float) baseline.y (xpos);
|
|
|
|
}
|
|
|
|
float x_height() const { //return x height
|
|
|
|
return xheight;
|
|
|
|
}
|
2009-07-11 10:14:57 +08:00
|
|
|
void set_x_height(float new_xheight) { // set x height
|
|
|
|
xheight = new_xheight;
|
|
|
|
}
|
2008-04-22 08:41:37 +08:00
|
|
|
inT32 kern() const { //return kerning
|
2007-03-08 04:03:40 +08:00
|
|
|
return kerning;
|
|
|
|
}
|
2012-02-02 11:06:39 +08:00
|
|
|
float body_size() const { //return body size
|
|
|
|
return bodysize;
|
|
|
|
}
|
|
|
|
void set_body_size(float new_size) { // set body size
|
|
|
|
bodysize = new_size;
|
|
|
|
}
|
2008-04-22 08:41:37 +08:00
|
|
|
inT32 space() const { //return spacing
|
2007-03-08 04:03:40 +08:00
|
|
|
return spacing;
|
|
|
|
}
|
|
|
|
float ascenders() const { //return size
|
|
|
|
return ascrise;
|
|
|
|
}
|
|
|
|
float descenders() const { //return size
|
|
|
|
return descdrop;
|
|
|
|
}
|
2008-04-22 08:41:37 +08:00
|
|
|
TBOX bounding_box() const { //return bounding box
|
2007-03-08 04:03:40 +08:00
|
|
|
return bound_box;
|
|
|
|
}
|
|
|
|
|
2012-02-02 11:06:39 +08:00
|
|
|
void set_lmargin(inT16 lmargin) {
|
|
|
|
lmargin_ = lmargin;
|
|
|
|
}
|
|
|
|
void set_rmargin(inT16 rmargin) {
|
|
|
|
rmargin_ = rmargin;
|
|
|
|
}
|
|
|
|
inT16 lmargin() const {
|
|
|
|
return lmargin_;
|
|
|
|
}
|
|
|
|
inT16 rmargin() const {
|
|
|
|
return rmargin_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_has_drop_cap(bool has) {
|
|
|
|
has_drop_cap_ = has;
|
|
|
|
}
|
|
|
|
bool has_drop_cap() const {
|
|
|
|
return has_drop_cap_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_para(PARA *p) {
|
|
|
|
para_ = p;
|
|
|
|
}
|
|
|
|
PARA *para() const {
|
|
|
|
return para_;
|
|
|
|
}
|
|
|
|
|
2007-03-08 04:03:40 +08:00
|
|
|
void recalc_bounding_box(); //recalculate BB
|
|
|
|
|
|
|
|
void move( // reposition row
|
|
|
|
const ICOORD vec); // by vector
|
|
|
|
|
|
|
|
void print( //print
|
|
|
|
FILE *fp); //file to print on
|
|
|
|
|
|
|
|
void plot( //draw one
|
2008-02-01 08:36:18 +08:00
|
|
|
ScrollView* window, //window to draw in
|
|
|
|
ScrollView::Color colour); //uniform colour
|
2007-03-08 04:03:40 +08:00
|
|
|
void plot( //draw one
|
2008-02-01 08:36:18 +08:00
|
|
|
ScrollView* window); //in rainbow colours
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
#ifndef GRAPHICS_DISABLED
|
|
|
|
void plot_baseline( //draw the baseline
|
2008-02-01 08:36:18 +08:00
|
|
|
ScrollView* window, //window to draw in
|
|
|
|
ScrollView::Color colour) { //colour to draw
|
2007-03-08 04:03:40 +08:00
|
|
|
//draw it
|
|
|
|
baseline.plot (window, colour);
|
|
|
|
}
|
|
|
|
#endif
|
2010-11-30 08:56:39 +08:00
|
|
|
ROW& operator= (const ROW & source);
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
private:
|
2008-04-22 08:41:37 +08:00
|
|
|
inT32 kerning; //inter char gap
|
|
|
|
inT32 spacing; //inter word gap
|
2012-02-02 11:06:39 +08:00
|
|
|
TBOX bound_box; //bounding box
|
2007-03-08 04:03:40 +08:00
|
|
|
float xheight; //height of line
|
|
|
|
float ascrise; //size of ascenders
|
|
|
|
float descdrop; //-size of descenders
|
2012-02-02 11:06:39 +08:00
|
|
|
float bodysize; //CJK character size. (equals to
|
|
|
|
//xheight+ascrise by default)
|
2007-03-08 04:03:40 +08:00
|
|
|
WERD_LIST words; //words
|
|
|
|
QSPLINE baseline; //baseline spline
|
2012-02-02 11:06:39 +08:00
|
|
|
|
|
|
|
// These get set after blocks have been determined.
|
|
|
|
bool has_drop_cap_;
|
|
|
|
inT16 lmargin_; // Distance to left polyblock margin.
|
|
|
|
inT16 rmargin_; // Distance to right polyblock margin.
|
|
|
|
|
|
|
|
// This gets set during paragraph analysis.
|
|
|
|
PARA *para_; // Paragraph of which this row is part.
|
2007-03-08 04:03:40 +08:00
|
|
|
};
|
|
|
|
|
2010-11-30 08:56:39 +08:00
|
|
|
ELISTIZEH (ROW)
|
2007-03-08 04:03:40 +08:00
|
|
|
#endif
|