Skip to content

Commit 676cf1a

Browse files
committed
Rename copy indices -> child indices to match spec update proposal.
w3c/IFT#252
1 parent 44d2398 commit 676cf1a

File tree

10 files changed

+48
-46
lines changed

10 files changed

+48
-46
lines changed

MODULE.bazel

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ http_archive(
7272
# Fontations
7373
http_archive(
7474
name = "fontations",
75-
urls = ["https://github.com/googlefonts/fontations/archive/e01046e776d4539daf9e1856f3d8c9ea02984b1d.zip"],
76-
strip_prefix = "fontations-e01046e776d4539daf9e1856f3d8c9ea02984b1d",
75+
urls = ["https://github.com/googlefonts/fontations/archive/9063931e9cb9c4e0b40a54c83314486dd36115f8.zip"],
76+
strip_prefix = "fontations-9063931e9cb9c4e0b40a54c83314486dd36115f8",
7777
build_file = "//third_party:fontations.BUILD",
78-
integrity = "sha256-S9whGuFK3+vqEdl0Fx4lNpEf7fZ8EwPJirxkGzS6wdY=",
78+
integrity = "sha256-aRxRkVF9A6aUE8Fu3y8StkH4tCLnM1iRFha6GcKbgFo=",
7979
)
8080

8181

@@ -111,4 +111,4 @@ git_override(
111111
module_name = "hedron_compile_commands",
112112
remote = "https://github.com/hedronvision/bazel-compile-commands-extractor.git",
113113
commit = "f5fbd4cee671d8d908f37c83abaf70fba5928fc7",
114-
)
114+
)

fontations/Cargo.lock

Lines changed: 5 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ift/encoder/encoder.cc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -794,16 +794,15 @@ Status Encoder::PopulateGlyphKeyedPatchMap(PatchMap& patch_map) const {
794794
}
795795

796796
PatchMap::Coverage coverage;
797-
coverage.copy_mode_append =
798-
false; // union the group members together (OR).
797+
coverage.conjunctive = false; // ... OR ...
799798

800799
for (uint32_t patch_id : group) {
801800
auto entry_index = patch_id_to_entry_index.find(patch_id);
802801
if (entry_index == patch_id_to_entry_index.end()) {
803802
return absl::InternalError(StrCat("entry for patch_id = ", patch_id,
804803
" was not previously created."));
805804
}
806-
coverage.copy_indices.insert(entry_index->second);
805+
coverage.child_indices.insert(entry_index->second);
807806
}
808807

809808
if (condition->required_groups.size() == 1 &&
@@ -831,15 +830,15 @@ Status Encoder::PopulateGlyphKeyedPatchMap(PatchMap& patch_map) const {
831830
for (auto condition = remaining_conditions.begin();
832831
condition != remaining_conditions.end(); condition++) {
833832
PatchMap::Coverage coverage;
834-
coverage.copy_mode_append = true; // append the groups (AND)
833+
coverage.conjunctive = true; // ... AND ...
835834

836835
for (const auto& group : condition->required_groups) {
837836
if (group.size() == 1) {
838-
coverage.copy_indices.insert(patch_id_to_entry_index[*group.begin()]);
837+
coverage.child_indices.insert(patch_id_to_entry_index[*group.begin()]);
839838
continue;
840839
}
841840

842-
coverage.copy_indices.insert(patch_group_to_entry_index[group]);
841+
coverage.child_indices.insert(patch_group_to_entry_index[group]);
843842
}
844843

845844
// TODO(garretrieger): required_features implies f1 AND f2 ..., but

ift/encoder/encoder_test.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,10 @@ void ClearCompatIdFromFormat2(uint8_t* data) {
700700
}
701701
}
702702

703+
// TODO(garretrieger): XXXXXXX test with activation conditions that ensures they
704+
// are expanded appropriately in the
705+
// initial font.
706+
703707
TEST_F(EncoderTest, Encode_ComplicatedActivationConditions) {
704708
Encoder encoder;
705709
hb_face_t* face = font.reference_face();

ift/integration_test.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,8 @@ TEST_F(IntegrationTest, MixedMode_OptionalFeatureTags) {
592592
ASSERT_FALSE(FontHelper::GlyfData(extended_face.get(), chunk6_gid)->empty());
593593
}
594594

595+
// TODO XXXX test using complex composite activation conditions
596+
595597
TEST_F(IntegrationTest, MixedMode_LocaLenChange) {
596598
Encoder encoder;
597599
auto sc = InitEncoderForMixedMode(encoder);

ift/proto/format_2_patch_map.cc

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ using common::SparseBitSet;
3030
namespace ift::proto {
3131

3232
constexpr uint8_t features_and_design_space_bit_mask = 1;
33-
constexpr uint8_t copy_indices_bit_mask = 1 << 1;
33+
constexpr uint8_t child_indices_bit_mask = 1 << 1;
3434
constexpr uint8_t index_delta_bit_mask = 1 << 2;
3535
constexpr uint8_t encoding_bit_mask = 1 << 3;
3636
constexpr uint8_t codepoint_bit_mask = 0b11 << 4;
@@ -246,7 +246,7 @@ Status EncodeEntry(const PatchMap::Entry& entry, uint32_t last_entry_index,
246246
bool has_codepoints = !coverage.codepoints.empty();
247247
bool has_features = !coverage.features.empty();
248248
bool has_design_space = !coverage.design_space.empty();
249-
bool has_copy_indices = !coverage.copy_indices.empty();
249+
bool has_child_indices = !coverage.child_indices.empty();
250250
bool has_features_or_design_space = has_features || has_design_space;
251251
int64_t delta =
252252
((int64_t)entry.patch_index) - ((int64_t)last_entry_index + 1);
@@ -258,10 +258,10 @@ Status EncodeEntry(const PatchMap::Entry& entry, uint32_t last_entry_index,
258258
// format
259259
uint8_t format =
260260
(has_features_or_design_space ? features_and_design_space_bit_mask
261-
: 0) | // bit 0
262-
(has_copy_indices ? copy_indices_bit_mask : 0) | // bit 1
263-
(has_delta ? index_delta_bit_mask : 0) | // bit 2
264-
(has_patch_encoding ? encoding_bit_mask : 0) | // bit 3
261+
: 0) | // bit 0
262+
(has_child_indices ? child_indices_bit_mask : 0) | // bit 1
263+
(has_delta ? index_delta_bit_mask : 0) | // bit 2
264+
(has_patch_encoding ? encoding_bit_mask : 0) | // bit 3
265265
(has_codepoints ? codepoint_bit_mask & BiasFormat(bias_bytes)
266266
: 0) | // bit 4 and 5
267267
(entry.ignored ? ignore_bit_mask : 0); // bit 6
@@ -285,20 +285,20 @@ Status EncodeEntry(const PatchMap::Entry& entry, uint32_t last_entry_index,
285285
}
286286
}
287287

288-
if (has_copy_indices) {
289-
if (entry.coverage.copy_indices.size() >
288+
if (has_child_indices) {
289+
if (entry.coverage.child_indices.size() >
290290
0b01111111) { // 7 bits are used to store the count.
291291
return absl::InvalidArgumentError(
292-
StrCat("Maximum number of copy indices exceeded: ",
293-
entry.coverage.copy_indices.size(), " > 127."));
292+
StrCat("Maximum number of child indices exceeded: ",
293+
entry.coverage.child_indices.size(), " > 127."));
294294
}
295-
uint8_t count = (uint8_t)entry.coverage.copy_indices.size();
296-
if (entry.coverage.copy_mode_append) {
295+
uint8_t count = (uint8_t)entry.coverage.child_indices.size();
296+
if (entry.coverage.conjunctive) {
297297
// MSB is used to record the append mode bit.
298298
count |= 0b10000000;
299299
}
300300
FontHelper::WriteUInt8(count, out);
301-
for (uint32_t index : entry.coverage.copy_indices) {
301+
for (uint32_t index : entry.coverage.child_indices) {
302302
WRITE_UINT24(index, out, "Exceeded max copy index size.");
303303
}
304304
}

ift/proto/format_2_patch_map_test.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,14 @@ TEST_F(Format2PatchMapTest, CopyIndices) {
9090
ASSERT_TRUE(sc.ok()) << sc;
9191

9292
PatchMap::Coverage union_cov;
93-
union_cov.copy_indices.insert(1);
94-
union_cov.copy_indices.insert(0);
93+
union_cov.child_indices.insert(1);
94+
union_cov.child_indices.insert(0);
9595
sc = map.AddEntry(union_cov, 3, TABLE_KEYED_FULL);
9696
ASSERT_TRUE(sc.ok()) << sc;
9797

9898
PatchMap::Coverage append_cov;
99-
append_cov.copy_indices.insert(2);
100-
append_cov.copy_mode_append = true;
99+
append_cov.child_indices.insert(2);
100+
append_cov.conjunctive = true;
101101
sc = map.AddEntry(append_cov, 4, TABLE_KEYED_FULL);
102102
ASSERT_TRUE(sc.ok()) << sc;
103103

ift/proto/patch_map.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,10 @@ Span<const PatchMap::Entry> PatchMap::GetEntries() const { return entries_; }
113113
Status PatchMap::AddEntry(const PatchMap::Coverage& coverage,
114114
uint32_t patch_index, PatchEncoding encoding,
115115
bool ignored) {
116-
// If copy indices are present ensure they refer only to entries prior to this
117-
// one.
118-
if (!coverage.copy_indices.empty()) {
119-
for (uint32_t index : coverage.copy_indices) {
116+
// If child indices are present ensure they refer only to entries prior to
117+
// this one.
118+
if (!coverage.child_indices.empty()) {
119+
for (uint32_t index : coverage.child_indices) {
120120
if (index >= entries_.size()) {
121121
return absl::InvalidArgumentError(
122122
absl::StrCat("Invalid copy index. ", index, " is out of bounds."));

ift/proto/patch_map.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,12 @@ class PatchMap {
5656
absl::btree_set<hb_tag_t> features;
5757
absl::btree_map<hb_tag_t, common::AxisRange> design_space;
5858

59-
// If true copy mode
60-
// (https://w3c.github.io/IFT/Overview.html#mapping-entry-copymodeandcount)
61-
// is "append", other it's "union".
62-
bool copy_mode_append = false;
63-
// Set of copy indices
64-
// (https://w3c.github.io/IFT/Overview.html#mapping-entry-copyindices)
59+
// https://w3c.github.io/IFT/Overview.html#mapping-entry-childentrymatchmodeandcount)
60+
bool conjunctive = false;
61+
// Set of child entry indices
62+
// (https://w3c.github.io/IFT/Overview.html#mapping-entry-childentrymatchmodeandcount)
6563
// values are the indices of previous entries.
66-
absl::btree_set<uint32_t> copy_indices;
64+
absl::btree_set<uint32_t> child_indices;
6765
};
6866

6967
struct Entry {

ift/proto/patch_map_test.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ TEST_F(PatchMapTest, AddEntry_WithCopyIndices) {
136136
};
137137

138138
PatchMap::Coverage cov;
139-
cov.copy_indices = {0, 1};
139+
cov.child_indices = {0, 1};
140140

141141
auto sc = map.AddEntry(cov, 5, TABLE_KEYED_FULL);
142142
ASSERT_TRUE(sc.ok()) << sc;
@@ -151,7 +151,7 @@ TEST_F(PatchMapTest, AddEntry_InvalidCopyIndices) {
151151
};
152152

153153
PatchMap::Coverage cov;
154-
cov.copy_indices = {0, 2};
154+
cov.child_indices = {0, 2};
155155

156156
auto sc = map.AddEntry(cov, 5, TABLE_KEYED_FULL);
157157
ASSERT_EQ(sc, absl::InvalidArgumentError(

0 commit comments

Comments
 (0)