| 1 | #cxx . . $ `<file>/gsk/gskprivate.c`/include "config.h"cxx . . $ `<file>/build/config.h`/ |
| 2 | |
| 3 | #include "gskresources.h"cxx . . $ `<file>/build/gsk/gskresources.h`/ |
| 4 | #include "gskprivate.h"cxx . . $ `<file>/gsk/gskprivate.h`/ |
| 5 | |
| 6 | #include <cairo.h> |
| 7 | #include <pango/pangocairo.h> |
| 8 | #ifdef HAVE_PANGOFTcxx . . $ `build/config.h:68:9`! |
| 9 | #include <pango/pangoft2.h> |
| 10 | #endif |
| 11 | #include <math.h> |
| 12 | |
| 13 | static gpointercxx . . $ gpointer# |
| 14 | register_resourcescxx . . $ register_resources(9f162e79bfc6c74). (gpointercxx . . $ gpointer# data) |
| 15 | { |
| 16 | _gsk_register_resourcecxx . . $ _gsk_register_resource(49f6e7a06ebc5aa8). (); |
| 17 | return NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 18 | } |
| 19 | |
| 20 | void |
| 21 | gsk_ensure_resourcescxx . . $ gsk_ensure_resources(49f6e7a06ebc5aa8). (void) |
| 22 | { |
| 23 | static GOncecxx . . $ GOnce# register_resources_once = G_ONCE_INITcxx . . $ `<external>/457917468643292165/gthread.h:104:9`!; |
| 24 | |
| 25 | g_oncecxx . . $ `<external>/457917468643292165/gthread.h:261:10`! (®ister_resources_once, register_resources, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!); |
| 26 | } |
| 27 | |
| 28 | /*< private > |
| 29 | * gsk_reload_font: |
| 30 | * @font: a `PangoFont` |
| 31 | * @scale: the scale to apply |
| 32 | * @hint_metris: hint metrics to use or `CAIRO_HINT_METRICS_DEFAILT` to keep the |
| 33 | * hint metrics of the font unchanged |
| 34 | * @hint_style: hint style to use or `CAIRO_HINT_STYLE_DEFAULT` to keep the |
| 35 | * hint style of @font unchanged |
| 36 | * @antialias: antialiasing to use, or `CAIRO_ANTIALIAS_DEFAULT` to keep the |
| 37 | * antialias option of @font unchanged |
| 38 | * |
| 39 | * Returns a font that is just like @font, but uses the |
| 40 | * given scale and hinting options for its glyphs and metrics. |
| 41 | * |
| 42 | * Returns: (transfer full): the modified `PangoFont` |
| 43 | */ |
| 44 | PangoFontcxx . . $ PangoFont# * |
| 45 | gsk_reload_fontcxx . . $ gsk_reload_font(d84fd3499bf877d0). (PangoFontcxx . . $ PangoFont# *font, |
| 46 | float scale, |
| 47 | cairo_hint_metrics_tcxx . . $ cairo_hint_metrics_t# hint_metrics, |
| 48 | cairo_hint_style_tcxx . . $ cairo_hint_style_t# hint_style, |
| 49 | cairo_antialias_tcxx . . $ cairo_antialias_t# antialias) |
| 50 | { |
| 51 | static cairo_font_options_tcxx . . $ cairo_font_options_t# *options = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 52 | static PangoContextcxx . . $ PangoContext# *context = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 53 | cairo_scaled_font_tcxx . . $ cairo_scaled_font_t# *sf; |
| 54 | |
| 55 | /* These requests often come in sequentially so keep the result |
| 56 | * around and re-use it if everything matches. |
| 57 | */ |
| 58 | static PangoFontcxx . . $ PangoFont# *last_font; |
| 59 | static float last_scale; |
| 60 | static cairo_hint_metrics_tcxx . . $ cairo_hint_metrics_t# last_hint_metrics; |
| 61 | static cairo_hint_style_tcxx . . $ cairo_hint_style_t# last_hint_style; |
| 62 | static cairo_antialias_tcxx . . $ cairo_antialias_t# last_antialias; |
| 63 | static PangoFontcxx . . $ PangoFont# *last_result; |
| 64 | |
| 65 | if (last_result != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`! && |
| 66 | last_font == font && |
| 67 | last_scale == scale && |
| 68 | last_hint_metrics == hint_metrics && |
| 69 | last_hint_style == hint_style && |
| 70 | last_antialias == antialias) |
| 71 | return g_object_refcxx . . $ `<external>/1341695927569185362/gobject.h:533:9`! (last_result); |
| 72 | |
| 73 | last_scale = scale; |
| 74 | last_hint_metrics = hint_metrics; |
| 75 | last_hint_style = hint_style; |
| 76 | last_antialias = antialias; |
| 77 | |
| 78 | g_set_objectcxx . . $ `<external>/1341695927569185362/gobject.h:762:9`! (&last_font, font); |
| 79 | g_clear_objectcxx . . $ `<external>/1341695927569185362/gobject.h:695:9`! (&last_result); |
| 80 | |
| 81 | if (G_UNLIKELYcxx . . $ `<external>/12741050725406041920/gmacros.h:1285:9`! (options == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!)) |
| 82 | options = cairo_font_options_createcxx . . $ cairo_font_options_create(a87260634a73aab3). (); |
| 83 | |
| 84 | sf = pango_cairo_font_get_scaled_fontcxx . . $ pango_cairo_font_get_scaled_font(cc4c7392c644b26b). (PANGO_CAIRO_FONTcxx . . $ `<external>/13124785942517375558/pangocairo.h:53:9`! (font)); |
| 85 | cairo_scaled_font_get_font_optionscxx . . $ cairo_scaled_font_get_font_options(e5eb332b9c4fe67a). (sf, options); |
| 86 | |
| 87 | if (hint_metrics == CAIRO_HINT_METRICS_DEFAULTcxx . . $ CAIRO_HINT_METRICS_DEFAULT.) |
| 88 | hint_metrics = cairo_font_options_get_hint_metricscxx . . $ cairo_font_options_get_hint_metrics(8e6a2d325cea51b5). (options); |
| 89 | |
| 90 | if (hint_style == CAIRO_HINT_STYLE_DEFAULTcxx . . $ CAIRO_HINT_STYLE_DEFAULT.) |
| 91 | hint_style = cairo_font_options_get_hint_stylecxx . . $ cairo_font_options_get_hint_style(a864f5fc22a999b7). (options); |
| 92 | |
| 93 | if (antialias == CAIRO_ANTIALIAS_DEFAULTcxx . . $ CAIRO_ANTIALIAS_DEFAULT.) |
| 94 | antialias = cairo_font_options_get_antialiascxx . . $ cairo_font_options_get_antialias(84c80d042eaef582). (options); |
| 95 | |
| 96 | if (1.0 == scale && |
| 97 | cairo_font_options_get_hint_metricscxx . . $ cairo_font_options_get_hint_metrics(8e6a2d325cea51b5). (options) == hint_metrics && |
| 98 | cairo_font_options_get_hint_stylecxx . . $ cairo_font_options_get_hint_style(a864f5fc22a999b7). (options) == hint_style && |
| 99 | cairo_font_options_get_antialiascxx . . $ cairo_font_options_get_antialias(84c80d042eaef582). (options) == antialias && |
| 100 | cairo_font_options_get_subpixel_ordercxx . . $ cairo_font_options_get_subpixel_order(117da00e56d38049). (options) == CAIRO_SUBPIXEL_ORDER_DEFAULTcxx . . $ CAIRO_SUBPIXEL_ORDER_DEFAULT.) |
| 101 | { |
| 102 | last_result = g_object_refcxx . . $ `<external>/1341695927569185362/gobject.h:533:9`! (font); |
| 103 | return g_object_refcxx . . $ `<external>/1341695927569185362/gobject.h:533:9`! (font); |
| 104 | } |
| 105 | |
| 106 | cairo_font_options_set_hint_metricscxx . . $ cairo_font_options_set_hint_metrics(180115c7db5a6972). (options, hint_metrics); |
| 107 | cairo_font_options_set_hint_stylecxx . . $ cairo_font_options_set_hint_style(33e11c79ba2fc534). (options, hint_style); |
| 108 | cairo_font_options_set_antialiascxx . . $ cairo_font_options_set_antialias(7157882dc9915317). (options, antialias); |
| 109 | cairo_font_options_set_subpixel_ordercxx . . $ cairo_font_options_set_subpixel_order(9793c983efa0405a). (options, CAIRO_SUBPIXEL_ORDER_DEFAULTcxx . . $ CAIRO_SUBPIXEL_ORDER_DEFAULT.); |
| 110 | |
| 111 | if (G_UNLIKELYcxx . . $ `<external>/12741050725406041920/gmacros.h:1285:9`! (context == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!)) |
| 112 | context = pango_context_newcxx . . $ pango_context_new(45575ff43a691991). (); |
| 113 | |
| 114 | pango_context_set_round_glyph_positionscxx . . $ pango_context_set_round_glyph_positions(e4dc1f7dfa528af6). (context, hint_metrics == CAIRO_HINT_METRICS_ONcxx . . $ CAIRO_HINT_METRICS_ON.); |
| 115 | pango_cairo_context_set_font_optionscxx . . $ pango_cairo_context_set_font_options(cc04274aff7a68f5). (context, options); |
| 116 | |
| 117 | last_result = pango_font_map_reload_fontcxx . . $ pango_font_map_reload_font(ea1380fb531c1d44). (pango_font_get_font_mapcxx . . $ pango_font_get_font_map(8de254890f980184). (font), font, scale, context, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!); |
| 118 | |
| 119 | return g_object_refcxx . . $ `<external>/1341695927569185362/gobject.h:533:9`! (last_result); |
| 120 | } |
| 121 | |
| 122 | /*< private > |
| 123 | * gsk_get_glyph_string_extents: |
| 124 | * @glyphs: a `PangoGlyphString` |
| 125 | * @font: a `PangoFont` |
| 126 | * @ink_rect: (out): rectangle used to store the extents of the glyph string as drawn |
| 127 | * |
| 128 | * Compute the ink extents of a glyph string. |
| 129 | * |
| 130 | * This is like [[email protected]], but it |
| 131 | * ignores hinting of the font. |
| 132 | */ |
| 133 | void |
| 134 | gsk_get_glyph_string_extentscxx . . $ gsk_get_glyph_string_extents(de35e94ae20a5496). (PangoGlyphStringcxx . . $ PangoGlyphString# *glyphs, |
| 135 | PangoFontcxx . . $ PangoFont# *font, |
| 136 | PangoRectanglecxx . . $ PangoRectangle# *ink_rect) |
| 137 | { |
| 138 | PangoFontcxx . . $ PangoFont# *unhinted; |
| 139 | |
| 140 | unhinted = gsk_reload_fontcxx . . $ gsk_reload_font(d84fd3499bf877d0). (font, |
| 141 | 1.0, |
| 142 | CAIRO_HINT_METRICS_DEFAULTcxx . . $ CAIRO_HINT_METRICS_DEFAULT., |
| 143 | CAIRO_HINT_STYLE_NONEcxx . . $ CAIRO_HINT_STYLE_NONE., |
| 144 | CAIRO_ANTIALIAS_DEFAULTcxx . . $ CAIRO_ANTIALIAS_DEFAULT.); |
| 145 | |
| 146 | pango_glyph_string_extentscxx . . $ pango_glyph_string_extents(703990e83ec1240f). (glyphs, unhinted, ink_rect, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!); |
| 147 | |
| 148 | g_object_unrefcxx . . $ g_object_unref(5d22bdacc48458e8). (unhinted); |
| 149 | } |
| 150 | |
| 151 | /*< private > |
| 152 | * gsk_font_get_hint_style: |
| 153 | * @font: a `PangoFont` |
| 154 | * |
| 155 | * Get the hint style from the cairo font options. |
| 156 | * |
| 157 | * Returns: the hint style |
| 158 | */ |
| 159 | cairo_hint_style_tcxx . . $ cairo_hint_style_t# |
| 160 | gsk_font_get_hint_stylecxx . . $ gsk_font_get_hint_style(3a1958ee82c0efd0). (PangoFontcxx . . $ PangoFont# *font) |
| 161 | { |
| 162 | static cairo_font_options_tcxx . . $ cairo_font_options_t# *options = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 163 | cairo_scaled_font_tcxx . . $ cairo_scaled_font_t# *sf; |
| 164 | cairo_hint_style_tcxx . . $ cairo_hint_style_t# style; |
| 165 | |
| 166 | if (G_UNLIKELYcxx . . $ `<external>/12741050725406041920/gmacros.h:1285:9`! (options == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!)) |
| 167 | options = cairo_font_options_createcxx . . $ cairo_font_options_create(a87260634a73aab3). (); |
| 168 | |
| 169 | sf = pango_cairo_font_get_scaled_fontcxx . . $ pango_cairo_font_get_scaled_font(cc4c7392c644b26b). (PANGO_CAIRO_FONTcxx . . $ `<external>/13124785942517375558/pangocairo.h:53:9`! (font)); |
| 170 | cairo_scaled_font_get_font_optionscxx . . $ cairo_scaled_font_get_font_options(e5eb332b9c4fe67a). (sf, options); |
| 171 | style = cairo_font_options_get_hint_stylecxx . . $ cairo_font_options_get_hint_style(a864f5fc22a999b7). (options); |
| 172 | |
| 173 | return style; |
| 174 | } |