mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-15 19:38:04 +02:00
Merge branch 'kwon-young/feat/svg_glyph_class' into 'master'
add glyph utf8 string as class attribute in svg export See merge request cairo/cairo!318
This commit is contained in:
commit
787ef51e93
1 changed files with 35 additions and 19 deletions
|
|
@ -3994,12 +3994,14 @@ _cairo_svg_surface_fill_stroke (void *abstract_surface,
|
|||
}
|
||||
|
||||
static cairo_int_status_t
|
||||
_cairo_svg_surface_show_glyphs_impl (cairo_svg_stream_t *output,
|
||||
cairo_svg_surface_t *surface,
|
||||
const cairo_pattern_t *source,
|
||||
cairo_glyph_t *glyphs,
|
||||
int num_glyphs,
|
||||
cairo_scaled_font_t *scaled_font)
|
||||
_cairo_svg_surface_show_text_glyphs_impl (cairo_svg_stream_t *output,
|
||||
cairo_svg_surface_t *surface,
|
||||
const cairo_pattern_t *source,
|
||||
cairo_glyph_t *glyphs,
|
||||
int num_glyphs,
|
||||
const char *utf8,
|
||||
int utf8_len,
|
||||
cairo_scaled_font_t *scaled_font)
|
||||
{
|
||||
cairo_status_t status;
|
||||
cairo_svg_document_t *document = surface->document;
|
||||
|
|
@ -4044,12 +4046,19 @@ _cairo_svg_surface_show_glyphs_impl (cairo_svg_stream_t *output,
|
|||
if (unlikely (status)) {
|
||||
return status;
|
||||
}
|
||||
|
||||
char * utf8_str = _cairo_malloc_ab(utf8_len + 1, sizeof(char));
|
||||
if (unlikely (utf8_str == NULL)) {
|
||||
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
|
||||
}
|
||||
strncpy(utf8_str, utf8, utf8_len);
|
||||
utf8_str[utf8_len] = '\0';
|
||||
_cairo_svg_stream_printf (output,
|
||||
"<use xlink:href=\"#glyph-%d-%d\" x=\"%f\" y=\"%f\"/>\n",
|
||||
"<use xlink:href=\"#glyph-%d-%d\" x=\"%f\" y=\"%f\" class=\"%s\"/>\n",
|
||||
subset_glyph.font_id,
|
||||
subset_glyph.subset_glyph_index,
|
||||
glyphs[i].x, glyphs[i].y);
|
||||
glyphs[i].x, glyphs[i].y,
|
||||
utf8_str);
|
||||
free(utf8_str);
|
||||
}
|
||||
|
||||
_cairo_svg_stream_printf (output, "</g>\n");
|
||||
|
|
@ -4083,13 +4092,18 @@ _cairo_svg_surface_show_glyphs_impl (cairo_svg_stream_t *output,
|
|||
}
|
||||
|
||||
static cairo_int_status_t
|
||||
_cairo_svg_surface_show_glyphs (void *abstract_surface,
|
||||
cairo_operator_t op,
|
||||
const cairo_pattern_t *source,
|
||||
cairo_glyph_t *glyphs,
|
||||
int num_glyphs,
|
||||
cairo_scaled_font_t *scaled_font,
|
||||
const cairo_clip_t *clip)
|
||||
_cairo_svg_surface_show_text_glyphs (void *abstract_surface,
|
||||
cairo_operator_t op,
|
||||
const cairo_pattern_t *source,
|
||||
const char *utf8,
|
||||
int utf8_len,
|
||||
cairo_glyph_t *glyphs,
|
||||
int num_glyphs,
|
||||
const cairo_text_cluster_t *clusters,
|
||||
int num_clusters,
|
||||
cairo_text_cluster_flags_t cluster_flags,
|
||||
cairo_scaled_font_t *scaled_font,
|
||||
const cairo_clip_t *clip)
|
||||
{
|
||||
cairo_svg_surface_t *surface = abstract_surface;
|
||||
cairo_int_status_t status;
|
||||
|
|
@ -4100,10 +4114,12 @@ _cairo_svg_surface_show_glyphs (void *abstract_surface,
|
|||
: CAIRO_INT_STATUS_UNSUPPORTED;
|
||||
}
|
||||
|
||||
_CAIRO_SVG_SURFACE_CALL_OPERATOR_IMPL (_cairo_svg_surface_show_glyphs_impl,
|
||||
_CAIRO_SVG_SURFACE_CALL_OPERATOR_IMPL (_cairo_svg_surface_show_text_glyphs_impl,
|
||||
source,
|
||||
glyphs,
|
||||
num_glyphs,
|
||||
utf8,
|
||||
utf8_len,
|
||||
scaled_font)
|
||||
}
|
||||
|
||||
|
|
@ -4156,9 +4172,9 @@ static const cairo_surface_backend_t cairo_svg_surface_backend = {
|
|||
_cairo_svg_surface_stroke,
|
||||
_cairo_svg_surface_fill,
|
||||
_cairo_svg_surface_fill_stroke,
|
||||
_cairo_svg_surface_show_glyphs,
|
||||
NULL, /* show_glyphs */
|
||||
NULL, /* has_show_text_glyphs */
|
||||
NULL, /* show_text_glyphs */
|
||||
_cairo_svg_surface_show_text_glyphs,
|
||||
_cairo_svg_surface_get_supported_mime_types,
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue