@@ -58,7 +58,7 @@ script:
5858## Documentation
5959
6060The documents under [ docs/experimental] ( docs/experimental ) provide some more detailed designs of various aspects of the IFT encoder. Of note:
61- * [ compiler.md] ( docs/experimental )
61+ * [ compiler.md] ( docs/experimental/compiler.md )
6262* [ closure_glyph_segmentation.md] ( docs/experimental/closure_glyph_segmentation.md )
6363* [ closure_glyph_segmentation_merging.md] ( docs/experimental/closure_glyph_segmentation_merging.md )
6464* [ closure_glyph_segmentation_complex_conditions.md] ( docs/experimental/closure_glyph_segmentation_complex_conditions.md )
@@ -77,13 +77,81 @@ bazel run @hedron_compile_commands//:refresh_all
7777
7878Will generate a compile_commands.json file.
7979
80- ## Producing IFT Encoded Fonts
80+ ## Producing IFT Encoded Fonts (with Auto Config)
8181
82- IFT encoded fonts are produced in two steps:
83- 1 . A segmentation plan is generated which specifies how the font file should be split up in the IFT encoding.
84- 2 . The IFT encoded font and patches are compiled by the Compiler sub module using the segmentation plan.
82+ The simplest way to create IFT fonts is via the ` font2ift ` utility utilizing the auto configuration mode.
83+ This is done by running the utility and not providing a segmentation plan. Example invocation:
8584
86- ### Generating Segmentation Plan
85+ ``` bash
86+ bazel run -c opt @ift_encoder//util:font2ift -- \
87+ --input_font=" $HOME /fonts/myfont/MyFont.ttf" \
88+ --output_path=$HOME /fonts/myfont/ift/ \
89+ --output_font=" MyFont-IFT.woff2"
90+ ```
91+
92+ This will analyze the input font, decide how to segment it, and then produce the final IFT encoded font
93+ and patches.
94+
95+ When utilizing auto config there are two optional flags which can be used to adjust the behaviour:
96+ * ` --auto_config_primary_script ` : this tells the config generator which language/script the font is intended
97+ to be used with. It has two effects: first the codepoints of the primary script are eligible to be moved
98+ into the initial font. Second for scripts with large overlaps, such as CJK, primary script selects which
99+ of the overlapping scripts to use frequency data from. Values refer to frequency data files in
100+ [ ift-encoder-data] ( https://github.com/w3c/ift-encoder-data/tree/main/data ) . Example values: "Script_bengali",
101+ "Language_fr"
102+
103+ * ` --auto_config_quality ` : This is analagous to a quality level in a compression library. It controls how much
104+ effort is spent to improve the efficiency of the final IFT font. Values range from 1 to 8, where higher
105+ values increase encoding times but typically result in a more efficient end IFT font (ie. less bytes
106+ transferred by clients using it).
107+
108+ Example command line with optional flags:
109+
110+ ``` bash
111+ bazel run -c opt @ift_encoder//util:font2ift -- \
112+ --input_font=" $HOME /fonts/NotoSansJP-Regular.otf" \
113+ --output_path=$HOME /fonts/ift/ \
114+ --output_font=" NotoSansJP-Regular-IFT.woff2" \
115+ --auto_config_primary_script=Script_japanese \
116+ --auto_config_quality=3
117+ ```
118+
119+ * Note: the auto configuration mode is still under development, in particular the auto selection of quality level
120+ is currently quite simplistic. It's expected to continue to evolve from it's current state.*
121+
122+ ## Producing IFT Encoded Fonts (Advanced)
123+
124+ Under the hood IFT font encoding happens in three stages:
125+
126+ 1 . Generate or write a segmenter config for the font.
127+ 2 . Generate a segmentation plan, which describes how the font is split into patches. Takes the segmenter config as an input.
128+ 3 . Compile the final IFT encoded font following the segmentation plan.
129+
130+ For more advanced use cases these steps can be performed individually. This allows the segmenter config
131+ and segmentation plans to be fine tuned beyond what auto configuration is capable of.
132+
133+ ### Step 1: Generating a Segmenter Config
134+
135+ There are two main options for generating a segmenter config:
136+
137+ 1 . Write the config by hand, the segmenter is configured via an input configuration file using the
138+ [ segmenter_config.proto] ( util/segmenter_config.proto ) schema, see the comments there for more details.
139+ This option is useful when maximum control over segmentation parameters is needed, or custom frequency
140+ data is being supplied.
141+
142+ 2 . Auto generate the segmenter config using ` util:generate_segmenter_config ` .
143+
144+ ```
145+ CC=clang bazel run //util:generate_segmenter_config -- \
146+ --quality=5 \
147+ --input_font=$HOME/MyFont.ttf > config.txtpb
148+ ```
149+
150+ This analyzes the input font and tries to pick appropriate config values automatically. As discussed in
151+ the previous "Producing IFT Encoded Fonts" section there is a configurable quality level. If needed
152+ the auto generated config can be hand tweaked after generation.
153+
154+ ### Step 2: Generating Segmentation Plan
87155
88156Segmentation plans are in a [ textproto format] ( https://protobuf.dev/reference/protobuf/textformat-spec/ ) using the
89157[ segmentation_plan.proto] ( util/segmentation_plan.proto ) schema. See the comments in the schema file for more information.
@@ -93,17 +161,9 @@ possible to write plans by hand, or develop new utilities to generate plans.
93161
94162In this repo 3 options are currently provided:
95163
96- 1 . ` util/generate_table_keyed_config ` : this utility generates the table keyed (extension segments that augment non
97- glyph data in the font) portion of a plan. Example execution:
98-
99- ``` sh
100- bazel run -c opt util:generate_table_keyed_config -- \
101- --font=$( pwd) /myfont.ttf \
102- latin.txt cyrillic.txt greek.txt > table_keyed.txtpb
103- ```
104-
105- 2. ` util/closure_glyph_keyed_segmenter_util` : this utility uses a subsetting closure based approach to generate a glyph
106- keyed segmentation plan (extension segments that augment glyph data). Example execution:
164+ 1 . [ Recommended] ` util/closure_glyph_keyed_segmenter_util ` : this utility uses a subsetting closure based approach
165+ to generate a glyph keyed segmentation plan (extension segments that augment glyph data). It can optionally
166+ generate the table keyed portion of the config as well. Example execution:
107167
108168 ``` sh
109169 bazel run -c opt util:closure_glyph_keyed_segmenter_util -- \
@@ -119,6 +179,15 @@ In this repo 3 options are currently provided:
119179 Note: this utility is under active development and still very experimental. See
120180 [the status section](docs/experimental/closure_glyph_segmentation.md#status) for more details.
121181
182+ 2. ` util/generate_table_keyed_config` : this utility generates the table keyed (extension segments that augment non
183+ glyph data in the font) portion of a plan. Example execution:
184+
185+ ` ` ` sh
186+ bazel run -c opt util:generate_table_keyed_config -- \
187+ --font=$( pwd) /myfont.ttf \
188+ latin.txt cyrillic.txt greek.txt > table_keyed.txtpb
189+ ` ` `
190+
1221913. ` util/iftb2config` : this utility converts a segmentation obtained from the
123192 [binned incremental font transfer prototype](https://github.com/adobe/binned-ift-reference)
124193 into and equivalent segmentation plan. Example execution:
@@ -128,23 +197,20 @@ In this repo 3 options are currently provided:
128197 bazel run util:iftb2config > segmentation_plan.txtpb
129198 ` ` `
130199
131- If seperate glyph keyed and table keyed configs were generated using # 1 and #2 they can then be combined into one
200+ If separate glyph keyed and table keyed configs were generated using # 1 and #2 they can then be combined into one
132201complete plan by concatenating them:
133202
134203` ` ` sh
135204cat glyph_keyed.txtpb table_keyed.txtpb > segmentation_plan.txtpb
136205` ` `
137206
138- Additional tools for generating encoder configs are planned to be added in the future.
139-
140207For concrete examples of how to generate IFT fonts, see the [IFT Demo](https://github.com/garretrieger/ift-demo).
141208In particular the [Makefile](https://github.com/garretrieger/ift-demo/blob/main/Makefile) and the
142209[segmenter configs](https://github.com/garretrieger/ift-demo/tree/main/config) may be helpful.
143210
144- # ## Generating an IFT Encoding
211+ # ## Step 3: Generating an IFT Encoding
145212
146- Once an segmentation plan has been created it can be combined with the target font to produce and incremental font and collection
147- of associated patches using the font2ift utility which is a wrapper around the compiler. Example execution:
213+ Once a segmentation plan has been created it can be combined with the target font to produce an incremental font and collection of associated patches using the font2ift utility which is a wrapper around the compiler. Example execution:
148214
149215` ` ` sh
150216bazel -c opt run util:font2ift -- \
0 commit comments