[helper-cairo] Remove a method

This commit is contained in:
Behdad Esfahbod 2022-12-29 18:11:41 -07:00
parent f2a6643fc1
commit 74d29cd168
2 changed files with 31 additions and 36 deletions

View File

@ -573,50 +573,46 @@ helper_cairo_destroy_context (cairo_t *cr)
struct helper_cairo_line_t {
cairo_glyph_t *glyphs;
unsigned int num_glyphs;
char *utf8;
unsigned int utf8_len;
cairo_text_cluster_t *clusters;
unsigned int num_clusters;
cairo_text_cluster_flags_t cluster_flags;
cairo_glyph_t *glyphs = nullptr;
unsigned int num_glyphs = 0;
char *utf8 = nullptr;
unsigned int utf8_len = 0;
cairo_text_cluster_t *clusters = nullptr;
unsigned int num_clusters = 0;
cairo_text_cluster_flags_t cluster_flags = (cairo_text_cluster_flags_t) 0;
void finish () {
helper_cairo_line_t (const char *utf8_,
unsigned utf8_len_,
hb_buffer_t *buffer,
hb_bool_t utf8_clusters,
int scale_bits) :
utf8 (utf8_ ? g_strndup (utf8_, utf8_len_) : nullptr),
utf8_len (utf8_len_)
{
hb_cairo_glyphs_from_buffer (buffer,
utf8_clusters,
1 << -scale_bits, 1 << -scale_bits,
0., 0.,
utf8, utf8_len,
&glyphs, &num_glyphs,
&clusters, &num_clusters,
&cluster_flags);
}
void finish ()
{
if (glyphs)
cairo_glyph_free (glyphs);
if (clusters)
cairo_text_cluster_free (clusters);
if (utf8)
g_free (utf8);
}
void get_advance (double *x_advance, double *y_advance) {
void get_advance (double *x_advance, double *y_advance)
{
*x_advance = glyphs[num_glyphs].x;
*y_advance = glyphs[num_glyphs].y;
}
};
static inline void
helper_cairo_line_from_buffer (helper_cairo_line_t *l,
hb_buffer_t *buffer,
const char *text,
unsigned int text_len,
int scale_bits,
hb_bool_t utf8_clusters)
{
memset (l, 0, sizeof (*l));
l->utf8 = text ? g_strndup (text, text_len) : nullptr;
l->utf8_len = text ? text_len : 0;
hb_cairo_glyphs_from_buffer (buffer,
utf8_clusters,
1 << -scale_bits, 1 << -scale_bits,
0., 0.,
l->utf8, l->utf8_len,
&l->glyphs, &l->num_glyphs,
&l->clusters, &l->num_clusters,
&l->cluster_flags);
}
#endif

View File

@ -63,8 +63,7 @@ struct view_cairo_t : view_options_t, output_options_t<>
hb_bool_t utf8_clusters)
{
direction = hb_buffer_get_direction (buffer);
helper_cairo_line_t l;
helper_cairo_line_from_buffer (&l, buffer, text, text_len, scale_bits, utf8_clusters);
helper_cairo_line_t l (text, text_len, buffer, utf8_clusters, scale_bits);
g_array_append_val (lines, l);
}
void finish (hb_buffer_t *buffer, const font_options_t *font_opts)