Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
418 changes: 0 additions & 418 deletions docs/experimental/closure_glyph_segmentation.md

This file was deleted.

157 changes: 0 additions & 157 deletions docs/experimental/closure_glyph_segmentation_complex_conditions.md

This file was deleted.

13 changes: 5 additions & 8 deletions docs/experimental/unicode_range_segmentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ With `@font-face` `unicode-range`, a font is split into a collection of standalo
| **Client Loading Model** | Single font instance incrementally extended by patches | Independent `@font-face` WOFF2 font files matched per character by `unicode-range` |
| **Initial Segment (`config.initial_segment`)** | Loaded once as the base font; initial font merging moves high-probability patches into it | Included in **every** subset (union of `initial_segment` codepoints/glyphs/features + default features and the patch's glyphs; useful for UVS codepoints, etc.). Initial font merging is disabled |
| **Layout Features** | Optional feature patches + table-keyed patches | Codepoints only; each subset statically retains the default layout features plus any explicitly requested in `config.initial_segment.features`. Optional feature segments and table-keyed segments are disallowed |
| **Unmapped Glyphs** | Configurable (defaults to `MOVE_TO_INIT_FONT`) | Must be `FIND_CONDITIONS` or `PATCH` (`AutoSegmenterConfig` sets `FIND_CONDITIONS`; `MOVE_TO_INIT_FONT` is rejected) |
| **Patch Merging** | Optional (`experimental_use_patch_merges`) | Disabled; only segment merges are performed |
| **Interacting Glyphs & Disjoint Conditions** | Can be placed in separate patches (e.g. `fi` in patch `f AND i`, shared component `A` in `A OR À`) | Determined via dependency graph / closure analysis; `MakeActivationConditionsDisjoint` merges triggering segments of non-exclusive conditions whose probability $\ge$ `disjoint_conditions_probability_threshold`. Conditions below the threshold are skipped |
| **Final Subsets & Activation Conditions** | CNF expressions (`(s1 OR s2) AND s3`) | Only **exclusive** patches (`(s_i)`) are emitted in the final plan (any remaining non-exclusive patches are ignored), yielding strictly disjunctive and mutually disjoint `unicode-range` sets |
Expand All @@ -29,16 +28,14 @@ With `@font-face` `unicode-range`, a font is split into a collection of standalo
A `TargetMode` enum (`IFT`, `UNICODE_RANGE`) in [segmenter_config.proto](../ift/config/segmenter_config.proto) selects the segmentation target mode (`target_mode` on `SegmenterConfig`, defaulting to `IFT`), alongside a `disjoint_conditions_probability_threshold` setting. The auto-configuration generator (`AutoSegmenterConfig::GenerateConfig`) also accepts `TargetMode` and automatically configures appropriate defaults when `UNICODE_RANGE` is selected:

* Disables optional feature segment generation (`generate_feature_segments = false`) and table-keyed segment generation (`generate_table_keyed_segments = false`).
* Sets `unmapped_glyph_handling = FIND_CONDITIONS` so all glyphs in the full closure receive activation conditions.
* Leaves initial font merging thresholds unset and skips IFT-specific base segmentation plan settings (`jump_ahead`, `use_prefetch_lists`).

To ensure invalid configurations are caught regardless of whether a caller goes through `SegmenterConfigUtil` or invokes `ClosureGlyphSegmenter` directly, `ClosureGlyphSegmenter` validates that when `target_mode == UNICODE_RANGE`:

1. `unmapped_glyph_handling` is set to either `FIND_CONDITIONS` or `PATCH` (`MOVE_TO_INIT_FONT` is rejected).
2. No input segment definitions contain layout features (optional feature loading is unsupported).
3. Initial font merging is not enabled on any merge group.
4. Patch merging is disabled on all merge groups.
5. `generate_table_keyed_segments` is not enabled.
1. No input segment definitions contain layout features (optional feature loading is unsupported).
2. Initial font merging is not enabled on any merge group.
3. Patch merging is disabled on all merge groups.
4. `generate_table_keyed_segments` is not enabled.

### Initial Segment Handling

Expand All @@ -57,7 +54,7 @@ In CSS `@font-face`, each subset is treated as a separate font face during text

### `MakeActivationConditionsDisjoint`

After initial condition analysis (and unmapped glyph condition finding when `FIND_CONDITIONS` is used), the segmenter runs a `MakeActivationConditionsDisjoint` pass before starting general cost-based or heuristic merging:
After initial condition analysis, the segmenter runs a `MakeActivationConditionsDisjoint` pass before starting general cost-based or heuristic merging:

1. Inspect all non-exclusive patch conditions (conditions involving more than one triggering segment, whether conjunctive or disjunctive).
2. Group segments into connected components by unioning the triggering segments of each non-exclusive condition.
Expand Down
12 changes: 2 additions & 10 deletions docs/segmenter.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,9 @@ In the proceeding sections each of these steps will be discussed in more details

## Condition Analysis

Detecting the conditions under which a glyph is needed can be done in a couple of different
ways. The segmentation implementation currently has two main approaches:
Condition analysis infers the activation conditions under which each glyph in the font is needed by analyzing a [glyph dependency graph](dependency_graph.md) and running [dependency graph condition extraction](dependency_graph_condition_extract.md) (previously, an experimental font-subsetting closure approach was also supported; that approach has been removed).

1. Infer glyph conditions via [font subsetting closure](experimental/closure_glyph_segmentation.md).
2. Infer glyph conditions via a [glyph dependency graph](dependency_graph.md) and [dependency graph condition extraction](dependency_graph_condition_extract.md).

Both approaches ultimately aim to detect conditions that each glyph is needed which will satisfy the glyph closure
requirement. The dependency graph is the default and recommended method for finding conditions. It's generally faster
and produces more detailed conditions.
Using the dependency graph generates detailed activation conditions that satisfy the glyph closure requirement, and the final segmentation is validated against HarfBuzz subsetting closure.

## Merging

Expand Down Expand Up @@ -373,8 +367,6 @@ In the merger implementation, actual cost delta computation is optimized by firs
*aggregate probability* $P_{\text{agg}}(c_i) = \sum_{m=1}^M P_m(c_i)$ of a condition across all
frequency data sets in the merge group, and then multiplying that sum once by $(\text{size}(p_i) + k)$
for each affected patch. This avoids redundant patch size evaluations and per-data-set delta loops.
Similarly, because the fallback patch is needed with probability $1.0$ under every frequency data set,
its size delta is multiplied by the number of data sets $M$.

### Prioritizing a Primary Script and Language

Expand Down
23 changes: 6 additions & 17 deletions ift/config/auto_segmenter_config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,6 @@ enum Quality {
// To start, the list of parameters we can use to make quality/performance
// tradeoffs:
//
// - unmapped_glyph_handling (global)
// Lower quality is to not find conditions (so use patch or init font), high
// quality is to find conditions.
//
// - generate_feature_segments (global): high quality generate segment per
// feature, low quality put all optional features
// in one segment.
Expand All @@ -135,10 +131,10 @@ enum Quality {
// Would be reasonable to always have this set to at least the minimum group
// size.
//
// - condition_analysis_mode: use DEP_GRAPH_ONLY if dependency API is available,
// otherwise CLOSURE_ONLY. DEP_GRAPH_ONLY_WITH_SIMPLIFICATION can significantly
// speed up cases with high condition complexity, at the cost of less specific
// final conditions.
// - condition_analysis_mode: use DEP_GRAPH_ONLY or
// DEP_GRAPH_ONLY_WITH_SIMPLIFICATION. DEP_GRAPH_ONLY_WITH_SIMPLIFICATION can
// significantly speed up cases with high condition complexity, at the cost of
// less specific final conditions.
//
// Merge group settings:
//
Expand Down Expand Up @@ -403,10 +399,9 @@ static Status GroupInteractingScripts(

std::unique_ptr<RequestedSegmentationInformation> segmentation_info =
TRY(RequestedSegmentationInformation::Create(
std::move(segments), init_segment, *closure_cache, FIND_CONDITIONS));
std::move(segments), init_segment, *closure_cache));
std::unique_ptr<DependencyClosure> dependency_closure =
TRY(DependencyClosure::Create(segmentation_info.get(), face, resolver,
/*allow_context_glyph_analysis=*/true));
TRY(DependencyClosure::Create(segmentation_info.get(), face, resolver));

GlyphPartition ungrouped_partition(ungrouped_list.size());
flat_hash_map<uint32_t, IntSet> ungrouped_to_scripts;
Expand Down Expand Up @@ -958,12 +953,6 @@ static void ApplyQualityLevelTo(Quality quality, MergeGroup& merge_group) {
static void ApplyQualityLevelTo(Quality quality, SegmenterConfig& config) {
config.set_preprocess_merging_group_size_for_ungrouped(kMinimumGroupSize * 3);

if (config.target_mode() == UNICODE_RANGE) {
config.set_unmapped_glyph_handling(FIND_CONDITIONS);
} else {
config.set_unmapped_glyph_handling(MOVE_TO_INIT_FONT);
}

if (quality == ONE) {
config.set_condition_analysis_mode(DEP_GRAPH_ONLY_WITH_SIMPLIFICATION);
} else {
Expand Down
Loading
Loading