~ubuntu-branches/ubuntu/vivid/tesseract/vivid

« back to all changes in this revision

Viewing changes to textord/oldbasel.cpp

  • Committer: Package Import Robot
  • Author(s): Jeff Breidenbach
  • Date: 2014-02-03 11:10:20 UTC
  • mfrom: (1.3.1) (19.1.1 experimental)
  • Revision ID: package-import@ubuntu.com-20140203111020-igquodd7pjlp3uri
Tags: 3.03.01-1
* New upstream release, includes critical fix to PDF rendering
* Complete leptonlib transition (see bug #735509)
* Promote from experimental to unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *
18
18
 **********************************************************************/
19
19
 
20
 
#include "mfcpch.h"
21
20
#include "ccstruct.h"
22
21
#include          "statistc.h"
23
22
#include          "quadlsq.h"
231
230
  float descheight;              /*mean descender drop */
232
231
  float mindescheight;           /*min allowed descheight */
233
232
  int desccount;                 /*no of samples */
234
 
  float xshift;                  /*shift in xheight */
235
233
 
236
234
                                 /*no samples */
237
235
  xcount = fullcount = desccount = 0;
286
284
      if (row->xheight >= lineheight * (1 - MAXHEIGHTVARIANCE)
287
285
      && row->xheight <= lineheight * (1 + MAXHEIGHTVARIANCE)) {
288
286
        row->ascrise = fullheight - lineheight;
289
 
                                 /*shift in x */
290
 
        xshift = lineheight - row->xheight;
291
287
                                 /*set to average */
292
288
        row->xheight = lineheight;
293
289
 
295
291
      else if (row->xheight >= fullheight * (1 - MAXHEIGHTVARIANCE)
296
292
      && row->xheight <= fullheight * (1 + MAXHEIGHTVARIANCE)) {
297
293
        row->ascrise = row->xheight - lineheight;
298
 
        xshift = -row->ascrise;  /*shift in x */
299
294
                                 /*set to average */
300
295
        row->xheight = lineheight;
301
296
        row->all_caps = TRUE;
303
298
      else {
304
299
        row->ascrise = (fullheight - lineheight) * row->xheight
305
300
          / fullheight;
306
 
        xshift = -row->ascrise;  /*shift in x */
307
301
                                 /*scale it */
308
302
        row->xheight -= row->ascrise;
309
303
        row->all_caps = TRUE;
1389
1383
  int poscount;                  /*count of best up step */
1390
1384
  int negcount;                  /*count of best down step */
1391
1385
  float partsteps[MAXPARTS];     /*average step to part */
1392
 
  float bestpos;                 /*best up step */
1393
1386
  float bestneg;                 /*best down step */
1394
1387
  int runlength;                 /*length of bad run */
1395
1388
  int biggestrun;                /*biggest bad run */
1401
1394
    xcentre = (blobcoords[blobindex].left ()
1402
1395
      + blobcoords[blobindex].right ()) >> 1;
1403
1396
                                 /*in other parts */
1404
 
    if (partids[blobindex] != bestpart) {
 
1397
    int part_id =
 
1398
        static_cast<int>(static_cast<unsigned char>(partids[blobindex]));
 
1399
    if (part_id != bestpart) {
1405
1400
      runlength++;               /*run of non bests */
1406
1401
      if (runlength > biggestrun)
1407
1402
        biggestrun = runlength;
1408
 
      partsteps[partids[blobindex]] += blobcoords[blobindex].bottom ()
1409
 
        - row->baseline.y (xcentre);
 
1403
      partsteps[part_id] += blobcoords[blobindex].bottom()
 
1404
        - row->baseline.y(xcentre);
1410
1405
    }
1411
1406
    else
1412
1407
      runlength = 0;
1416
1411
  else
1417
1412
    row->xheight = 1.0f;         /*success */
1418
1413
  poscount = negcount = 0;
1419
 
  bestpos = bestneg = 0.0;       /*no step yet */
 
1414
  bestneg = 0.0;       /*no step yet */
1420
1415
  for (partition = 0; partition < partcount; partition++) {
1421
1416
    if (partition != bestpart) {
1422
1417
 
1430
1425
 
1431
1426
      if (partsteps[partition] >= MINASCRISE
1432
1427
      && partsizes[partition] > poscount) {
1433
 
                                 /*ascender rise */
1434
 
        bestpos = partsteps[partition];
1435
 
                                 /*2nd most popular */
1436
1428
        poscount = partsizes[partition];
1437
1429
      }
1438
1430
      if (partsteps[partition] <= -MINASCRISE