diff --git a/formats/data/opentype/aots/cmap0_font1.snap b/formats/data/opentype/aots/cmap0_font1.snap index 97036315e..3e3511527 100644 --- a/formats/data/opentype/aots/cmap0_font1.snap +++ b/formats/data/opentype/aots/cmap0_font1.snap @@ -824,7 +824,18 @@ stdout = ''' ], ] 5164 = [ - {}, + { + version = 196608, + italic_angle = 0, + underline_position = -100, + underline_thickness = 50, + is_fixed_pitch = 0, + min_mem_type42 = 0, + max_mem_type42 = 0, + min_mem_type1 = 0, + max_mem_type1 = 0, + names = {}, + }, ] ''' stderr = '' diff --git a/formats/data/opentype/aots/cmap10_font1.snap b/formats/data/opentype/aots/cmap10_font1.snap index c77b5153a..028fb8ca1 100644 --- a/formats/data/opentype/aots/cmap10_font1.snap +++ b/formats/data/opentype/aots/cmap10_font1.snap @@ -580,7 +580,18 @@ stdout = ''' ], ] 4936 = [ - {}, + { + version = 196608, + italic_angle = 0, + underline_position = -100, + underline_thickness = 50, + is_fixed_pitch = 0, + min_mem_type42 = 0, + max_mem_type42 = 0, + min_mem_type1 = 0, + max_mem_type1 = 0, + names = {}, + }, ] ''' stderr = '' diff --git a/formats/data/opentype/aots/cmap10_font2.snap b/formats/data/opentype/aots/cmap10_font2.snap index 50a13e075..92949fff8 100644 --- a/formats/data/opentype/aots/cmap10_font2.snap +++ b/formats/data/opentype/aots/cmap10_font2.snap @@ -576,7 +576,18 @@ stdout = ''' ], ] 4928 = [ - {}, + { + version = 196608, + italic_angle = 0, + underline_position = -100, + underline_thickness = 50, + is_fixed_pitch = 0, + min_mem_type42 = 0, + max_mem_type42 = 0, + min_mem_type1 = 0, + max_mem_type1 = 0, + names = {}, + }, ] ''' stderr = '' diff --git a/formats/data/opentype/aots/cmap12_font1.snap b/formats/data/opentype/aots/cmap12_font1.snap index be6b96406..cbf34bed1 100644 --- a/formats/data/opentype/aots/cmap12_font1.snap +++ b/formats/data/opentype/aots/cmap12_font1.snap @@ -586,7 +586,18 @@ stdout = ''' ], ] 4948 = [ - {}, + { + version = 196608, + italic_angle = 0, + underline_position = -100, + underline_thickness = 50, + is_fixed_pitch = 0, + min_mem_type42 = 0, + max_mem_type42 = 0, + min_mem_type1 = 0, + max_mem_type1 = 0, + names = {}, + }, ] ''' stderr = '' diff --git a/formats/data/opentype/aots/cmap14_font1.snap b/formats/data/opentype/aots/cmap14_font1.snap index a4410fe29..9d964a0b5 100644 --- a/formats/data/opentype/aots/cmap14_font1.snap +++ b/formats/data/opentype/aots/cmap14_font1.snap @@ -675,7 +675,18 @@ stdout = ''' ], ] 4996 = [ - {}, + { + version = 196608, + italic_angle = 0, + underline_position = -100, + underline_thickness = 50, + is_fixed_pitch = 0, + min_mem_type42 = 0, + max_mem_type42 = 0, + min_mem_type1 = 0, + max_mem_type1 = 0, + names = {}, + }, ] ''' stderr = '' diff --git a/formats/data/opentype/aots/cmap2_font1.snap b/formats/data/opentype/aots/cmap2_font1.snap index a5761a652..712e856ae 100644 --- a/formats/data/opentype/aots/cmap2_font1.snap +++ b/formats/data/opentype/aots/cmap2_font1.snap @@ -824,7 +824,18 @@ stdout = ''' ], ] 5968 = [ - {}, + { + version = 196608, + italic_angle = 0, + underline_position = -100, + underline_thickness = 50, + is_fixed_pitch = 0, + min_mem_type42 = 0, + max_mem_type42 = 0, + min_mem_type1 = 0, + max_mem_type1 = 0, + names = {}, + }, ] ''' stderr = '' diff --git a/formats/data/opentype/aots/cmap4_font1.snap b/formats/data/opentype/aots/cmap4_font1.snap index 53ef26ccd..155d6df61 100644 --- a/formats/data/opentype/aots/cmap4_font1.snap +++ b/formats/data/opentype/aots/cmap4_font1.snap @@ -588,7 +588,18 @@ stdout = ''' ], ] 4932 = [ - {}, + { + version = 196608, + italic_angle = 0, + underline_position = -100, + underline_thickness = 50, + is_fixed_pitch = 0, + min_mem_type42 = 0, + max_mem_type42 = 0, + min_mem_type1 = 0, + max_mem_type1 = 0, + names = {}, + }, ] ''' stderr = '' diff --git a/formats/data/opentype/aots/cmap4_font2.snap b/formats/data/opentype/aots/cmap4_font2.snap index 31067c8cf..31beb363d 100644 --- a/formats/data/opentype/aots/cmap4_font2.snap +++ b/formats/data/opentype/aots/cmap4_font2.snap @@ -584,7 +584,18 @@ stdout = ''' ], ] 4924 = [ - {}, + { + version = 196608, + italic_angle = 0, + underline_position = -100, + underline_thickness = 50, + is_fixed_pitch = 0, + min_mem_type42 = 0, + max_mem_type42 = 0, + min_mem_type1 = 0, + max_mem_type1 = 0, + names = {}, + }, ] ''' stderr = '' diff --git a/formats/data/opentype/aots/cmap4_font3.snap b/formats/data/opentype/aots/cmap4_font3.snap index c90423b6c..6c04cc290 100644 --- a/formats/data/opentype/aots/cmap4_font3.snap +++ b/formats/data/opentype/aots/cmap4_font3.snap @@ -584,7 +584,18 @@ stdout = ''' ], ] 4924 = [ - {}, + { + version = 196608, + italic_angle = 0, + underline_position = -100, + underline_thickness = 50, + is_fixed_pitch = 0, + min_mem_type42 = 0, + max_mem_type42 = 0, + min_mem_type1 = 0, + max_mem_type1 = 0, + names = {}, + }, ] ''' stderr = '' diff --git a/formats/data/opentype/aots/cmap4_font4.snap b/formats/data/opentype/aots/cmap4_font4.snap index ebe6cded8..b82dda9fe 100644 --- a/formats/data/opentype/aots/cmap4_font4.snap +++ b/formats/data/opentype/aots/cmap4_font4.snap @@ -592,7 +592,18 @@ stdout = ''' ], ] 4940 = [ - {}, + { + version = 196608, + italic_angle = 0, + underline_position = -100, + underline_thickness = 50, + is_fixed_pitch = 0, + min_mem_type42 = 0, + max_mem_type42 = 0, + min_mem_type1 = 0, + max_mem_type1 = 0, + names = {}, + }, ] ''' stderr = '' diff --git a/formats/data/opentype/aots/cmap6_font1.snap b/formats/data/opentype/aots/cmap6_font1.snap index f5afdf40e..c7f64b816 100644 --- a/formats/data/opentype/aots/cmap6_font1.snap +++ b/formats/data/opentype/aots/cmap6_font1.snap @@ -573,7 +573,18 @@ stdout = ''' ], ] 4916 = [ - {}, + { + version = 196608, + italic_angle = 0, + underline_position = -100, + underline_thickness = 50, + is_fixed_pitch = 0, + min_mem_type42 = 0, + max_mem_type42 = 0, + min_mem_type1 = 0, + max_mem_type1 = 0, + names = {}, + }, ] ''' stderr = '' diff --git a/formats/data/opentype/aots/cmap6_font2.snap b/formats/data/opentype/aots/cmap6_font2.snap index f6c4313b7..5239aa0f3 100644 --- a/formats/data/opentype/aots/cmap6_font2.snap +++ b/formats/data/opentype/aots/cmap6_font2.snap @@ -569,7 +569,18 @@ stdout = ''' ], ] 4912 = [ - {}, + { + version = 196608, + italic_angle = 0, + underline_position = -100, + underline_thickness = 50, + is_fixed_pitch = 0, + min_mem_type42 = 0, + max_mem_type42 = 0, + min_mem_type1 = 0, + max_mem_type1 = 0, + names = {}, + }, ] ''' stderr = '' diff --git a/formats/data/opentype/aots/cmap8_font1.snap b/formats/data/opentype/aots/cmap8_font1.snap index 13aa08fd1..79a024b95 100644 --- a/formats/data/opentype/aots/cmap8_font1.snap +++ b/formats/data/opentype/aots/cmap8_font1.snap @@ -8799,7 +8799,18 @@ stdout = ''' ], ] 13192 = [ - {}, + { + version = 196608, + italic_angle = 0, + underline_position = -100, + underline_thickness = 50, + is_fixed_pitch = 0, + min_mem_type42 = 0, + max_mem_type42 = 0, + min_mem_type1 = 0, + max_mem_type1 = 0, + names = {}, + }, ] ''' stderr = '' diff --git a/formats/data/opentype/woff/valid-001.snap b/formats/data/opentype/woff/valid-001.snap index 4b8c0dbc1..b7b169311 100644 --- a/formats/data/opentype/woff/valid-001.snap +++ b/formats/data/opentype/woff/valid-001.snap @@ -1144,7 +1144,18 @@ stdout = ''' }, ] 1248 = [ - {}, + { + version = 196608, + italic_angle = 0, + underline_position = -75, + underline_thickness = 50, + is_fixed_pitch = 0, + min_mem_type42 = 0, + max_mem_type42 = 0, + min_mem_type1 = 0, + max_mem_type1 = 0, + names = {}, + }, ] 1280 = [ {}, diff --git a/formats/data/opentype/woff/valid-005.snap b/formats/data/opentype/woff/valid-005.snap index 060078e97..a53f3d029 100644 --- a/formats/data/opentype/woff/valid-005.snap +++ b/formats/data/opentype/woff/valid-005.snap @@ -1432,7 +1432,18 @@ stdout = ''' ], ] 3584 = [ - {}, + { + version = 196608, + italic_angle = 0, + underline_position = -154, + underline_thickness = 102, + is_fixed_pitch = 0, + min_mem_type42 = 0, + max_mem_type42 = 0, + min_mem_type1 = 0, + max_mem_type1 = 0, + names = {}, + }, ] ''' stderr = '' diff --git a/formats/data/opentype/woff2/SFNT-TTF-Composite.snap b/formats/data/opentype/woff2/SFNT-TTF-Composite.snap index 11dca7646..03608c2bf 100644 --- a/formats/data/opentype/woff2/SFNT-TTF-Composite.snap +++ b/formats/data/opentype/woff2/SFNT-TTF-Composite.snap @@ -1516,7 +1516,18 @@ stdout = ''' ], ] 3860 = [ - {}, + { + version = 196608, + italic_angle = 0, + underline_position = -154, + underline_thickness = 102, + is_fixed_pitch = 0, + min_mem_type42 = 0, + max_mem_type42 = 0, + min_mem_type1 = 0, + max_mem_type1 = 0, + names = {}, + }, ] ''' stderr = '' diff --git a/formats/opentype.fathom b/formats/opentype.fathom index 86c5527ef..2d5336fb1 100644 --- a/formats/opentype.fathom +++ b/formats/opentype.fathom @@ -1052,14 +1052,12 @@ let simple_glyph = fun (number_of_contours : U16) => { 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. + /// Array of flag 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); + /// xCoordinates[variable] Contour point x-coordinates. 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); + /// yCoordinates[variable] Contour point y-coordinates. Coordinate for the first point is relative to (0,0); /// others are relative to previous point. // or int16 <- uint8, }; @@ -1225,6 +1223,70 @@ let os2_table = fun (table_length : U32) => { // ----------------------------------------------------------------------------- + + +/// # PostScript Table +/// +/// ## References +/// +/// - [Microsoft's OpenType Spec: Glyph Data](https://docs.microsoft.com/en-us/typography/opentype/spec/post) +/// - [Apple's TrueType Reference Manual: The `'post'` table](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6post.html) +let post_table = { + /// 0x00010000 for version 1.0 0x00020000 for version 2.0 + /// 0x00025000 for version 2.5 (deprecated) 0x00030000 for version 3.0 + version <- version16dot16, + /// Italic angle in counter-clockwise degrees from the vertical. Zero for upright text, + /// negative for text that leans to the right (forward). + italic_angle <- fixed, + /// This is the suggested distance of the top of the underline from the baseline (negative + /// values indicate below baseline). The PostScript definition of this FontInfo dictionary key + /// (the y coordinate of the center of the stroke) is not used for historical reasons. The + /// value of the PostScript key may be calculated by subtracting half the underlineThickness + /// from the value of this field. + underline_position <- fword, + /// Suggested values for the underline thickness. In general, the underline thickness should + /// match the thickness of the underscore character (U+005F LOW LINE), and should also match + /// the strikeout thickness, which is specified in the OS/2 table. + underline_thickness <- fword, + /// Set to 0 if the font is proportionally spaced, non-zero if the font is not proportionally + /// spaced (i.e. monospaced). + is_fixed_pitch <- u32be, + /// Minimum memory usage when an OpenType font is downloaded. + min_mem_type42 <- u32be, + /// Maximum memory usage when an OpenType font is downloaded. + max_mem_type42 <- u32be, + /// Minimum memory usage when an OpenType font is downloaded as a Type 1 font. + min_mem_type1 <- u32be, + /// Maximum memory usage when an OpenType font is downloaded as a Type 1 font. + max_mem_type1 <- u32be, + names <- match version { + /// Version 1, standard Macintosh names + 0x00010000 => {}, + /// Version 2, non-stanard names stored in table as Pascal strings + 0x00020000 => { + /// Number of glyphs (this should be the same as numGlyphs in 'maxp' table). + num_glyphs <- u16be, + /// Array of indices into the string data. + glyph_name_index <- array16 num_glyphs u16be, + /// Storage for the string data. + string_data <- stream_pos, + }, + /// Version 2.5 (deprecated), offset from standard Macintosh index + 0x00025000 => { + /// Number of glyphs + num_glyphs <- u16be, + /// Difference between graphic index and standard order of glyph + offset <- array16 num_glyphs s8, + }, + /// Version 3, no glyph names stored in font + 0x00030000 => {}, + _ => fail, + } +}; + + +// ----------------------------------------------------------------------------- + // TODO: "PCLT" .. "sbix" tables @@ -1428,7 +1490,7 @@ let table_directory = fun (file_start : Pos) => { }, name <- required_table "name" name_table, os2 <- required_table_with_len "OS/2" os2_table, - post <- required_table "post" unknown_table, + post <- required_table "post" post_table, // TrueType Outline Tables // diff --git a/formats/opentype.snap b/formats/opentype.snap index 2e1b978eb..dc6ec43db 100644 --- a/formats/opentype.snap +++ b/formats/opentype.snap @@ -345,6 +345,31 @@ let os2_table : _ = fun table_length => { _ => fail, }, }; +let post_table : _ = { + version <- version16dot16, + italic_angle <- fixed, + underline_position <- fword, + underline_thickness <- fword, + is_fixed_pitch <- u32be, + min_mem_type42 <- u32be, + max_mem_type42 <- u32be, + min_mem_type1 <- u32be, + max_mem_type1 <- u32be, + names <- match version { + 0x10000 => {}, + 0x20000 => { + num_glyphs <- u16be, + glyph_name_index <- array16 num_glyphs u16be, + string_data <- stream_pos, + }, + 0x25000 => { + num_glyphs <- u16be, + offset <- array16 num_glyphs s8, + }, + 0x30000 => {}, + _ => fail, + }, +}; let base_table : _ = unknown_table; let gdef_table : _ = unknown_table; let gpos_table : _ = unknown_table; @@ -399,7 +424,7 @@ let table_directory : _ = fun file_start => { }, name <- required_table "name" name_table, os2 <- required_table_with_len "OS/2" os2_table, - post <- required_table "post" unknown_table, + post <- required_table "post" post_table, cvt <- optional_table "cvt " unknown_table, fpgm <- optional_table "fpgm" unknown_table, glyf <- optional_table "glyf" {