src/api/pdfrenderer.cpp
static void ClipBaseline(int ppi, int x1, int y1, int x2, int y2, int *line_x1, int *line_y1,
                         int *line_x2, int *line_y2) {
  *line_x1 = x1;
  *line_y1 = y1;
  *line_x2 = x2;
  *line_y2 = y2;
  int rise = abs(y2 - y1) * 72;
  int run = abs(x2 - x1) * 72;
  if (rise < 2 * ppi && 2 * ppi < run) {
    *line_y1 = *line_y2 = (y1 + y2) / 2;
  }
}
// There are some really awkward PDF viewers in the wild, such as
// 'Preview' which ships with the Mac. They do a better job with text
// selection and highlighting when given perfectly flat baseline
// instead of very slightly tilted. We clip small tilts to appease
// these viewers. I chose this threshold large enough to absorb noise,
// but small enough that lines probably won't cross each other if the
// whole page is tilted at almost exactly the clipping threshold.
There are some really awkward PDF viewers in the wild, such as
'Preview' which ships with the Mac. They do a better job with text
selection and highlighting when given perfectly flat baseline
instead of very slightly tilted. We clip small tilts to appease
these viewers. I chose this threshold large enough to absorb noise,
but small enough that lines probably won't cross each other if the
whole page is tilted at almost exactly the clipping threshold.
There are some really awkward PDF viewers in the wild such as ' Preview ' which ships with the Mac . They do a better job with text selection and highlighting when given perfectly flat baseline instead of very slightly tilted . We clip small tilts to appease these viewers . I chose this threshold large enough to absorb noise but small enough that lines probably won ' t cross each other if the whole page is tilted at almost exactly the clipping threshold .
static void ClipBaseline(int ppi, int x1, int y1, int x2, int y2, int *line_x1, int *line_y1,
                         int *line_x2, int *line_y2) {
  *line_x1 = x1;
  *line_y1 = y1;
  *line_x2 = x2;
  *line_y2 = y2;
  int rise = abs(y2 - y1) * 72;
  int run = abs(x2 - x1) * 72;
  if (rise < 2 * ppi && 2 * ppi < run) {
    *line_y1 = *line_y2 = (y1 + y2) / 2;
  }
}
static void ClipBaseline ( int ppi , int x1 , int y1 , int x2 , int y2 , int * line_x1 , int * line_y1 , int * line_x2 , int * line_y2 ) { * line_x1 = x1 ; * line_y1 = y1 ; * line_x2 = x2 ; * line_y2 = y2 ; int rise = abs ( y2 - y1 ) * 72 ; int run = abs ( x2 - x1 ) * 72 ; if ( rise < 2 * ppi && 2 * ppi < run ) { * line_y1 = * line_y2 = ( y1 + y2 ) / 2 ; } }
There are some really awkward PDF viewers in the wild, such as
'Preview' which ships with the Mac.
There are some really awkward PDF viewers in the wild such as ' Preview ' which ships with the Mac .