Skip to content

Commit 6bc9950

Browse files
committed
Merge branch 'fix-maxp-again'
# By Alexander Mankuta (2) and Thomas Dy (1) * fix-maxp-again: Add changelog entry Add spec for maxp encoding Pass correct glyph mapping when encoding maxp
2 parents ad8367a + ff7be51 commit 6bc9950

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
77

88
## [Unreleased]
99

10+
### Fixed
11+
12+
* `maxp` table encoding
13+
14+
The table was encoded with the reverse subset indexinx. This resulted in
15+
incorrect values being encoded in `maxp` table. This tripped some of the more
16+
fussy renderers like Adobe Acrobat, but also constrained implementations such
17+
as in most printers.
18+
19+
Thomas Dy
20+
1021
## [1.8.0][] - 2024-03-05
1122

1223
### Fixed

lib/ttfunk/ttf_encoder.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def hhea_table
107107
end
108108

109109
def maxp_table
110-
@maxp_table ||= TTFunk::Table::Maxp.encode(original.maximum_profile, old_to_new_glyph)
110+
@maxp_table ||= TTFunk::Table::Maxp.encode(original.maximum_profile, new_to_old_glyph)
111111
end
112112

113113
def post_table

spec/ttfunk/ttf_encoder_spec.rb

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99
let(:original) { TTFunk::File.open(original_font_path) }
1010

1111
let(:encoder_options) { {} }
12+
let(:subset_characters) { 'a'..'z' }
1213
let(:encoder) do
1314
subset =
1415
TTFunk::Subset::Unicode.new(original).tap do |sub_set|
1516
# ASCII lowercase
16-
(97..122).each { |char| sub_set.use(char) }
17+
subset_characters.each { |char| sub_set.use(char.ord) }
1718
end
1819

1920
described_class.new(original, subset, encoder_options)
@@ -65,7 +66,16 @@
6566

6667
# verified via the Font-Validator tool at:
6768
# https://github.com/HinTak/Font-Validator
68-
expect(checksum).to eq(0xEEAE9DCF)
69+
expect(checksum).to eq(0xEEB49DA9)
70+
end
71+
72+
example_group 'maxp regression', issue: 102 do
73+
let(:subset_characters) { ['A'] }
74+
75+
it 'correctly encodes maxp table for subset' do
76+
maxp = new_font.maximum_profile
77+
expect(maxp.max_points).to eq 11
78+
end
6979
end
7080
end
7181
end

0 commit comments

Comments
 (0)