From 1ab1740f567a336356439506b4d14b43d15c03b1 Mon Sep 17 00:00:00 2001 From: Wesley Moore Date: Wed, 27 Apr 2022 14:18:37 +1000 Subject: [PATCH 1/3] Add abs primitives --- fathom/src/core.rs | 8 ++++++++ fathom/src/core/semantics.rs | 8 ++++++++ fathom/src/surface/elaboration.rs | 8 ++++++++ tests/succeed/primitives.fathom | 8 ++++++++ tests/succeed/primitives.snap | 8 ++++++++ 5 files changed, 40 insertions(+) diff --git a/fathom/src/core.rs b/fathom/src/core.rs index 35524d63b..a0bc4b1d8 100644 --- a/fathom/src/core.rs +++ b/fathom/src/core.rs @@ -358,6 +358,8 @@ def_prims! { S8Sub => "s8_sub", S8Mul => "s8_mul", S8Div => "s8_div", + S8Abs => "s8_abs", + S8UAbs => "s8_unsigned_abs", S16Eq => "s16_eq", S16Neq => "s16_neq", @@ -370,6 +372,8 @@ def_prims! { S16Sub => "s16_sub", S16Mul => "s16_mul", S16Div => "s16_div", + S16Abs => "s16_abs", + S16UAbs => "s16_unsigned_abs", S32Eq => "s32_eq", S32Neq => "s32_neq", @@ -382,6 +386,8 @@ def_prims! { S32Sub => "s32_sub", S32Mul => "s32_mul", S32Div => "s32_div", + S32Abs => "s32_abs", + S32UAbs => "s32_unsigned_abs", S64Eq => "s64_eq", S64Neq => "s64_neq", @@ -394,6 +400,8 @@ def_prims! { S64Sub => "s64_sub", S64Mul => "s64_mul", S64Div => "s64_div", + S64Abs => "s64_abs", + S64UAbs => "s64_unsigned_abs", PosAddU8 => "pos_add_u8", PosAddU16 => "pos_add_u16", diff --git a/fathom/src/core/semantics.rs b/fathom/src/core/semantics.rs index b77091238..4b615f3f9 100644 --- a/fathom/src/core/semantics.rs +++ b/fathom/src/core/semantics.rs @@ -463,6 +463,8 @@ fn prim_step(prim: Prim) -> Option { Prim::S8Sub => const_step!([x: S8, y: S8] => Const::S8(i8::checked_sub(*x, *y)?)), Prim::S8Mul => const_step!([x: S8, y: S8] => Const::S8(i8::checked_mul(*x, *y)?)), Prim::S8Div => const_step!([x: S8, y: S8] => Const::S8(i8::checked_div(*x, *y)?)), + Prim::S8Abs => const_step!([x: S8] => Const::S8(i8::abs(*x))), + Prim::S8UAbs => const_step!([x: S8] => Const::U8(i8::unsigned_abs(*x), UIntStyle::Decimal)), Prim::S16Eq => const_step!([x: S16, y: S16] => Const::Bool(x == y)), Prim::S16Neq => const_step!([x: S16, y: S16] => Const::Bool(x != y)), @@ -475,6 +477,8 @@ fn prim_step(prim: Prim) -> Option { Prim::S16Sub => const_step!([x: S16, y: S16] => Const::S16(i16::checked_sub(*x, *y)?)), Prim::S16Mul => const_step!([x: S16, y: S16] => Const::S16(i16::checked_mul(*x, *y)?)), Prim::S16Div => const_step!([x: S16, y: S16] => Const::S16(i16::checked_div(*x, *y)?)), + Prim::S16Abs => const_step!([x: S16] => Const::S16(i16::abs(*x))), + Prim::S16UAbs => const_step!([x: S16] => Const::U16(i16::unsigned_abs(*x), UIntStyle::Decimal)), Prim::S32Eq => const_step!([x: S32, y: S32] => Const::Bool(x == y)), Prim::S32Neq => const_step!([x: S32, y: S32] => Const::Bool(x != y)), @@ -487,6 +491,8 @@ fn prim_step(prim: Prim) -> Option { Prim::S32Sub => const_step!([x: S32, y: S32] => Const::S32(i32::checked_sub(*x, *y)?)), Prim::S32Mul => const_step!([x: S32, y: S32] => Const::S32(i32::checked_mul(*x, *y)?)), Prim::S32Div => const_step!([x: S32, y: S32] => Const::S32(i32::checked_div(*x, *y)?)), + Prim::S32Abs => const_step!([x: S32] => Const::S32(i32::abs(*x))), + Prim::S32UAbs => const_step!([x: S32] => Const::U32(i32::unsigned_abs(*x), UIntStyle::Decimal)), Prim::S64Eq => const_step!([x: S64, y: S64] => Const::Bool(x == y)), Prim::S64Neq => const_step!([x: S64, y: S64] => Const::Bool(x != y)), @@ -499,6 +505,8 @@ fn prim_step(prim: Prim) -> Option { Prim::S64Sub => const_step!([x: S64, y: S64] => Const::S64(i64::checked_sub(*x, *y)?)), Prim::S64Mul => const_step!([x: S64, y: S64] => Const::S64(i64::checked_mul(*x, *y)?)), Prim::S64Div => const_step!([x: S64, y: S64] => Const::S64(i64::checked_div(*x, *y)?)), + Prim::S64Abs => const_step!([x: S64] => Const::S64(i64::abs(*x))), + Prim::S64UAbs => const_step!([x: S64] => Const::U64(i64::unsigned_abs(*x), UIntStyle::Decimal)), Prim::PosAddU8 => const_step!([x: Pos, y: U8] => Const::Pos(u64::checked_add(*x, u64::from(*y))?)), Prim::PosAddU16 => const_step!([x: Pos, y: U16] => Const::Pos(u64::checked_add(*x, u64::from(*y))?)), diff --git a/fathom/src/surface/elaboration.rs b/fathom/src/surface/elaboration.rs index 5764e5f73..e3bb32275 100644 --- a/fathom/src/surface/elaboration.rs +++ b/fathom/src/surface/elaboration.rs @@ -257,6 +257,8 @@ impl<'arena> RigidEnv<'arena> { env.define_prim_fun(S8Sub, [&S8_TYPE, &S8_TYPE], &S8_TYPE); env.define_prim_fun(S8Mul, [&S8_TYPE, &S8_TYPE], &S8_TYPE); env.define_prim_fun(S8Div, [&S8_TYPE, &S8_TYPE], &S8_TYPE); + env.define_prim_fun(S8Abs, [&S8_TYPE], &S8_TYPE); + env.define_prim_fun(S8UAbs, [&S8_TYPE], &U8_TYPE); env.define_prim_fun(S16Eq, [&S16_TYPE, &S16_TYPE], &BOOL_TYPE); env.define_prim_fun(S16Neq, [&S16_TYPE, &S16_TYPE], &BOOL_TYPE); @@ -269,6 +271,8 @@ impl<'arena> RigidEnv<'arena> { env.define_prim_fun(S16Sub, [&S16_TYPE, &S16_TYPE], &S16_TYPE); env.define_prim_fun(S16Mul, [&S16_TYPE, &S16_TYPE], &S16_TYPE); env.define_prim_fun(S16Div, [&S16_TYPE, &S16_TYPE], &S16_TYPE); + env.define_prim_fun(S16Abs, [&S16_TYPE], &S16_TYPE); + env.define_prim_fun(S16UAbs, [&S16_TYPE], &U16_TYPE); env.define_prim_fun(S32Eq, [&S32_TYPE, &S32_TYPE], &BOOL_TYPE); env.define_prim_fun(S32Neq, [&S32_TYPE, &S32_TYPE], &BOOL_TYPE); @@ -281,6 +285,8 @@ impl<'arena> RigidEnv<'arena> { env.define_prim_fun(S32Sub, [&S32_TYPE, &S32_TYPE], &S32_TYPE); env.define_prim_fun(S32Mul, [&S32_TYPE, &S32_TYPE], &S32_TYPE); env.define_prim_fun(S32Div, [&S32_TYPE, &S32_TYPE], &S32_TYPE); + env.define_prim_fun(S32Abs, [&S32_TYPE], &S32_TYPE); + env.define_prim_fun(S32UAbs, [&S32_TYPE], &U32_TYPE); env.define_prim_fun(S64Eq, [&S64_TYPE, &S64_TYPE], &BOOL_TYPE); env.define_prim_fun(S64Neq, [&S64_TYPE, &S64_TYPE], &BOOL_TYPE); @@ -293,6 +299,8 @@ impl<'arena> RigidEnv<'arena> { env.define_prim_fun(S64Sub, [&S64_TYPE, &S64_TYPE], &S64_TYPE); env.define_prim_fun(S64Mul, [&S64_TYPE, &S64_TYPE], &S64_TYPE); env.define_prim_fun(S64Div, [&S64_TYPE, &S64_TYPE], &S64_TYPE); + env.define_prim_fun(S64Abs, [&S64_TYPE], &S64_TYPE); + env.define_prim_fun(S64UAbs, [&S64_TYPE], &U64_TYPE); env.define_prim_fun(PosAddU8, [&POS_TYPE, &U8_TYPE], &POS_TYPE); env.define_prim_fun(PosAddU16, [&POS_TYPE, &U16_TYPE], &POS_TYPE); diff --git a/tests/succeed/primitives.fathom b/tests/succeed/primitives.fathom index 35901521e..3d6124470 100644 --- a/tests/succeed/primitives.fathom +++ b/tests/succeed/primitives.fathom @@ -146,6 +146,8 @@ let _ = s8_add : S8 -> S8 -> S8; let _ = s8_sub : S8 -> S8 -> S8; let _ = s8_mul : S8 -> S8 -> S8; let _ = s8_div : S8 -> S8 -> S8; +let _ = s8_abs : S8 -> S8; +let _ = s8_unsigned_abs : S8 -> U8; let _ = s16_eq : S16 -> S16 -> Bool; let _ = s16_neq : S16 -> S16 -> Bool; @@ -158,6 +160,8 @@ let _ = s16_add : S16 -> S16 -> S16; let _ = s16_sub : S16 -> S16 -> S16; let _ = s16_mul : S16 -> S16 -> S16; let _ = s16_div : S16 -> S16 -> S16; +let _ = s16_abs : S16 -> S16; +let _ = s16_unsigned_abs : S16 -> U16; let _ = s32_eq : S32 -> S32 -> Bool; let _ = s32_neq : S32 -> S32 -> Bool; @@ -170,6 +174,8 @@ let _ = s32_add : S32 -> S32 -> S32; let _ = s32_sub : S32 -> S32 -> S32; let _ = s32_mul : S32 -> S32 -> S32; let _ = s32_div : S32 -> S32 -> S32; +let _ = s32_abs : S32 -> S32; +let _ = s32_unsigned_abs : S32 -> U32; let _ = s64_eq : S64 -> S64 -> Bool; let _ = s64_neq : S64 -> S64 -> Bool; @@ -182,6 +188,8 @@ let _ = s64_add : S64 -> S64 -> S64; let _ = s64_sub : S64 -> S64 -> S64; let _ = s64_mul : S64 -> S64 -> S64; let _ = s64_div : S64 -> S64 -> S64; +let _ = s64_abs : S64 -> S64; +let _ = s64_unsigned_abs : S64 -> U64; let _ = pos_add_u8 : Pos -> U8 -> Pos; let _ = pos_add_u16 : Pos -> U16 -> Pos; diff --git a/tests/succeed/primitives.snap b/tests/succeed/primitives.snap index 4e69271c1..6934d3856 100644 --- a/tests/succeed/primitives.snap +++ b/tests/succeed/primitives.snap @@ -137,6 +137,8 @@ let _ : _ = s8_add; let _ : _ = s8_sub; let _ : _ = s8_mul; let _ : _ = s8_div; +let _ : _ = s8_abs; +let _ : _ = s8_unsigned_abs; let _ : _ = s16_eq; let _ : _ = s16_neq; let _ : _ = s16_gt; @@ -148,6 +150,8 @@ let _ : _ = s16_add; let _ : _ = s16_sub; let _ : _ = s16_mul; let _ : _ = s16_div; +let _ : _ = s16_abs; +let _ : _ = s16_unsigned_abs; let _ : _ = s32_eq; let _ : _ = s32_neq; let _ : _ = s32_gt; @@ -159,6 +163,8 @@ let _ : _ = s32_add; let _ : _ = s32_sub; let _ : _ = s32_mul; let _ : _ = s32_div; +let _ : _ = s32_abs; +let _ : _ = s32_unsigned_abs; let _ : _ = s64_eq; let _ : _ = s64_neq; let _ : _ = s64_gt; @@ -170,6 +176,8 @@ let _ : _ = s64_add; let _ : _ = s64_sub; let _ : _ = s64_mul; let _ : _ = s64_div; +let _ : _ = s64_abs; +let _ : _ = s64_unsigned_abs; let _ : _ = pos_add_u8; let _ : _ = pos_add_u16; let _ : _ = pos_add_u32; From b551f96443dec9b0c955b19552e41c73904a3387 Mon Sep 17 00:00:00 2001 From: Wesley Moore Date: Wed, 27 Apr 2022 16:17:00 +1000 Subject: [PATCH 2/3] Add part of glyf and loca to OpenType format --- formats/data/opentype/woff/README.md | 54 ++ formats/data/opentype/woff/valid-001.snap | 320 ++++++++++ formats/data/opentype/woff/valid-001.ttf | Bin 0 -> 1856 bytes formats/data/opentype/woff/valid-005.snap | 550 ++++++++++++++++++ formats/data/opentype/woff/valid-005.ttf | Bin 0 -> 3616 bytes formats/data/opentype/woff2/README.md | 30 + .../opentype/woff2/SFNT-TTF-Composite.snap | 540 +++++++++++++++++ .../opentype/woff2/SFNT-TTF-Composite.ttf | Bin 0 -> 3892 bytes formats/opentype.fathom | 96 ++- formats/opentype.snap | 32 +- 10 files changed, 1617 insertions(+), 5 deletions(-) create mode 100644 formats/data/opentype/woff/README.md create mode 100644 formats/data/opentype/woff/valid-001.snap create mode 100644 formats/data/opentype/woff/valid-001.ttf create mode 100644 formats/data/opentype/woff/valid-005.snap create mode 100644 formats/data/opentype/woff/valid-005.ttf create mode 100644 formats/data/opentype/woff2/README.md create mode 100644 formats/data/opentype/woff2/SFNT-TTF-Composite.snap create mode 100644 formats/data/opentype/woff2/SFNT-TTF-Composite.ttf diff --git a/formats/data/opentype/woff/README.md b/formats/data/opentype/woff/README.md new file mode 100644 index 000000000..beb5f6b75 --- /dev/null +++ b/formats/data/opentype/woff/README.md @@ -0,0 +1,54 @@ +WOFF Test Fonts +=============== + +The fonts in this subdirectory are from the [WC3 WOFF WG test suite][woff]. +Licensed under the [W3C Software and Document Notice and License][licence]. + +### Font Info + +* `valid-001.ttf`: CFF +* `valid-005.ttf`: TTF simple glyph + +### Generating The Fonts + +The fonts were generated via a docker container as follows. +The container was used because the scripts require Python 2: + + docker run --rm -it -v $(pwd):/woff debian:8-slim + +Then in the container: + + cd /woff + apt update + apt install fonttools python-numpy + adduser wmoore + cd generators + python FormatTestCaseGenerator.py + +Then outside the container the fonts were converted back to TTFs from the WOFF files: + + for f in valid-00*.woff; do woff2sfnt-zopfli "$f" > "${f%.woff}.ttf"; done + +where `woff2sfnt-zopfli` is . + +### License + +> By obtaining and/or copying this work, you (the licensee) agree that you have read, understood, and will comply with the following terms and conditions. +> +> Permission to copy, modify, and distribute this work, with or without modification, for any purpose and without fee or royalty is hereby granted, provided that you include the following on ALL copies of the work or portions thereof, including modifications: +> +> * The full text of this NOTICE in a location viewable to users of the redistributed or derivative work. +> * Any pre-existing intellectual property disclaimers, notices, or terms and conditions. If none exist, the W3C Software and Document Short Notice should be included. +> * Notice of any changes or modifications, through a copyright statement on the new code or document such as "This software or document includes material copied from or derived from [title and URI of the W3C document]. Copyright © [YEAR] W3C® (MIT, ERCIM, Keio, Beihang)." +> +> ### Disclaimers +> +> THIS WORK IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE OR DOCUMENT WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. +> +> COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENT. +> +> The name and trademarks of copyright holders may NOT be used in advertising or publicity pertaining to the work without specific, written prior permission. Title to copyright in this work will at all times remain with copyright holders. + +[woff]: https://github.com/w3c/woff/tree/c8402e6a5a892d45ba8193c22aed06be92833be2 +[licence]: http://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + diff --git a/formats/data/opentype/woff/valid-001.snap b/formats/data/opentype/woff/valid-001.snap new file mode 100644 index 000000000..1577068b9 --- /dev/null +++ b/formats/data/opentype/woff/valid-001.snap @@ -0,0 +1,320 @@ +stdout = ''' +0 = [ + { + start = 0, + directory = { + sfnt_version = 1330926671, + _sfnt_version = {}, + num_tables = 9, + search_range = 128, + entry_selector = 3, + range_shift = 16, + table_records = [ + { + table_id = 1128678944, + checksum = 2312911615, + offset = 1280, + length = 558, + link = 1280, + }, + { + table_id = 1330851634, + checksum = 2107474081, + offset = 256, + length = 96, + link = 256, + }, + { + table_id = 1668112752, + checksum = 11469276, + offset = 1016, + length = 230, + link = 1016, + }, + { + table_id = 1751474532, + checksum = 4199932307, + offset = 156, + length = 54, + link = 156, + }, + { + table_id = 1751672161, + checksum = 200869999, + offset = 212, + length = 36, + link = 212, + }, + { + table_id = 1752003704, + checksum = 399966408, + offset = 1840, + length = 16, + link = 1840, + }, + { + table_id = 1835104368, + checksum = 282624, + offset = 248, + length = 6, + link = 248, + }, + { + table_id = 1851878757, + checksum = 720423648, + offset = 352, + length = 663, + link = 352, + }, + { + table_id = 1886352244, + checksum = 4290248754, + offset = 1248, + length = 32, + link = 1248, + }, + ], + }, + }, +] +156 = [ + { + major_version = 1, + _major_version = {}, + minor_version = 0, + font_revision = 65536, + checksum_adjustment = 1155811448, + magic_number = 1594834165, + _magic_number = {}, + flags = 3, + units_per_em = 1000, + _units_per_em = {}, + created = 3374127268, + modified = 3374417235, + glyph_extents = { + x_min = 100, + y_min = -10, + x_max = 2204, + y_max = 710, + }, + mac_style = 0, + lowest_rec_ppem = 3, + font_direction_hint = 2, + index_to_loc_format = 0, + glyph_data_format = 0, + }, +] +212 = [ + { + major_version = 1, + _major_version = {}, + minor_version = 0, + ascent = 750, + descent = -250, + line_gap = 9, + advance_width_max = 2304, + min_left_side_bearing = 100, + min_right_side_bearing = 100, + x_max_extent = 2204, + caret_slope = { + rise = 1, + run = 0, + }, + caret_offset = 0, + _reserved0 = 0, + _reserved1 = 0, + _reserved2 = 0, + _reserved3 = 0, + metric_data_format = 0, + number_of_long_horizontal_metrics = 4, + }, +] +248 = [ + { + version = 20480, + num_glyphs = 4, + }, +] +256 = [ + {}, +] +352 = [ + { + table_start = 352, + version = 0, + name_count = 14, + storage_offset = 174, + }, +] +1016 = [ + { + table_start = 1016, + version = 0, + num_tables = 3, + encoding_records = [ + { + platform = 0, + encoding = 3, + subtable_offset = { + offset = 28, + link = 1044, + }, + }, + { + platform = 1, + encoding = 0, + subtable_offset = { + offset = 76, + link = 1092, + }, + }, + { + platform = 3, + encoding = 1, + subtable_offset = { + offset = 28, + link = 1044, + }, + }, + ], + }, +] +1044 = [ + { + table_start = 1044, + format = 4, + data = { + length = 48, + language = 0, + seg_count_x2 = 8, + seg_count = 4, + search_range = 8, + entry_selector = 2, + range_shift = 0, + end_code = [ + 32, + 70, + 80, + 65535, + ], + _reserved_pad = 0, + start_code = [ + 32, + 70, + 80, + 65535, + ], + id_delta = [ + -31, + -68, + -77, + 1, + ], + id_range_offsets = [ + 0, + 0, + 0, + 0, + ], + }, + }, +] +1092 = [ + { + table_start = 1092, + format = 6, + data = { + length = 154, + language = 0, + first_code = 9, + entry_count = 72, + glyph_id_array = [ + 1, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 2, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 3, + ], + }, + }, +] +1248 = [ + {}, +] +1280 = [ + {}, +] +1840 = [ + { + h_metrics = [], + }, +] +''' +stderr = '' diff --git a/formats/data/opentype/woff/valid-001.ttf b/formats/data/opentype/woff/valid-001.ttf new file mode 100644 index 0000000000000000000000000000000000000000..b45d434c9896cadc7e5c707d0728b759f7761c6e GIT binary patch literal 1856 zcmcIlZA@EL7=CWsd)o#CoD>b8mpHem(3K`IzWkwsjs(^=qta=jtU#d%?S)bZS-J>I zw#d*p^#@DG5*IaoEa;C#wiwX;aemDo&LzfVn31??vN(-#o?8!C-`n0Ah@0_`=jNRA zywCe_-t*pb?)CV59#}C2BMNr8T=LA7#uOj|FxWkvJDdkkPMrb-lCi%x92miS!WF=% zl6*ZB4D|i+`06W!=c(6)h{#D=6vCIOZw-ZGllOjuPXV)o1!N37Ck3oL-ieZu!1#vOB-|7L3LpiN|MU_r0E;D-U;~FZH`+ z-f)3rBMcf#jeHC@QxdFJpbveP`OF3~%JgUgC=VK85^o8|v<(}M8upRgo|%QG;S{Pi zcxW(PhAih+B0=FiW$8_?1uZvOw-J6b+$1{^spa8a-BZ9_Bxj-+U?wSpjVMQ5v4PfF*0B-I_(I1fY!l2n7I93d*0HpKx1dT` z_Iv0E_=00Gna;xA;K2BBAX;O0I2=vdZksfNU@W4fn3?G6RLyXX_G_#lF0gPi90Yp&)I~?h!32rEekhbY>@2qdevl^Ry zvupgjRTo8!QU-(R=<=o&z38O8wDmXU5hBYNdein3q|fN=sKrjoElhb2QB2LIpRymO z$USrbw0+oVu0cH-$W}%RTG2(lgKFW$9zt%ahM#QJe@>M#gTE z6spjOb}o&2FV#;~hjuE6E2Vp(-B$}e+KrMaq&G!hg)B;~rj}A?bT6VIAwi>+POIjx zwd|ac?lk^4t2=pb=CgNyBb(hJajEyU@5(=$0Fw!VAQax_0BU@tnh&+apq3idGSknq zWmJ~=t1nfw1`c!=hzIZ<1?&?oniHBuS%tobKPrG z6ReFdsPlYU;#Wy#(@8JkH5cD!`-D%5JXgw-)pB;h#;R9Wn3W&d|vJTA2Z0Cot2V@3hBjL`)%5PCDXM(i-n`_ EFF(7zi~s-t literal 0 HcmV?d00001 diff --git a/formats/data/opentype/woff/valid-005.snap b/formats/data/opentype/woff/valid-005.snap new file mode 100644 index 000000000..ae160e56b --- /dev/null +++ b/formats/data/opentype/woff/valid-005.snap @@ -0,0 +1,550 @@ +stdout = ''' +0 = [ + { + start = 0, + directory = { + sfnt_version = 65536, + _sfnt_version = {}, + num_tables = 11, + search_range = 128, + entry_selector = 3, + range_shift = 48, + table_records = [ + { + table_id = 1330851634, + checksum = 2376691328, + offset = 312, + length = 96, + link = 312, + }, + { + table_id = 1447316824, + checksum = 1856861796, + offset = 424, + length = 1504, + link = 424, + }, + { + table_id = 1668112752, + checksum = 39519805, + offset = 1928, + length = 338, + link = 1928, + }, + { + table_id = 1735162214, + checksum = 1310482003, + offset = 2280, + length = 680, + link = 2280, + }, + { + table_id = 1751474532, + checksum = 61377574, + offset = 188, + length = 54, + link = 188, + }, + { + table_id = 1751672161, + checksum = 404689708, + offset = 244, + length = 36, + link = 244, + }, + { + table_id = 1752003704, + checksum = 819134874, + offset = 408, + length = 16, + link = 408, + }, + { + table_id = 1819239265, + checksum = 22282304, + offset = 2268, + length = 10, + link = 2268, + }, + { + table_id = 1835104368, + checksum = 721102, + offset = 280, + length = 32, + link = 280, + }, + { + table_id = 1851878757, + checksum = 1076474391, + offset = 2960, + length = 621, + link = 2960, + }, + { + table_id = 1886352244, + checksum = 4285071462, + offset = 3584, + length = 32, + link = 3584, + }, + ], + }, + }, +] +188 = [ + { + major_version = 1, + _major_version = {}, + minor_version = 0, + font_revision = 65536, + checksum_adjustment = 2594036854, + magic_number = 1594834165, + _magic_number = {}, + flags = 11, + units_per_em = 2048, + _units_per_em = {}, + created = 3371744314, + modified = 3374417236, + glyph_extents = { + x_min = 205, + y_min = -20, + x_max = 4514, + y_max = 1454, + }, + mac_style = 0, + lowest_rec_ppem = 9, + font_direction_hint = 2, + index_to_loc_format = 0, + glyph_data_format = 0, + }, +] +244 = [ + { + major_version = 1, + _major_version = {}, + minor_version = 0, + ascent = 1454, + descent = -20, + line_gap = 0, + advance_width_max = 4719, + min_left_side_bearing = 205, + min_right_side_bearing = 204, + x_max_extent = 4514, + caret_slope = { + rise = 1, + run = 0, + }, + caret_offset = 0, + _reserved0 = 0, + _reserved1 = 0, + _reserved2 = 0, + _reserved3 = 0, + metric_data_format = 0, + number_of_long_horizontal_metrics = 4, + }, +] +280 = [ + { + version = 65536, + num_glyphs = 4, + }, +] +312 = [ + {}, +] +408 = [ + { + h_metrics = [], + }, +] +424 = [ + {}, +] +1928 = [ + { + table_start = 1928, + version = 0, + num_tables = 3, + encoding_records = [ + { + platform = 0, + encoding = 3, + subtable_offset = { + offset = 28, + link = 1956, + }, + }, + { + platform = 1, + encoding = 0, + subtable_offset = { + offset = 76, + link = 2004, + }, + }, + { + platform = 3, + encoding = 1, + subtable_offset = { + offset = 28, + link = 1956, + }, + }, + ], + }, +] +1956 = [ + { + table_start = 1956, + format = 4, + data = { + length = 48, + language = 0, + seg_count_x2 = 8, + seg_count = 4, + search_range = 8, + entry_selector = 2, + range_shift = 0, + end_code = [ + 32, + 70, + 80, + 65535, + ], + _reserved_pad = 0, + start_code = [ + 32, + 70, + 80, + 65535, + ], + id_delta = [ + -31, + -68, + -77, + 1, + ], + id_range_offsets = [ + 0, + 0, + 0, + 0, + ], + }, + }, +] +2004 = [ + { + table_start = 2004, + format = 0, + data = { + length = 262, + language = 0, + glyph_id_array = [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 2, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 3, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ], + }, + }, +] +2268 = [ + { + offsets = [ + 0, + 0, + ], + }, +] +2280 = [ + { + glyphs = [ + { + header = { + number_of_contours = 5, + x_min = 205, + y_min = 0, + x_max = 4514, + y_max = 1434, + }, + data = { + end_pts_of_contours = [ + 7, + 17, + 23, + 27, + 30, + ], + instruction_length = 0, + instructions = [], + }, + }, + ], + }, +] +2960 = [ + { + table_start = 2960, + version = 0, + name_count = 14, + storage_offset = 174, + }, +] +3584 = [ + {}, +] +''' +stderr = '' diff --git a/formats/data/opentype/woff/valid-005.ttf b/formats/data/opentype/woff/valid-005.ttf new file mode 100644 index 0000000000000000000000000000000000000000..0354c52aedf7b31804ce1ed2959f22690da52db4 GIT binary patch literal 3616 zcmdVdeOy)b9S88wIro7F5xI(BfZPixJ|SMXJcWpe3O=MLlA;iJl?x(pFY=TIrB^#^~!SgP_@ZsV*d%ap>90&NV zV_9KU?TX5oQDt)g|BnH+Yl*{Nq3hZZ&wEdCPg}x*LFNGo%$KfS}=&2GND;g-8+x||L^vjww^ zaI*@>7RrOv(R;hIK#p41+6ensa2#3jvC#51R17){4;njzka5zLtwNymy=7{xpe2{ap{>3A^*iOdr)hUSVBVP&3#Bsy8l zLo#zdY;+1z=u~kUQkkbCjou~BKsxhGWY7ZKNoR?(k;z<$v2>1Dge>N}F^!i05vwts zc`5FqHDWDhFxO!wb)tZ}#CptPUWVDUL2N`Ja}(y!W)#sD@m}1`yc~1s3h_S7V{Sz; zZNq$ezxV(aFt0=jT_vtYDf5H4hdzWd`mneL<;;&@Azdr3gPnOj7STt=$FP`r11ji7 zIOyZzCR8$SMiqTRd=g8Tx1gG~V=3(rpF$1u)2O9e#b;2*+zBUr7B0F?+>UzY9au(p zio4Ljyc>;l51Qz6;$Ac}KaUprg18U&GIwD)-7mg~70fT;K6(JH^q_bMZOn&pKRqJ8 zj0c#HVkJF>RkT|?j@8Vs;6Zvqd=(EdzlMkDNvxsY5>Md~=F?b9zb(Fwb|F5}ou{c$WTJd>`AGFJL?UK>Q7MF#i@i>4(@wKN5e3 z-ORto9{LCIBA#RZBlgli;d%P8_-DMp{1@z_e-$sGi}@4mr=N;{!;8#+$4m4dI6(g? z{tE}0FXIrsB3{K|=Ff11Uc<}u-{N%~Wxj!9^mDNX-OO$rryjgQ!5P@QM|tN0eo1ta zqM+y3kCP;S+SFn}9^XaJSIP5{=alD|?=BW|s_@QQl5dAhIJdj_W%*ZgnKry{<;#Xn_YwCM_i=ZSq4UOj?oC>$nyQ@F zCUk8jvQ=jL1b!)3@+)_i|57H~z?f8G0*le)2qYFw<*FV19(*4dJ?)zp+kby%V
fMu|2IQT}g?LV};~2 zB}VsuH=>rk)3fX3Np(TUA?K3;iakQ%VQ=WRo` zIWTiU^W^c4y!gTSD@xbwEwM~ov9Dr!^{kxOsCc8<+;@8Y#)9mssly}l+w9A>EgY5G zvZp+&Y)XnLFr;s=|7WAyJG#0$+Lf)!nGXWnZ?={nKX}Tmt;I#&rnTMWS>;n~rat|G z`v$0uJqOHYL#a8drlYvHy(X*YfO6)O^x3HqW^?IM{p;6Td3BRJsboiU?vR|4w2TF_ zrp0H}Ih%6kchqEs4-Ov@s~T6o){-$auOd6kUNmF)m_>E1Qw!JHQ^O*{jQyepx{F^u z-4k}&-K{QD#(tfKysuX<4*A|?h3h!q%8+lqAJ4omt&VG=P+!(_?KaVu4J)jhkaSc)x>FE)?=g+>B|NTS0?+i5%Ef$FZ&}w*)p#n zFV9lsXl$|+73CE=s+w!<4f7m}@?6fQ#(A!WnrdfNeuJyIKJ%7}7GKTGWNVW3e_omE zXlSf&qgYaRF7pPh=iHltpl$kxLXU6|tm{=T%&+ z)N-NJzTs(D_;WnKf%n^Di@cB^wf|TB_x1$} C6-S@| literal 0 HcmV?d00001 diff --git a/formats/data/opentype/woff2/README.md b/formats/data/opentype/woff2/README.md new file mode 100644 index 000000000..39f4c3ced --- /dev/null +++ b/formats/data/opentype/woff2/README.md @@ -0,0 +1,30 @@ +WOFF2 Test Fonts +================ + +The fonts in this subdirectory are from the [WC3 WOFF2 WG test suite][woff2]. +Licensed under the [W3C Software and Document Notice and License][licence]. + +### Font Info + +* `SFNT-TTF-Composite.ttf`: TTF composite glyph + +### License + +> By obtaining and/or copying this work, you (the licensee) agree that you have read, understood, and will comply with the following terms and conditions. +> +> Permission to copy, modify, and distribute this work, with or without modification, for any purpose and without fee or royalty is hereby granted, provided that you include the following on ALL copies of the work or portions thereof, including modifications: +> +> * The full text of this NOTICE in a location viewable to users of the redistributed or derivative work. +> * Any pre-existing intellectual property disclaimers, notices, or terms and conditions. If none exist, the W3C Software and Document Short Notice should be included. +> * Notice of any changes or modifications, through a copyright statement on the new code or document such as "This software or document includes material copied from or derived from [title and URI of the W3C document]. Copyright © [YEAR] W3C® (MIT, ERCIM, Keio, Beihang)." +> +> ### Disclaimers +> +> THIS WORK IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE OR DOCUMENT WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. +> +> COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENT. +> +> The name and trademarks of copyright holders may NOT be used in advertising or publicity pertaining to the work without specific, written prior permission. Title to copyright in this work will at all times remain with copyright holders. + +[woff2]: https://github.com/w3c/woff2-tests/tree/7efc18fb4d4c488ef7ebe04e6cb80ee0ef36741f +[licence]: http://www.w3.org/Consortium/Legal/2015/copyright-software-and-document diff --git a/formats/data/opentype/woff2/SFNT-TTF-Composite.snap b/formats/data/opentype/woff2/SFNT-TTF-Composite.snap new file mode 100644 index 000000000..499fbacf0 --- /dev/null +++ b/formats/data/opentype/woff2/SFNT-TTF-Composite.snap @@ -0,0 +1,540 @@ +stdout = ''' +0 = [ + { + start = 0, + directory = { + sfnt_version = 65536, + _sfnt_version = {}, + num_tables = 11, + search_range = 128, + entry_selector = 3, + range_shift = 48, + table_records = [ + { + table_id = 1330851634, + checksum = 2376691328, + offset = 312, + length = 96, + link = 312, + }, + { + table_id = 1447316824, + checksum = 1856861796, + offset = 444, + length = 1504, + link = 444, + }, + { + table_id = 1668112752, + checksum = 39519805, + offset = 1948, + length = 338, + link = 1948, + }, + { + table_id = 1735162214, + checksum = 4060625394, + offset = 2316, + length = 836, + link = 2316, + }, + { + table_id = 1751474532, + checksum = 227156863, + offset = 188, + length = 54, + link = 188, + }, + { + table_id = 1751672161, + checksum = 391318683, + offset = 244, + length = 36, + link = 244, + }, + { + table_id = 1752003704, + checksum = 819134874, + offset = 408, + length = 34, + link = 408, + }, + { + table_id = 1819239265, + checksum = 58589866, + offset = 2288, + length = 26, + link = 2288, + }, + { + table_id = 1835104368, + checksum = 1376537, + offset = 280, + length = 32, + link = 280, + }, + { + table_id = 1851878757, + checksum = 3342286371, + offset = 3152, + length = 708, + link = 3152, + }, + { + table_id = 1886352244, + checksum = 4285071462, + offset = 3860, + length = 32, + link = 3860, + }, + ], + }, + }, +] +188 = [ + { + major_version = 1, + _major_version = {}, + minor_version = 0, + font_revision = 65536, + checksum_adjustment = 773317341, + magic_number = 1594834165, + _magic_number = {}, + flags = 11, + units_per_em = 2048, + _units_per_em = {}, + created = 3371744314, + modified = 3553631405, + glyph_extents = { + x_min = 0, + y_min = -20, + x_max = 4514, + y_max = 1454, + }, + mac_style = 0, + lowest_rec_ppem = 9, + font_direction_hint = 2, + index_to_loc_format = 0, + glyph_data_format = 0, + }, +] +244 = [ + { + major_version = 1, + _major_version = {}, + minor_version = 0, + ascent = 1454, + descent = -20, + line_gap = 0, + advance_width_max = 4719, + min_left_side_bearing = 0, + min_right_side_bearing = -1478, + x_max_extent = 4514, + caret_slope = { + rise = 1, + run = 0, + }, + caret_offset = 0, + _reserved0 = 0, + _reserved1 = 0, + _reserved2 = 0, + _reserved3 = 0, + metric_data_format = 0, + number_of_long_horizontal_metrics = 5, + }, +] +280 = [ + { + version = 65536, + num_glyphs = 12, + }, +] +312 = [ + {}, +] +408 = [ + { + h_metrics = [], + }, +] +444 = [ + {}, +] +1948 = [ + { + table_start = 1948, + version = 0, + num_tables = 3, + encoding_records = [ + { + platform = 0, + encoding = 3, + subtable_offset = { + offset = 28, + link = 1976, + }, + }, + { + platform = 1, + encoding = 0, + subtable_offset = { + offset = 76, + link = 2024, + }, + }, + { + platform = 3, + encoding = 1, + subtable_offset = { + offset = 28, + link = 1976, + }, + }, + ], + }, +] +1976 = [ + { + table_start = 1976, + format = 4, + data = { + length = 48, + language = 0, + seg_count_x2 = 8, + seg_count = 4, + search_range = 8, + entry_selector = 2, + range_shift = 0, + end_code = [ + 32, + 70, + 80, + 65535, + ], + _reserved_pad = 0, + start_code = [ + 32, + 70, + 80, + 65535, + ], + id_delta = [ + -31, + -68, + -77, + 1, + ], + id_range_offsets = [ + 0, + 0, + 0, + 0, + ], + }, + }, +] +2024 = [ + { + table_start = 2024, + format = 0, + data = { + length = 262, + language = 0, + glyph_id_array = [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 2, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 3, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ], + }, + }, +] +2288 = [ + { + offsets = [ + 0, + 0, + ], + }, +] +2316 = [ + { + glyphs = [ + { + header = { + number_of_contours = -1, + x_min = 205, + y_min = 0, + x_max = 4514, + y_max = 1434, + }, + data = {}, + }, + ], + }, +] +3152 = [ + { + table_start = 3152, + version = 0, + name_count = 14, + storage_offset = 174, + }, +] +3860 = [ + {}, +] +''' +stderr = '' diff --git a/formats/data/opentype/woff2/SFNT-TTF-Composite.ttf b/formats/data/opentype/woff2/SFNT-TTF-Composite.ttf new file mode 100644 index 0000000000000000000000000000000000000000..1c6fe829a542d1b43139ffeb8d210d4322d5a035 GIT binary patch literal 3892 zcmdVdd014}83yq8&c+U+EQ-JkjG{)xfdN5+h@jwxpb|ka;wS?mFoP_{eMw@BCPs~r z7&I=##3f2h)Ru@n?t9NY z_nvcRhI#w?%4@gs zIJU+)*QQ;eIRJQn$>WGx+oC#zDt&mqH;+vYTdn==lngWAUjS%M*Et&+-BqXnfz5UFQ{O{gaeU&_kzh)mwQ>W9MG`0V=whxqU;mpSQQkPKO~($ELWMAbT~lhi7`0vk(7#Q=q6D{BgtE4R09SZjRH7`of#~iT?0m z4uCHW6ocT$+ynkJ7y-1W*b9NoAqb+OVi?Q>;S)^8!qv^T`Vp^ z5%W?M(`A@Jmy0V9@r<@F??l zu#Uco_4K>q_wX3=X*^E9FTRBh%x~if`i}SmY-Ii+Hqm#nnf^#TgD2e`_%XK7_r&+n z%=`gb=uhwzJuChcPcwgrt@LN&M|g($=V+zBz&84^_zAW%{}RvAbK! z{Z#x6yO}Sbjs8Zwi07Dpi#_yrc%J@V`~zNK{v3PhAH_@9$NUBM)63$YaDe$syh#6y zgY=5{7aU@~igtQUypETc|BA!(241Fr6K~=b=36*I|1NgmD6ZFdZ&js20=*&{r+cR&=$Er)vw{mVqa7@=rm(X!kx$g3H_0_k!4!f?oj=B6h z*C_h8Sl5elI1-c?C1ya3S1+qpIjWhZ9Ci6*xn_@QxxQ52db8r{RZX&Tw)0z7F7g_F zA?n?gi|RdZR`9#&Y`Z_t>ATuiE^0DweWGu@^^t31XM4JAo)1A3s|Q;{W0I}G=H!^f zXiaEHpvJ5u#hJ~)*2Lk;=Jz^woj9Q>X*#}a^yp>Bn-uTnmVNtLnl%j_2aQJkOk;X= zOL1{?b-J?UwNo8or_`T@{8;oW^?SI6hyeO)W4sK}8mqLDI6OtMDr!_>w7QU;u71TK z`oVeDQlnA1pjjZ}b6?Un za}_mS?Y%i(YmN^?=7ELRgf7Q8D}sW118pO$j_)8Kd^7^GTVafvj=A_ zY%5EjH7+UGw?{yrx4zw#P`aZjt6yg6@YIrm32~{lj>gOxE!FAaQQ?DPHHOu%FHG&9 zQ=XA-E6f`>Y)=JjAM6Mdf7N@uwPJM zfX{zD4seCp?s@Jg{LVeUK>iNAc+~lT(Q^G3?a4Z>74tk<&);B;CmZ;TTjj~#2;&^f zC!fxTCGni=I||HY_kv`@8HHr3ebi|li9oQ}qZB4>Sdm7_AZ-q}=_cIPFYnrVra1k0Ug zZr{x0sWaVP-%#arm@Jlrc#Fki>bgX2o~_@mKeSuxCQtJwX`d^>d_L=QU_v46Xy95) zO@&gD&2?EV>SzP1c*f3ErJZZLCVr|muF#5j#C0IgJ9xH%$4-`3v#x`+a+#g1TZgoN z*~*>wOhY1Pq6EJGvz`s@*0<^GTfOvK?VXADQ|}rtdkc@dx6(EG&avM;^6vNVK6X>L T(VPBZ{GMseU7`N3dH41e*3fcg literal 0 HcmV?d00001 diff --git a/formats/opentype.fathom b/formats/opentype.fathom index d82cc9970..9517f0b35 100644 --- a/formats/opentype.fathom +++ b/formats/opentype.fathom @@ -2,6 +2,8 @@ //~ example-data = [ //~ "data/opentype/aots/*.otf", +//~ "data/opentype/woff/*.ttf", +//~ "data/opentype/woff2/*.ttf", //~ ] // ----------------------------------------------------------------------------- @@ -378,7 +380,7 @@ let cmap_subtable_format2 = fun (platform : Repr platform_id) => { // /// Variable-length array of SubHeader records. // sub_headers[ ] <- SubHeader, // /// Variable-length array containing subarrays used for mapping the low byte of 2-byte characters. - // glyph_id_array[ ] <- uint16, + // glyph_id_array[ ] <- u16be, }; /// # Format 4: Segment mapping to delta values @@ -1002,6 +1004,94 @@ let naming = { // } }; +/// # Index to location table +/// +/// ## References +/// +/// - [Microsoft's OpenType Spec: `loca` table](https://docs.microsoft.com/en-us/typography/opentype/spec/loca) +/// - [Apple's TrueType Reference Manual: The `'loca'` table](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6loca.html) +let index_to_location = fun (num_glyphs : U16) => fun (index_to_loc_format : S16) => { + offsets <- match index_to_loc_format { + // short offsets + 0 => array16 (u16_add num_glyphs 1) u16be, // TODO Offset16 + // long offsets + 1 => array16 (u16_add num_glyphs 1) u32be, // TODO Offset32 + _ => fail + } +}; + +/// # Glyph Header +/// +/// ## References +/// +/// - [Microsoft's OpenType Spec: Glyph Headers](https://docs.microsoft.com/en-us/typography/opentype/spec/glyf#glyph-headers) +/// - [Apple's TrueType Reference Manual: The `'loca'` table](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6glyf.html) +let glyph_header = { + /// If the number of contours is greater than or equal to zero, this is a simple glyph. If + /// negative, this is a composite glyph — the value -1 should be used for composite glyphs. + number_of_contours <- s16be, + /// Minimum x for coordinate data. + x_min <- s16be, + /// Minimum y for coordinate data. + y_min <- s16be, + /// Maximum x for coordinate data. + x_max <- s16be, + /// Maximum y for coordinate data. + y_max <- s16be, +}; + +/// # Simple glyph description +/// +/// ## References +/// +/// - [Microsoft's OpenType Spec: Glyph Headers](https://docs.microsoft.com/en-us/typography/opentype/spec/glyf#simple-glyph-description) +/// - [Apple's TrueType Reference Manual: The `'loca'` table](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6glyf.html) +let simple_glyph = fun (number_of_contours : U16) => { + /// Array of point indices for the last point of each contour, in increasing numeric order. + end_pts_of_contours <- array16 number_of_contours u16be, + /// Total number of bytes for instructions. If instructionLength is zero, no instructions are + /// present for this glyph, and this field is followed directly by the flags field. + instruction_length <- u16be, + /// Array of instruction byte code for the glyph. + instructions <- array16 instruction_length u8, + /// Array of flag elements. See below for details regarding the number of flag array elements. + // flags[variable] <- uint8, + /// xCoordinates[variable] Contour point x-coordinates. See below for details regarding the + /// number of coordinate array elements. Coordinate for the first point is relative to (0,0); + /// others are relative to previous point. + // or int16 <- uint8, + /// yCoordinates[variable] Contour point y-coordinates. See below for details regarding the + /// number of coordinate array elements. Coordinate for the first point is relative to (0,0); + /// others are relative to previous point. + // or int16 <- uint8, +}; + +/// # Composite glyph description +/// +/// ## References +/// +/// - [Microsoft's OpenType Spec: Glyph Headers](https://docs.microsoft.com/en-us/typography/opentype/spec/glyf#composite-glyph-description) +/// - [Apple's TrueType Reference Manual: The `'loca'` table](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6glyf.html) +let composite_glyph = unknown_table; // TODO + +/// # TrueType glyph +let glyph = { + header <- glyph_header, + data <- match (s16_lt header.number_of_contours 0) { + true => composite_glyph, + false => simple_glyph (s16_unsigned_abs header.number_of_contours), + } +}; + +/// # Glyph data table (TrueType) +/// +/// ## References +/// +/// - [Microsoft's OpenType Spec: Glyph Data](https://docs.microsoft.com/en-us/typography/opentype/spec/glyf) +/// - [Apple's TrueType Reference Manual: The `'glyf'` table](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6glyf.html) +let glyph_data = fun (num_glyphs : U16) => { + glyphs <- array16 num_glyphs glyph, +}; // ----------------------------------------------------------------------------- @@ -1107,8 +1197,8 @@ let font_table = fun (table_id : Repr tag) => match table_id { // https://docs.microsoft.com/en-us/typography/opentype/spec/otff#tables-related-to-truetype-outlines "cvt " => unknown_table, "fpgm" => unknown_table, - "glyf" => unknown_table, - "loca" => unknown_table, + "glyf" => glyph_data 1, // TODO: Use maximum_profile.num_glyphs, + "loca" => index_to_location 1 0, // TODO: Use maximum_profile.num_glyphs font_header.index_to_loc_format, "prep" => unknown_table, "gasp" => unknown_table, diff --git a/formats/opentype.snap b/formats/opentype.snap index 2d84adcf5..13f0770e0 100644 --- a/formats/opentype.snap +++ b/formats/opentype.snap @@ -236,6 +236,34 @@ let naming : _ = { name_count <- u16be, storage_offset <- u16be, }; +let index_to_location : _ = fun num_glyphs => fun index_to_loc_format => { + offsets <- match index_to_loc_format { + 0 => array16 (u16_add num_glyphs 1) u16be, + 1 => array16 (u16_add num_glyphs 1) u32be, + _ => fail, + }, +}; +let glyph_header : _ = { + number_of_contours <- s16be, + x_min <- s16be, + y_min <- s16be, + x_max <- s16be, + y_max <- s16be, +}; +let simple_glyph : _ = fun number_of_contours => { + end_pts_of_contours <- array16 number_of_contours u16be, + instruction_length <- u16be, + instructions <- array16 instruction_length u8, +}; +let composite_glyph : _ = unknown_table; +let glyph : _ = { + header <- glyph_header, + data <- match (s16_lt header.number_of_contours 0) { + false => simple_glyph (s16_unsigned_abs header.number_of_contours), + true => composite_glyph, + }, +}; +let glyph_data : _ = fun num_glyphs => { glyphs <- array16 num_glyphs glyph }; let baseline_data : _ = unknown_table; let glyph_definition_data : _ = unknown_table; let glyph_positioning_data : _ = unknown_table; @@ -277,14 +305,14 @@ let font_table : _ = fun table_id => match table_id { "fpgm" => unknown_table, "fvar" => unknown_table, "gasp" => unknown_table, - "glyf" => unknown_table, + "glyf" => glyph_data 1, "gvar" => unknown_table, "hdmx" => unknown_table, "head" => font_header, "hhea" => horizontal_header, "hmtx" => horizontal_metrics 0 0, "kern" => unknown_table, - "loca" => unknown_table, + "loca" => index_to_location 1 0, "maxp" => maximum_profile, "meta" => unknown_table, "name" => naming, From 74a6f67a7c08c868ecbc0b49468791f5d9332103 Mon Sep 17 00:00:00 2001 From: Wesley Moore Date: Wed, 27 Apr 2022 17:37:23 +1000 Subject: [PATCH 3/3] Read some composite glyph data --- .../opentype/woff2/SFNT-TTF-Composite.snap | 7 ++++- formats/opentype.fathom | 28 ++++++++++++++++++- formats/opentype.snap | 18 +++++++++++- 3 files changed, 50 insertions(+), 3 deletions(-) diff --git a/formats/data/opentype/woff2/SFNT-TTF-Composite.snap b/formats/data/opentype/woff2/SFNT-TTF-Composite.snap index 499fbacf0..43b1d7953 100644 --- a/formats/data/opentype/woff2/SFNT-TTF-Composite.snap +++ b/formats/data/opentype/woff2/SFNT-TTF-Composite.snap @@ -520,7 +520,12 @@ stdout = ''' x_max = 4514, y_max = 1434, }, - data = {}, + data = { + flags = 4135, + glyphIndex = 7, + argument1 = 3453, + argument2 = 0, + }, }, ], }, diff --git a/formats/opentype.fathom b/formats/opentype.fathom index 9517f0b35..352c51871 100644 --- a/formats/opentype.fathom +++ b/formats/opentype.fathom @@ -1066,13 +1066,39 @@ let simple_glyph = fun (number_of_contours : U16) => { // or int16 <- uint8, }; +let args_are_signed = fun (flags : U16) => + (u16_neq (u16_and flags 0x0002) 0); + +let arg_format = fun (flags : U16) => + match (u16_neq (u16_and flags 0x0001) 0) { + // If the bit is set the arguments are 16-bit + true => match (args_are_signed flags) { + true => s16be, + false => u16be, + }, + // Otherwise they are 8-bit + false => match (args_are_signed flags) { + true => s8, + false => u8, + }, + }; + /// # Composite glyph description /// /// ## References /// /// - [Microsoft's OpenType Spec: Glyph Headers](https://docs.microsoft.com/en-us/typography/opentype/spec/glyf#composite-glyph-description) /// - [Apple's TrueType Reference Manual: The `'loca'` table](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6glyf.html) -let composite_glyph = unknown_table; // TODO +let composite_glyph = { + /// component flag + flags <- u16be, + /// glyph index of component + glyphIndex <- u16be, + /// x-offset for component or point number; type depends on bits 0 and 1 in component flags + argument1 <- arg_format flags, + /// y-offset for component or point number; type depends on bits 0 and 1 in component flags + argument2 <- arg_format flags, +}; /// # TrueType glyph let glyph = { diff --git a/formats/opentype.snap b/formats/opentype.snap index 13f0770e0..0aefe6736 100644 --- a/formats/opentype.snap +++ b/formats/opentype.snap @@ -255,7 +255,23 @@ let simple_glyph : _ = fun number_of_contours => { instruction_length <- u16be, instructions <- array16 instruction_length u8, }; -let composite_glyph : _ = unknown_table; +let args_are_signed : _ = fun flags => u16_neq (u16_and flags 0x2) 0; +let arg_format : _ = fun flags => match (u16_neq (u16_and flags 0x1) 0) { + false => match (args_are_signed flags) { + false => u8, + true => s8, + }, + true => match (args_are_signed flags) { + false => u16be, + true => s16be, + }, +}; +let composite_glyph : _ = { + flags <- u16be, + glyphIndex <- u16be, + argument1 <- arg_format flags, + argument2 <- arg_format flags, +}; let glyph : _ = { header <- glyph_header, data <- match (s16_lt header.number_of_contours 0) {