Text: colour-glyph comments cite the right source and size

The placement formula is Skia's own fontations port
(src/ports/fontations/src/bitmap.rs) reading the sbix spec's
lower-left-corner rule; the earlier comment named CoreText, which that
source does not mention. Apple Color Emoji measures ~180 MB on current
macOS (the 190 MB figure is a hosted copy of the file), so the comments
say ~180 MB.

No behaviour change: comments only.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
This commit is contained in:
fede9234
2026-10-14 16:44:20 +02:00
parent 54ba84eddc
commit de5ba60bc4
3 changed files with 7 additions and 6 deletions
+4 -3
View File
@@ -136,9 +136,10 @@ impl Face {
made
}
/// Read a strike bitmap and place it. The formula is the one Skia (and CoreText behind it)
/// uses: bearings are in font units and scale with the em, the origin offsets and the image
/// with the strike's ppem, and an sbix image is measured from its lower-left corner.
/// Read a strike bitmap and place it the way Skia's fontations port does
/// (`src/ports/fontations/src/bitmap.rs`): the outer bearings are in font units and scale with
/// the em, the inner ones are pixels at the strike's ppem, and an sbix image is measured from
/// its lower-left corner (the spec places the graphic's origin at the glyph box's xMin, yMin).
fn read_bitmap(&self, gid: u32, size: f64) -> Option<ColorBitmap> {
let gid = GlyphId::new(gid);
let font = FontRef::from_index(self.bytes.data(), self.index).ok()?;
+2 -2
View File
@@ -639,7 +639,7 @@ impl FontDb {
}
/// Colour emoji faces, for characters no other fallback covers. Kept out of
/// [`fallbacks`](Self::fallbacks) because the files are large (Apple Color Emoji is ~190 MB)
/// [`fallbacks`](Self::fallbacks) because the files are large (Apple Color Emoji is ~180 MB)
/// and only texts that actually show emoji need them; each family reads one face.
pub fn emoji_fallbacks(&mut self) -> Vec<Arc<Face>> {
let mut out = Vec::new();
@@ -725,7 +725,7 @@ fn scan_dir(dir: &std::path::Path, depth: usize, out: &mut BTreeMap<String, (Str
if !matches!(ext.as_str(), "ttf" | "otf" | "ttc" | "otc") {
continue;
}
// Very large files are indexed all the same (Apple Color Emoji is ~190 MB, and its faces
// Very large files are indexed all the same (Apple Color Emoji is ~180 MB, and its faces
// are the colour emoji themselves): `index_bytes` reads headers and name tables out of a
// zeroed buffer, so only those parts are ever touched.
let Some(bytes) = usize::try_from(meta.len()).ok().filter(|l| *l <= 256 * 1024 * 1024).and_then(|l| index_bytes(&path, l)) else { continue };
+1 -1
View File
@@ -328,7 +328,7 @@ pub fn layout(text: &TextData, box_width: Option<f64>, box_height: Option<f64>)
for s in &styles {
faces.push(dbw.find(&s.font_family, &s.font_style).or_else(|| dbw.default_face()));
}
// Colour emoji are their own, large faces (Apple Color Emoji is ~190 MB): they are read only
// Colour emoji are their own, large faces (Apple Color Emoji is ~180 MB): they are read only
// for a text whose characters nothing above covers.
let covered = |c: char| c == '\n' || faces.iter().flatten().any(|f| f.has_char(c)) || fallbacks.iter().any(|f| f.has_char(c));
if chars.iter().any(|c| !covered(*c)) {