euv-core 0.53.1

Core cross-platform runtime for euv featuring arena-based fine-grained reactivity, deterministic layout, flat scene graph, multi-mode rendering, and direct OS platform adapters.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
use super::*;

/// Builds the 128-entry compile-time proportional advance ratio lookup table for ASCII bytes `0..128`.
///
/// # Returns
///
/// - `[f32; 128]` - Proportional width ratio relative to font size for every ASCII codepoint.
#[must_use]
pub(crate) const fn build_ascii_advance_lut() -> [f32; 128] {
    let mut table: [f32; 128] = [PROPORTIONAL_ADVANCE_RATIO; 128];
    let groups: [(&[u8], f32); 17] = [
        (b"ijl|", 0.26),
        (b"I ", 0.27),
        (b"'.,:;!", 0.29),
        (b"/\\", 0.30),
        (b"ft", 0.36),
        (b"r()[]{}", 0.38),
        (b"1*-\"", 0.46),
        (b"`?sxJzvky", 0.53),
        (b"acLeF", 0.56),
        (b"gpqbd", 0.60),
        (b"023456789#$+<=>^~TPS", 0.63),
        (b"RYBKZAVX", 0.66),
        (b"&CDUHNG", 0.73),
        (b"OQw", 0.77),
        (b"mM", 0.86),
        (b"@%", 0.92),
        (b"W", 0.96),
    ];
    let mut g_idx: usize = 0;
    while g_idx < groups.len() {
        let (bytes, ratio): (&[u8], f32) = groups[g_idx];
        let mut idx: usize = 0;
        while idx < bytes.len() {
            table[bytes[idx] as usize] = ratio;
            idx += 1;
        }
        g_idx += 1;
    }
    table
}

/// Resolves the deterministic proportional bold width multiplier matching native glyph rasterization.
///
/// # Arguments
///
/// - `TextStyle` - Active typography style.
///
/// # Returns
///
/// - `f32` - Width multiplier (`1.0` for monospace or non-bold weights, `BOLD_PROPORTIONAL_FACTOR` for bold proportional weights).
#[inline(always)]
#[must_use]
pub fn text_bold_advance_factor(style: TextStyle) -> f32 {
    if style.get_family() == FontFamily::Monospace {
        1.0
    } else if style.get_weight().is_bold() {
        BOLD_PROPORTIONAL_FACTOR
    } else {
        1.0
    }
}

/// Looks up the raw 5x7 bitmap rows for a Unicode character.
///
/// # Arguments
///
/// - `char` - Character to query.
///
/// # Returns
///
/// - `[u8; BITMAP_GLYPH_HEIGHT]` - Seven 5-bit row bitmasks.
#[inline(always)]
#[must_use]
pub fn glyph_bitmap_rows(ch: char) -> [u8; BITMAP_GLYPH_HEIGHT] {
    let code: u32 = ch as u32;
    if (ASCII_FIRST_PRINTABLE..=ASCII_LAST_PRINTABLE).contains(&code) {
        ASCII_FONT_5X7[(code - ASCII_FIRST_PRINTABLE) as usize]
    } else {
        FALLBACK_GLYPH_ROWS
    }
}

/// Computes deterministic logical advance width for a character under `style`.
///
/// # Arguments
///
/// - `char` - Character to measure.
/// - `TextStyle` - Active typography style.
///
/// # Returns
///
/// - `f32` - Advance width in logical pixels.
#[inline(always)]
#[must_use]
pub fn measure_char_advance(ch: char, style: TextStyle) -> f32 {
    let code: u32 = ch as u32;
    if matches!(code, 0x200B | 0x200C | 0x200D | 0xFE0E | 0xFE0F) {
        return 0.0;
    }
    let is_mono: bool = style.get_family() == FontFamily::Monospace;
    let bold_factor: f32 = text_bold_advance_factor(style);
    if code < 128 {
        let ratio: f32 = if is_mono {
            MONOSPACE_ADVANCE_RATIO
        } else {
            ASCII_ADVANCE_LUT[code as usize]
        };
        return style.get_font_size() * ratio * bold_factor + style.get_letter_spacing();
    }
    if is_wide_unicode(ch) {
        let wide_ratio: f32 = if is_emoji_unicode(ch) {
            WIDE_EMOJI_ADVANCE_RATIO
        } else {
            WIDE_CJK_ADVANCE_RATIO
        };
        return style.get_font_size() * wide_ratio + style.get_letter_spacing();
    }
    let ratio: f32 = if is_mono {
        MONOSPACE_ADVANCE_RATIO
    } else {
        NON_ASCII_ADVANCE_RATIO
    };
    style.get_font_size() * ratio * bold_factor + style.get_letter_spacing()
}

/// Applies optional horizontal bold stroke dilation to a 5-bit glyph bitmap row mask.
///
/// # Arguments
///
/// - `u8` - Source 5-bit row mask (`bit 4` is column 0, `bit 0` is column 4).
/// - `bool` - Whether bold stroke thickening is active.
///
/// # Returns
///
/// - `u8` - Effective 5-bit row mask encoding `hit || bold_hit` for every column.
#[inline(always)]
#[must_use]
fn dilate_row_mask(row_bits: u8, bold: bool) -> u8 {
    if bold {
        row_bits | ((row_bits >> 1) & 0x0F)
    } else {
        row_bits
    }
}

/// Computes the exact 1D squared Euclidean distance transform in `O(n)` via the Felzenszwalb-Huttenlocher lower envelope.
///
/// # Arguments
///
/// - `&[f32]` - Input 1D squared-distance seed values.
/// - `&mut [f32]` - Output 1D squared Euclidean distances.
/// - `&mut [usize]` - Scratch parabola index stack of length `>= input.len()`.
/// - `&mut [f32]` - Scratch boundary coordinate stack of length `>= input.len() + 1`.
fn compute_edt_1d(
    input: &[f32],
    output: &mut [f32],
    parabola_idx: &mut [usize],
    boundary_pos: &mut [f32],
) {
    let count: usize = input.len();
    if count == 0 {
        return;
    }
    let mut top: usize = 0;
    parabola_idx[0] = 0;
    boundary_pos[0] = f32::NEG_INFINITY;
    boundary_pos[1] = f32::INFINITY;
    for q_idx in 1..count {
        let fq: f32 = input[q_idx];
        let qf: f32 = q_idx as f32;
        loop {
            let p_idx: usize = parabola_idx[top];
            let pf: f32 = p_idx as f32;
            let fp: f32 = input[p_idx];
            let intersection: f32 = ((fq + qf * qf) - (fp + pf * pf)) / (2.0 * (qf - pf));
            if intersection <= boundary_pos[top] {
                if top == 0 {
                    parabola_idx[0] = q_idx;
                    boundary_pos[1] = f32::INFINITY;
                    break;
                }
                top -= 1;
            } else {
                top += 1;
                parabola_idx[top] = q_idx;
                boundary_pos[top] = intersection;
                boundary_pos[top + 1] = f32::INFINITY;
                break;
            }
        }
    }
    let mut cursor: usize = 0;
    for (q_idx, dst) in output.iter_mut().enumerate().take(count) {
        let qf: f32 = q_idx as f32;
        while boundary_pos[cursor + 1] < qf {
            cursor += 1;
        }
        let p_idx: usize = parabola_idx[cursor];
        let delta: f32 = qf - (p_idx as f32);
        *dst = delta * delta + input[p_idx];
    }
}

/// Computes the exact 2D Euclidean distance transform over a `width x height` binary grid.
///
/// # Arguments
///
/// - `&mut [f32]` - In-place grid initialized to `0.0` for feature pixels and `GLYPH_EDT_INF` otherwise.
/// - `usize` - Grid width in pixels.
/// - `usize` - Grid height in pixels.
fn compute_edt_2d(grid: &mut [f32], width: usize, height: usize) {
    let max_dim: usize = width.max(height);
    if max_dim == 0 {
        return;
    }
    let mut line_in: Vec<f32> = vec![0.0; max_dim];
    let mut line_out: Vec<f32> = vec![0.0; max_dim];
    let mut parabola_idx: Vec<usize> = vec![0; max_dim];
    let mut boundary_pos: Vec<f32> = vec![0.0; max_dim + 1];
    for col in 0..width {
        for row in 0..height {
            line_in[row] = grid[row * width + col];
        }
        compute_edt_1d(
            &line_in[..height],
            &mut line_out[..height],
            &mut parabola_idx[..height],
            &mut boundary_pos[..=height],
        );
        for row in 0..height {
            grid[row * width + col] = line_out[row];
        }
    }
    for row in 0..height {
        let row_start: usize = row * width;
        line_in[..width].copy_from_slice(&grid[row_start..row_start + width]);
        compute_edt_1d(
            &line_in[..width],
            &mut line_out[..width],
            &mut parabola_idx[..width],
            &mut boundary_pos[..=width],
        );
        grid[row_start..row_start + width].copy_from_slice(&line_out[..width]);
    }
    for val in grid.iter_mut() {
        *val = val.max(0.0).sqrt();
    }
}

/// Builds an exact Euclidean signed-distance field (`SdfGlyphField`) from a canonical rasterized glyph for resolution-independent gigantic scaling.
///
/// # Arguments
///
/// - `&RasterizedGlyph` - Canonical source glyph rasterized at `canonical_size_px`.
/// - `f32` - Canonical raster size in pixels (`> 0.0`).
/// - `f32` - Signed-distance spread radius in canonical pixels.
///
/// # Returns
///
/// - `SdfGlyphField` - Resolution-independent signed-distance field ready for smooth analytic reconstruction.
#[must_use]
pub fn build_glyph_sdf_field(
    source: &RasterizedGlyph,
    canonical_size_px: f32,
    spread_px: f32,
) -> SdfGlyphField {
    let src_w: usize = source.get_width() as usize;
    let src_h: usize = source.get_height() as usize;
    let safe_canonical: f32 = canonical_size_px.max(GLYPH_MIN_PHYSICAL_PX);
    let safe_spread: f32 = spread_px.clamp(1.0, 32.0);
    let advance_ratio: f32 = (source.get_advance() as f32) / safe_canonical;
    if src_w == 0 || src_h == 0 {
        return SdfGlyphField::new(0, 0, safe_canonical, safe_spread, advance_ratio, Vec::new());
    }
    let total: usize = src_w.saturating_mul(src_h);
    let cov: &[u8] = source.get_coverage().as_slice();
    let mut outside_dist: Vec<f32> = vec![GLYPH_EDT_INF; total];
    let mut inside_dist: Vec<f32> = vec![GLYPH_EDT_INF; total];
    let mut any_inside: bool = false;
    for (idx, &alpha) in cov.iter().enumerate().take(total) {
        if alpha >= 128 {
            outside_dist[idx] = 0.0;
            any_inside = true;
        } else {
            inside_dist[idx] = 0.0;
        }
    }
    if !any_inside {
        let distances: Vec<f32> = vec![safe_spread; total];
        return SdfGlyphField::new(
            src_w as u32,
            src_h as u32,
            safe_canonical,
            safe_spread,
            advance_ratio,
            distances,
        );
    }
    compute_edt_2d(&mut outside_dist, src_w, src_h);
    compute_edt_2d(&mut inside_dist, src_w, src_h);
    let mut distances: Vec<f32> = Vec::with_capacity(total);
    for idx in 0..total {
        let alpha_frac: f32 = (cov[idx] as f32) / 255.0;
        let subpixel_bias: f32 = 0.5 - alpha_frac;
        let signed: f32 =
            (outside_dist[idx] - inside_dist[idx] + subpixel_bias).clamp(-safe_spread, safe_spread);
        distances.push(signed);
    }
    SdfGlyphField::new(
        src_w as u32,
        src_h as u32,
        safe_canonical,
        safe_spread,
        advance_ratio,
        distances,
    )
}

/// Evaluates a `SdfGlyphField` analytically at arbitrary target physical size with smooth 1px sub-pixel anti-aliasing.
///
/// # Arguments
///
/// - `&SdfGlyphField` - Precomputed canonical glyph signed-distance field.
/// - `f32` - Desired target physical font size in pixels.
///
/// # Returns
///
/// - `RasterizedGlyph` - Crisp analytically anti-aliased glyph bitmap at `target_size_px`.
#[must_use]
pub fn evaluate_glyph_sdf(field: &SdfGlyphField, target_size_px: f32) -> RasterizedGlyph {
    let safe_target: f32 =
        target_size_px.clamp(GLYPH_MIN_PHYSICAL_PX, GLYPH_ANALYTIC_MAX_PHYSICAL_PX);
    let canonical: f32 = field.get_canonical_size_px().max(GLYPH_MIN_PHYSICAL_PX);
    let scale_ratio: f32 = safe_target / canonical;
    let advance: u32 = (field.get_advance_ratio() * safe_target).ceil().max(4.0) as u32;
    let src_w: u32 = field.get_width();
    let src_h: u32 = field.get_height();
    let distances: &[f32] = field.get_distances().as_slice();
    if src_w == 0 || src_h == 0 || distances.is_empty() {
        let out_h: u32 = (safe_target * 0.86).round().max(7.0) as u32;
        let out_w: u32 = (advance as f32 * 0.86).round().max(3.0) as u32;
        return RasterizedGlyph::new(
            out_w,
            out_h,
            advance,
            vec![0; (out_w as usize).saturating_mul(out_h as usize)],
        );
    }
    let out_w: u32 = ((src_w as f32) * scale_ratio).round().max(1.0) as u32;
    let out_h: u32 = ((src_h as f32) * scale_ratio).round().max(1.0) as u32;
    let out_w_usize: usize = out_w as usize;
    let src_w_usize: usize = src_w as usize;
    let max_sx: f32 = (src_w - 1) as f32;
    let max_sy: f32 = (src_h - 1) as f32;
    let inv_scale_x: f32 = (src_w as f32) / (out_w as f32);
    let inv_scale_y: f32 = (src_h as f32) / (out_h as f32);
    let aa_half_canonical: f32 = (0.5 / scale_ratio).max(0.05);
    let mut coverage: Vec<u8> = vec![0; out_w_usize.saturating_mul(out_h as usize)];
    for py in 0..out_h {
        let sy: f32 = (((py as f32) + 0.5) * inv_scale_y - 0.5).clamp(0.0, max_sy);
        let y0: usize = sy.floor() as usize;
        let y1: usize = (y0 + 1).min((src_h - 1) as usize);
        let fy: f32 = sy - (y0 as f32);
        let row0: usize = y0 * src_w_usize;
        let row1: usize = y1 * src_w_usize;
        let dst_row_start: usize = (py as usize) * out_w_usize;
        let dst_row: &mut [u8] = &mut coverage[dst_row_start..dst_row_start + out_w_usize];
        for (px, dst_px) in dst_row.iter_mut().enumerate() {
            let sx: f32 = (((px as f32) + 0.5) * inv_scale_x - 0.5).clamp(0.0, max_sx);
            let x0: usize = sx.floor() as usize;
            let x1: usize = (x0 + 1).min((src_w - 1) as usize);
            let fx: f32 = sx - (x0 as f32);
            let d00: f32 = distances[row0 + x0];
            let d10: f32 = distances[row0 + x1];
            let d01: f32 = distances[row1 + x0];
            let d11: f32 = distances[row1 + x1];
            let top_d: f32 = d00 + (d10 - d00) * fx;
            let bot_d: f32 = d01 + (d11 - d01) * fx;
            let dist: f32 = top_d + (bot_d - top_d) * fy;
            let linear_cov: f32 =
                ((aa_half_canonical - dist) / (2.0 * aa_half_canonical)).clamp(0.0, 1.0);
            let smooth_cov: f32 = linear_cov * linear_cov * (3.0 - 2.0 * linear_cov);
            *dst_px = (smooth_cov * 255.0 + 0.5) as u8;
        }
    }
    RasterizedGlyph::new(out_w, out_h, advance, coverage)
}

/// Rasterizes a glyph into a smooth alpha-coverage bitmap at the requested key size, using exact analytic SDF reconstruction above `512px`.
///
/// # Arguments
///
/// - `GlyphKey` - Quantized glyph descriptor.
///
/// # Returns
///
/// - `RasterizedGlyph` - Coverage bitmap and pixel metrics.
#[must_use]
pub fn rasterize_glyph(key: GlyphKey) -> RasterizedGlyph {
    if key.uses_analytic_sdf_fallback() {
        let canonical_key: GlyphKey = key.with_physical_size(GLYPH_SDF_CANONICAL_PX);
        let canonical_glyph: RasterizedGlyph = rasterize_glyph(canonical_key);
        let field: SdfGlyphField = build_glyph_sdf_field(
            &canonical_glyph,
            GLYPH_SDF_CANONICAL_PX,
            GLYPH_SDF_DEFAULT_SPREAD_PX,
        );
        return evaluate_glyph_sdf(&field, key.physical_size_px());
    }
    let code: u32 = key.get_codepoint() as u32;
    if code > ASCII_LAST_PRINTABLE {
        return rasterize_unicode_deterministic(key);
    }
    let size_px: f32 = (key.get_size_tenths() as f32) * 0.1;
    let mut prop_style: TextStyle = TextStyle::default();
    prop_style
        .set_font_size(size_px)
        .set_family(if key.get_monospace() {
            FontFamily::Monospace
        } else {
            FontFamily::Sans
        })
        .set_weight(if key.get_bold() {
            FontWeight::Bold
        } else {
            FontWeight::Normal
        });
    let target_adv: f32 = measure_char_advance(key.get_codepoint(), prop_style);
    let out_h: u32 = (size_px * 0.86).round().max(7.0) as u32;
    let advance: u32 = target_adv.round().max(3.0) as u32;
    let out_w: u32 = (target_adv * 0.86).round().max(3.0).min(advance as f32) as u32;
    let rows: [u8; BITMAP_GLYPH_HEIGHT] = glyph_bitmap_rows(key.get_codepoint());
    let out_w_usize: usize = out_w as usize;
    let total_pixels: usize = out_w_usize * (out_h as usize);
    let mut coverage: Vec<u8> = vec![0; total_pixels];
    if rows == [0; BITMAP_GLYPH_HEIGHT] {
        return RasterizedGlyph::new(out_w, out_h, advance, coverage);
    }
    let bold: bool = key.get_bold();
    let italic: bool = key.get_italic();
    let src_w: f32 = BITMAP_GLYPH_WIDTH as f32;
    let src_h: f32 = BITMAP_GLYPH_HEIGHT as f32;
    let dst_w: f32 = out_w as f32;
    let dst_h: f32 = out_h as f32;
    let max_sx: f32 = src_w - 0.01;
    let max_row: usize = BITMAP_GLYPH_HEIGHT - 1;
    let max_col: usize = BITMAP_GLYPH_WIDTH - 1;
    if !italic && out_w_usize <= GLYPH_STACK_COL_CACHE {
        let mut shift_l_buf: [u8; GLYPH_STACK_COL_CACHE] = [0; GLYPH_STACK_COL_CACHE];
        let mut shift_r_buf: [u8; GLYPH_STACK_COL_CACHE] = [0; GLYPH_STACK_COL_CACHE];
        for px in 0..out_w_usize {
            let pxf: f32 = px as f32;
            let sx_l: f32 = ((pxf + 0.25) * src_w / dst_w).clamp(0.0, max_sx);
            let sx_r: f32 = ((pxf + 0.75) * src_w / dst_w).clamp(0.0, max_sx);
            let col_l: usize = (sx_l.floor() as usize).min(max_col);
            let col_r: usize = (sx_r.floor() as usize).min(max_col);
            shift_l_buf[px] = (max_col - col_l) as u8;
            shift_r_buf[px] = (max_col - col_r) as u8;
        }
        for py in 0..out_h {
            let pyf: f32 = py as f32;
            let row_top_idx: usize = (((pyf + 0.25) * src_h / dst_h).floor() as usize).min(max_row);
            let row_bot_idx: usize = (((pyf + 0.75) * src_h / dst_h).floor() as usize).min(max_row);
            let eff_top: u8 = dilate_row_mask(rows[row_top_idx], bold);
            let eff_bot: u8 = dilate_row_mask(rows[row_bot_idx], bold);
            if eff_top == 0 && eff_bot == 0 {
                continue;
            }
            let row_off: usize = (py as usize) * out_w_usize;
            let row_dst: &mut [u8] = &mut coverage[row_off..row_off + out_w_usize];
            for (px, dst_px) in row_dst.iter_mut().enumerate() {
                let sl: u8 = shift_l_buf[px];
                let sr: u8 = shift_r_buf[px];
                let hits: u8 = ((eff_top >> sl) & 1)
                    + ((eff_top >> sr) & 1)
                    + ((eff_bot >> sl) & 1)
                    + ((eff_bot >> sr) & 1);
                if hits > 0 {
                    *dst_px = SUBPIXEL_ALPHA_LUT[hits as usize];
                }
            }
        }
        return RasterizedGlyph::new(out_w, out_h, advance, coverage);
    }
    let inv_dst_h_italic: f32 = 1.0 / dst_h.max(1.0);
    for py in 0..out_h {
        let pyf: f32 = py as f32;
        let row_top_idx: usize = (((pyf + 0.25) * src_h / dst_h).floor() as usize).min(max_row);
        let row_bot_idx: usize = (((pyf + 0.75) * src_h / dst_h).floor() as usize).min(max_row);
        let eff_top: u8 = dilate_row_mask(rows[row_top_idx], bold);
        let eff_bot: u8 = dilate_row_mask(rows[row_bot_idx], bold);
        if eff_top == 0 && eff_bot == 0 {
            continue;
        }
        let italic_shift: f32 = if italic {
            (0.5 - pyf * inv_dst_h_italic) * 0.85
        } else {
            0.0
        };
        let row_off: usize = (py as usize) * out_w_usize;
        let row_dst: &mut [u8] = &mut coverage[row_off..row_off + out_w_usize];
        for (px, dst_px) in row_dst.iter_mut().enumerate() {
            let pxf: f32 = px as f32;
            let sx_l: f32 = ((pxf + 0.25) * src_w / dst_w - italic_shift).clamp(0.0, max_sx);
            let sx_r: f32 = ((pxf + 0.75) * src_w / dst_w - italic_shift).clamp(0.0, max_sx);
            let sl: u8 = (max_col - (sx_l.floor() as usize).min(max_col)) as u8;
            let sr: u8 = (max_col - (sx_r.floor() as usize).min(max_col)) as u8;
            let hits: u8 = ((eff_top >> sl) & 1)
                + ((eff_top >> sr) & 1)
                + ((eff_bot >> sl) & 1)
                + ((eff_bot >> sr) & 1);
            if hits > 0 {
                *dst_px = SUBPIXEL_ALPHA_LUT[hits as usize];
            }
        }
    }
    RasterizedGlyph::new(out_w, out_h, advance, coverage)
}