From fd19155bf252fef381dc021e55fee33b1a5c39a9 Mon Sep 17 00:00:00 2001 From: Simon Cozens Date: Thu, 31 Oct 2024 11:37:50 +0000 Subject: [PATCH 1/8] Add kunnasta crate --- Cargo.toml | 2 ++ kunnasta/Cargo.toml | 12 ++++++++++++ kunnasta/src/lib.rs | 1 + 3 files changed, 15 insertions(+) create mode 100644 kunnasta/Cargo.toml create mode 100644 kunnasta/src/lib.rs diff --git a/Cargo.toml b/Cargo.toml index 4852b8c25..0098df404 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,6 +14,7 @@ members = [ "fuzz", "shared-brotli-patch-decoder", "incremental-font-transfer", + "kunnasta", ] [workspace.package] @@ -42,6 +43,7 @@ core_maths = "0.1" font-test-data = { path = "font-test-data" } font-types = { version = "0.7.2", path = "font-types" } read-fonts = { version = "0.23.0", path = "read-fonts", default-features = false } +kunnasta = { version = "0.1.0", path = "kunnasta" } # Disable default-features so that fauntlet can use skrifa without autohint # shaping support skrifa = { version = "0.24.0", path = "skrifa", default-features = false, features = ["std"] } diff --git a/kunnasta/Cargo.toml b/kunnasta/Cargo.toml new file mode 100644 index 000000000..9e52ee0af --- /dev/null +++ b/kunnasta/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "kunnasta" +version = "0.1.0" +edition.workspace = true +license.workspace = true +repository.workspace = true +description = "Library of constants related to font processing." +readme = "README.md" +categories = ["text-processing"] + +[dependencies] +num_enum = "0.7" \ No newline at end of file diff --git a/kunnasta/src/lib.rs b/kunnasta/src/lib.rs new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/kunnasta/src/lib.rs @@ -0,0 +1 @@ + From 761cb32d8abf21fb47ffd3f3583655e6fd9114f7 Mon Sep 17 00:00:00 2001 From: Simon Cozens Date: Thu, 31 Oct 2024 11:38:16 +0000 Subject: [PATCH 2/8] Add PANOSE constants --- kunnasta/src/lib.rs | 2 +- kunnasta/src/panose.rs | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 kunnasta/src/panose.rs diff --git a/kunnasta/src/lib.rs b/kunnasta/src/lib.rs index 8b1378917..59f3d7b00 100644 --- a/kunnasta/src/lib.rs +++ b/kunnasta/src/lib.rs @@ -1 +1 @@ - +pub mod panose; diff --git a/kunnasta/src/panose.rs b/kunnasta/src/panose.rs new file mode 100644 index 000000000..84c88d9d7 --- /dev/null +++ b/kunnasta/src/panose.rs @@ -0,0 +1,36 @@ +use num_enum::IntoPrimitive; + +#[derive(IntoPrimitive)] +#[repr(u8)] +pub enum FamilyType { + Any, + NoFit, + LatinText, + LatinHandWritten, + LatinDecorative, + LatinSymbol, +} + +#[derive(IntoPrimitive)] +#[repr(u8)] +pub enum Proportion { + Any, + NoFit, + OldStyle, + Modern, + EvenWidth, + Expanded, + Condensed, + VeryExpanded, + VeryCondensed, + Monospaced, +} + +#[derive(IntoPrimitive)] +#[repr(u8)] +pub enum Spacing { + Any, + NoFit, + Proportional, + Monospaced, +} From 404128b949343cc61ae785845b06397201e9889c Mon Sep 17 00:00:00 2001 From: Simon Cozens Date: Thu, 31 Oct 2024 11:38:45 +0000 Subject: [PATCH 3/8] Move OS/2 unicode range constant to kunnasta --- kunnasta/src/lib.rs | 1 + kunnasta/src/os2.rs | 174 ++++++++++++++++++++++++++++++++++ read-fonts/src/tables/os2.rs | 175 ----------------------------------- 3 files changed, 175 insertions(+), 175 deletions(-) create mode 100644 kunnasta/src/os2.rs diff --git a/kunnasta/src/lib.rs b/kunnasta/src/lib.rs index 59f3d7b00..da2002782 100644 --- a/kunnasta/src/lib.rs +++ b/kunnasta/src/lib.rs @@ -1 +1,2 @@ +pub mod os2; pub mod panose; diff --git a/kunnasta/src/os2.rs b/kunnasta/src/os2.rs new file mode 100644 index 000000000..46de200f9 --- /dev/null +++ b/kunnasta/src/os2.rs @@ -0,0 +1,174 @@ +// unicode range array generated from the ot spec: +// (https://docs.microsoft.com/en-us/typography/opentype/spec/os2#ur). +// sorted by range start codepoints +pub static UNICODE_RANGES: [(u32, u32, u8); 169] = [ + (0x0, 0x7F, 0), // Basic Latin + (0x80, 0xFF, 1), // Latin-1 Supplement + (0x100, 0x17F, 2), // Latin Extended-A + (0x180, 0x24F, 3), // Latin Extended-B + (0x250, 0x2AF, 4), // IPA Extensions + (0x2B0, 0x2FF, 5), // Spacing Modifier Letters + (0x300, 0x36F, 6), // Combining Diacritical Marks + (0x370, 0x3FF, 7), // Greek and Coptic + (0x400, 0x4FF, 9), // Cyrillic + (0x500, 0x52F, 9), // Cyrillic Supplement + (0x530, 0x58F, 10), // Armenian + (0x590, 0x5FF, 11), // Hebrew + (0x600, 0x6FF, 13), // Arabic + (0x700, 0x74F, 71), // Syriac + (0x750, 0x77F, 13), // Arabic Supplement + (0x780, 0x7BF, 72), // Thaana + (0x7C0, 0x7FF, 14), // NKo + (0x900, 0x97F, 15), // Devanagari + (0x980, 0x9FF, 16), // Bengali + (0xA00, 0xA7F, 17), // Gurmukhi + (0xA80, 0xAFF, 18), // Gujarati + (0xB00, 0xB7F, 19), // Oriya + (0xB80, 0xBFF, 20), // Tamil + (0xC00, 0xC7F, 21), // Telugu + (0xC80, 0xCFF, 22), // Kannada + (0xD00, 0xD7F, 23), // Malayalam + (0xD80, 0xDFF, 73), // Sinhala + (0xE00, 0xE7F, 24), // Thai + (0xE80, 0xEFF, 25), // Lao + (0xF00, 0xFFF, 70), // Tibetan + (0x1000, 0x109F, 74), // Myanmar + (0x10A0, 0x10FF, 26), // Georgian + (0x1100, 0x11FF, 28), // Hangul Jamo + (0x1200, 0x137F, 75), // Ethiopic + (0x1380, 0x139F, 75), // Ethiopic Supplement + (0x13A0, 0x13FF, 76), // Cherokee + (0x1400, 0x167F, 77), // Unified Canadian Aboriginal Syllabics + (0x1680, 0x169F, 78), // Ogham + (0x16A0, 0x16FF, 79), // Runic + (0x1700, 0x171F, 84), // Tagalog + (0x1720, 0x173F, 84), // Hanunoo + (0x1740, 0x175F, 84), // Buhid + (0x1760, 0x177F, 84), // Tagbanwa + (0x1780, 0x17FF, 80), // Khmer + (0x1800, 0x18AF, 81), // Mongolian + (0x1900, 0x194F, 93), // Limbu + (0x1950, 0x197F, 94), // Tai Le + (0x1980, 0x19DF, 95), // New Tai Lue + (0x19E0, 0x19FF, 80), // Khmer Symbols + (0x1A00, 0x1A1F, 96), // Buginese + (0x1B00, 0x1B7F, 27), // Balinese + (0x1B80, 0x1BBF, 112), // Sundanese + (0x1C00, 0x1C4F, 113), // Lepcha + (0x1C50, 0x1C7F, 114), // Ol Chiki + (0x1D00, 0x1D7F, 4), // Phonetic Extensions + (0x1D80, 0x1DBF, 4), // Phonetic Extensions Supplement + (0x1DC0, 0x1DFF, 6), // Combining Diacritical Marks Supplement + (0x1E00, 0x1EFF, 29), // Latin Extended Additional + (0x1F00, 0x1FFF, 30), // Greek Extended + (0x2000, 0x206F, 31), // General Punctuation + (0x2070, 0x209F, 32), // Superscripts And Subscripts + (0x20A0, 0x20CF, 33), // Currency Symbols + (0x20D0, 0x20FF, 34), // Combining Diacritical Marks For Symbols + (0x2100, 0x214F, 35), // Letterlike Symbols + (0x2150, 0x218F, 36), // Number Forms + (0x2190, 0x21FF, 37), // Arrows + (0x2200, 0x22FF, 38), // Mathematical Operators + (0x2300, 0x23FF, 39), // Miscellaneous Technical + (0x2400, 0x243F, 40), // Control Pictures + (0x2440, 0x245F, 41), // Optical Character Recognition + (0x2460, 0x24FF, 42), // Enclosed Alphanumerics + (0x2500, 0x257F, 43), // Box Drawing + (0x2580, 0x259F, 44), // Block Elements + (0x25A0, 0x25FF, 45), // Geometric Shapes + (0x2600, 0x26FF, 46), // Miscellaneous Symbols + (0x2700, 0x27BF, 47), // Dingbats + (0x27C0, 0x27EF, 38), // Miscellaneous Mathematical Symbols-A + (0x27F0, 0x27FF, 37), // Supplemental Arrows-A + (0x2800, 0x28FF, 82), // Braille Patterns + (0x2900, 0x297F, 37), // Supplemental Arrows-B + (0x2980, 0x29FF, 38), // Miscellaneous Mathematical Symbols-B + (0x2A00, 0x2AFF, 38), // Supplemental Mathematical Operators + (0x2B00, 0x2BFF, 37), // Miscellaneous Symbols and Arrows + (0x2C00, 0x2C5F, 97), // Glagolitic + (0x2C60, 0x2C7F, 29), // Latin Extended-C + (0x2C80, 0x2CFF, 8), // Coptic + (0x2D00, 0x2D2F, 26), // Georgian Supplement + (0x2D30, 0x2D7F, 98), // Tifinagh + (0x2D80, 0x2DDF, 75), // Ethiopic Extended + (0x2DE0, 0x2DFF, 9), // Cyrillic Extended-A + (0x2E00, 0x2E7F, 31), // Supplemental Punctuation + (0x2E80, 0x2EFF, 59), // CJK Radicals Supplement + (0x2F00, 0x2FDF, 59), // Kangxi Radicals + (0x2FF0, 0x2FFF, 59), // Ideographic Description Characters + (0x3000, 0x303F, 48), // CJK Symbols And Punctuation + (0x3040, 0x309F, 49), // Hiragana + (0x30A0, 0x30FF, 50), // Katakana + (0x3100, 0x312F, 51), // Bopomofo + (0x3130, 0x318F, 52), // Hangul Compatibility Jamo + (0x3190, 0x319F, 59), // Kanbun + (0x31A0, 0x31BF, 51), // Bopomofo Extended + (0x31C0, 0x31EF, 61), // CJK Strokes + (0x31F0, 0x31FF, 50), // Katakana Phonetic Extensions + (0x3200, 0x32FF, 54), // Enclosed CJK Letters And Months + (0x3300, 0x33FF, 55), // CJK Compatibility + (0x3400, 0x4DBF, 59), // CJK Unified Ideographs Extension A + (0x4DC0, 0x4DFF, 99), // Yijing Hexagram Symbols + (0x4E00, 0x9FFF, 59), // CJK Unified Ideographs + (0xA000, 0xA48F, 83), // Yi Syllables + (0xA490, 0xA4CF, 83), // Yi Radicals + (0xA500, 0xA63F, 12), // Vai + (0xA640, 0xA69F, 9), // Cyrillic Extended-B + (0xA700, 0xA71F, 5), // Modifier Tone Letters + (0xA720, 0xA7FF, 29), // Latin Extended-D + (0xA800, 0xA82F, 100), // Syloti Nagri + (0xA840, 0xA87F, 53), // Phags-pa + (0xA880, 0xA8DF, 115), // Saurashtra + (0xA900, 0xA92F, 116), // Kayah Li + (0xA930, 0xA95F, 117), // Rejang + (0xAA00, 0xAA5F, 118), // Cham + (0xAC00, 0xD7AF, 56), // Hangul Syllables + (0xD800, 0xDFFF, 57), // Non-Plane 0 * + (0xE000, 0xF8FF, 60), // Private Use Area (plane 0) + (0xF900, 0xFAFF, 61), // CJK Compatibility Ideographs + (0xFB00, 0xFB4F, 62), // Alphabetic Presentation Forms + (0xFB50, 0xFDFF, 63), // Arabic Presentation Forms-A + (0xFE00, 0xFE0F, 91), // Variation Selectors + (0xFE10, 0xFE1F, 65), // Vertical Forms + (0xFE20, 0xFE2F, 64), // Combining Half Marks + (0xFE30, 0xFE4F, 65), // CJK Compatibility Forms + (0xFE50, 0xFE6F, 66), // Small Form Variants + (0xFE70, 0xFEFF, 67), // Arabic Presentation Forms-B + (0xFF00, 0xFFEF, 68), // Halfwidth And Fullwidth Forms + (0xFFF0, 0xFFFF, 69), // Specials + (0x10000, 0x1007F, 101), // Linear B Syllabary + (0x10080, 0x100FF, 101), // Linear B Ideograms + (0x10100, 0x1013F, 101), // Aegean Numbers + (0x10140, 0x1018F, 102), // Ancient Greek Numbers + (0x10190, 0x101CF, 119), // Ancient Symbols + (0x101D0, 0x101FF, 120), // Phaistos Disc + (0x10280, 0x1029F, 121), // Lycian + (0x102A0, 0x102DF, 121), // Carian + (0x10300, 0x1032F, 85), // Old Italic + (0x10330, 0x1034F, 86), // Gothic + (0x10380, 0x1039F, 103), // Ugaritic + (0x103A0, 0x103DF, 104), // Old Persian + (0x10400, 0x1044F, 87), // Deseret + (0x10450, 0x1047F, 105), // Shavian + (0x10480, 0x104AF, 106), // Osmanya + (0x10800, 0x1083F, 107), // Cypriot Syllabary + (0x10900, 0x1091F, 58), // Phoenician + (0x10920, 0x1093F, 121), // Lydian + (0x10A00, 0x10A5F, 108), // Kharoshthi + (0x12000, 0x123FF, 110), // Cuneiform + (0x12400, 0x1247F, 110), // Cuneiform Numbers and Punctuation + (0x1D000, 0x1D0FF, 88), // Byzantine Musical Symbols + (0x1D100, 0x1D1FF, 88), // Musical Symbols + (0x1D200, 0x1D24F, 88), // Ancient Greek Musical Notation + (0x1D300, 0x1D35F, 109), // Tai Xuan Jing Symbols + (0x1D360, 0x1D37F, 111), // Counting Rod Numerals + (0x1D400, 0x1D7FF, 89), // Mathematical Alphanumeric Symbols + (0x1F000, 0x1F02F, 122), // Mahjong Tiles + (0x1F030, 0x1F09F, 122), // Domino Tiles + (0x20000, 0x2A6DF, 59), // CJK Unified Ideographs Extension B + (0x2F800, 0x2FA1F, 61), // CJK Compatibility Ideographs Supplement + (0xE0000, 0xE007F, 92), // Tags + (0xE0100, 0xE01EF, 91), // Variation Selectors Supplement + (0xF0000, 0xFFFFD, 90), // Private Use (plane 15) + (0x100000, 0x10FFFD, 90), // Private Use (plane 16) +]; diff --git a/read-fonts/src/tables/os2.rs b/read-fonts/src/tables/os2.rs index af296d62e..24a88d150 100644 --- a/read-fonts/src/tables/os2.rs +++ b/read-fonts/src/tables/os2.rs @@ -2,181 +2,6 @@ include!("../../generated/generated_os2.rs"); -// unicode range array generated from the ot spec: -// (https://docs.microsoft.com/en-us/typography/opentype/spec/os2#ur). -// sorted by range start codepoints -pub static OS2_UNICODE_RANGES: [(u32, u32, u8); 169] = [ - (0x0, 0x7F, 0), // Basic Latin - (0x80, 0xFF, 1), // Latin-1 Supplement - (0x100, 0x17F, 2), // Latin Extended-A - (0x180, 0x24F, 3), // Latin Extended-B - (0x250, 0x2AF, 4), // IPA Extensions - (0x2B0, 0x2FF, 5), // Spacing Modifier Letters - (0x300, 0x36F, 6), // Combining Diacritical Marks - (0x370, 0x3FF, 7), // Greek and Coptic - (0x400, 0x4FF, 9), // Cyrillic - (0x500, 0x52F, 9), // Cyrillic Supplement - (0x530, 0x58F, 10), // Armenian - (0x590, 0x5FF, 11), // Hebrew - (0x600, 0x6FF, 13), // Arabic - (0x700, 0x74F, 71), // Syriac - (0x750, 0x77F, 13), // Arabic Supplement - (0x780, 0x7BF, 72), // Thaana - (0x7C0, 0x7FF, 14), // NKo - (0x900, 0x97F, 15), // Devanagari - (0x980, 0x9FF, 16), // Bengali - (0xA00, 0xA7F, 17), // Gurmukhi - (0xA80, 0xAFF, 18), // Gujarati - (0xB00, 0xB7F, 19), // Oriya - (0xB80, 0xBFF, 20), // Tamil - (0xC00, 0xC7F, 21), // Telugu - (0xC80, 0xCFF, 22), // Kannada - (0xD00, 0xD7F, 23), // Malayalam - (0xD80, 0xDFF, 73), // Sinhala - (0xE00, 0xE7F, 24), // Thai - (0xE80, 0xEFF, 25), // Lao - (0xF00, 0xFFF, 70), // Tibetan - (0x1000, 0x109F, 74), // Myanmar - (0x10A0, 0x10FF, 26), // Georgian - (0x1100, 0x11FF, 28), // Hangul Jamo - (0x1200, 0x137F, 75), // Ethiopic - (0x1380, 0x139F, 75), // Ethiopic Supplement - (0x13A0, 0x13FF, 76), // Cherokee - (0x1400, 0x167F, 77), // Unified Canadian Aboriginal Syllabics - (0x1680, 0x169F, 78), // Ogham - (0x16A0, 0x16FF, 79), // Runic - (0x1700, 0x171F, 84), // Tagalog - (0x1720, 0x173F, 84), // Hanunoo - (0x1740, 0x175F, 84), // Buhid - (0x1760, 0x177F, 84), // Tagbanwa - (0x1780, 0x17FF, 80), // Khmer - (0x1800, 0x18AF, 81), // Mongolian - (0x1900, 0x194F, 93), // Limbu - (0x1950, 0x197F, 94), // Tai Le - (0x1980, 0x19DF, 95), // New Tai Lue - (0x19E0, 0x19FF, 80), // Khmer Symbols - (0x1A00, 0x1A1F, 96), // Buginese - (0x1B00, 0x1B7F, 27), // Balinese - (0x1B80, 0x1BBF, 112), // Sundanese - (0x1C00, 0x1C4F, 113), // Lepcha - (0x1C50, 0x1C7F, 114), // Ol Chiki - (0x1D00, 0x1D7F, 4), // Phonetic Extensions - (0x1D80, 0x1DBF, 4), // Phonetic Extensions Supplement - (0x1DC0, 0x1DFF, 6), // Combining Diacritical Marks Supplement - (0x1E00, 0x1EFF, 29), // Latin Extended Additional - (0x1F00, 0x1FFF, 30), // Greek Extended - (0x2000, 0x206F, 31), // General Punctuation - (0x2070, 0x209F, 32), // Superscripts And Subscripts - (0x20A0, 0x20CF, 33), // Currency Symbols - (0x20D0, 0x20FF, 34), // Combining Diacritical Marks For Symbols - (0x2100, 0x214F, 35), // Letterlike Symbols - (0x2150, 0x218F, 36), // Number Forms - (0x2190, 0x21FF, 37), // Arrows - (0x2200, 0x22FF, 38), // Mathematical Operators - (0x2300, 0x23FF, 39), // Miscellaneous Technical - (0x2400, 0x243F, 40), // Control Pictures - (0x2440, 0x245F, 41), // Optical Character Recognition - (0x2460, 0x24FF, 42), // Enclosed Alphanumerics - (0x2500, 0x257F, 43), // Box Drawing - (0x2580, 0x259F, 44), // Block Elements - (0x25A0, 0x25FF, 45), // Geometric Shapes - (0x2600, 0x26FF, 46), // Miscellaneous Symbols - (0x2700, 0x27BF, 47), // Dingbats - (0x27C0, 0x27EF, 38), // Miscellaneous Mathematical Symbols-A - (0x27F0, 0x27FF, 37), // Supplemental Arrows-A - (0x2800, 0x28FF, 82), // Braille Patterns - (0x2900, 0x297F, 37), // Supplemental Arrows-B - (0x2980, 0x29FF, 38), // Miscellaneous Mathematical Symbols-B - (0x2A00, 0x2AFF, 38), // Supplemental Mathematical Operators - (0x2B00, 0x2BFF, 37), // Miscellaneous Symbols and Arrows - (0x2C00, 0x2C5F, 97), // Glagolitic - (0x2C60, 0x2C7F, 29), // Latin Extended-C - (0x2C80, 0x2CFF, 8), // Coptic - (0x2D00, 0x2D2F, 26), // Georgian Supplement - (0x2D30, 0x2D7F, 98), // Tifinagh - (0x2D80, 0x2DDF, 75), // Ethiopic Extended - (0x2DE0, 0x2DFF, 9), // Cyrillic Extended-A - (0x2E00, 0x2E7F, 31), // Supplemental Punctuation - (0x2E80, 0x2EFF, 59), // CJK Radicals Supplement - (0x2F00, 0x2FDF, 59), // Kangxi Radicals - (0x2FF0, 0x2FFF, 59), // Ideographic Description Characters - (0x3000, 0x303F, 48), // CJK Symbols And Punctuation - (0x3040, 0x309F, 49), // Hiragana - (0x30A0, 0x30FF, 50), // Katakana - (0x3100, 0x312F, 51), // Bopomofo - (0x3130, 0x318F, 52), // Hangul Compatibility Jamo - (0x3190, 0x319F, 59), // Kanbun - (0x31A0, 0x31BF, 51), // Bopomofo Extended - (0x31C0, 0x31EF, 61), // CJK Strokes - (0x31F0, 0x31FF, 50), // Katakana Phonetic Extensions - (0x3200, 0x32FF, 54), // Enclosed CJK Letters And Months - (0x3300, 0x33FF, 55), // CJK Compatibility - (0x3400, 0x4DBF, 59), // CJK Unified Ideographs Extension A - (0x4DC0, 0x4DFF, 99), // Yijing Hexagram Symbols - (0x4E00, 0x9FFF, 59), // CJK Unified Ideographs - (0xA000, 0xA48F, 83), // Yi Syllables - (0xA490, 0xA4CF, 83), // Yi Radicals - (0xA500, 0xA63F, 12), // Vai - (0xA640, 0xA69F, 9), // Cyrillic Extended-B - (0xA700, 0xA71F, 5), // Modifier Tone Letters - (0xA720, 0xA7FF, 29), // Latin Extended-D - (0xA800, 0xA82F, 100), // Syloti Nagri - (0xA840, 0xA87F, 53), // Phags-pa - (0xA880, 0xA8DF, 115), // Saurashtra - (0xA900, 0xA92F, 116), // Kayah Li - (0xA930, 0xA95F, 117), // Rejang - (0xAA00, 0xAA5F, 118), // Cham - (0xAC00, 0xD7AF, 56), // Hangul Syllables - (0xD800, 0xDFFF, 57), // Non-Plane 0 * - (0xE000, 0xF8FF, 60), // Private Use Area (plane 0) - (0xF900, 0xFAFF, 61), // CJK Compatibility Ideographs - (0xFB00, 0xFB4F, 62), // Alphabetic Presentation Forms - (0xFB50, 0xFDFF, 63), // Arabic Presentation Forms-A - (0xFE00, 0xFE0F, 91), // Variation Selectors - (0xFE10, 0xFE1F, 65), // Vertical Forms - (0xFE20, 0xFE2F, 64), // Combining Half Marks - (0xFE30, 0xFE4F, 65), // CJK Compatibility Forms - (0xFE50, 0xFE6F, 66), // Small Form Variants - (0xFE70, 0xFEFF, 67), // Arabic Presentation Forms-B - (0xFF00, 0xFFEF, 68), // Halfwidth And Fullwidth Forms - (0xFFF0, 0xFFFF, 69), // Specials - (0x10000, 0x1007F, 101), // Linear B Syllabary - (0x10080, 0x100FF, 101), // Linear B Ideograms - (0x10100, 0x1013F, 101), // Aegean Numbers - (0x10140, 0x1018F, 102), // Ancient Greek Numbers - (0x10190, 0x101CF, 119), // Ancient Symbols - (0x101D0, 0x101FF, 120), // Phaistos Disc - (0x10280, 0x1029F, 121), // Lycian - (0x102A0, 0x102DF, 121), // Carian - (0x10300, 0x1032F, 85), // Old Italic - (0x10330, 0x1034F, 86), // Gothic - (0x10380, 0x1039F, 103), // Ugaritic - (0x103A0, 0x103DF, 104), // Old Persian - (0x10400, 0x1044F, 87), // Deseret - (0x10450, 0x1047F, 105), // Shavian - (0x10480, 0x104AF, 106), // Osmanya - (0x10800, 0x1083F, 107), // Cypriot Syllabary - (0x10900, 0x1091F, 58), // Phoenician - (0x10920, 0x1093F, 121), // Lydian - (0x10A00, 0x10A5F, 108), // Kharoshthi - (0x12000, 0x123FF, 110), // Cuneiform - (0x12400, 0x1247F, 110), // Cuneiform Numbers and Punctuation - (0x1D000, 0x1D0FF, 88), // Byzantine Musical Symbols - (0x1D100, 0x1D1FF, 88), // Musical Symbols - (0x1D200, 0x1D24F, 88), // Ancient Greek Musical Notation - (0x1D300, 0x1D35F, 109), // Tai Xuan Jing Symbols - (0x1D360, 0x1D37F, 111), // Counting Rod Numerals - (0x1D400, 0x1D7FF, 89), // Mathematical Alphanumeric Symbols - (0x1F000, 0x1F02F, 122), // Mahjong Tiles - (0x1F030, 0x1F09F, 122), // Domino Tiles - (0x20000, 0x2A6DF, 59), // CJK Unified Ideographs Extension B - (0x2F800, 0x2FA1F, 61), // CJK Compatibility Ideographs Supplement - (0xE0000, 0xE007F, 92), // Tags - (0xE0100, 0xE01EF, 91), // Variation Selectors Supplement - (0xF0000, 0xFFFFD, 90), // Private Use (plane 15) - (0x100000, 0x10FFFD, 90), // Private Use (plane 16) -]; - #[cfg(test)] mod tests { use crate::{table_provider::TableProvider, FontRef}; From 3940dd4fdf088a1f94e85045f4e93cdbefd50cf1 Mon Sep 17 00:00:00 2001 From: Simon Cozens Date: Thu, 31 Oct 2024 11:39:07 +0000 Subject: [PATCH 4/8] Use kunnasta for constant --- klippa/Cargo.toml | 1 + klippa/src/os2.rs | 14 +++++--------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/klippa/Cargo.toml b/klippa/Cargo.toml index d974b829f..05a563308 100644 --- a/klippa/Cargo.toml +++ b/klippa/Cargo.toml @@ -16,6 +16,7 @@ clap = { version = "4.5.4", features = ["derive"] } fnv = "1.0.7" regex = "1.10.4" skrifa = { workspace = true } +kunnasta = { workspace = true } thiserror = "1.0.58" write-fonts = { workspace = true, features = ["read"] } diff --git a/klippa/src/os2.rs b/klippa/src/os2.rs index 04afe7b3a..300d9cc69 100644 --- a/klippa/src/os2.rs +++ b/klippa/src/os2.rs @@ -1,13 +1,9 @@ //! impl subset() for OS/2 -use crate::SubsetFlags; -use crate::{Plan, Subset, SubsetError}; +use crate::{Plan, Subset, SubsetError, SubsetFlags}; +use kunnasta::os2::UNICODE_RANGES; use std::cmp::Ordering; use write_fonts::{ - read::{ - collections::IntSet, - tables::os2::{Os2, OS2_UNICODE_RANGES}, - FontRef, TopLevelTable, - }, + read::{collections::IntSet, tables::os2::Os2, FontRef, TopLevelTable}, FontBuilder, }; @@ -78,10 +74,10 @@ fn update_unicode_ranges(unicodes: &IntSet, ul_unicode_range: &mut [u8]) { // Returns the bit to be set in os/2 ulUnicodeOS2Range for a given codepoint. fn get_unicode_range_bit(cp: u32) -> Option { - OS2_UNICODE_RANGES + UNICODE_RANGES .binary_search_by(|&(a, b, _)| OS2Range::new(a, b).cmp(cp)) .ok() - .map(|i| OS2_UNICODE_RANGES[i].2) + .map(|i| UNICODE_RANGES[i].2) } pub struct OS2Range { From b6daa663494b08e69768dbd4c24c7ad0bad07fcb Mon Sep 17 00:00:00 2001 From: Simon Cozens Date: Thu, 31 Oct 2024 11:47:33 +0000 Subject: [PATCH 5/8] Add layout registry --- kunnasta/src/layout.rs | 108 +++++++++++++++++++++++++++++++++++++++++ kunnasta/src/lib.rs | 1 + 2 files changed, 109 insertions(+) create mode 100644 kunnasta/src/layout.rs diff --git a/kunnasta/src/layout.rs b/kunnasta/src/layout.rs new file mode 100644 index 000000000..916fe0057 --- /dev/null +++ b/kunnasta/src/layout.rs @@ -0,0 +1,108 @@ +//! OpenType layout tag registry +//! +//! Valid as at OpenType 1.9.1 + +/// List of valid OpenType script tags +pub const VALID_SCRIPT_TAGS: [&str; 170] = [ + "DFLT", "adlm", "ahom", "hluw", "arab", "armn", "avst", "bali", "bamu", "bass", "batk", "beng", + "bng2", "bhks", "bopo", "brah", "brai", "bugi", "buhd", "byzm", "cans", "cari", "aghb", "cakm", + "cham", "cher", "chrs", "hani", "copt", "cprt", "cyrl", "DFLT", "dsrt", "deva", "dev2", "diak", + "dogr", "dupl", "egyp", "elba", "elym", "ethi", "geor", "glag", "goth", "gran", "grek", "gujr", + "gjr2", "gong", "guru", "gur2", "hang", "jamo", "rohg", "hano", "hatr", "hebr", "kana", "armi", + "phli", "prti", "java", "kthi", "knda", "knd2", "kana", "kali", "khar", "kits", "khmr", "khoj", + "sind", "lao ", "latn", "lepc", "limb", "lina", "linb", "lisu", "lyci", "lydi", "mahj", "maka", + "mlym", "mlm2", "mand", "mani", "marc", "gonm", "math", "medf", "mtei", "mend", "merc", "mero", + "plrd", "modi", "mong", "mroo", "mult", "musc", "mymr", "mym2", "nbat", "nand", "newa", "talu", + "nko ", "nshu", "hmnp", "orya", "ory2", "ogam", "olck", "ital", "hung", "narb", "perm", "xpeo", + "sogo", "sarb", "orkh", "osge", "osma", "hmng", "palm", "pauc", "phag", "phnx", "phlp", "rjng", + "runr", "samr", "saur", "shrd", "shaw", "sidd", "sgnw", "sinh", "sogd", "sora", "soyo", "xsux", + "sund", "sylo", "syrc", "tglg", "tagb", "tale", "lana", "tavt", "takr", "taml", "tml2", "tang", + "telu", "tel2", "thaa", "thai", "tibt", "tfng", "tirh", "ugar", "vai ", "wcho", "wara", "yezi", + "yi ", "zanb", +]; + +/// List of valid OpenType language tags +pub const VALID_LANG_TAGS: [&str; 612] = [ + "dflt", "ABA ", "ABK ", "ACH ", "ACR ", "ADY ", "AFK ", "AFR ", "AGW ", "AIO ", "AKA ", "AKB ", + "ALS ", "ALT ", "AMH ", "ANG ", "APPH", "ARA ", "ARG ", "ARI ", "ARK ", "ASM ", "AST ", "ATH ", + "AVR ", "AWA ", "AYM ", "AZB ", "AZE ", "BAD ", "BAD0", "BAG ", "BAL ", "BAN ", "BAR ", "BAU ", + "BBC ", "BBR ", "BCH ", "BCR ", "BDY ", "BEL ", "BEM ", "BEN ", "BGC ", "BGQ ", "BGR ", "BHI ", + "BHO ", "BIK ", "BIL ", "BIS ", "BJJ ", "BKF ", "BLI ", "BLK ", "BLN ", "BLT ", "BMB ", "BML ", + "BOS ", "BPY ", "BRE ", "BRH ", "BRI ", "BRM ", "BRX ", "BSH ", "BSK ", "BTD ", "BTI ", "BTK ", + "BTM ", "BTS ", "BTX ", "BTZ ", "BUG ", "BYV ", "CAK ", "CAT ", "CBK ", "CCHN", "CEB ", "CGG ", + "CHA ", "CHE ", "CHG ", "CHH ", "CHI ", "CHK ", "CHK0", "CHO ", "CHP ", "CHR ", "CHU ", "CHY ", + "CJA ", "CJM ", "CMR ", "COP ", "COR ", "COS ", "CPP ", "CRE ", "CRR ", "CRT ", "CSB ", "CSL ", + "CSY ", "CTG ", "CUK ", "DAG ", "DAN ", "DAR ", "DAX ", "DCR ", "DEU ", "DGO ", "DGR ", "DHG ", + "DHV ", "DIQ ", "DIV ", "DJR ", "DJR0", "DNG ", "DNJ ", "DNK ", "DRI ", "DUJ ", "DUN ", "DZN ", + "EBI ", "ECR ", "EDO ", "EFI ", "ELL ", "EMK ", "ENG ", "ERZ ", "ESP ", "ESU ", "ETI ", "EUQ ", + "EVK ", "EVN ", "EWE ", "FAN ", "FAN0", "FAR ", "FAT ", "FIN ", "FJI ", "FLE ", "FMP ", "FNE ", + "FON ", "FOS ", "FRA ", "FRC ", "FRI ", "FRL ", "FRP ", "FTA ", "FUL ", "FUV ", "GAD ", "GAE ", + "GAG ", "GAL ", "GAR ", "GAW ", "GEZ ", "GIH ", "GIL ", "GIL0", "GKP ", "GLK ", "GMZ ", "GNN ", + "GOG ", "GON ", "GRN ", "GRO ", "GUA ", "GUC ", "GUF ", "GUJ ", "GUZ ", "HAI ", "HAL ", "HAR ", + "HAU ", "HAW ", "HAY ", "HAZ ", "HBN ", "HER ", "HIL ", "HIN ", "HMA ", "HMN ", "HMO ", "HND ", + "HO ", "HRI ", "HRV ", "HUN ", "HYE ", "HYE0", "IBA ", "IBB ", "IBO ", "IDO ", "IJO ", "ILE ", + "ILO ", "INA ", "IND ", "ING ", "INU ", "IPK ", "IPPH", "IRI ", "IRT ", "ISL ", "ISM ", "ITA ", + "IWR ", "JAM ", "JAN ", "JAV ", "JBO ", "JCT ", "JII ", "JUD ", "JUL ", "KAB ", "KAB0", "KAC ", + "KAL ", "KAN ", "KAR ", "KAT ", "KAZ ", "KDE ", "KEA ", "KEB ", "KEK ", "KGE ", "KHA ", "KHK ", + "KHM ", "KHS ", "KHT ", "KHV ", "KHW ", "KIK ", "KIR ", "KIS ", "KIU ", "KJD ", "KJP ", "KJZ ", + "KKN ", "KLM ", "KMB ", "KMN ", "KMO ", "KMS ", "KMZ ", "KNR ", "KOD ", "KOH ", "KOK ", "KOM ", + "KON ", "KON0", "KOP ", "KOR ", "KOS ", "KOZ ", "KPL ", "KRI ", "KRK ", "KRL ", "KRM ", "KRN ", + "KRT ", "KSH ", "KSH0", "KSI ", "KSM ", "KSW ", "KUA ", "KUI ", "KUL ", "KUM ", "KUR ", "KUU ", + "KUY ", "KYK ", "KYU ", "LAD ", "LAH ", "LAK ", "LAM ", "LAO ", "LAT ", "LAZ ", "LCR ", "LDK ", + "LEZ ", "LIJ ", "LIM ", "LIN ", "LIS ", "LJP ", "LKI ", "LMA ", "LMB ", "LMO ", "LMW ", "LOM ", + "LRC ", "LSB ", "LSM ", "LTH ", "LTZ ", "LUA ", "LUB ", "LUG ", "LUH ", "LUO ", "LVI ", "MAD ", + "MAG ", "MAH ", "MAJ ", "MAK ", "MAL ", "MAM ", "MAN ", "MAP ", "MAR ", "MAW ", "MBN ", "MBO ", + "MCH ", "MCR ", "MDE ", "MDR ", "MEN ", "MER ", "MFA ", "MFE ", "MIN ", "MIZ ", "MKD ", "MKR ", + "MKW ", "MLE ", "MLG ", "MLN ", "MLR ", "MLY ", "MND ", "MNG ", "MNI ", "MNK ", "MNX ", "MOH ", + "MOK ", "MOL ", "MON ", "MOR ", "MOS ", "MRI ", "MTH ", "MTS ", "MUN ", "MUS ", "MWL ", "MWW ", + "MYN ", "MZN ", "NAG ", "NAH ", "NAN ", "NAP ", "NAS ", "NAU ", "NAV ", "NCR ", "NDB ", "NDC ", + "NDG ", "NDS ", "NEP ", "NEW ", "NGA ", "NGR ", "NHC ", "NIS ", "NIU ", "NKL ", "NKO ", "NLD ", + "NOE ", "NOG ", "NOR ", "NOV ", "NSM ", "NSO ", "NTA ", "NTO ", "NYM ", "NYN ", "NZA ", "OCI ", + "OCR ", "OJB ", "ORI ", "ORO ", "OSS ", "PAA ", "PAG ", "PAL ", "PAM ", "PAN ", "PAP ", "PAP0", + "PAS ", "PAU ", "PCC ", "PCD ", "PDC ", "PGR ", "PHK ", "PIH ", "PIL ", "PLG ", "PLK ", "PMS ", + "PNB ", "POH ", "PON ", "PRO ", "PTG ", "PWO ", "QIN ", "QUC ", "QUH ", "QUZ ", "QVI ", "QWH ", + "RAJ ", "RAR ", "RBU ", "RCR ", "REJ ", "RIA ", "RIF ", "RIT ", "RKW ", "RMS ", "RMY ", "ROM ", + "ROY ", "RSY ", "RTM ", "RUA ", "RUN ", "RUP ", "RUS ", "SAD ", "SAN ", "SAS ", "SAT ", "SAY ", + "SCN ", "SCO ", "SCS ", "SEK ", "SEL ", "SGA ", "SGO ", "SGS ", "SHI ", "SHN ", "SIB ", "SID ", + "SIG ", "SKS ", "SKY ", "SLA ", "SLV ", "SML ", "SMO ", "SNA ", "SNA0", "SND ", "SNH ", "SNK ", + "SOG ", "SOP ", "SOT ", "SQI ", "SRB ", "SRD ", "SRK ", "SRR ", "SSL ", "SSM ", "STQ ", "SUK ", + "SUN ", "SUR ", "SVA ", "SVE ", "SWA ", "SWK ", "SWZ ", "SXT ", "SXU ", "SYL ", "SYR ", "SYRE", + "SYRJ", "SYRN", "SZL ", "TAB ", "TAJ ", "TAM ", "TAT ", "TCR ", "TDD ", "TEL ", "TET ", "TGL ", + "TGN ", "TGR ", "TGY ", "THA ", "THT ", "TIB ", "TIV ", "TKM ", "TMH ", "TMN ", "TNA ", "TNE ", + "TNG ", "TOD ", "TOD0", "TPI ", "TRK ", "TSG ", "TSJ ", "TUA ", "TUL ", "TUM ", "TUV ", "TVL ", + "TWI ", "TYZ ", "TZM ", "TZO ", "UDM ", "UKR ", "UMB ", "URD ", "USB ", "UYG ", "UZB ", "VEC ", + "VEN ", "VIT ", "VOL ", "VRO ", "WA ", "WAG ", "WAR ", "WCR ", "WEL ", "WLF ", "WLN ", "WTM ", + "XBD ", "XHS ", "XJB ", "XKF ", "XOG ", "XPE ", "YAK ", "YAO ", "YAP ", "YBA ", "YCR ", "YIC ", + "YIM ", "ZEA ", "ZGH ", "ZHA ", "ZHH ", "ZHP ", "ZHS ", "ZHT ", "ZHTM", "ZND ", "ZUL ", "ZZA ", +]; + +/// List of valid OpenType feature tags +#[rustfmt::skip] +pub const VALID_FEATURE_TAGS: [&str; 241] = [ + "aalt", "abvf", "abvm", "abvs", "afrc", "akhn", "blwf", "blwm", "blws", "c2pc", "c2sc", "calt", + "case", "ccmp", "cfar", "chws", "cjct", "clig", "cpct", "cpsp", "cswh", "curs", "dist", "dlig", + "dnom", "dtls", "expt", "falt", "fin2", "fin3", "fina", "flac", "frac", "fwid", "half", "haln", + "halt", "hist", "hkna", "hlig", "hngl", "hojo", "hwid", "init", "isol", "ital", "jalt", "jp04", + "jp78", "jp83", "jp90", "kern", "lfbd", "liga", "ljmo", "lnum", "locl", "ltra", "ltrm", "mark", + "med2", "medi", "mgrk", "mkmk", "mset", "nalt", "nlck", "nukt", "numr", "onum", "opbd", "ordn", + "ornm", "palt", "pcap", "pkna", "pnum", "pref", "pres", "pstf", "psts", "pwid", "qwid", "rand", + "rclt", "rkrf", "rlig", "rphf", "rtbd", "rtla", "rtlm", "ruby", "rvrn", "salt", "sinf", "size", + "smcp", "smpl", "ssty", "stch", "subs", "sups", "swsh", "titl", "tjmo", "tnam", "tnum", "trad", + "twid", "unic", "valt", "vatu", "vchw", "vert", "vhal", "vjmo", "vkna", "vkrn", "vpal", "vrt2", + "vrtr", "zero", + + // Character variations + "cv01", "cv02", "cv03", "cv04", "cv05", "cv06", "cv07", "cv08", "cv09", "cv10", "cv11", "cv12", + "cv13", "cv14", "cv15", "cv16", "cv17", "cv18", "cv19", "cv20", "cv21", "cv22", "cv23", "cv24", + "cv25", "cv26", "cv27", "cv28", "cv29", "cv30", "cv31", "cv32", "cv33", "cv34", "cv35", "cv36", + "cv37", "cv38", "cv39", "cv40", "cv41", "cv42", "cv43", "cv44", "cv45", "cv46", "cv47", "cv48", + "cv49", "cv50", "cv51", "cv52", "cv53", "cv54", "cv55", "cv56", "cv57", "cv58", "cv59", "cv60", + "cv61", "cv62", "cv63", "cv64", "cv65", "cv66", "cv67", "cv68", "cv69", "cv70", "cv71", "cv72", + "cv73", "cv74", "cv75", "cv76", "cv77", "cv78", "cv79", "cv80", "cv81", "cv82", "cv83", "cv84", + "cv85", "cv86", "cv87", "cv88", "cv89", "cv90", "cv91", "cv92", "cv93", "cv94", "cv95", "cv96", + "cv97", "cv98", "cv99", + + // Stylistic sets (OT spec only supports 20) + "ss01", "ss02", "ss03", "ss04", "ss05", "ss06", "ss07", "ss08", "ss09", "ss10", "ss11", "ss12", + "ss13", "ss14", "ss15", "ss16", "ss17", "ss18", "ss19", "ss20", +]; diff --git a/kunnasta/src/lib.rs b/kunnasta/src/lib.rs index da2002782..8871cfe50 100644 --- a/kunnasta/src/lib.rs +++ b/kunnasta/src/lib.rs @@ -1,2 +1,3 @@ +pub mod layout; pub mod os2; pub mod panose; From 2cae4fd0b7aa1bd1a3dad4da8ae2d0b368b9d6a9 Mon Sep 17 00:00:00 2001 From: Simon Cozens Date: Thu, 31 Oct 2024 11:47:41 +0000 Subject: [PATCH 6/8] Docs --- kunnasta/src/os2.rs | 10 +++++++--- kunnasta/src/panose.rs | 3 +++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/kunnasta/src/os2.rs b/kunnasta/src/os2.rs index 46de200f9..ddeed2426 100644 --- a/kunnasta/src/os2.rs +++ b/kunnasta/src/os2.rs @@ -1,6 +1,10 @@ -// unicode range array generated from the ot spec: -// (https://docs.microsoft.com/en-us/typography/opentype/spec/os2#ur). -// sorted by range start codepoints +//! OS/2 table constants + +/// OS/2 Unicode ranges +/// +/// Unicode range array generated from the ot spec: +/// (https://docs.microsoft.com/en-us/typography/opentype/spec/os2#ur). +/// sorted by range start codepoints pub static UNICODE_RANGES: [(u32, u32, u8); 169] = [ (0x0, 0x7F, 0), // Basic Latin (0x80, 0xFF, 1), // Latin-1 Supplement diff --git a/kunnasta/src/panose.rs b/kunnasta/src/panose.rs index 84c88d9d7..a667f541f 100644 --- a/kunnasta/src/panose.rs +++ b/kunnasta/src/panose.rs @@ -1,3 +1,6 @@ +//! Panose Classification settings +//! +//! See the [PANOSE Classification Metrics Guide](https://monotype.github.io/panose/pan1.html) use num_enum::IntoPrimitive; #[derive(IntoPrimitive)] From 905f49efe418dd54ca696601cc80500569f5f9c1 Mon Sep 17 00:00:00 2001 From: Simon Cozens Date: Thu, 31 Oct 2024 12:31:24 +0000 Subject: [PATCH 7/8] Ignore typos --- .typos.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/.typos.toml b/.typos.toml index 6264e4b96..ae23dabd0 100644 --- a/.typos.toml +++ b/.typos.toml @@ -9,6 +9,7 @@ extend-exclude = [ # /.git isn't in .gitignore, because git never tracks it. # Typos doesn't know that, though. '/.git', + 'kunnasta/src/layout.rs', # Lots of tags that look like words but aren't ] # Corrections take the form of a key/value pair. The key is the incorrect word From 6839223ae0b221078a450b86e2e5c2cdef01e45f Mon Sep 17 00:00:00 2001 From: Simon Cozens Date: Thu, 31 Oct 2024 12:51:21 +0000 Subject: [PATCH 8/8] Fix doc link --- kunnasta/src/os2.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kunnasta/src/os2.rs b/kunnasta/src/os2.rs index ddeed2426..499c2c6c6 100644 --- a/kunnasta/src/os2.rs +++ b/kunnasta/src/os2.rs @@ -2,9 +2,9 @@ /// OS/2 Unicode ranges /// -/// Unicode range array generated from the ot spec: -/// (https://docs.microsoft.com/en-us/typography/opentype/spec/os2#ur). -/// sorted by range start codepoints +/// Unicode range array generated from the +/// [OpenType specification](https://docs.microsoft.com/en-us/typography/opentype/spec/os2#ur), +/// sorted by range start codepoints. pub static UNICODE_RANGES: [(u32, u32, u8); 169] = [ (0x0, 0x7F, 0), // Basic Latin (0x80, 0xFF, 1), // Latin-1 Supplement