| /* |
| * Copyright © 2026 Behdad Esfahbod |
| * |
| * This is part of HarfBuzz, a text shaping library. |
| * |
| * Permission is hereby granted, without written agreement and without |
| * license or royalty fees, to use, copy, modify, and distribute this |
| * software and its documentation for any purpose, provided that the |
| * above copyright notice and the following two paragraphs appear in |
| * all copies of this software. |
| * |
| * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR |
| * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES |
| * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN |
| * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH |
| * DAMAGE. |
| * |
| * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, |
| * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND |
| * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS |
| * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO |
| * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
| * |
| * Author(s): Behdad Esfahbod |
| */ |
| |
| #include "hb.hh" |
| |
| #include "hb-raster.h" |
| |
| /** |
| * SECTION:hb-raster |
| * @title: hb-raster |
| * @short_description: Glyph rasterization |
| * @include: hb-raster.h |
| * |
| * Functions for rasterizing glyph outlines into pixel buffers. |
| * |
| * #hb_raster_draw_t rasterizes outline geometry and always outputs |
| * @HB_RASTER_FORMAT_A8. Typical flow: |
| * ``` |
| * hb_raster_draw_t *draw = hb_raster_draw_create_or_fail (); |
| * hb_raster_draw_set_scale_factor (draw, 64.f, 64.f); |
| * hb_raster_draw_set_transform (draw, 1.f, 0.f, 0.f, 1.f, 0.f, 0.f); |
| * hb_raster_draw_set_glyph_extents (draw, &glyph_extents); |
| * hb_raster_draw_glyph (draw, font, gid, pen_x, pen_y); |
| * hb_raster_image_t *mask = hb_raster_draw_render (draw); |
| * ``` |
| * |
| * #hb_raster_paint_t renders color paint graphs and always outputs |
| * @HB_RASTER_FORMAT_BGRA32. Typical flow: |
| * ``` |
| * hb_raster_paint_t *paint = hb_raster_paint_create_or_fail (); |
| * hb_raster_paint_set_scale_factor (paint, 64.f, 64.f); |
| * hb_raster_paint_set_transform (paint, 1.f, 0.f, 0.f, 1.f, 0.f, 0.f); |
| * hb_raster_paint_set_foreground (paint, foreground); |
| * hb_glyph_extents_t glyph_extents; |
| * hb_font_get_glyph_extents (font, gid, &glyph_extents); |
| * hb_raster_paint_set_glyph_extents (paint, &glyph_extents); |
| * hb_raster_paint_glyph (paint, font, gid, pen_x, pen_y, 0, foreground); |
| * hb_raster_image_t *img = hb_raster_paint_render (paint); |
| * ``` |
| * |
| * In both modes, set extents explicitly (or via glyph extents) before |
| * rendering to avoid implicit allocations and to get deterministic bounds. |
| **/ |