mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2025-12-26 01:50:10 +01:00
[show_text_glyphs] Replace the bool backward with cairo_text_cluster_flags
Chris rightfully complained that having a boolean function argument is new in cairo_show_text_glyphs, and indeed avoiding them has been one of the API design criteria for cairo. Trying to come up with alternatives, Owen suggested using a flag type which nicely solves the problem AND future-proofs such a complex API. Please welcome _flags_t APIs to cairo.h
This commit is contained in:
parent
a8cd426a4c
commit
1fe7088a11
22 changed files with 152 additions and 141 deletions
|
|
@ -398,6 +398,7 @@ cairo_glyph_t
|
|||
cairo_font_slant_t
|
||||
cairo_font_weight_t
|
||||
cairo_text_cluster_t
|
||||
cairo_text_cluster_flags_t
|
||||
cairo_select_font_face
|
||||
cairo_set_font_size
|
||||
cairo_set_font_matrix
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ size and transformation and a certain set of font options.
|
|||
@num_glyphs:
|
||||
@clusters:
|
||||
@num_clusters:
|
||||
@backward:
|
||||
@cluster_flags:
|
||||
@Returns:
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -79,6 +79,13 @@ Cairo has two sets of text rendering capabilities:
|
|||
@num_bytes:
|
||||
@num_glyphs:
|
||||
|
||||
<!-- ##### ENUM cairo_text_cluster_flags_t ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@CAIRO_TEXT_CLUSTER_FLAG_BACKWARD:
|
||||
|
||||
<!-- ##### FUNCTION cairo_select_font_face ##### -->
|
||||
<para>
|
||||
|
||||
|
|
@ -211,7 +218,7 @@ Cairo has two sets of text rendering capabilities:
|
|||
@num_glyphs:
|
||||
@clusters:
|
||||
@num_clusters:
|
||||
@backward:
|
||||
@cluster_flags:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION cairo_font_extents ##### -->
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ this feature (1.8 and later).
|
|||
@num_glyphs:
|
||||
@clusters:
|
||||
@num_clusters:
|
||||
@backward:
|
||||
@cluster_flags:
|
||||
@Returns:
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -634,7 +634,7 @@ _cairo_analysis_surface_show_text_glyphs (void *abstract_surface,
|
|||
int num_glyphs,
|
||||
const cairo_text_cluster_t *clusters,
|
||||
int num_clusters,
|
||||
cairo_bool_t backward,
|
||||
cairo_text_cluster_flags_t cluster_flags,
|
||||
cairo_scaled_font_t *scaled_font)
|
||||
{
|
||||
cairo_analysis_surface_t *surface = abstract_surface;
|
||||
|
|
@ -648,8 +648,7 @@ _cairo_analysis_surface_show_text_glyphs (void *abstract_surface,
|
|||
source,
|
||||
utf8, utf8_len,
|
||||
glyphs, num_glyphs,
|
||||
clusters, num_clusters,
|
||||
backward,
|
||||
clusters, num_clusters, cluster_flags,
|
||||
scaled_font);
|
||||
if (backend_status == CAIRO_INT_STATUS_UNSUPPORTED && surface->target->backend->show_glyphs) {
|
||||
int remaining_glyphs = num_glyphs;
|
||||
|
|
|
|||
|
|
@ -1461,16 +1461,16 @@ _cairo_gstate_get_font_extents (cairo_gstate_t *gstate,
|
|||
}
|
||||
|
||||
cairo_status_t
|
||||
_cairo_gstate_text_to_glyphs (cairo_gstate_t *gstate,
|
||||
double x,
|
||||
double y,
|
||||
const char *utf8,
|
||||
int utf8_len,
|
||||
cairo_glyph_t **glyphs,
|
||||
int *num_glyphs,
|
||||
cairo_text_cluster_t **clusters,
|
||||
int *num_clusters,
|
||||
cairo_bool_t *backward)
|
||||
_cairo_gstate_text_to_glyphs (cairo_gstate_t *gstate,
|
||||
double x,
|
||||
double y,
|
||||
const char *utf8,
|
||||
int utf8_len,
|
||||
cairo_glyph_t **glyphs,
|
||||
int *num_glyphs,
|
||||
cairo_text_cluster_t **clusters,
|
||||
int *num_clusters,
|
||||
cairo_text_cluster_flags_t *cluster_flags)
|
||||
{
|
||||
cairo_status_t status;
|
||||
|
||||
|
|
@ -1482,7 +1482,7 @@ _cairo_gstate_text_to_glyphs (cairo_gstate_t *gstate,
|
|||
utf8, utf8_len,
|
||||
glyphs, num_glyphs,
|
||||
clusters, num_clusters,
|
||||
backward);
|
||||
cluster_flags);
|
||||
}
|
||||
|
||||
cairo_status_t
|
||||
|
|
@ -1536,7 +1536,7 @@ _cairo_gstate_show_text_glyphs (cairo_gstate_t *gstate,
|
|||
int num_glyphs,
|
||||
const cairo_text_cluster_t *clusters,
|
||||
int num_clusters,
|
||||
cairo_bool_t backward)
|
||||
cairo_text_cluster_flags_t cluster_flags)
|
||||
{
|
||||
cairo_status_t status;
|
||||
cairo_pattern_union_t source_pattern;
|
||||
|
|
@ -1594,7 +1594,7 @@ _cairo_gstate_show_text_glyphs (cairo_gstate_t *gstate,
|
|||
utf8, utf8_len,
|
||||
transformed_glyphs, num_glyphs,
|
||||
clusters, num_clusters,
|
||||
backward,
|
||||
cluster_flags,
|
||||
gstate->scaled_font);
|
||||
} else {
|
||||
cairo_path_fixed_t path;
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ typedef struct _cairo_command_show_text_glyphs {
|
|||
unsigned int num_glyphs;
|
||||
cairo_text_cluster_t *clusters;
|
||||
int num_clusters;
|
||||
cairo_bool_t backward;
|
||||
cairo_text_cluster_flags_t cluster_flags;
|
||||
cairo_scaled_font_t *scaled_font;
|
||||
} cairo_command_show_text_glyphs_t;
|
||||
|
||||
|
|
|
|||
|
|
@ -418,7 +418,7 @@ _cairo_meta_surface_show_text_glyphs (void *abstract_surface,
|
|||
int num_glyphs,
|
||||
const cairo_text_cluster_t *clusters,
|
||||
int num_clusters,
|
||||
cairo_bool_t backward,
|
||||
cairo_text_cluster_flags_t cluster_flags,
|
||||
cairo_scaled_font_t *scaled_font)
|
||||
{
|
||||
cairo_status_t status;
|
||||
|
|
@ -469,7 +469,7 @@ _cairo_meta_surface_show_text_glyphs (void *abstract_surface,
|
|||
memcpy (command->clusters, clusters, sizeof (clusters[0]) * num_clusters);
|
||||
}
|
||||
|
||||
command->backward = backward;
|
||||
command->cluster_flags = cluster_flags;
|
||||
|
||||
command->scaled_font = cairo_scaled_font_reference (scaled_font);
|
||||
|
||||
|
|
@ -926,7 +926,7 @@ _cairo_meta_surface_replay_internal (cairo_surface_t *surface,
|
|||
command->show_text_glyphs.utf8, command->show_text_glyphs.utf8_len,
|
||||
dev_glyphs, num_glyphs,
|
||||
command->show_text_glyphs.clusters, command->show_text_glyphs.num_clusters,
|
||||
command->show_text_glyphs.backward,
|
||||
command->show_text_glyphs.cluster_flags,
|
||||
command->show_text_glyphs.scaled_font);
|
||||
|
||||
free (dev_glyphs);
|
||||
|
|
|
|||
|
|
@ -240,7 +240,7 @@ slim_hidden_def (cairo_text_cluster_free);
|
|||
* @num_glyphs: number of glyphs
|
||||
* @clusters: array of cluster mapping information
|
||||
* @num_clusters: number of clusters in the mapping
|
||||
* @backward: whether the text to glyphs mapping goes backward
|
||||
* @cluster_flags: cluster flags
|
||||
*
|
||||
* Check that clusters cover the entire glyphs and utf8 arrays,
|
||||
* and that cluster boundaries are UTF-8 boundaries.
|
||||
|
|
@ -257,7 +257,7 @@ _cairo_validate_text_clusters (const char *utf8,
|
|||
int num_glyphs,
|
||||
const cairo_text_cluster_t *clusters,
|
||||
int num_clusters,
|
||||
cairo_bool_t backward)
|
||||
cairo_text_cluster_flags_t cluster_flags)
|
||||
{
|
||||
cairo_status_t status;
|
||||
unsigned int n_bytes = 0;
|
||||
|
|
|
|||
|
|
@ -622,7 +622,7 @@ _cairo_paginated_surface_show_text_glyphs (void *abstract_surface,
|
|||
int num_glyphs,
|
||||
const cairo_text_cluster_t *clusters,
|
||||
int num_clusters,
|
||||
cairo_bool_t backward,
|
||||
cairo_text_cluster_flags_t cluster_flags,
|
||||
cairo_scaled_font_t *scaled_font)
|
||||
{
|
||||
cairo_paginated_surface_t *surface = abstract_surface;
|
||||
|
|
@ -649,7 +649,7 @@ _cairo_paginated_surface_show_text_glyphs (void *abstract_surface,
|
|||
utf8, utf8_len,
|
||||
glyphs, num_glyphs,
|
||||
clusters, num_clusters,
|
||||
backward,
|
||||
cluster_flags,
|
||||
scaled_font);
|
||||
CAIRO_MUTEX_LOCK (scaled_font->mutex);
|
||||
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ _cairo_pdf_operators_show_text_glyphs (cairo_pdf_operators_t *pdf_operators,
|
|||
int num_glyphs,
|
||||
const cairo_text_cluster_t *clusters,
|
||||
int num_clusters,
|
||||
cairo_bool_t backward,
|
||||
cairo_text_cluster_flags_t cluster_flags,
|
||||
cairo_scaled_font_t *scaled_font);
|
||||
|
||||
#endif /* CAIRO_PDF_OPERATORS_H */
|
||||
|
|
|
|||
|
|
@ -1251,7 +1251,7 @@ _cairo_pdf_operators_emit_cluster (cairo_pdf_operators_t *pdf_operators,
|
|||
int utf8_len,
|
||||
cairo_glyph_t *glyphs,
|
||||
int num_glyphs,
|
||||
cairo_bool_t backward,
|
||||
cairo_text_cluster_flags_t cluster_flags,
|
||||
cairo_scaled_font_t *scaled_font)
|
||||
{
|
||||
cairo_scaled_font_subsets_glyph_t subset_glyph;
|
||||
|
|
@ -1316,7 +1316,7 @@ _cairo_pdf_operators_emit_cluster (cairo_pdf_operators_t *pdf_operators,
|
|||
if (status)
|
||||
return status;
|
||||
|
||||
if (backward)
|
||||
if ((cluster_flags & CAIRO_TEXT_CLUSTER_FLAG_BACKWARD))
|
||||
cur_glyph--;
|
||||
else
|
||||
cur_glyph++;
|
||||
|
|
@ -1338,7 +1338,7 @@ _cairo_pdf_operators_show_text_glyphs (cairo_pdf_operators_t *pdf_operators,
|
|||
int num_glyphs,
|
||||
const cairo_text_cluster_t *clusters,
|
||||
int num_clusters,
|
||||
cairo_bool_t backward,
|
||||
cairo_text_cluster_flags_t cluster_flags,
|
||||
cairo_scaled_font_t *scaled_font)
|
||||
{
|
||||
cairo_status_t status;
|
||||
|
|
@ -1391,25 +1391,25 @@ _cairo_pdf_operators_show_text_glyphs (cairo_pdf_operators_t *pdf_operators,
|
|||
|
||||
if (num_clusters > 0) {
|
||||
cur_text = utf8;
|
||||
if (backward)
|
||||
if ((cluster_flags & CAIRO_TEXT_CLUSTER_FLAG_BACKWARD))
|
||||
cur_glyph = glyphs + num_glyphs;
|
||||
else
|
||||
cur_glyph = glyphs;
|
||||
for (i = 0; i < num_clusters; i++) {
|
||||
if (backward)
|
||||
if ((cluster_flags & CAIRO_TEXT_CLUSTER_FLAG_BACKWARD))
|
||||
cur_glyph -= clusters[i].num_glyphs;
|
||||
status = _cairo_pdf_operators_emit_cluster (pdf_operators,
|
||||
cur_text,
|
||||
clusters[i].num_bytes,
|
||||
cur_glyph,
|
||||
clusters[i].num_glyphs,
|
||||
backward,
|
||||
cluster_flags,
|
||||
scaled_font);
|
||||
if (status)
|
||||
return status;
|
||||
|
||||
cur_text += clusters[i].num_bytes;
|
||||
if (!backward)
|
||||
if (!(cluster_flags & CAIRO_TEXT_CLUSTER_FLAG_BACKWARD))
|
||||
cur_glyph += clusters[i].num_glyphs;
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ typedef struct _cairo_pdf_smask_group
|
|||
int num_glyphs;
|
||||
cairo_text_cluster_t *clusters;
|
||||
int num_clusters;
|
||||
cairo_bool_t backward;
|
||||
cairo_bool_t cluster_flags;
|
||||
cairo_scaled_font_t *scaled_font;
|
||||
} cairo_pdf_smask_group_t;
|
||||
|
||||
|
|
|
|||
|
|
@ -4037,7 +4037,7 @@ _cairo_pdf_surface_write_smask_group (cairo_pdf_surface_t *surface,
|
|||
group->utf8, group->utf8_len,
|
||||
group->glyphs, group->num_glyphs,
|
||||
group->clusters, group->num_clusters,
|
||||
group->backward,
|
||||
group->cluster_flags,
|
||||
group->scaled_font);
|
||||
break;
|
||||
}
|
||||
|
|
@ -4808,7 +4808,7 @@ _cairo_pdf_surface_show_text_glyphs (void *abstract_surface,
|
|||
int num_glyphs,
|
||||
const cairo_text_cluster_t *clusters,
|
||||
int num_clusters,
|
||||
cairo_bool_t backward,
|
||||
cairo_text_cluster_flags_t cluster_flags,
|
||||
cairo_scaled_font_t *scaled_font)
|
||||
{
|
||||
cairo_pdf_surface_t *surface = abstract_surface;
|
||||
|
|
@ -4910,7 +4910,7 @@ _cairo_pdf_surface_show_text_glyphs (void *abstract_surface,
|
|||
utf8, utf8_len,
|
||||
glyphs, num_glyphs,
|
||||
clusters, num_clusters,
|
||||
backward,
|
||||
cluster_flags,
|
||||
scaled_font);
|
||||
if (status)
|
||||
return status;
|
||||
|
|
|
|||
|
|
@ -1325,8 +1325,8 @@ slim_hidden_def (cairo_scaled_font_glyph_extents);
|
|||
* @num_glyphs: pointer to number of glyphs
|
||||
* @clusters: pointer to array of cluster mapping information to fill, or %NULL
|
||||
* @num_clusters: pointer to number of clusters, or %NULL
|
||||
* @backward: pointer to whether the text to glyphs mapping goes backward, or
|
||||
* %NULL
|
||||
* @cluster_flags: pointer to location to store cluster flags corresponding to the
|
||||
* output @clusters, or %NULL
|
||||
*
|
||||
* Converts UTF-8 text to an array of glyphs, optionally with cluster
|
||||
* mapping, that can be used to render later using @scaled_font.
|
||||
|
|
@ -1340,7 +1340,7 @@ slim_hidden_def (cairo_scaled_font_glyph_extents);
|
|||
* after the call, the user is responsible for freeing the allocated glyph
|
||||
* array using cairo_glyph_free().
|
||||
*
|
||||
* If @clusters is not %NULL, @num_clusters and @backward should not be %NULL,
|
||||
* If @clusters is not %NULL, @num_clusters and @cluster_flags should not be %NULL,
|
||||
* and cluster mapping will be computed.
|
||||
* The semantics of how cluster array allocation works is similar to the glyph
|
||||
* array. That is,
|
||||
|
|
@ -1362,21 +1362,19 @@ slim_hidden_def (cairo_scaled_font_glyph_extents);
|
|||
* int num_glyphs;
|
||||
* cairo_text_cluster_t *clusters = NULL;
|
||||
* int num_clusters;
|
||||
* cairo_bool_t backward;
|
||||
* cairo_text_cluster_flags_t cluster_flags;
|
||||
*
|
||||
* status = cairo_scaled_font_text_to_glyphs (scaled_font,
|
||||
* x, y,
|
||||
* utf8, utf8_len,
|
||||
* &glyphs, &num_glyphs,
|
||||
* &clusters, &num_clusters,
|
||||
* &backward);
|
||||
* &clusters, &num_clusters, &cluster_flags);
|
||||
*
|
||||
* if (status == CAIRO_STATUS_SUCCESS) {
|
||||
* cairo_show_text_glyphs (cr,
|
||||
* utf8, utf8_len,
|
||||
* *glyphs, *num_glyphs,
|
||||
* *clusters, *num_clusters,
|
||||
* *backward);
|
||||
* *clusters, *num_clusters, *cluster_flags);
|
||||
*
|
||||
* cairo_glyph_free (*glyphs);
|
||||
* cairo_text_cluster_free (*clusters);
|
||||
|
|
@ -1414,21 +1412,19 @@ slim_hidden_def (cairo_scaled_font_glyph_extents);
|
|||
* cairo_text_cluster_t stack_clusters[40];
|
||||
* cairo_text_cluster_t *clusters = stack_clusters;
|
||||
* int num_clusters = sizeof (stack_clusters) / sizeof (stack_clusters[0]);
|
||||
* cairo_bool_t backward;
|
||||
* cairo_text_cluster_flags_t cluster_flags;
|
||||
*
|
||||
* status = cairo_scaled_font_text_to_glyphs (scaled_font,
|
||||
* x, y,
|
||||
* utf8, utf8_len,
|
||||
* &glyphs, &num_glyphs,
|
||||
* &clusters, &num_clusters,
|
||||
* &backward);
|
||||
* &clusters, &num_clusters, &cluster_flags);
|
||||
*
|
||||
* if (status == CAIRO_STATUS_SUCCESS) {
|
||||
* cairo_show_text_glyphs (cr,
|
||||
* utf8, utf8_len,
|
||||
* *glyphs, *num_glyphs,
|
||||
* *clusters, *num_clusters,
|
||||
* *backward);
|
||||
* *clusters, *num_clusters, *cluster_flags);
|
||||
*
|
||||
* if (glyphs != stack_glyphs)
|
||||
* cairo_glyph_free (*glyphs);
|
||||
|
|
@ -1437,7 +1433,7 @@ slim_hidden_def (cairo_scaled_font_glyph_extents);
|
|||
* }
|
||||
* </programlisting></informalexample>
|
||||
*
|
||||
* For details of how @clusters, @num_clusters, and @backward map input
|
||||
* For details of how @clusters, @num_clusters, and @cluster_flags map input
|
||||
* UTF-8 text to the output glyphs see cairo_show_text_glyphs().
|
||||
*
|
||||
* The output values can be readily passed to cairo_show_text_glyphs()
|
||||
|
|
@ -1461,7 +1457,7 @@ cairo_scaled_font_text_to_glyphs (cairo_scaled_font_t *scaled_font,
|
|||
int *num_glyphs,
|
||||
cairo_text_cluster_t **clusters,
|
||||
int *num_clusters,
|
||||
cairo_bool_t *backward)
|
||||
cairo_text_cluster_flags_t *cluster_flags)
|
||||
{
|
||||
int i;
|
||||
int num_chars = 0;
|
||||
|
|
@ -1488,9 +1484,9 @@ cairo_scaled_font_text_to_glyphs (cairo_scaled_font_t *scaled_font,
|
|||
utf8_len = 0;
|
||||
|
||||
/* No NULLs for non-NULLs! */
|
||||
if ((utf8_len && utf8 == NULL) ||
|
||||
(clusters && num_clusters == NULL) ||
|
||||
(clusters && backward == NULL)) {
|
||||
if ((utf8_len && utf8 == NULL) ||
|
||||
(clusters && num_clusters == NULL) ||
|
||||
(clusters && cluster_flags == NULL)) {
|
||||
status = CAIRO_STATUS_NULL_POINTER;
|
||||
goto BAIL;
|
||||
}
|
||||
|
|
@ -1511,12 +1507,12 @@ cairo_scaled_font_text_to_glyphs (cairo_scaled_font_t *scaled_font,
|
|||
num_clusters = NULL;
|
||||
}
|
||||
|
||||
if (backward) {
|
||||
*backward = FALSE;
|
||||
if (cluster_flags) {
|
||||
*cluster_flags = FALSE;
|
||||
}
|
||||
|
||||
if (!clusters && backward) {
|
||||
backward = NULL;
|
||||
if (!clusters && cluster_flags) {
|
||||
cluster_flags = NULL;
|
||||
}
|
||||
|
||||
/* Apart from that, no negatives */
|
||||
|
|
@ -1549,7 +1545,7 @@ cairo_scaled_font_text_to_glyphs (cairo_scaled_font_t *scaled_font,
|
|||
utf8, utf8_len,
|
||||
glyphs, num_glyphs,
|
||||
clusters, num_clusters,
|
||||
backward);
|
||||
cluster_flags);
|
||||
|
||||
if (status != CAIRO_INT_STATUS_UNSUPPORTED) {
|
||||
|
||||
|
|
@ -1583,7 +1579,7 @@ cairo_scaled_font_text_to_glyphs (cairo_scaled_font_t *scaled_font,
|
|||
status = _cairo_validate_text_clusters (utf8, utf8_len,
|
||||
*glyphs, *num_glyphs,
|
||||
*clusters, *num_clusters,
|
||||
*backward);
|
||||
*cluster_flags);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2217,7 +2217,7 @@ _cairo_surface_show_text_glyphs (cairo_surface_t *surface,
|
|||
int num_glyphs,
|
||||
const cairo_text_cluster_t *clusters,
|
||||
int num_clusters,
|
||||
cairo_bool_t backward,
|
||||
cairo_text_cluster_flags_t cluster_flags,
|
||||
cairo_scaled_font_t *scaled_font)
|
||||
{
|
||||
cairo_status_t status;
|
||||
|
|
@ -2272,8 +2272,7 @@ _cairo_surface_show_text_glyphs (cairo_surface_t *surface,
|
|||
status = surface->backend->show_text_glyphs (surface, op, dev_source,
|
||||
utf8, utf8_len,
|
||||
glyphs, num_glyphs,
|
||||
clusters, num_clusters,
|
||||
backward,
|
||||
clusters, num_clusters, cluster_flags,
|
||||
dev_scaled_font);
|
||||
}
|
||||
if (status == CAIRO_INT_STATUS_UNSUPPORTED && surface->backend->show_glyphs) {
|
||||
|
|
@ -2311,8 +2310,7 @@ _cairo_surface_show_text_glyphs (cairo_surface_t *surface,
|
|||
status = surface->backend->show_text_glyphs (surface, op, dev_source,
|
||||
utf8, utf8_len,
|
||||
glyphs, num_glyphs,
|
||||
clusters, num_clusters,
|
||||
backward,
|
||||
clusters, num_clusters, cluster_flags,
|
||||
dev_scaled_font);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -271,16 +271,16 @@ _cairo_user_ucs4_to_index (void *abstract_font,
|
|||
}
|
||||
|
||||
static cairo_int_status_t
|
||||
_cairo_user_text_to_glyphs (void *abstract_font,
|
||||
double x,
|
||||
double y,
|
||||
const char *utf8,
|
||||
int utf8_len,
|
||||
cairo_glyph_t **glyphs,
|
||||
int *num_glyphs,
|
||||
cairo_text_cluster_t **clusters,
|
||||
int *num_clusters,
|
||||
cairo_bool_t *backward)
|
||||
_cairo_user_text_to_glyphs (void *abstract_font,
|
||||
double x,
|
||||
double y,
|
||||
const char *utf8,
|
||||
int utf8_len,
|
||||
cairo_glyph_t **glyphs,
|
||||
int *num_glyphs,
|
||||
cairo_text_cluster_t **clusters,
|
||||
int *num_clusters,
|
||||
cairo_text_cluster_flags_t *cluster_flags)
|
||||
{
|
||||
cairo_int_status_t status = CAIRO_INT_STATUS_UNSUPPORTED;
|
||||
|
||||
|
|
@ -295,8 +295,7 @@ _cairo_user_text_to_glyphs (void *abstract_font,
|
|||
status = face->scaled_font_methods.text_to_glyphs (&scaled_font->base,
|
||||
utf8, utf8_len,
|
||||
glyphs, num_glyphs,
|
||||
clusters, num_clusters,
|
||||
backward);
|
||||
clusters, num_clusters, cluster_flags);
|
||||
|
||||
if (status != CAIRO_STATUS_SUCCESS)
|
||||
return status;
|
||||
|
|
|
|||
19
src/cairo.c
19
src/cairo.c
|
|
@ -3077,7 +3077,7 @@ cairo_show_text (cairo_t *cr, const char *utf8)
|
|||
cairo_glyph_t *glyphs = NULL, *last_glyph;
|
||||
cairo_text_cluster_t *clusters = NULL;
|
||||
int utf8_len, num_glyphs, num_clusters;
|
||||
cairo_bool_t backward;
|
||||
cairo_text_cluster_flags_t cluster_flags;
|
||||
double x, y;
|
||||
|
||||
if (cr->status)
|
||||
|
|
@ -3095,7 +3095,7 @@ cairo_show_text (cairo_t *cr, const char *utf8)
|
|||
utf8, utf8_len,
|
||||
&glyphs, &num_glyphs,
|
||||
cairo_has_show_text_glyphs (cr) ? &clusters : NULL, &num_clusters,
|
||||
&backward);
|
||||
&cluster_flags);
|
||||
if (status)
|
||||
goto BAIL;
|
||||
|
||||
|
|
@ -3106,7 +3106,7 @@ cairo_show_text (cairo_t *cr, const char *utf8)
|
|||
utf8, utf8_len,
|
||||
glyphs, num_glyphs,
|
||||
clusters, num_clusters,
|
||||
backward);
|
||||
cluster_flags);
|
||||
if (status)
|
||||
goto BAIL;
|
||||
|
||||
|
|
@ -3208,7 +3208,7 @@ slim_hidden_def (cairo_has_show_text_glyphs);
|
|||
* @num_glyphs: number of glyphs to show
|
||||
* @clusters: array of cluster mapping information
|
||||
* @num_clusters: number of clusters in the mapping
|
||||
* @backward: whether the text to glyphs mapping goes backward
|
||||
* @cluster_flags: cluster mapping flags
|
||||
*
|
||||
* This operation has rendering effects similar to cairo_show_glyphs()
|
||||
* but, if the target surface supports it, uses the provided text and
|
||||
|
|
@ -3224,7 +3224,8 @@ slim_hidden_def (cairo_has_show_text_glyphs);
|
|||
* and @glyphs in entirety.
|
||||
*
|
||||
* The first cluster always covers bytes from the beginning of @utf8.
|
||||
* If @backward is %FALSE, the first cluster also covers the beginning
|
||||
* If @cluster_flags do not have the %CAIRO_TEXT_CLUSTER_FLAG_BACKWARD
|
||||
* set, the first cluster also covers the beginning
|
||||
* of @glyphs, otherwise it covers the end of the @glyphs array and
|
||||
* following clusters move backward.
|
||||
*
|
||||
|
|
@ -3240,7 +3241,7 @@ cairo_show_text_glyphs (cairo_t *cr,
|
|||
int num_glyphs,
|
||||
const cairo_text_cluster_t *clusters,
|
||||
int num_clusters,
|
||||
cairo_bool_t backward)
|
||||
cairo_text_cluster_flags_t cluster_flags)
|
||||
{
|
||||
cairo_status_t status;
|
||||
|
||||
|
|
@ -3275,8 +3276,7 @@ cairo_show_text_glyphs (cairo_t *cr,
|
|||
* and that cluster boundaries are UTF-8 boundaries. */
|
||||
status = _cairo_validate_text_clusters (utf8, utf8_len,
|
||||
glyphs, num_glyphs,
|
||||
clusters, num_clusters,
|
||||
backward);
|
||||
clusters, num_clusters, cluster_flags);
|
||||
if (status == CAIRO_STATUS_INVALID_CLUSTERS) {
|
||||
/* Either got invalid UTF-8 text, or cluster mapping is bad.
|
||||
* Differentiate those. */
|
||||
|
|
@ -3297,8 +3297,7 @@ cairo_show_text_glyphs (cairo_t *cr,
|
|||
status = _cairo_gstate_show_text_glyphs (cr->gstate,
|
||||
utf8, utf8_len,
|
||||
glyphs, num_glyphs,
|
||||
clusters, num_clusters,
|
||||
!!backward);
|
||||
clusters, num_clusters, cluster_flags);
|
||||
if (status)
|
||||
_cairo_set_error (cr, status);
|
||||
}
|
||||
|
|
|
|||
56
src/cairo.h
56
src/cairo.h
|
|
@ -892,6 +892,19 @@ cairo_text_cluster_allocate (int num_clusters);
|
|||
cairo_public void
|
||||
cairo_text_cluster_free (cairo_text_cluster_t *clusters);
|
||||
|
||||
/**
|
||||
* cairo_text_cluster_flags_t:
|
||||
* @CAIRO_TEXT_CLUSTER_FLAG_BACKWARD: The clusters in the cluster array
|
||||
* map to glyphs in the glyph array from end to start.
|
||||
*
|
||||
* Specifies properties of a text cluster mapping.
|
||||
*
|
||||
* Since: 1.8
|
||||
**/
|
||||
typedef enum _cairo_text_cluster_flags {
|
||||
CAIRO_TEXT_CLUSTER_FLAG_BACKWARD = 0x00000001
|
||||
} cairo_text_cluster_flags_t;
|
||||
|
||||
/**
|
||||
* cairo_text_extents_t:
|
||||
* @x_bearing: the horizontal distance from the origin to the
|
||||
|
|
@ -1231,7 +1244,7 @@ cairo_show_text_glyphs (cairo_t *cr,
|
|||
int num_glyphs,
|
||||
const cairo_text_cluster_t *clusters,
|
||||
int num_clusters,
|
||||
cairo_bool_t backward);
|
||||
cairo_text_cluster_flags_t cluster_flags);
|
||||
|
||||
cairo_public void
|
||||
cairo_text_path (cairo_t *cr, const char *utf8);
|
||||
|
|
@ -1376,16 +1389,16 @@ cairo_scaled_font_glyph_extents (cairo_scaled_font_t *scaled_font,
|
|||
cairo_text_extents_t *extents);
|
||||
|
||||
cairo_public cairo_status_t
|
||||
cairo_scaled_font_text_to_glyphs (cairo_scaled_font_t *scaled_font,
|
||||
double x,
|
||||
double y,
|
||||
const char *utf8,
|
||||
int utf8_len,
|
||||
cairo_glyph_t **glyphs,
|
||||
int *num_glyphs,
|
||||
cairo_text_cluster_t **clusters,
|
||||
int *num_clusters,
|
||||
cairo_bool_t *backward);
|
||||
cairo_scaled_font_text_to_glyphs (cairo_scaled_font_t *scaled_font,
|
||||
double x,
|
||||
double y,
|
||||
const char *utf8,
|
||||
int utf8_len,
|
||||
cairo_glyph_t **glyphs,
|
||||
int *num_glyphs,
|
||||
cairo_text_cluster_t **clusters,
|
||||
int *num_clusters,
|
||||
cairo_text_cluster_flags_t *cluster_flags);
|
||||
|
||||
cairo_public cairo_font_face_t *
|
||||
cairo_scaled_font_get_font_face (cairo_scaled_font_t *scaled_font);
|
||||
|
|
@ -1525,7 +1538,8 @@ typedef cairo_status_t (*cairo_user_scaled_font_render_glyph_func_t) (cairo_scal
|
|||
* @num_glyphs: pointer to number of glyphs
|
||||
* @clusters: pointer to array of cluster mapping information to fill, or %NULL
|
||||
* @num_clusters: pointer to number of clusters
|
||||
* @backward: pointer to whether the text to glyphs mapping goes backward
|
||||
* @cluster_flags: pointer to location to store cluster flags corresponding to the
|
||||
* output @clusters
|
||||
*
|
||||
* #cairo_user_scaled_font_text_to_glyphs_func_t is the type of function which
|
||||
* is called to convert input text to an array of glyphs. This is used by the
|
||||
|
|
@ -1551,7 +1565,7 @@ typedef cairo_status_t (*cairo_user_scaled_font_render_glyph_func_t) (cairo_scal
|
|||
* If the value @glyphs points at has changed after the call, cairo will
|
||||
* free the allocated glyph array using cairo_glyph_free().
|
||||
*
|
||||
* If @clusters is not %NULL, @num_clusters and @backward are also non-%NULL,
|
||||
* If @clusters is not %NULL, @num_clusters and @cluster_flags are also non-%NULL,
|
||||
* and cluster mapping should be computed.
|
||||
* The semantics of how cluster array allocation works is similar to the glyph
|
||||
* array. That is,
|
||||
|
|
@ -1581,14 +1595,14 @@ typedef cairo_status_t (*cairo_user_scaled_font_render_glyph_func_t) (cairo_scal
|
|||
*
|
||||
* Since: 1.8
|
||||
**/
|
||||
typedef cairo_status_t (*cairo_user_scaled_font_text_to_glyphs_func_t) (cairo_scaled_font_t *scaled_font,
|
||||
const char *utf8,
|
||||
int utf8_len,
|
||||
cairo_glyph_t **glyphs,
|
||||
int *num_glyphs,
|
||||
cairo_text_cluster_t **clusters,
|
||||
int *num_clusters,
|
||||
cairo_bool_t *backward);
|
||||
typedef cairo_status_t (*cairo_user_scaled_font_text_to_glyphs_func_t) (cairo_scaled_font_t *scaled_font,
|
||||
const char *utf8,
|
||||
int utf8_len,
|
||||
cairo_glyph_t **glyphs,
|
||||
int *num_glyphs,
|
||||
cairo_text_cluster_t **clusters,
|
||||
int *num_clusters,
|
||||
cairo_text_cluster_flags_t *cluster_flags);
|
||||
|
||||
/**
|
||||
* cairo_user_scaled_font_unicode_to_glyph_func_t:
|
||||
|
|
|
|||
|
|
@ -431,16 +431,16 @@ struct _cairo_scaled_font_backend {
|
|||
* then just converting characters one by one.
|
||||
*/
|
||||
cairo_warn cairo_int_status_t
|
||||
(*text_to_glyphs) (void *scaled_font,
|
||||
double x,
|
||||
double y,
|
||||
const char *utf8,
|
||||
int utf8_len,
|
||||
cairo_glyph_t **glyphs,
|
||||
int *num_glyphs,
|
||||
cairo_text_cluster_t **clusters,
|
||||
int *num_clusters,
|
||||
cairo_bool_t *backward);
|
||||
(*text_to_glyphs) (void *scaled_font,
|
||||
double x,
|
||||
double y,
|
||||
const char *utf8,
|
||||
int utf8_len,
|
||||
cairo_glyph_t **glyphs,
|
||||
int *num_glyphs,
|
||||
cairo_text_cluster_t **clusters,
|
||||
int *num_clusters,
|
||||
cairo_text_cluster_flags_t *cluster_flags);
|
||||
|
||||
unsigned long
|
||||
(*ucs4_to_index) (void *scaled_font,
|
||||
|
|
@ -792,7 +792,7 @@ struct _cairo_surface_backend {
|
|||
int num_glyphs,
|
||||
const cairo_text_cluster_t *clusters,
|
||||
int num_clusters,
|
||||
cairo_bool_t backward,
|
||||
cairo_text_cluster_flags_t cluster_flags,
|
||||
cairo_scaled_font_t *scaled_font);
|
||||
};
|
||||
|
||||
|
|
@ -1224,16 +1224,16 @@ _cairo_gstate_set_font_face (cairo_gstate_t *gstate,
|
|||
cairo_font_face_t *font_face);
|
||||
|
||||
cairo_private cairo_status_t
|
||||
_cairo_gstate_text_to_glyphs (cairo_gstate_t *gstate,
|
||||
double x,
|
||||
double y,
|
||||
const char *utf8,
|
||||
int utf8_len,
|
||||
cairo_glyph_t **glyphs,
|
||||
int *num_glyphs,
|
||||
cairo_text_cluster_t **clusters,
|
||||
int *num_clusters,
|
||||
cairo_bool_t *backward);
|
||||
_cairo_gstate_text_to_glyphs (cairo_gstate_t *gstate,
|
||||
double x,
|
||||
double y,
|
||||
const char *utf8,
|
||||
int utf8_len,
|
||||
cairo_glyph_t **glyphs,
|
||||
int *num_glyphs,
|
||||
cairo_text_cluster_t **clusters,
|
||||
int *num_clusters,
|
||||
cairo_text_cluster_flags_t *cluster_flags);
|
||||
|
||||
cairo_private cairo_status_t
|
||||
_cairo_gstate_glyph_extents (cairo_gstate_t *gstate,
|
||||
|
|
@ -1252,7 +1252,7 @@ _cairo_gstate_show_text_glyphs (cairo_gstate_t *gstate,
|
|||
int num_glyphs,
|
||||
const cairo_text_cluster_t *clusters,
|
||||
int num_clusters,
|
||||
cairo_bool_t backward);
|
||||
cairo_text_cluster_flags_t cluster_flags);
|
||||
|
||||
cairo_private cairo_status_t
|
||||
_cairo_gstate_glyph_path (cairo_gstate_t *gstate,
|
||||
|
|
@ -1358,7 +1358,7 @@ _cairo_validate_text_clusters (const char *utf8,
|
|||
int num_glyphs,
|
||||
const cairo_text_cluster_t *clusters,
|
||||
int num_clusters,
|
||||
cairo_bool_t backward);
|
||||
cairo_text_cluster_flags_t cluster_flags);
|
||||
|
||||
/* cairo-path-fixed.c */
|
||||
cairo_private void
|
||||
|
|
@ -1763,7 +1763,7 @@ _cairo_surface_show_text_glyphs (cairo_surface_t *surface,
|
|||
int num_glyphs,
|
||||
const cairo_text_cluster_t *clusters,
|
||||
int num_clusters,
|
||||
cairo_bool_t backward,
|
||||
cairo_text_cluster_flags_t cluster_flags,
|
||||
cairo_scaled_font_t *scaled_font);
|
||||
|
||||
cairo_private cairo_status_t
|
||||
|
|
|
|||
|
|
@ -273,7 +273,7 @@ _test_meta_surface_show_text_glyphs (void *abstract_surface,
|
|||
int num_glyphs,
|
||||
const cairo_text_cluster_t *clusters,
|
||||
int num_clusters,
|
||||
cairo_bool_t backward,
|
||||
cairo_text_cluster_flags_t cluster_flags,
|
||||
cairo_scaled_font_t *scaled_font)
|
||||
{
|
||||
test_meta_surface_t *surface = abstract_surface;
|
||||
|
|
@ -295,8 +295,7 @@ _test_meta_surface_show_text_glyphs (void *abstract_surface,
|
|||
status = _cairo_surface_show_text_glyphs (surface->meta, op, source,
|
||||
utf8, utf8_len,
|
||||
glyphs, num_glyphs,
|
||||
clusters, num_clusters,
|
||||
backward,
|
||||
clusters, num_clusters, cluster_flags,
|
||||
scaled_font);
|
||||
CAIRO_MUTEX_LOCK (scaled_font->mutex);
|
||||
|
||||
|
|
|
|||
|
|
@ -250,7 +250,7 @@ _test_paginated_surface_show_text_glyphs (void *abstract_surface,
|
|||
int num_glyphs,
|
||||
const cairo_text_cluster_t *clusters,
|
||||
int num_clusters,
|
||||
cairo_bool_t backward,
|
||||
cairo_text_cluster_flags_t cluster_flags,
|
||||
cairo_scaled_font_t *scaled_font)
|
||||
{
|
||||
test_paginated_surface_t *surface = abstract_surface;
|
||||
|
|
@ -273,8 +273,7 @@ _test_paginated_surface_show_text_glyphs (void *abstract_surface,
|
|||
status = _cairo_surface_show_text_glyphs (surface->target, op, source,
|
||||
utf8, utf8_len,
|
||||
glyphs, num_glyphs,
|
||||
clusters, num_clusters,
|
||||
backward,
|
||||
clusters, num_clusters, cluster_flags,
|
||||
scaled_font);
|
||||
CAIRO_MUTEX_LOCK (scaled_font->mutex);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue