third_party/cairo/src/cairo-pdf-operators.c
static cairo_status_t
_cairo_pdf_operators_emit_glyph_string_with_positioning (
    cairo_pdf_operators_t   *pdf_operators,
    cairo_output_stream_t   *stream)
{
    int i;

    _cairo_output_stream_printf (stream, "[%s", pdf_operators->is_latin ? "(" : "<");
    for (i = 0; i < pdf_operators->num_glyphs; i++) {
	if (pdf_operators->glyphs[i].x_position != pdf_operators->cur_x)
	{
	    double delta = pdf_operators->glyphs[i].x_position - pdf_operators->cur_x;
	    int rounded_delta;

	    delta = -1000.0*delta;
	    /* As the delta is in 1/1000 of a unit of text space,
	     * rounding to an integer should still provide sufficient
	     * precision. We round the delta before adding to Tm_x so
	     * that we keep track of the accumulated rounding error in
	     * the PDF interpreter and compensate for it when
	     * calculating subsequent deltas.
	     */
	    rounded_delta = _cairo_lround (delta);
	    if (abs(rounded_delta) < 3)
		rounded_delta = 0;
	    if (rounded_delta != 0) {
		if (pdf_operators->is_latin) {
		    _cairo_output_stream_printf (stream,
						 ")%d(",
						 rounded_delta);
		} else {
		    _cairo_output_stream_printf (stream,
						 ">%d<",
						 rounded_delta);
		}
	    }

	    /* Convert the rounded delta back to text
	     * space before adding to the current text
	     * position. */
	    delta = rounded_delta/-1000.0;
	    pdf_operators->cur_x += delta;
	}

	_cairo_pdf_operators_emit_glyph_index (pdf_operators,
					       stream,
					       pdf_operators->glyphs[i].glyph_index);
	pdf_operators->cur_x += pdf_operators->glyphs[i].x_advance;
    }
    _cairo_output_stream_printf (stream, "%s]TJ\n", pdf_operators->is_latin ? ")" : ">");

    return _cairo_output_stream_get_status (stream);
}
/* Emit the string of glyphs using the 'TJ' operator.
 *
 * The TJ operator takes an array of strings of glyphs. Each string of
 * glyphs is displayed using the glyph advances of each glyph to
 * position the glyphs. A relative adjustment to the glyph advance may
 * be specified by including the adjustment between two strings. The
 * adjustment is in units of text space * -1000.
 */
Emit the string of glyphs using the 'TJ' operator.
The TJ operator takes an array of strings of glyphs. Each string of
glyphs is displayed using the glyph advances of each glyph to
position the glyphs. A relative adjustment to the glyph advance may
be specified by including the adjustment between two strings. The
adjustment is in units of text space * -1000.
Emit the string of glyphs using the ' TJ ' operator . The TJ operator takes an array of strings of glyphs . Each string of glyphs is displayed using the glyph advances of each glyph to position the glyphs . A relative adjustment to the glyph advance may be specified by including the adjustment between two strings . The adjustment is in units of text space * - 1000 .
static cairo_status_t
_cairo_pdf_operators_emit_glyph_string_with_positioning (
    cairo_pdf_operators_t   *pdf_operators,
    cairo_output_stream_t   *stream)
{
    int i;
    _cairo_output_stream_printf (stream, "[%s", pdf_operators->is_latin ? "(" : "<");
    for (i = 0; i < pdf_operators->num_glyphs; i++) {
	if (pdf_operators->glyphs[i].x_position != pdf_operators->cur_x)
	{
	    double delta = pdf_operators->glyphs[i].x_position - pdf_operators->cur_x;
	    int rounded_delta;
	    delta = -1000.0*delta;
	    rounded_delta = _cairo_lround (delta);
	    if (abs(rounded_delta) < 3)
		rounded_delta = 0;
	    if (rounded_delta != 0) {
		if (pdf_operators->is_latin) {
		    _cairo_output_stream_printf (stream,
						 ")%d(",
						 rounded_delta);
		} else {
		    _cairo_output_stream_printf (stream,
						 ">%d<",
						 rounded_delta);
		}
	    }
	    delta = rounded_delta/-1000.0;
	    pdf_operators->cur_x += delta;
	}
	_cairo_pdf_operators_emit_glyph_index (pdf_operators,
					       stream,
					       pdf_operators->glyphs[i].glyph_index);
	pdf_operators->cur_x += pdf_operators->glyphs[i].x_advance;
    }
    _cairo_output_stream_printf (stream, "%s]TJ\n", pdf_operators->is_latin ? ")" : ">");
    return _cairo_output_stream_get_status (stream);
}
static cairo_status_t _cairo_pdf_operators_emit_glyph_string_with_positioning ( cairo_pdf_operators_t * pdf_operators , cairo_output_stream_t * stream ) { int i ; _cairo_output_stream_printf ( stream , " " , pdf_operators -> is_latin ? " " : " " ) ; for ( i = 0 ; i < pdf_operators -> num_glyphs ; i ++ ) { if ( pdf_operators -> glyphs [ i ] . x_position != pdf_operators -> cur_x ) { double delta = pdf_operators -> glyphs [ i ] . x_position - pdf_operators -> cur_x ; int rounded_delta ; delta = -1000.0 * delta ; rounded_delta = _cairo_lround ( delta ) ; if ( abs ( rounded_delta ) < 3 ) rounded_delta = 0 ; if ( rounded_delta != 0 ) { if ( pdf_operators -> is_latin ) { _cairo_output_stream_printf ( stream , " " , rounded_delta ) ; } else { _cairo_output_stream_printf ( stream , " " , rounded_delta ) ; } } delta = rounded_delta / -1000.0 ; pdf_operators -> cur_x += delta ; } _cairo_pdf_operators_emit_glyph_index ( pdf_operators , stream , pdf_operators -> glyphs [ i ] . glyph_index ) ; pdf_operators -> cur_x += pdf_operators -> glyphs [ i ] . x_advance ; } _cairo_output_stream_printf ( stream , " \n " , pdf_operators -> is_latin ? " " : " " ) ; return _cairo_output_stream_get_status ( stream ) ; }
Emit the string of glyphs using the 'TJ' operator.
Emit the string of glyphs using the ' TJ ' operator .
/* As the delta is in 1/1000 of a unit of text space,
	     * rounding to an integer should still provide sufficient
	     * precision. We round the delta before adding to Tm_x so
	     * that we keep track of the accumulated rounding error in
	     * the PDF interpreter and compensate for it when
	     * calculating subsequent deltas.
	     */ /* Convert the rounded delta back to text
	     * space before adding to the current text
	     * position. */