0

Roll Fontations, Skrifa to 0.28

List of changes:
https://github.com/googlefonts/fontations/compare/skrifa-v0.27.0...skrifa-v0.28.0

Updated crates:

* read-fonts: 0.26.0 => 0.27.0
* skrifa: 0.27.0 => 0.28.0
* font-types: 0.8.2 => 0.8.3

Crates vetted for
"safe-to-deploy", "does-not-implement-crypto", "ub-risk-0"
except for font-types at ub-risk-1 instead of ub-risk-0.
No new unsafe.

Bug: chromium:40045339
Change-Id: I0250ca3e849b1e4ceabe3a08d0cbe50e2811cfa4
Cq-Include-Trybots: chromium/try:android-rust-arm32-rel
Cq-Include-Trybots: chromium/try:android-rust-arm64-dbg
Cq-Include-Trybots: chromium/try:android-rust-arm64-rel
Cq-Include-Trybots: chromium/try:linux-rust-x64-dbg
Cq-Include-Trybots: chromium/try:linux-rust-x64-rel
Cq-Include-Trybots: chromium/try:win-rust-x64-dbg
Cq-Include-Trybots: chromium/try:win-rust-x64-rel
Disable-Rts: True
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6261197
Reviewed-by: Łukasz Anforowicz <lukasza@chromium.org>
Commit-Queue: Dominik Röttsches <drott@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1420369}
This commit is contained in:
Dominik Röttsches
2025-02-14 01:13:29 -08:00
committed by Chromium LUCI CQ
parent 2b9093cb15
commit b7ebab601b
282 changed files with 926 additions and 539 deletions
content/browser
infra
skia
third_party/rust
chromium_crates_io
Cargo.lockCargo.toml
supply-chain
vendor
font-types-0.8.2
font-types-0.8.3
read-fonts-0.26.0
read-fonts-0.27.1
.cargo-checksum.json.cargo_vcs_info.jsonCargo.lockCargo.tomlCargo.toml.origLICENSE-APACHELICENSE-MITREADME.md
benches
generated
src
skrifa-0.27.0
skrifa-0.28.0
font_types
read_fonts
skrifa

@ -43,8 +43,8 @@ if (is_android) {
]
deps = [
"//third_party/rust/font_types/v0_8:lib",
"//third_party/rust/read_fonts/v0_26:lib",
"//third_party/rust/skrifa/v0_27:lib",
"//third_party/rust/read_fonts/v0_27:lib",
"//third_party/rust/skrifa/v0_28:lib",
]
}
}

@ -301,7 +301,7 @@ third_party/afl/src/docs 11 2
third_party/afl/src/llvm_mode 1 1
third_party/afl/src/qemu_mode 1 1
third_party/android_build_tools/json 1 1
third_party/android_deps/buildSrc/src/main/groovy 35 2
third_party/android_deps/buildSrc/src/main/groovy 36 2
third_party/android_deps/libs 1 1
third_party/android_deps/libs/com_google_auto_service_auto_service_annotations 1 1
third_party/android_deps/libs/com_google_errorprone_error_prone_annotations 1 1
@ -693,7 +693,7 @@ third_party/rust/chromium_crates_io/vendor/rand_chacha-0.3.1 4 1
third_party/rust/chromium_crates_io/vendor/rand_core-0.6.4 4 1
third_party/rust/chromium_crates_io/vendor/rand_core-0.6.4/src 3 1
third_party/rust/chromium_crates_io/vendor/rand_pcg-0.3.1 4 1
third_party/rust/chromium_crates_io/vendor/read-fonts-0.26.0/src/tables 3 2
third_party/rust/chromium_crates_io/vendor/read-fonts-0.27.1/src/tables 3 2
third_party/rust/chromium_crates_io/vendor/regex-1.11.1 1 1
third_party/rust/chromium_crates_io/vendor/regex-1.11.1/src 1 1
third_party/rust/chromium_crates_io/vendor/regex-1.11.1/tests 7 6
@ -824,7 +824,7 @@ tools/metrics/actions 1 1
tools/metrics/histograms 13 2
tools/metrics/histograms/metadata/gpu 1 1
tools/metrics/ukm 1 1
tools/perf 7 5
tools/perf 26 8
tools/perf/cli_tools/update_wpr 2 1
tools/perf/core 13 4
tools/perf/core/results_processor/formatters 1 1

@ -49,8 +49,8 @@ rust_static_library("bridge_rust_side") {
deps = [
":path_bridge",
"//third_party/rust/font_types/v0_8:lib",
"//third_party/rust/read_fonts/v0_26:lib",
"//third_party/rust/skrifa/v0_27:lib",
"//third_party/rust/read_fonts/v0_27:lib",
"//third_party/rust/skrifa/v0_28:lib",
]
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [

@ -328,7 +328,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "font-types"
version = "0.8.2"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bytemuck",
@ -1037,7 +1037,7 @@ dependencies = [
[[package]]
name = "read-fonts"
version = "0.26.0"
version = "0.27.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bytemuck",
@ -1198,7 +1198,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "skrifa"
version = "0.27.0"
version = "0.28.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bytemuck",

@ -37,12 +37,12 @@ qr_code = "2"
quote = "1"
rand = "0.8"
rand_pcg = "0.3"
read-fonts = "0.26"
read-fonts = "0.27"
regex = "1"
rustc-demangle-capi = "0.1"
serde = "1"
serde_json = "1"
skrifa = "0.27"
skrifa = "0.28"
small_ctor = "0.1"
static_assertions = "1"
strum = "0.25.0"

@ -1516,6 +1516,12 @@ criteria = ["safe-to-deploy", "does-not-implement-crypto", "ub-risk-1"]
delta = "0.7.3 -> 0.8.2"
notes = "No new unsafe, more inlining, checked add. Minor spec compliance issues."
[[audits.font-types]]
who = "Dominik Röttsches <drott@chromium.org>"
criteria = ["safe-to-deploy", "does-not-implement-crypto", "ub-risk-1"]
delta = "0.8.2 -> 0.8.3"
notes = "Changes to reading IndexSubtable, reverting adding Tag::NULL associated constant."
[[audits.getrandom]]
who = "danakj@chromium.org"
criteria = ["safe-to-run", "does-not-implement-crypto"]
@ -2416,6 +2422,12 @@ criteria = ["safe-to-deploy", "does-not-implement-crypto", "ub-risk-0"]
delta = "0.25.3 -> 0.26.0"
notes = "Added min_byte_range() method, expose IndexSubtableList for bitmaps. No new unsafe. Gvar delta API changes."
[[audits.read-fonts]]
who = "Dominik Röttsches <drott@chromium.org>"
criteria = ["safe-to-deploy", "does-not-implement-crypto", "ub-risk-0"]
delta = "0.26.0 -> 0.27.1"
notes = "IFT impl behind feature flag."
[[audits.regex]]
who = "danakj@chromium.org"
criteria = ["safe-to-run", "does-not-implement-crypto"]
@ -3184,6 +3196,12 @@ criteria = ["safe-to-deploy", "does-not-implement-crypto", "ub-risk-0"]
delta = "0.26.5 -> 0.27.0"
notes = "Mostly a fuzzer fix, rejecting oversized composite outlines."
[[audits.skrifa]]
who = "Dominik Röttsches <drott@chromium.org>"
criteria = ["safe-to-deploy", "does-not-implement-crypto", "ub-risk-0"]
delta = "0.27.0 -> 0.28.0"
notes = "Minor clippy fix."
[[audits.small_ctor]]
who = "danakj@chromium.org"
criteria = ["safe-to-run", "does-not-implement-crypto"]

@ -149,7 +149,7 @@ criteria = ["crypto-safe", "safe-to-deploy", "ub-risk-2"]
[policy."foldhash:0.1.4"]
criteria = ["crypto-safe", "safe-to-deploy", "ub-risk-2"]
[policy."font-types:0.8.2"]
[policy."font-types:0.8.3"]
criteria = ["crypto-safe", "safe-to-deploy", "ub-risk-2"]
[policy."getrandom:0.2.15"]
@ -356,7 +356,7 @@ criteria = ["crypto-safe", "safe-to-run"]
[policy."rand_pcg:0.3.1"]
criteria = ["crypto-safe", "safe-to-run"]
[policy."read-fonts:0.26.0"]
[policy."read-fonts:0.27.1"]
criteria = ["crypto-safe", "safe-to-deploy", "ub-risk-2"]
[policy."regex-automata:0.4.9"]
@ -416,7 +416,7 @@ criteria = []
[policy."simd-adler32:0.3.7"]
criteria = ["crypto-safe", "safe-to-deploy", "ub-risk-2"]
[policy."skrifa:0.27.0"]
[policy."skrifa:0.28.0"]
criteria = ["crypto-safe", "safe-to-deploy", "ub-risk-2"]
[policy."small_ctor:0.1.2"]

@ -1,6 +0,0 @@
{
"git": {
"sha1": "a5bc98f8f3af8fbaaa12ae5f32228cdc684e676e"
},
"path_in_vcs": "font-types"
}

@ -0,0 +1,6 @@
{
"git": {
"sha1": "ad6e5a986c09211f2c0baa5fe352744577905701"
},
"path_in_vcs": "font-types"
}

@ -0,0 +1,117 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "bytemuck"
version = "1.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b37c88a63ffd85d15b406896cc343916d7cf57838a847b3a6f2ca5d39a5695a"
dependencies = [
"bytemuck_derive",
]
[[package]]
name = "bytemuck_derive"
version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bcfcc3cd946cb52f0bbfdbbcfa2f4e24f75ebb6c0e1002f7c25904fada18b9ec"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "font-types"
version = "0.8.3"
dependencies = [
"bytemuck",
"serde",
"serde_json",
]
[[package]]
name = "itoa"
version = "1.0.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "540654e97a3f4470a492cd30ff187bc95d89557a903a2bbf112e2fae98104ef2"
[[package]]
name = "memchr"
version = "2.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
[[package]]
name = "proc-macro2"
version = "1.0.89"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af"
dependencies = [
"proc-macro2",
]
[[package]]
name = "ryu"
version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f"
[[package]]
name = "serde"
version = "1.0.215"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.215"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "serde_json"
version = "1.0.133"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377"
dependencies = [
"itoa",
"memchr",
"ryu",
"serde",
]
[[package]]
name = "syn"
version = "2.0.87"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "unicode-ident"
version = "1.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83"

@ -12,7 +12,7 @@
[package]
edition = "2021"
name = "font-types"
version = "0.8.2"
version = "0.8.3"
build = false
autolib = false
autobins = false

@ -1,6 +1,6 @@
[package]
name = "font-types"
version = "0.8.2"
version = "0.8.3"
description = "Scalar types used in fonts."
readme = "README.md"
categories = ["text-processing"]

@ -46,6 +46,12 @@ impl From<u16> for GlyphId16 {
}
}
impl From<GlyphId16> for usize {
fn from(value: GlyphId16) -> Self {
value.0 as usize
}
}
impl std::fmt::Display for GlyphId16 {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "GID_{}", self.0)

@ -44,7 +44,9 @@ impl Int24 {
pub const fn from_be_bytes(bytes: [u8; 3]) -> Self {
let extra_byte = ((bytes[0] & 0b10000000) >> 7) * 0b11111111;
let extra_byte = (extra_byte as i32) << 24;
Int24::new(extra_byte | (bytes[0] as i32) << 16 | (bytes[1] as i32) << 8 | bytes[2] as i32)
Int24::new(
extra_byte | ((bytes[0] as i32) << 16) | ((bytes[1] as i32) << 8) | bytes[2] as i32,
)
}
}

@ -39,7 +39,7 @@ impl Uint24 {
}
pub const fn from_be_bytes(bytes: [u8; 3]) -> Self {
Uint24::new((bytes[0] as u32) << 16 | (bytes[1] as u32) << 8 | bytes[2] as u32)
Uint24::new(((bytes[0] as u32) << 16) | ((bytes[1] as u32) << 8) | bytes[2] as u32)
}
}

@ -62,7 +62,7 @@ impl Version16Dot16 {
/// Panics if `minor > 9`.
pub const fn new(major: u16, minor: u16) -> Self {
assert!(minor < 10, "minor version must be in the range [0, 9)");
let version = (major as u32) << 16 | (minor as u32) << 12;
let version = ((major as u32) << 16) | ((minor as u32) << 12);
Version16Dot16(version)
}

@ -1,6 +0,0 @@
{
"git": {
"sha1": "10971dae3a6a7f35841f8c22420bb92da9b8ae0e"
},
"path_in_vcs": "read-fonts"
}

@ -0,0 +1,6 @@
{
"git": {
"sha1": "7da01ca7044f00b92baf47f4b6d561dd365de407"
},
"path_in_vcs": "read-fonts"
}

@ -209,9 +209,9 @@ checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0"
[[package]]
name = "font-types"
version = "0.8.2"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "11c3a23a5a151afb1f74ea797f8c300dee41eff9ee3cb1bf94ed316d860c46b3"
checksum = "d868ec188a98bb014c606072edd47e52e7ab7297db943b0b28503121e1d037bd"
dependencies = [
"bytemuck",
"serde",
@ -431,7 +431,7 @@ dependencies = [
[[package]]
name = "read-fonts"
version = "0.26.0"
version = "0.27.1"
dependencies = [
"bytemuck",
"core_maths",

@ -12,7 +12,7 @@
[package]
edition = "2021"
name = "read-fonts"
version = "0.26.0"
version = "0.27.1"
build = false
autolib = false
autobins = false
@ -62,7 +62,7 @@ version = "0.1"
optional = true
[dependencies.font-types]
version = "0.8.2"
version = "0.8.3"
features = ["bytemuck"]
[dependencies.serde]
@ -80,6 +80,7 @@ version = "0.8.5"
codegen_test = []
default = ["std"]
experimental_traverse = ["std"]
ift = []
libm = ["dep:core_maths"]
scaler_test = []
serde = [

@ -1,6 +1,6 @@
[package]
name = "read-fonts"
version = "0.26.0"
version = "0.27.1"
description = "Reading OpenType font files."
readme = "README.md"
categories = ["text-processing", "parsing", "graphics"]
@ -18,6 +18,9 @@ features = ["libm", "serde", "std"]
std = ["font-types/std"]
codegen_test = []
scaler_test = []
# experimental support for incremental font transfer (https://www.w3.org/TR/IFT/)
# code behind this feature does not honor semver and may break at any time.
ift = []
# this feature is not stable, but provides untyped traversal of font tables.
# we do not consider this feature public API for the purposes of semver.
experimental_traverse = ["std"]

@ -861,7 +861,8 @@ impl IndexSubtableRecord {
/// The `data` argument should be retrieved from the parent table
/// By calling its `offset_data` method.
pub fn index_subtable<'a>(&self, data: FontData<'a>) -> Result<IndexSubtable<'a>, ReadError> {
self.index_subtable_offset().resolve(data)
let args = (self.last_glyph_index(), self.first_glyph_index());
self.index_subtable_offset().resolve_with_args(data, &args)
}
}
@ -889,118 +890,6 @@ impl<'a> SomeRecord<'a> for IndexSubtableRecord {
}
}
/// [IndexSubtables](https://learn.microsoft.com/en-us/typography/opentype/spec/eblc#indexsubtables) format type.
#[derive(Clone)]
pub enum IndexSubtable<'a> {
Format1(IndexSubtable1<'a>),
Format2(IndexSubtable2<'a>),
Format3(IndexSubtable3<'a>),
Format4(IndexSubtable4<'a>),
Format5(IndexSubtable5<'a>),
}
impl<'a> IndexSubtable<'a> {
///Return the `FontData` used to resolve offsets for this table.
pub fn offset_data(&self) -> FontData<'a> {
match self {
Self::Format1(item) => item.offset_data(),
Self::Format2(item) => item.offset_data(),
Self::Format3(item) => item.offset_data(),
Self::Format4(item) => item.offset_data(),
Self::Format5(item) => item.offset_data(),
}
}
/// Format of this IndexSubTable.
pub fn index_format(&self) -> u16 {
match self {
Self::Format1(item) => item.index_format(),
Self::Format2(item) => item.index_format(),
Self::Format3(item) => item.index_format(),
Self::Format4(item) => item.index_format(),
Self::Format5(item) => item.index_format(),
}
}
/// Format of EBDT image data.
pub fn image_format(&self) -> u16 {
match self {
Self::Format1(item) => item.image_format(),
Self::Format2(item) => item.image_format(),
Self::Format3(item) => item.image_format(),
Self::Format4(item) => item.image_format(),
Self::Format5(item) => item.image_format(),
}
}
/// Offset to image data in EBDT table.
pub fn image_data_offset(&self) -> u32 {
match self {
Self::Format1(item) => item.image_data_offset(),
Self::Format2(item) => item.image_data_offset(),
Self::Format3(item) => item.image_data_offset(),
Self::Format4(item) => item.image_data_offset(),
Self::Format5(item) => item.image_data_offset(),
}
}
}
impl<'a> FontRead<'a> for IndexSubtable<'a> {
fn read(data: FontData<'a>) -> Result<Self, ReadError> {
let format: u16 = data.read_at(0usize)?;
match format {
IndexSubtable1Marker::FORMAT => Ok(Self::Format1(FontRead::read(data)?)),
IndexSubtable2Marker::FORMAT => Ok(Self::Format2(FontRead::read(data)?)),
IndexSubtable3Marker::FORMAT => Ok(Self::Format3(FontRead::read(data)?)),
IndexSubtable4Marker::FORMAT => Ok(Self::Format4(FontRead::read(data)?)),
IndexSubtable5Marker::FORMAT => Ok(Self::Format5(FontRead::read(data)?)),
other => Err(ReadError::InvalidFormat(other.into())),
}
}
}
impl MinByteRange for IndexSubtable<'_> {
fn min_byte_range(&self) -> Range<usize> {
match self {
Self::Format1(item) => item.min_byte_range(),
Self::Format2(item) => item.min_byte_range(),
Self::Format3(item) => item.min_byte_range(),
Self::Format4(item) => item.min_byte_range(),
Self::Format5(item) => item.min_byte_range(),
}
}
}
#[cfg(feature = "experimental_traverse")]
impl<'a> IndexSubtable<'a> {
fn dyn_inner<'b>(&'b self) -> &'b dyn SomeTable<'a> {
match self {
Self::Format1(table) => table,
Self::Format2(table) => table,
Self::Format3(table) => table,
Self::Format4(table) => table,
Self::Format5(table) => table,
}
}
}
#[cfg(feature = "experimental_traverse")]
impl std::fmt::Debug for IndexSubtable<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
self.dyn_inner().fmt(f)
}
}
#[cfg(feature = "experimental_traverse")]
impl<'a> SomeTable<'a> for IndexSubtable<'a> {
fn type_name(&self) -> &str {
self.dyn_inner().type_name()
}
fn get_field(&self, idx: usize) -> Option<Field<'a>> {
self.dyn_inner().get_field(idx)
}
}
impl Format<u16> for IndexSubtable1Marker {
const FORMAT: u16 = 1;
}
@ -1040,14 +929,24 @@ impl MinByteRange for IndexSubtable1Marker {
}
}
impl<'a> FontRead<'a> for IndexSubtable1<'a> {
fn read(data: FontData<'a>) -> Result<Self, ReadError> {
impl ReadArgs for IndexSubtable1<'_> {
type Args = (GlyphId16, GlyphId16);
}
impl<'a> FontReadWithArgs<'a> for IndexSubtable1<'a> {
fn read_with_args(
data: FontData<'a>,
args: &(GlyphId16, GlyphId16),
) -> Result<Self, ReadError> {
let (last_glyph_index, first_glyph_index) = *args;
let mut cursor = data.cursor();
cursor.advance::<u16>();
cursor.advance::<u16>();
cursor.advance::<u32>();
let sbit_offsets_byte_len =
cursor.remaining_bytes() / u32::RAW_BYTE_LEN * u32::RAW_BYTE_LEN;
(transforms::subtract_add_two(last_glyph_index, first_glyph_index))
.checked_mul(u32::RAW_BYTE_LEN)
.ok_or(ReadError::OutOfBounds)?;
cursor.advance_by(sbit_offsets_byte_len);
cursor.finish(IndexSubtable1Marker {
sbit_offsets_byte_len,
@ -1055,6 +954,21 @@ impl<'a> FontRead<'a> for IndexSubtable1<'a> {
}
}
impl<'a> IndexSubtable1<'a> {
/// A constructor that requires additional arguments.
///
/// This type requires some external state in order to be
/// parsed.
pub fn read(
data: FontData<'a>,
last_glyph_index: GlyphId16,
first_glyph_index: GlyphId16,
) -> Result<Self, ReadError> {
let args = (last_glyph_index, first_glyph_index);
Self::read_with_args(data, &args)
}
}
/// [IndexSubTable1](https://learn.microsoft.com/en-us/typography/opentype/spec/eblc#indexsubtable1-variable-metrics-glyphs-with-4-byte-offsets): variable-metrics glyphs with 4-byte offsets.
pub type IndexSubtable1<'a> = TableRef<'a, IndexSubtable1Marker>;
@ -1274,14 +1188,24 @@ impl MinByteRange for IndexSubtable3Marker {
}
}
impl<'a> FontRead<'a> for IndexSubtable3<'a> {
fn read(data: FontData<'a>) -> Result<Self, ReadError> {
impl ReadArgs for IndexSubtable3<'_> {
type Args = (GlyphId16, GlyphId16);
}
impl<'a> FontReadWithArgs<'a> for IndexSubtable3<'a> {
fn read_with_args(
data: FontData<'a>,
args: &(GlyphId16, GlyphId16),
) -> Result<Self, ReadError> {
let (last_glyph_index, first_glyph_index) = *args;
let mut cursor = data.cursor();
cursor.advance::<u16>();
cursor.advance::<u16>();
cursor.advance::<u32>();
let sbit_offsets_byte_len =
cursor.remaining_bytes() / u16::RAW_BYTE_LEN * u16::RAW_BYTE_LEN;
(transforms::subtract_add_two(last_glyph_index, first_glyph_index))
.checked_mul(u16::RAW_BYTE_LEN)
.ok_or(ReadError::OutOfBounds)?;
cursor.advance_by(sbit_offsets_byte_len);
cursor.finish(IndexSubtable3Marker {
sbit_offsets_byte_len,
@ -1289,6 +1213,21 @@ impl<'a> FontRead<'a> for IndexSubtable3<'a> {
}
}
impl<'a> IndexSubtable3<'a> {
/// A constructor that requires additional arguments.
///
/// This type requires some external state in order to be
/// parsed.
pub fn read(
data: FontData<'a>,
last_glyph_index: GlyphId16,
first_glyph_index: GlyphId16,
) -> Result<Self, ReadError> {
let args = (last_glyph_index, first_glyph_index);
Self::read_with_args(data, &args)
}
}
/// [IndexSubTable3](https://learn.microsoft.com/en-us/typography/opentype/spec/eblc#indexsubtable3-variable-metrics-glyphs-with-2-byte-offsets): variable-metrics glyphs with 2-byte offsets.
pub type IndexSubtable3<'a> = TableRef<'a, IndexSubtable3Marker>;

@ -985,9 +985,9 @@ pub struct EntryDataMarker {
design_space_count_byte_start: Option<usize>,
design_space_segments_byte_start: Option<usize>,
design_space_segments_byte_len: Option<usize>,
copy_count_byte_start: Option<usize>,
copy_indices_byte_start: Option<usize>,
copy_indices_byte_len: Option<usize>,
match_mode_and_count_byte_start: Option<usize>,
child_indices_byte_start: Option<usize>,
child_indices_byte_len: Option<usize>,
entry_id_delta_byte_start: Option<usize>,
entry_id_delta_byte_len: Option<usize>,
patch_format_byte_start: Option<usize>,
@ -1020,14 +1020,14 @@ impl EntryDataMarker {
Some(start..start + self.design_space_segments_byte_len?)
}
pub fn copy_count_byte_range(&self) -> Option<Range<usize>> {
let start = self.copy_count_byte_start?;
Some(start..start + u8::RAW_BYTE_LEN)
pub fn match_mode_and_count_byte_range(&self) -> Option<Range<usize>> {
let start = self.match_mode_and_count_byte_start?;
Some(start..start + MatchModeAndCount::RAW_BYTE_LEN)
}
pub fn copy_indices_byte_range(&self) -> Option<Range<usize>> {
let start = self.copy_indices_byte_start?;
Some(start..start + self.copy_indices_byte_len?)
pub fn child_indices_byte_range(&self) -> Option<Range<usize>> {
let start = self.child_indices_byte_start?;
Some(start..start + self.child_indices_byte_len?)
}
pub fn entry_id_delta_byte_range(&self) -> Option<Range<usize>> {
@ -1041,7 +1041,7 @@ impl EntryDataMarker {
}
pub fn codepoint_data_byte_range(&self) -> Range<usize> {
let start = self . patch_format_byte_range () . map (| range | range . end) . unwrap_or_else (|| self . entry_id_delta_byte_range () . map (| range | range . end) . unwrap_or_else (|| self . copy_indices_byte_range () . map (| range | range . end) . unwrap_or_else (|| self . copy_count_byte_range () . map (| range | range . end) . unwrap_or_else (|| self . design_space_segments_byte_range () . map (| range | range . end) . unwrap_or_else (|| self . design_space_count_byte_range () . map (| range | range . end) . unwrap_or_else (|| self . feature_tags_byte_range () . map (| range | range . end) . unwrap_or_else (|| self . feature_count_byte_range () . map (| range | range . end) . unwrap_or_else (|| self . format_flags_byte_range () . end)))))))) ;
let start = self . patch_format_byte_range () . map (| range | range . end) . unwrap_or_else (|| self . entry_id_delta_byte_range () . map (| range | range . end) . unwrap_or_else (|| self . child_indices_byte_range () . map (| range | range . end) . unwrap_or_else (|| self . match_mode_and_count_byte_range () . map (| range | range . end) . unwrap_or_else (|| self . design_space_segments_byte_range () . map (| range | range . end) . unwrap_or_else (|| self . design_space_count_byte_range () . map (| range | range . end) . unwrap_or_else (|| self . feature_tags_byte_range () . map (| range | range . end) . unwrap_or_else (|| self . feature_count_byte_range () . map (| range | range . end) . unwrap_or_else (|| self . format_flags_byte_range () . end)))))))) ;
start..start + self.codepoint_data_byte_len
}
}
@ -1069,7 +1069,7 @@ impl<'a> FontReadWithArgs<'a> for EntryData<'a> {
.contains(EntryFormatFlags::FEATURES_AND_DESIGN_SPACE)
.then(|| cursor.read::<u8>())
.transpose()?
.unwrap_or(0);
.unwrap_or_default();
let feature_tags_byte_start = format_flags
.contains(EntryFormatFlags::FEATURES_AND_DESIGN_SPACE)
.then(|| cursor.position())
@ -1092,7 +1092,7 @@ impl<'a> FontReadWithArgs<'a> for EntryData<'a> {
.contains(EntryFormatFlags::FEATURES_AND_DESIGN_SPACE)
.then(|| cursor.read::<u16>())
.transpose()?
.unwrap_or(0);
.unwrap_or_default();
let design_space_segments_byte_start = format_flags
.contains(EntryFormatFlags::FEATURES_AND_DESIGN_SPACE)
.then(|| cursor.position())
@ -1107,27 +1107,27 @@ impl<'a> FontReadWithArgs<'a> for EntryData<'a> {
if let Some(value) = design_space_segments_byte_len {
cursor.advance_by(value);
}
let copy_count_byte_start = format_flags
.contains(EntryFormatFlags::COPY_INDICES)
let match_mode_and_count_byte_start = format_flags
.contains(EntryFormatFlags::CHILD_INDICES)
.then(|| cursor.position())
.transpose()?;
let copy_count = format_flags
.contains(EntryFormatFlags::COPY_INDICES)
.then(|| cursor.read::<u8>())
let match_mode_and_count = format_flags
.contains(EntryFormatFlags::CHILD_INDICES)
.then(|| cursor.read::<MatchModeAndCount>())
.transpose()?
.unwrap_or(0);
let copy_indices_byte_start = format_flags
.contains(EntryFormatFlags::COPY_INDICES)
.unwrap_or_default();
let child_indices_byte_start = format_flags
.contains(EntryFormatFlags::CHILD_INDICES)
.then(|| cursor.position())
.transpose()?;
let copy_indices_byte_len = format_flags
.contains(EntryFormatFlags::COPY_INDICES)
let child_indices_byte_len = format_flags
.contains(EntryFormatFlags::CHILD_INDICES)
.then_some(
(copy_count as usize)
(usize::try_from(match_mode_and_count).unwrap_or_default())
.checked_mul(Uint24::RAW_BYTE_LEN)
.ok_or(ReadError::OutOfBounds)?,
);
if let Some(value) = copy_indices_byte_len {
if let Some(value) = child_indices_byte_len {
cursor.advance_by(value);
}
let entry_id_delta_byte_start = format_flags
@ -1160,9 +1160,9 @@ impl<'a> FontReadWithArgs<'a> for EntryData<'a> {
design_space_count_byte_start,
design_space_segments_byte_start,
design_space_segments_byte_len,
copy_count_byte_start,
copy_indices_byte_start,
copy_indices_byte_len,
match_mode_and_count_byte_start,
child_indices_byte_start,
child_indices_byte_len,
entry_id_delta_byte_start,
entry_id_delta_byte_len,
patch_format_byte_start,
@ -1214,13 +1214,13 @@ impl<'a> EntryData<'a> {
Some(self.data.read_array(range).unwrap())
}
pub fn copy_count(&self) -> Option<u8> {
let range = self.shape.copy_count_byte_range()?;
pub fn match_mode_and_count(&self) -> Option<MatchModeAndCount> {
let range = self.shape.match_mode_and_count_byte_range()?;
Some(self.data.read_at(range.start).unwrap())
}
pub fn copy_indices(&self) -> Option<&'a [BigEndian<Uint24>]> {
let range = self.shape.copy_indices_byte_range()?;
pub fn child_indices(&self) -> Option<&'a [BigEndian<Uint24>]> {
let range = self.shape.child_indices_byte_range()?;
Some(self.data.read_array(range).unwrap())
}
@ -1276,11 +1276,12 @@ impl<'a> SomeTable<'a> for EntryData<'a> {
),
))
}
5usize if format_flags.contains(EntryFormatFlags::COPY_INDICES) => {
Some(Field::new("copy_count", self.copy_count().unwrap()))
}
6usize if format_flags.contains(EntryFormatFlags::COPY_INDICES) => {
Some(Field::new("copy_indices", self.copy_indices().unwrap()))
5usize if format_flags.contains(EntryFormatFlags::CHILD_INDICES) => Some(Field::new(
"match_mode_and_count",
traversal::FieldType::Unknown,
)),
6usize if format_flags.contains(EntryFormatFlags::CHILD_INDICES) => {
Some(Field::new("child_indices", self.child_indices().unwrap()))
}
7usize if format_flags.contains(EntryFormatFlags::ENTRY_ID_DELTA) => {
Some(Field::new("entry_id_delta", traversal::FieldType::Unknown))
@ -1312,7 +1313,7 @@ pub struct EntryFormatFlags {
impl EntryFormatFlags {
pub const FEATURES_AND_DESIGN_SPACE: Self = Self { bits: 0b00000001 };
pub const COPY_INDICES: Self = Self { bits: 0b00000010 };
pub const CHILD_INDICES: Self = Self { bits: 0b00000010 };
pub const ENTRY_ID_DELTA: Self = Self { bits: 0b00000100 };
@ -1339,7 +1340,7 @@ impl EntryFormatFlags {
pub const fn all() -> Self {
Self {
bits: Self::FEATURES_AND_DESIGN_SPACE.bits
| Self::COPY_INDICES.bits
| Self::CHILD_INDICES.bits
| Self::ENTRY_ID_DELTA.bits
| Self::PATCH_FORMAT.bits
| Self::CODEPOINTS_BIT_1.bits
@ -1565,7 +1566,7 @@ impl std::fmt::Debug for EntryFormatFlags {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
let members: &[(&str, Self)] = &[
("FEATURES_AND_DESIGN_SPACE", Self::FEATURES_AND_DESIGN_SPACE),
("COPY_INDICES", Self::COPY_INDICES),
("CHILD_INDICES", Self::CHILD_INDICES),
("ENTRY_ID_DELTA", Self::ENTRY_ID_DELTA),
("PATCH_FORMAT", Self::PATCH_FORMAT),
("CODEPOINTS_BIT_1", Self::CODEPOINTS_BIT_1),

@ -76,7 +76,7 @@ impl<'a> FontRead<'a> for Name<'a> {
.compatible(1u16)
.then(|| cursor.read::<u16>())
.transpose()?
.unwrap_or(0);
.unwrap_or_default();
let lang_tag_record_byte_start = version
.compatible(1u16)
.then(|| cursor.position())

@ -109,7 +109,7 @@ impl<'a> FontRead<'a> for Post<'a> {
.compatible((2u16, 0u16))
.then(|| cursor.read::<u16>())
.transpose()?
.unwrap_or(0);
.unwrap_or_default();
let glyph_name_index_byte_start = version
.compatible((2u16, 0u16))
.then(|| cursor.position())

Some files were not shown because too many files have changed in this diff Show More