mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-07 00:08:39 +09:00
Issue #3039 - Extend cairo API with an explicit font_get_hint_metrics function.
This extension allows us to get font hint metrics without having to create and destroy cairo font options structs. Since this is used in loops, this will improve performance, especially in documents which have many text segments.
This commit is contained in:
parent
be7e9c26bb
commit
517a6b90a3
5 changed files with 26 additions and 4 deletions
|
|
@ -267,6 +267,7 @@
|
|||
#define cairo_scaled_font_get_font_face _moz_cairo_scaled_font_get_font_face
|
||||
#define cairo_scaled_font_get_font_matrix _moz_cairo_scaled_font_get_font_matrix
|
||||
#define cairo_scaled_font_get_font_options _moz_cairo_scaled_font_get_font_options
|
||||
#define cairo_scaled_font_get_hint_metrics _moz_cairo_scaled_font_get_hint_metrics
|
||||
#define cairo_scaled_font_get_reference_count _moz_cairo_scaled_font_get_reference_count
|
||||
#define cairo_scaled_font_get_scale_matrix _moz_cairo_scaled_font_get_scale_matrix
|
||||
#define cairo_scaled_font_get_type _moz_cairo_scaled_font_get_type
|
||||
|
|
|
|||
|
|
@ -2952,3 +2952,23 @@ cairo_scaled_font_get_font_options (cairo_scaled_font_t *scaled_font,
|
|||
_cairo_font_options_init_copy (options, &scaled_font->options);
|
||||
}
|
||||
slim_hidden_def (cairo_scaled_font_get_font_options);
|
||||
|
||||
/**
|
||||
* cairo_scaled_font_get_hint_metrics:
|
||||
* @scaled_font: a #cairo_scaled_font_t
|
||||
*
|
||||
* Mozilla extension since the required malloc/free to use
|
||||
* cairo_scaled_font_get_font_options() above is too slow.
|
||||
**/
|
||||
cairo_public cairo_hint_metrics_t
|
||||
cairo_scaled_font_get_hint_metrics (cairo_scaled_font_t *scaled_font)
|
||||
{
|
||||
cairo_font_options_t options;
|
||||
if (scaled_font->status) {
|
||||
_cairo_font_options_init_default (&options);
|
||||
} else {
|
||||
_cairo_font_options_init_copy (&options, &scaled_font->options);
|
||||
}
|
||||
return options.hint_metrics;
|
||||
}
|
||||
slim_hidden_def (cairo_scaled_font_get_hint_metrics);
|
||||
|
|
@ -1465,6 +1465,9 @@ cairo_public void
|
|||
cairo_scaled_font_get_font_options (cairo_scaled_font_t *scaled_font,
|
||||
cairo_font_options_t *options);
|
||||
|
||||
// API extension for GRE.
|
||||
cairo_public cairo_hint_metrics_t
|
||||
cairo_scaled_font_get_hint_metrics (cairo_scaled_font_t *scaled_font);
|
||||
|
||||
/* Toy fonts */
|
||||
|
||||
|
|
|
|||
|
|
@ -2434,6 +2434,7 @@ slim_hidden_proto (cairo_scaled_font_get_ctm);
|
|||
slim_hidden_proto (cairo_scaled_font_get_font_face);
|
||||
slim_hidden_proto (cairo_scaled_font_get_font_matrix);
|
||||
slim_hidden_proto (cairo_scaled_font_get_font_options);
|
||||
slim_hidden_proto (cairo_scaled_font_get_hint_metrics); // GRE API extension
|
||||
slim_hidden_proto (cairo_scaled_font_glyph_extents);
|
||||
slim_hidden_proto_no_warn (cairo_scaled_font_reference);
|
||||
slim_hidden_proto (cairo_scaled_font_status);
|
||||
|
|
|
|||
|
|
@ -591,11 +591,8 @@ gfxFontShaper::GetRoundOffsetsToPixels(DrawTarget* aDrawTarget,
|
|||
}
|
||||
|
||||
// Sometimes hint metrics gets set for us, most notably for printing.
|
||||
cairo_font_options_t *font_options = cairo_font_options_create();
|
||||
cairo_scaled_font_get_font_options(scaled_font, font_options);
|
||||
cairo_hint_metrics_t hint_metrics =
|
||||
cairo_font_options_get_hint_metrics(font_options);
|
||||
cairo_font_options_destroy(font_options);
|
||||
cairo_scaled_font_get_hint_metrics(scaled_font);
|
||||
|
||||
switch (hint_metrics) {
|
||||
case CAIRO_HINT_METRICS_OFF:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue