Commit Graph
44 Commits
Author SHA1 Message Date
Khaled Hosny 3e2897e631 [hb-raster] Fix building with PNG disabled
In file included from ../util/hb-raster.cc:30:
../util/raster-output.hh:828:16: error: a type specifier is required for all declarations
  828 |     HB_UNUSED (img);
      |                ^
../util/raster-output.hh:829:16: error: a type specifier is required for all declarations
  829 |     HB_UNUSED (protocol);
      |                ^
2 errors generated.
2026-03-12 17:36:39 +02:00
Behdad Esfahbod 2ea0e18a43 [util] Move shared ANSI image helpers out of Cairo wrapper
The RGB24-to-ANSI output path was implemented in helper-cairo-ansi.hh,
so hb-raster picked up a Cairo header dependency even though it only
needed the shared image-output code. That broke builds configured with
-Dcairo=disabled.

Move the shared callback, Chafa, and RGB24-to-ANSI helpers into
helper-image-output.hh, keep helper-cairo-ansi.hh focused on adapting
Cairo surfaces, and switch raster-output.hh to include only the shared
image helper.

Testing:
meson test -C build

Assisted-by: OpenAI Codex
2026-03-11 22:12:40 -03:00
Behdad Esfahbod cfd9a52c9d [svg] Gate SVG table processing under HB_NO_SVG (#5814)
Skip the SVG table accelerator and do not define the public
SVG color APIs when HB_NO_SVG is set. Guard internal
callers so SVG-table-dependent code compiles out cleanly,
and add HB_NO_SVG to the HB_TINY profile.

Tested: meson setup build-nosvg -Dc_args=-DHB_NO_SVG -Dcpp_args=-DHB_NO_SVG
Tested: meson compile -C build-nosvg hb-shape hb-info hb-vector main
Tested: meson compile -C build-nosvg (libharfbuzz/libharfbuzz-raster/libharfbuzz-vector linked; full tree stopped on unrelated missing chafa.h in util/hb-raster.cc)
Tested: nm -gU build-nosvg/src/libharfbuzz.0.dylib | grep -E "hb_ot_color_.*svg" (no matches)

Assisted-by: OpenAI Codex
2026-03-10 00:19:39 -06:00
Behdad Esfahbod bec407b6ab util: prefer PNG as the default image format 2026-03-09 21:35:30 -03:00
Behdad Esfahbod a4ddc4c35c util: composite hb-raster PNG output against background 2026-03-09 21:27:08 -03:00
Behdad Esfahbod 7623e5524c util: add terminal output modes to hb-raster 2026-03-09 23:37:36 +02:00
Behdad Esfahbod e36b7a3f5d util: add PNG output support to hb-raster 2026-03-09 23:37:36 +02:00
Behdad Esfahbod 9c6f4c201f raster: add PNG paint_image support via libpng 2026-03-09 18:18:52 +02:00
Behdad Esfahbod c2efaa5ced Unify view extents defaults 2026-03-03 17:19:15 -03:00
Behdad Esfahbod 46bf94ef0e [util] Centralize foreground/background parsing in view options 2026-02-26 21:04:18 -03:00
Behdad Esfahbod 164d58c8d7 [util] Parse custom palette once in view-options and reuse 2026-02-26 21:00:21 -03:00
Behdad Esfahbod 953f222c2e [raster] Remove extents safety pad for view parity 2026-02-25 18:32:45 -03:00
Behdad Esfahbod 24912d7990 [raster] Fix logical bounds to avoid trailing empty line 2026-02-25 18:31:25 -03:00
Behdad Esfahbod 3f0bee360f [raster] Fix non-rainbow A8 output extents usage 2026-02-25 18:25:18 -03:00
Behdad Esfahbod b141d47b8e [raster] Implement show-extents overlays 2026-02-25 16:40:09 -03:00
Behdad Esfahbod 21b8e0a4c4 [raster] Apply foreground palette cycling to non-color glyphs 2026-02-25 16:35:16 -03:00
Behdad Esfahbod f5e211094b [raster] Honor font-extents for line step with scaling 2026-02-25 16:32:28 -03:00
Behdad Esfahbod ba51d73241 [raster] Scale line-space to font units 2026-02-25 16:30:35 -03:00
Behdad Esfahbod d0149e5e2f [raster] Honor view line-space in line step 2026-02-25 16:28:24 -03:00
Behdad Esfahbod 323ae8bd6c [raster] Implement logical/ink extents selection 2026-02-25 16:26:07 -03:00
Behdad Esfahbod d7e890d363 [util] Run view foreground setup in post-parse hook 2026-02-25 16:18:55 -03:00
Behdad Esfahbod 1ab77842a7 [raster] Reuse shared view_options_t for CLI flags 2026-02-25 16:16:51 -03:00
Behdad Esfahbod f2edc612ee Merge branch 'main' into raster-svg
# Conflicts:
#	util/raster-output.hh
2026-02-25 15:49:13 -03:00
Behdad Esfahbod 6a90ed9c39 Revert "[util/raster] Use glyph extents for margins; drop AA pad"
This reverts commit 3d48a0bce0.
2026-02-25 15:47:15 -03:00
Behdad Esfahbod 27d9aff7b8 [raster] Add custom palette overrides for COLR and SVG 2026-02-25 15:33:44 -03:00
Behdad Esfahbod 533bac1da0 [raster] Add --font-palette and pass palette to paint 2026-02-25 15:16:44 -03:00
Behdad Esfahbod 3d48a0bce0 [util/raster] Use glyph extents for margins; drop AA pad 2026-02-25 11:46:42 -03:00
Behdad Esfahbod eaa141fdd0 [util/raster] Add --margin option to hb-raster 2026-02-25 11:27:25 -03:00
Behdad EsfahbodandClaude Opus 4.6 291bc6e1f2 [raster] Add SVG table rasterizer
Implement a minimal SVG parser/renderer that translates OpenType SVG
table documents into paint commands through the existing hb_paint_funcs_t
interface. All pixel-level rendering (gradients, compositing, clipping)
is handled by the existing hb_raster_paint_t infrastructure.

Features:
- XML tokenizer and SVG path data parser (all commands including arcs)
- Shape-to-path converters (rect, circle, ellipse, line, polyline, polygon)
- Gradient support (linearGradient, radialGradient with stops and transforms)
- SVG color parser (#RGB, #RRGGBB, rgb(), named colors, currentColor)
- CPAL palette colors via var(--colorN) with fallback support
- Transform parser (matrix, translate, scale, rotate, skewX, skewY)
- Defs/use resolution, clipPath support, group opacity
- Hook into hb-raster utility for SVG font rendering

New files: hb-raster-svg.cc, hb-raster-svg.hh, hb-raster-paint.hh

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 11:10:35 -03:00
Behdad Esfahbod f67799a819 Use hb-raster glyph convenience APIs in raster tools 2026-02-24 09:05:12 -03:00
Behdad Esfahbod bcd19a4c39 raster: add draw/paint scale-factor API 2026-02-24 05:02:35 -03:00
Behdad Esfahbod 5ea04afcda raster: adopt create_or_fail and strict render semantics 2026-02-24 04:46:51 -03:00
Behdad Esfahbod 0727834314 raster-image: consolidate configuration API 2026-02-24 04:22:51 -03:00
Behdad Esfahbod e13b688611 util: use hb_memcpy/hb_memset for raster paths 2026-02-24 04:08:43 -03:00
Behdad Esfahbod 3fd6adf678 util/raster: use hb_raster_image_t as output buffer 2026-02-24 04:05:44 -03:00
Behdad Esfahbod 90ef078e46 [util] Centralize --num-iterations and skip repeat shaping for raster 2026-02-23 22:34:19 -03:00
Behdad Esfahbod f1e6108523 [util] Add raster --num-iterations loops and recycle draw image 2026-02-23 22:34:14 -03:00
Behdad Esfahbod 426ab081d3 util/raster-output: remove upem_font normalization
Was leftover from hb-draw design picked up by agents.
2026-02-23 22:31:24 -03:00
Behdad Esfahbod dfcdf16c0f [hb-raster] Don't write out to terminal 2026-02-22 19:09:51 -03:00
Behdad Esfahbod 646fef15fb util: drop PNG-only color detection in raster tools 2026-02-22 15:29:17 -03:00
Behdad EsfahbodandClaude Opus 4.6 917d18735f raster: always emit PPM for consistent output format
Both hb-raster and hb-ft-raster now always produce PPM (color) output,
compositing alpha over foreground/background colors. This makes the
output format consistent regardless of whether the font has color data.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 14:21:09 -03:00
Behdad EsfahbodandClaude Opus 4.6 7951782491 hb-raster: add --foreground and --background CLI options
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 01:47:34 -03:00
Behdad EsfahbodandClaude Opus 4.6 49838acdad raster: add hb_raster_paint_t for color glyph rendering
Implement a software paint backend (hb_raster_paint_t) that renders
COLRv0/v1 color glyphs into BGRA32 pixel buffers with no external
dependencies. Implements all 14 hb_paint_funcs_t callbacks including
solid fills, linear/radial/sweep gradients, glyph clipping, rectangle
clipping, group compositing, and BGRA image blitting.

Update hb-raster utility to detect color fonts and use the paint path,
outputting PPM (RGB) instead of PGM (greyscale).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 01:24:44 -03:00
Behdad EsfahbodandClaude Sonnet 4.6 08b76f5db1 hb-raster: add util/hb-raster tool
Renders shaped text into a single auto-sized A8 PGM raster image,
written to stdout or --output-file.  Mirrors util/hb-draw in structure.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-21 17:29:05 -03:00