f-office-docx 0.2.3

DOCX model and Word's layout rules.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978
6979
6980
6981
6982
6983
6984
6985
6986
6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
7340
7341
7342
7343
7344
7345
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
7366
7367
7368
7369
7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383
7384
7385
7386
7387
7388
7389
7390
7391
7392
7393
7394
7395
7396
7397
7398
7399
7400
7401
7402
7403
7404
7405
7406
7407
7408
7409
7410
7411
7412
7413
7414
7415
7416
7417
7418
7419
7420
7421
7422
7423
7424
7425
7426
7427
7428
7429
7430
7431
7432
7433
7434
7435
7436
7437
7438
7439
7440
7441
7442
7443
7444
7445
7446
7447
7448
7449
7450
7451
7452
7453
7454
7455
7456
7457
7458
7459
7460
7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7481
7482
7483
7484
7485
7486
7487
7488
7489
7490
7491
7492
7493
7494
7495
7496
7497
7498
7499
7500
7501
7502
7503
7504
7505
7506
7507
7508
7509
7510
7511
7512
7513
7514
7515
7516
7517
7518
7519
7520
7521
7522
7523
7524
7525
7526
7527
7528
7529
7530
7531
7532
7533
7534
7535
7536
7537
7538
7539
7540
7541
7542
7543
7544
7545
7546
7547
7548
7549
7550
7551
7552
7553
7554
7555
7556
7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
7583
7584
7585
7586
7587
7588
7589
7590
7591
7592
7593
7594
7595
7596
7597
7598
7599
7600
7601
7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
7653
7654
7655
7656
7657
7658
7659
7660
7661
7662
7663
7664
7665
7666
7667
7668
7669
7670
7671
7672
7673
7674
7675
7676
7677
7678
7679
7680
7681
7682
7683
7684
7685
7686
7687
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
7699
7700
7701
7702
7703
7704
7705
7706
7707
7708
7709
7710
7711
7712
7713
7714
7715
7716
7717
7718
7719
7720
7721
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731
7732
7733
7734
7735
7736
7737
7738
7739
7740
7741
7742
7743
7744
7745
7746
7747
7748
7749
7750
7751
7752
7753
7754
7755
7756
7757
7758
7759
7760
7761
7762
7763
7764
7765
7766
7767
7768
7769
7770
7771
7772
7773
7774
7775
7776
7777
7778
7779
7780
7781
7782
7783
7784
7785
7786
7787
7788
7789
7790
7791
7792
7793
7794
7795
7796
7797
7798
7799
7800
7801
7802
7803
7804
7805
7806
7807
7808
7809
7810
7811
7812
7813
7814
7815
7816
7817
7818
7819
7820
7821
7822
7823
7824
7825
7826
7827
7828
7829
7830
7831
7832
7833
7834
7835
7836
7837
7838
7839
7840
7841
7842
7843
7844
7845
7846
7847
7848
7849
7850
7851
7852
7853
7854
7855
7856
7857
7858
7859
7860
7861
7862
7863
7864
7865
7866
7867
7868
7869
7870
7871
7872
7873
7874
7875
//! The quirk registry: the behaviors of Word that are not numbers. A quirk is one point where
//! Word's behavior can vary, written as an enum whose variants are the behaviors seen there,
//! each named after what it does. A target's profile names the variant of every quirk, and
//! the profile module is the only code that builds [`Quirks`].
//!
//! The doc comment of each variant ends with lines that give its class and its status, as the
//! parameter registry (`params.rs`) does:
//!
//! ```text
//! /// - class: undocumented
//! /// - status: unknown
//! ```
//!
//! The classes are `specification` (the behavior follows a specification), `compatibility
//! option` (a documented compatibility option selects it), `undocumented` (undocumented
//! behavior of the product) and `regression` (a regression in some builds). F-Office reproduces
//! the target's behavior in every class. The statuses are those of the parameter registry, and
//! an unknown variant counts with the unknown parameters.
//!
//! A quirk starts with the behavior of the base target. A target with another behavior adds a
//! variant, its profile names it, and the code at the quirk's place reads the profile's
//! [`Quirks`] from then on. Until then, each place
//! cites its quirk in a comment.

use std::fmt;

/// A quirk: an enum of the behaviors seen at one point.
pub trait Quirk: Copy + Sized + 'static {
    /// The quirk's name in a profile: the name of its enum.
    const NAME: &'static str;
    /// The variants, by their names in a profile.
    const VARIANTS: &'static [(&'static str, Self)];

    /// The variant that a profile names `name`.
    #[must_use]
    fn named(name: &str) -> Option<Self> {
        Self::VARIANTS
            .iter()
            .find(|(own, _)| *own == name)
            .map(|(_, variant)| *variant)
    }
}

macro_rules! quirk {
    ($quirk:ident: $($variant:ident),+ $(,)?) => {
        impl Quirk for $quirk {
            const NAME: &'static str = stringify!($quirk);
            const VARIANTS: &'static [(&'static str, Self)] =
                &[$((stringify!($variant), Self::$variant)),+];
        }
    };
}

/// How a document prints its comments and tracked changes.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Markup {
    /// A document whose body has comments prints with the markup area, and tracked changes
    /// print inline with their marks. Word prints some
    /// documents with comments without the markup area, and why is not known.
    ///
    /// - class: undocumented
    /// - status: unknown
    PrintsMarkupArea,
    /// A document prints as it reads with every tracked change accepted, and without its
    /// comments: no markup area, no deleted or moved-away text, no marks and no change bars
    /// (`revisions::accept`).
    ///
    /// - class: undocumented
    /// - status: unknown
    PrintsNoMarkup,
}
quirk!(Markup: PrintsMarkupArea, PrintsNoMarkup);

/// How a glyph advance at a size on the device grid is written.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum GridAdvances {
    /// The advance rounds to the PDF writer's advance steps. At a size off the device grid,
    /// each text object takes a character spacing and corrections in whole thousandths of an
    /// em that do not carry from one glyph to the next (`layout::line::draw::drawn_x`). Word's PDF
    /// writer also writes some runs on the grid with character spacing, and when is not known.
    ///
    /// - class: undocumented
    /// - status: unknown
    RoundToPdfSteps,
    /// Each glyph of a line goes one step after the glyph before, where the step is the
    /// distance between the two plus a bias, rounded to a dot, and it moves one dot when its
    /// right edge would end too far from its exact right edge. The steps start again at each
    /// segment of the line. The profile gives the bias, the limit and the segment's length
    /// (`layout.glyph_step_bias_half_emus`, `layout.glyph_edge_limit_half_emus`,
    /// `layout.glyph_segment_length_half_emus`); see `grid::EdgeSteps`. The glyphs are drawn
    /// where the PDF writer draws these places, in text objects (`grid::TextObject`).
    ///
    /// - class: undocumented
    /// - status: measured
    RightEdgeSteps,
}
quirk!(GridAdvances: RoundToPdfSteps, RightEdgeSteps);

/// Where a segment of a line ends under `GridAdvances::RightEdgeSteps`, after which the glyph
/// whose exact right edge first ends past it starts the device steps again (`grid::EdgeSteps`).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum GlyphSegments {
    /// A whole number of segments after the exact place of the line's first glyph, or of the
    /// first glyph after a tab or a list label's gap; another gap with a width, such as an inline object, keeps the
    /// segment.
    ///
    /// - class: undocumented
    /// - status: measured
    FromLineStart,
    /// One segment after the exact place of the glyph that started the current segment, so
    /// that each segment counts from its own first glyph; the glyph that starts a segment
    /// counts its exact place from the dot of the segment before.
    ///
    /// - class: undocumented
    /// - status: measured
    FromRestart,
}
quirk!(GlyphSegments: FromLineStart, FromRestart);

/// How the device steps a glyph under `GridAdvances::RightEdgeSteps`: at which drawn size the
/// step from a glyph to the next counts where the two glyphs' sizes differ
/// (`grid::EdgeSteps::at_size`), whether a run's character spacing and the kerning of a face
/// that stands in for a missing name step as extras of their own beside the glyph's device
/// width (`text::ShaperSettings`), how such an extra rounds to whole dots (`grid::EdgeSteps`),
/// and where a line number's digits lie (`grid::Device::line_number_start`). One quirk holds
/// them, because one step explains each on Word for Windows: the glyph's device width plus each
/// extra that the line gives it, rounded to whole dots on its own.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum DeviceAdvance {
    /// The device steps a glyph's exact advance with its extras in it, without a model of how
    /// a device steps them:
    ///
    /// - the step from a glyph to the next counts at the drawn size of the next glyph, the one
    ///   that the step places;
    /// - a run's character spacing is part of each glyph's advance, which the PDF writer writes
    ///   as the glyph's width and the device steps as one length. F-Office's writer takes a
    ///   character spacing (`Tc`) only when
    ///   `params::WRITER_SPACING_SHARE` of the exact steps share it;
    /// - a character spacing that steps alone rounds to the nearest dot with a half dot up, as a
    ///   position rounds, and a justified space's share and the space's spacing round summed,
    ///   once, as a share rounds;
    /// - a kerned run of a face that stands in for a name that no installed font carries steps as
    ///   the face does under its own name (`KernedDeviceWidths::in_run`);
    /// - a line number starts the distance and its digits' exact widths left of the dot of its
    ///   column's left edge, to the nearest dot with a half up, and its digits step as any line's
    ///   glyphs do, with the edge check.
    ///
    /// The target that chooses it does not step glyphs by whole dots, so it changes nothing
    /// there but the line numbers.
    ///
    /// - class: undocumented
    /// - status: derived
    ExactAdvances,
    /// Each step is the glyph's device width plus each extra that the line gives the glyph,
    /// rounded to whole dots on its own:
    ///
    /// - the step from a glyph to the next counts at the drawn size of the glyph before, whose
    ///   advance the distance holds, and the next glyph's own step keeps its own size;
    /// - the PDF writer writes a spaced glyph with its own width and puts the spacing into the
    ///   adjustment after it, as it does with kerning, and the spacing steps on its own, as a
    ///   justified space's extra does;
    /// - a character spacing alone rounds to the nearest dot with a half dot away from zero, so
    ///   that a spacing of -2.5 dots steps as -3 dots, and a justified space's share and the
    ///   space's spacing round each on its own, the share with a half dot up, and add: a share
    ///   of 5.34 dots with a spacing of -0.83 dot steps 4 dots, not 5;
    /// - each glyph of a kerned run of a face that stands in for a missing name steps by its own
    ///   device width and the bias plus the pair's kerning in whole dots on its own
    ///   (`KernedDeviceWidths::OwnWithKerningOnItsOwn`), in every mode;
    /// - a line number ends on the dot of its column's left edge, as a line's start takes it,
    ///   less the distance to its nearest dot with a half up; each digit lies one device width
    ///   in whole dots after the one before, and no edge check moves one.
    ///
    /// - class: undocumented
    /// - status: measured
    ExtrasOnTheirOwn,
}
quirk!(DeviceAdvance: ExactAdvances, ExtrasOnTheirOwn);

impl DeviceAdvance {
    /// The steps of a kerned run whose face steps by `steps` under its own name, when the face
    /// stands in for the run's font (`stands_in`) or not.
    #[must_use]
    pub fn stand_in_steps(self, steps: KernedDeviceWidths, stands_in: bool) -> KernedDeviceWidths {
        match self {
            Self::ExtrasOnTheirOwn if stands_in => KernedDeviceWidths::OwnWithKerningOnItsOwn,
            _ => steps,
        }
    }
}

/// Which run gives a page number or page count that Word computes its faces, sizes, bold, italic
/// and color, when the field's code has no `\* MERGEFORMAT`, and the box of a check box form
/// field its face and size. A page reference keeps the format of its own run.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ComputedFieldFormat {
    /// The run that shows the value, the run of the stored result, as the file writes it; for
    /// a check box, the run of the field's start. This keeps F-Office's existing reading rather
    /// than asserting a behavior of the targets that choose it. On Word for Windows it holds for
    /// a code with `\* MERGEFORMAT`.
    ///
    /// - class: undocumented
    /// - status: derived
    ResultRun,
    /// The first run of the field's code, as it sets these properties directly; with
    /// `\* MERGEFORMAT` the run of the stored result. A check box takes the first run of its
    /// code too, whatever its code says.
    ///
    /// - class: undocumented
    /// - status: measured
    CodeRun,
}
quirk!(ComputedFieldFormat: ResultRun, CodeRun);

/// Whether a page number or page count that Word computes keeps the direct underline,
/// strikethrough and highlight of the run that shows it, whatever its code's switch.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ComputedFieldDecorations {
    /// It keeps them, as the run sets them. This keeps F-Office's existing reading rather than
    /// asserting a behavior of the targets that choose it.
    ///
    /// - class: undocumented
    /// - status: derived
    Drawn,
    /// It draws none of them, neither those of the run of its stored result nor those of the
    /// first run of its code, with or without `\* MERGEFORMAT` and `\* CHARFORMAT`.
    ///
    /// - class: undocumented
    /// - status: measured
    Dropped,
}
quirk!(ComputedFieldDecorations: Drawn, Dropped);

/// Which paragraphs Word's built-in list numbers: decimal labels such as "1." and a tab at each
/// level, for the paragraphs whose list no list definition of the package gives.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum BuiltInList {
    /// The paragraphs of a package without a numbering part, without an indent, each list ID
    /// counting on its own. With a numbering part, a list that it does not define numbers no
    /// paragraph. This keeps F-Office's existing reading rather than asserting a behavior of
    /// the targets that choose it.
    ///
    /// - class: undocumented
    /// - status: derived
    WithoutPart,
    /// Every paragraph whose list the numbering part does not define, or whose list instance's
    /// abstract list it lacks, and every listed paragraph of a package without a numbering
    /// part. Each level hangs its label by an indent step left of its text, which lies one
    /// step further right for each level. The list IDs are instances of the one built-in list
    /// that override the start of every level: the first paragraph of a list ID starts the
    /// counters again, and a later one continues the counters that the lists share.
    ///
    /// - class: undocumented
    /// - status: measured
    ForUndefined,
}
quirk!(BuiltInList: WithoutPart, ForUndefined);

/// How the edge check of `GridAdvances::RightEdgeSteps` counts a glyph's exact right edge,
/// which it compares with the limit (`grid::EdgeSteps`).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum GlyphEdgeCheck {
    /// The exact places count from the advances as F-Office keeps them, in whole half-EMUs,
    /// and an edge within `params::GLYPH_EDGE_TIE` of the limit counts as on it. The tie
    /// stands in for the exact arithmetic of the target.
    ///
    /// - class: undocumented
    /// - status: limit
    RoundedWithTie,
    /// The exact places count from each glyph's exact advance, the font's advance at the size
    /// cut down to whole parts of `params::ADVANCE_PARTS_PER_POINT`, with what rounding to
    /// half-EMUs took from it, and the edge compares with the limit exactly, with no tie.
    ///
    /// - class: undocumented
    /// - status: fitted
    Exact,
}
quirk!(GlyphEdgeCheck: RoundedWithTie, Exact);

/// Where the device draws the last visible glyph of a filled justified line when stretched
/// spaces, not a glyph, come right before it, such as a word of one character at the line's
/// end, with a space after it (`layout::line`).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum SpacedLastGlyph {
    /// At the place that the device's steps give it, as at every other glyph.
    ///
    /// - class: undocumented
    /// - status: derived
    StepsPlace,
    /// Left of its steps' place by whole dots until that place, with the edge check's move,
    /// lies no more than the edge check's limit right of the glyph's exact place, and never
    /// right of it.
    ///
    /// - class: undocumented
    /// - status: unknown
    EdgeLimit,
}
quirk!(SpacedLastGlyph: StepsPlace, EdgeLimit);

/// How a filled justified line shares the free space that its stretched spaces take among them,
/// where the spaces stretch (`layout::line`), from `WIDTH_SHARE_MODE`; in an earlier mode, each
/// stretched space takes the same share whatever the target.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum StretchedSpaceShare {
    /// Each stretched space takes the same share.
    ///
    /// - class: undocumented
    /// - status: derived
    Equal,
    /// Each stretched space first takes a share in proportion to its own width, up to the part
    /// `STRETCH_BY_WIDTH` of that width, and the spaces take what is left of the free space in
    /// equal parts, both where the spaces stretch and where they shrink. Spaces of one width
    /// take equal shares, as with `Equal`.
    ///
    /// - class: undocumented
    /// - status: measured
    WidthFirst,
}
quirk!(StretchedSpaceShare: Equal, WidthFirst);

/// Whether a justified line stretches and shrinks a no-break space as it does a plain space,
/// below `NO_BREAK_SHARE_MODE`.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum NoBreakSpaceShare {
    /// A no-break space keeps its width in a justified line. This is F-Office's layout before
    /// the rule.
    ///
    /// - class: undocumented
    /// - status: derived
    None,
    /// A no-break space takes the share of a plain space where the styles part has no
    /// `w:rPrDefault`, or the East Asian font of its run defaults is one made for East Asian text,
    /// as for the East Asian spacing of letters and digits; elsewhere it keeps its width. A line
    /// still never breaks at it.
    ///
    /// - class: undocumented
    /// - status: measured
    EastAsianDefaults,
}
quirk!(NoBreakSpaceShare: None, EastAsianDefaults);

/// Whether the PDF writer starts a text object where the font side of the glyphs changes
/// inside one face: between a character that the run's East Asian font draws and one that its
/// other fonts draw, when both name the same face (`grid::TextObjects`).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum FontSideChange {
    /// The writer keeps one text object across the change. This keeps F-Office's existing
    /// objects rather than asserting a behavior of the targets that choose it.
    ///
    /// - class: undocumented
    /// - status: derived
    Joins,
    /// The writer starts a text object at a glyph whose font side, East Asian or other,
    /// differs from the side of the last glyph before it that has one. A space keeps the side
    /// before it, and an open character leaves no side.
    ///
    /// - class: undocumented
    /// - status: derived
    StartsObject,
}
quirk!(FontSideChange: Joins, StartsObject);

/// Whether the PDF writer starts a text object at a format character that the shaper leaves
/// out (U+200B to U+200F, U+202A to U+202E, U+FEFF), which draws nothing and takes no room
/// (`grid::TextObjects`).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum FormatCharacterObjects {
    /// The writer keeps one text object across the character. This keeps F-Office's existing
    /// objects rather than asserting a behavior of the targets that choose it.
    ///
    /// - class: undocumented
    /// - status: derived
    Joins,
    /// The writer starts a text object at the first glyph after each such character in
    /// reading order, so that the glyphs on its two sides lie in different objects. In
    /// right-to-left text that glyph lies left of the character, and the object starts, from
    /// the left, at the glyph right of it.
    ///
    /// - class: undocumented
    /// - status: derived
    StartsObject,
}
quirk!(FormatCharacterObjects: Joins, StartsObject);

/// The order in which the PDF writer counts the glyphs and leading spaces of right-to-left
/// text when starting text objects (`grid::TextObjects`).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum RightToLeftObjectCount {
    /// From the line's left end, as the glyphs of left-to-right text. This keeps F-Office's
    /// existing objects rather than asserting a behavior of the targets that choose it.
    ///
    /// - class: undocumented
    /// - status: derived
    FromTheLeft,
    /// In reading order, from the right end of each stretch of right-to-left text and from
    /// each glyph that starts a run, a text piece, or another face. The object that the
    /// writer starts after the most glyphs holds the glyphs that come next in reading order,
    /// left of the full one on the line; reading-order leading spaces form their own
    /// space-only object on the right of the following letters, while reading-order trailing
    /// spaces stay inside the object of the glyphs before them.
    ///
    /// - class: undocumented
    /// - status: derived
    ReadingOrder,
}
quirk!(RightToLeftObjectCount: FromTheLeft, ReadingOrder);

/// Whether the PDF writer starts a text object at the edges of a hyperlink (`w:hyperlink`): at
/// the first drawn glyph of its content and at the first drawn glyph after its end, also where
/// the runs on both sides have the same properties.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum HyperlinkObjects {
    /// The writer keeps one text object across a hyperlink's edges where the runs on both
    /// sides would share one. This keeps F-Office's existing objects rather than asserting a
    /// behavior of the targets that choose it.
    ///
    /// - class: undocumented
    /// - status: derived
    Joins,
    /// The writer takes a hyperlink as a field whose result is its content: it starts a text
    /// object at the first drawn glyph of the content and at the first drawn glyph after the
    /// hyperlink's end, as at a field result and after a field's end.
    ///
    /// - class: undocumented
    /// - status: derived
    StartsObject,
}
quirk!(HyperlinkObjects: Joins, StartsObject);

/// What a field, a hyperlink (`w:hyperlink`), deleted text and a content control take in the
/// text buffers beside the content that a page shows.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum FieldBuffer {
    /// A field takes only its result, a hyperlink only its text, and deleted text and content
    /// controls nothing. This keeps F-Office's count before the rule rather than asserting a
    /// behavior of the targets that choose it.
    ///
    /// - class: undocumented
    /// - status: derived
    ResultOnly,
    /// A field takes its three marks, its code and its result, and a `HYPERLINK` field one
    /// character more. A hyperlink takes what the `HYPERLINK` field that Word makes of it takes:
    /// the marks, the one character more, and a code of `HYPERLINK`, the address or the anchor,
    /// the tooltip and the target frame, and a switch when it does not record history. Deleted
    /// text that the target accepts takes its characters and a deleted paragraph mark one, and
    /// a content control takes a start and an end mark.
    ///
    /// - class: undocumented
    /// - status: derived
    MarksAndCode,
}
quirk!(FieldBuffer: ResultOnly, MarksAndCode);

/// What a comment's reference (`w:commentReference`) takes in the text buffers. The marks of a
/// comment's range take nothing on every target.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum CommentBuffer {
    /// The reference takes nothing. This keeps F-Office's count before the rule rather than
    /// asserting a behavior of the targets that choose it.
    ///
    /// - class: undocumented
    /// - status: derived
    Nothing,
    /// The reference takes a mark of one character, as a footnote's reference does.
    ///
    /// - class: undocumented
    /// - status: measured
    ReferenceMark,
}
quirk!(CommentBuffer: Nothing, ReferenceMark);

/// Whether a named bookmark's start (`w:bookmarkStart`) ends the text of runs with the same
/// properties that layout measures as one.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum BookmarkText {
    /// The text before a bookmark's start ends there: the text after it is measured alone, its
    /// first glyph counts as the first glyph of a run, and the places of its characters in their
    /// run count from it. This keeps F-Office's layout before the rule rather than asserting a
    /// behavior of the targets that choose it.
    ///
    /// - class: undocumented
    /// - status: derived
    Splits,
    /// A bookmark's start leaves the runs on both sides one measured text, as if the bookmark were
    /// not there.
    ///
    /// - class: undocumented
    /// - status: derived
    Joins,
}
quirk!(BookmarkText: Splits, Joins);

/// How the writer reads a revision ID of zero (`w:rsidR` or `w:rsidRPr` of `00000000`) when it
/// decides whether a run continues the text object of the run before it.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ZeroRevision {
    /// An ID of zero is an ID like any other: a run with it beside a run without that ID starts
    /// a text object. This keeps F-Office's reading before the rule rather than asserting a
    /// behavior of the targets that choose it.
    ///
    /// - class: undocumented
    /// - status: derived
    AnId,
    /// An ID of zero is no ID: a run with it beside a run without that ID continues the text
    /// object, as two runs without it do.
    ///
    /// - class: undocumented
    /// - status: measured
    NoId,
}
quirk!(ZeroRevision: AnId, NoId);

impl ZeroRevision {
    /// The revision IDs of a run, the session that added it, the one that last formatted it and
    /// the accepted insertion that held it, as the writer compares them with those of the run
    /// before.
    #[must_use]
    pub fn read(self, [added, formatted, insertion]: [Option<u32>; 3]) -> [Option<u32>; 3] {
        match self {
            Self::AnId => [added, formatted, insertion],
            Self::NoId => {
                let id = |revision: Option<u32>| revision.filter(|&value| value != 0);
                [id(added), id(formatted), insertion]
            }
        }
    }
}

/// Whether the PDF writer starts a text object at the first drawn glyph after tracked deleted
/// or moved-away text (`w:del`, `w:moveFrom`) that the target accepts, also where the runs on
/// both sides have the same properties and revision IDs.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum RemovedTextObjects {
    /// The runs on both sides of the removed text are one text object where they would be one
    /// without it. This keeps F-Office's objects before the rule rather than asserting a
    /// behavior of the targets that choose it.
    ///
    /// - class: undocumented
    /// - status: derived
    Joins,
    /// The first drawn glyph after removed text starts a text object, as after a field's end.
    ///
    /// - class: undocumented
    /// - status: measured
    StartsObject,
}
quirk!(RemovedTextObjects: Joins, StartsObject);

/// Whether the PDF writer starts a text object at the edges of a content control in a
/// paragraph (`w:sdt`): at the first drawn glyph of its content and at the first drawn glyph
/// after its end, also where the runs on both sides have the same properties and revision IDs.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ControlObjects {
    /// The runs on both sides of a content control's edge are one text object where they would
    /// be one without it. This keeps F-Office's objects before the rule rather than asserting a
    /// behavior of the targets that choose it.
    ///
    /// - class: undocumented
    /// - status: derived
    Joins,
    /// The writer starts a text object at the first drawn glyph of a content control's content
    /// and at the first drawn glyph after its end; the runs inside one control join.
    ///
    /// - class: undocumented
    /// - status: measured
    StartsObject,
}
quirk!(ControlObjects: Joins, StartsObject);

/// Which tracked insertions (`w:ins`, `w:moveTo`) that the target accepts are one revision, so
/// that their runs can join into one text object.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum InsertionRevision {
    /// The insertions of one author are one revision, whatever their dates. This keeps
    /// F-Office's numbering before the rule rather than asserting a behavior of the targets that
    /// choose it.
    ///
    /// - class: undocumented
    /// - status: derived
    Author,
    /// The insertions of one author whose dates (`w:date`) lie in the same minute, or that have
    /// no date, are one revision; another minute is another revision.
    ///
    /// - class: undocumented
    /// - status: measured
    AuthorAndMinute,
}
quirk!(InsertionRevision: Author, AuthorAndMinute);

impl InsertionRevision {
    /// What makes the insertion of `author` at `date` one revision with another: its author,
    /// and its date to the minute where the variant says so.
    #[must_use]
    pub fn key<'a>(self, author: &'a str, date: Option<&'a str>) -> (&'a str, Option<&'a str>) {
        match self {
            Self::Author => (author, None),
            Self::AuthorAndMinute => (author, date.map(to_minute)),
        }
    }
}

/// `date`, an ISO 8601 date and time such as `2026-01-05T10:00:30Z`, cut before the colon of
/// its seconds, or whole when it has no seconds.
fn to_minute(date: &str) -> &str {
    let seconds = date.split_once('T').and_then(|(day, time)| {
        let (at, _) = time.match_indices(':').nth(1)?;
        Some(day.len() + 'T'.len_utf8() + at)
    });
    seconds.and_then(|end| date.get(..end)).unwrap_or(date)
}

/// How a non-breaking hyphen (`w:noBreakHyphen`) is drawn: its glyph, its width and the text
/// objects of the PDF writer around it. It never breaks the line under any variant.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum NonBreakingHyphen {
    /// With the face's glyph for U+2011, or else its hyphen-minus, inside the text object of
    /// the glyphs around it. This keeps F-Office's existing drawing rather than asserting a
    /// behavior of the targets that choose it.
    ///
    /// - class: undocumented
    /// - status: derived
    OwnGlyph,
    /// As a hyphen-minus at the same place: the face's glyph for the hyphen-minus with its
    /// width, as a text object of its own, with another one starting at the glyph after it. It
    /// keeps the kerning pairs of the glyph that `OwnGlyph` draws.
    ///
    /// - class: undocumented
    /// - status: measured
    AsHyphenMinus,
}
quirk!(NonBreakingHyphen: OwnGlyph, AsHyphenMinus);

/// Which languages a document's automatic hyphenation (`w:autoHyphenation`) hyphenates: the
/// language of a word's run decides whether the word may break at its hyphenation points at
/// the end of a line.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum AutomaticHyphenation {
    /// None: every word stays whole at the end of a line. This keeps F-Office's existing layout
    /// rather than asserting a behavior of the targets that choose it.
    ///
    /// - class: undocumented
    /// - status: derived
    Off,
    /// English, French and Spanish, of every region; the words of every other language, and of
    /// a run without a language, stay whole.
    ///
    /// - class: undocumented
    /// - status: measured
    EnglishFrenchSpanish,
}
quirk!(AutomaticHyphenation: Off, EnglishFrenchSpanish);

/// How the target draws the kinds of underline (`w:u`) other than a single one, and a double
/// line through the text (`w:dstrike`).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum UnderlineForms {
    /// Every kind of underline but none as a single underline, and a double line through the
    /// text as a single one. This keeps F-Office's existing drawing rather than asserting a
    /// behavior of the targets that choose it.
    ///
    /// - class: undocumented
    /// - status: derived
    AllSingle,
    /// Each kind in its own form, from the single underline of the run (its top `p` dots below
    /// the baseline and `s` dots thick): a `words` underline as the single line under each word
    /// and none under the spaces; the dotted and dashed kinds as rows of dots and dashes of
    /// fixed lengths from the run's start (`params::UNDERLINE_DOT` and its neighbors), at the
    /// single line's place or, for a heavy kind, in the thick band; a `double` underline as two
    /// lines `ceil(s / 2)` dots thick, the upper one's top `ceil(p / 2)` dots below the
    /// baseline and the lower one's bottom at the single line's bottom or, where that leaves
    /// less than `params::UNDERLINE_DOUBLE_GAP` between them, that gap below the upper line;
    /// a `thick` underline as the band from the double's upper top to its lower top; and a
    /// double line through the text as two lines as thick as the single one, one its thickness
    /// above it and one its thickness below. The waves stay single underlines.
    ///
    /// - class: undocumented
    /// - status: measured
    ByKind,
}
quirk!(UnderlineForms: AllSingle, ByKind);

/// Where the target draws the line of a picture (`a:ln` of `pic:spPr`) that is single, solid
/// and of one color.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum PictureLinePlace {
    /// No line. This keeps F-Office's drawing before the rule, without a warning, rather than
    /// asserting a behavior of the targets that choose it.
    ///
    /// - class: undocumented
    /// - status: derived
    Undrawn,
    /// Wholly outside the picture's box, whatever the line's alignment (`algn`) and the
    /// drawing's effect extent: the ring between the box and the box grown by the line's width,
    /// its outer corners round by half the width, as a stroke with round joins along the box
    /// grown by half the width draws it.
    ///
    /// - class: undocumented
    /// - status: measured
    Outside,
}
quirk!(PictureLinePlace: Undrawn, Outside);

/// How far below its reference point the target puts the baseline of a line of metafile text
/// that a font of an em height (`lfHeight` below 0) draws aligned at its top (`TA_TOP`).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum MetafileTopAscent {
    /// The ascent of the face that draws the line, in font units at the em on the page. This
    /// keeps F-Office's drawing before the rule, rather than asserting a behavior of the
    /// targets that choose it.
    ///
    /// - class: undocumented
    /// - status: derived
    FontUnits,
    /// The face's pixel ascent at the font's size in whole logical units (`|lfHeight|` pixels
    /// per em), times the size of a logical unit on the page: the face's `VDMX` height above
    /// the baseline where its table lists that size, or else `usWinAscent` at that size,
    /// rounded to the nearest pixel. The pixels are those of the picture's logical units, not
    /// of its reference device.
    ///
    /// - class: undocumented
    /// - status: measured
    LogicalPixels,
}
quirk!(MetafileTopAscent: FontUnits, LogicalPixels);

impl AutomaticHyphenation {
    /// The hyphenation language of a run's language tag (`w:lang w:val`), or `None` where the
    /// target keeps the words of that language whole.
    #[must_use]
    pub fn language(self, tag: &str) -> Option<f_office_hyphenate::Language> {
        use f_office_hyphenate::Language;
        match self {
            Self::Off => None,
            Self::EnglishFrenchSpanish => Language::of_tag(tag)
                .filter(|l| matches!(l, Language::English | Language::French | Language::Spanish)),
        }
    }
}

/// Which face the complex script characters of a run with complex script italic (`w:iCs`)
/// take when the italic face of the run's family holds letters of a complex script, Hebrew or
/// Arabic, but not those of the script of the run's bidi language (`w:lang w:bidi` of the run
/// or of the document defaults; Arabic when neither names one).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ComplexItalicFace {
    /// The italic face, as every other italic run. This keeps F-Office's existing choice
    /// rather than asserting a behavior of the targets that choose it.
    ///
    /// - class: undocumented
    /// - status: derived
    Italic,
    /// The upright face of the same family and weight, when it holds the letters of that
    /// script; else the italic face.
    ///
    /// - class: undocumented
    /// - status: measured
    UprightForLanguage,
}
quirk!(ComplexItalicFace: Italic, UprightForLanguage);

/// Which font side the PDF writer gives, in a run with the East Asian hint, a character of
/// Latin-1 but the section sign and the middle dot, a Latin letter of Latin Extended-A and -B,
/// the IPA Extensions or Latin Extended Additional, or a character of Greek Extended
/// (`FontSideChange`).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum HintedFontSide {
    /// Such a character is open: it keeps the side before it. This keeps F-Office's existing
    /// sides rather than asserting a behavior of the targets that choose it.
    ///
    /// - class: undocumented
    /// - status: derived
    Open,
    /// Such a character takes the side of the table of the East Asian hint in ECMA-376 Part 1,
    /// 17.3.2.26, by the run's East Asian language and the character set of its East Asian
    /// font, and stays open where the face of that side has no glyph for it: the target then
    /// draws it in another face.
    ///
    /// - class: specification
    /// - status: derived
    ByLanguage,
}
quirk!(HintedFontSide: Open, ByLanguage);

/// Which characters a run with the East Asian hint (`w:rFonts w:hint="eastAsia"`) draws with its
/// East Asian face, besides the characters of East Asian scripts.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum HintedSlot {
    /// The middle dot, and the dashes, quotes, bullets, ellipsis, primes and reference marks of
    /// General Punctuation. This keeps F-Office's existing choice rather than asserting a
    /// behavior of the targets that choose it.
    ///
    /// - class: undocumented
    /// - status: derived
    Punctuation,
    /// Those, the spacing modifier letters, Greek and Cyrillic, and every character from the
    /// superscripts to the dingbats (U+2070 to U+27BF), unless the run's East Asian face is
    /// Times New Roman: then the hint moves no character.
    ///
    /// - class: undocumented
    /// - status: measured
    Symbols,
}
quirk!(HintedSlot: Punctuation, Symbols);

/// Which East Asian language picks the script whose font the theme gives a run's East Asian
/// theme font (`w:eastAsiaTheme`) when the theme leaves that font's typeface empty.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ThemeEastAsian {
    /// The run's own East Asian language (`w:lang w:eastAsia`), with its defaults; a run with
    /// none, or with a language of no East Asian script, names no family. This keeps
    /// F-Office's existing choice rather than asserting a behavior of the targets that choose
    /// it.
    ///
    /// - class: undocumented
    /// - status: derived
    RunLanguage,
    /// The settings' East Asian language (`w:themeFontLang w:eastAsia`), whatever the run's;
    /// with none in the settings, the font is MS Mincho.
    ///
    /// - class: undocumented
    /// - status: measured
    SettingsLanguage,
}
quirk!(ThemeEastAsian: RunLanguage, SettingsLanguage);

/// Which count the PDF writer rounds to a whole-thousandth adjustment.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum WriterAdjustments {
    /// The exact carried ideal: a step shorter than its width takes the ideal rounded to the
    /// nearest whole thousandth, and a longer step the ideal plus
    /// `params::WRITER_LONGER_EXTRA`, so that an ideal that ends in exactly a half thousandth
    /// goes to the whole number farther from zero, as Word for the web writes it. The writer's
    /// count in single precision since its last written adjustment (`params::WRITER_COUNT_BITS`)
    /// decides a step whose ideal is exactly `params::WRITER_DEAD_ZONE` thousandths either way,
    /// a dead-zone tie, which the writer writes or carries.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    ExactIdeal,
    /// The accumulated width sum less the place sum, subtracted and multiplied by 1000 in
    /// binary single precision. The same count decides a dead-zone tie, as under `ExactIdeal`.
    ///
    /// - class: undocumented
    /// - status: measured
    SingleCount,
    /// The two-sum count decides every step and gives its number: the sum of
    /// the widths with their spacing and the sum of the device steps, each step taken to
    /// inches, points and ems of the drawn size, every operation in single precision. A step
    /// writes when the two sums differ by the dead zone or more, the number of their difference
    /// in thousandths plus a half, toward zero, and both sums start again at zero after a write
    /// and at each text object. The halves and the ties of the other variants decide nothing
    /// then.
    ///
    /// - class: undocumented
    /// - status: measured
    TwoSums,
}
quirk!(WriterAdjustments: ExactIdeal, SingleCount, TwoSums);

/// Which image a picture draws.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum PictureImage {
    /// A picture draws the image file of the document. Word resamples some images to 220
    /// pixels per inch, and when and how is not known.
    ///
    /// - class: undocumented
    /// - status: unknown
    DrawsStoredImage,
}
quirk!(PictureImage: DrawsStoredImage);

/// How the inks of a JPEG picture of four components (CMYK or YCCK) turn into the colors that
/// it draws.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum FourComponentInks {
    /// Through the CMYK profile that the file embeds, with the perceptual intent, and by the
    /// plain conversion for a file without one. Nearer to the target's pictures than the plain
    /// conversion alone, but not the target's own conversion.
    ///
    /// - class: undocumented
    /// - status: derived
    ThroughEmbeddedProfile,
    /// Through the ink table, the target's measured colors of six amounts of each ink,
    /// interpolated multilinear between them, for every such file, with or without a profile,
    /// whatever intent the profile's header names.
    ///
    /// - class: undocumented
    /// - status: derived
    ThroughInkTable,
}
quirk!(FourComponentInks: ThroughEmbeddedProfile, ThroughInkTable);

/// How the most that a superscript rises rounds.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum SuperscriptRise {
    /// The rise from the font's superscript offset rounds to the nearest unit. Word's Cambria
    /// superscripts rise one device dot more than the offset gives at larger sizes, and
    /// whether that is rounding or another value is not known.
    ///
    /// - class: undocumented
    /// - status: unknown
    RoundsToNearest,
}
quirk!(SuperscriptRise: RoundsToNearest);

/// How far a superscript rises and a subscript drops.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ScriptPlacement {
    /// A superscript rises by the size that it loses, no higher than its font raises
    /// superscripts ([`SuperscriptRise`]), and a subscript drops by a quarter of that size: the
    /// variant follows from the fitted parameters `params::SCRIPT_SIZE` and
    /// `params::SUBSCRIPT_DROP_PARTS`.
    ///
    /// - class: undocumented
    /// - status: derived
    LostSize,
    /// A superscript's top meets the top of its line at the full size, and a subscript's
    /// bottom meets the line's bottom: each edge rounds to the nearest dot of the layout device
    /// and then to the nearest half-point, and each move goes no farther than the font's
    /// superscript or subscript offset at the full size, to the nearest half-point. A
    /// superscript or subscript whose font's own script values are not used
    /// ([`ScriptSize::FaceValues`]) has no such cap, and a superscript's font's top then counts
    /// no higher than its em; that variant says how its font's values move a subscript.
    ///
    /// - class: undocumented
    /// - status: measured
    AlignsLineEdges,
}
quirk!(ScriptPlacement: LostSize, AlignsLineEdges);

/// How large superscript and subscript text is.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ScriptSize {
    /// Two thirds of the run's size, rounded down to whole half-points, in every font: the
    /// variant follows from the fitted parameter `params::SCRIPT_SIZE`.
    ///
    /// - class: undocumented
    /// - status: derived
    TwoThirds,
    /// The run's size times the font's own `OS/2` y size of that kind of script
    /// (`ySuperscriptYSize` or `ySubscriptYSize`) over its units per em, to the nearest
    /// half-point. A font whose superscript y size lies above `params::SCRIPT_KEPT_SIZE_MAX`,
    /// or whose superscript y offset is 0 or above `params::SCRIPT_KEPT_OFFSET_MAX`, takes
    /// `params::SCRIPT_FALLBACK_SIZE` of the run's size instead, to the nearest half-point, for
    /// both kinds of script; those limits are the edges of the values seen, not exact bounds. So
    /// does a script whose own size comes to at most `params::SCRIPT_FALLBACK_LINE_SHARE` of the
    /// run's size or whose superscript y offset, to the nearest half-point, lies below
    /// `params::SCRIPT_FALLBACK_OFFSET_MIN` of the run's size (cut toward zero to whole
    /// half-points), line by line. Under [`ScriptPlacement::AlignsLineEdges`], a superscript that
    /// takes that size meets the top of its line with no cap by the font's offset, the font's top
    /// no higher than its em; in a font made for East Asian text it rises by the size it loses.
    /// A subscript that takes that size meets the bottom of its line with no cap by its font's
    /// offset, but drops no more than `params::SCRIPT_FALLBACK_DROP_MAX` of the run's size, to
    /// the nearest half-point; a subscript that takes its font's own size does not move when
    /// its font's subscript y offset is 0; and the bottom of a font made for East Asian text
    /// lies below its descent by the room that its line gets there.
    ///
    /// - class: undocumented
    /// - status: measured
    FaceValues,
}
quirk!(ScriptSize: TwoThirds, FaceValues);

/// Which of a font's lines gives its single line height.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(
    not(feature = "development"),
    expect(
        clippy::enum_variant_names,
        reason = "the variants keep the names that the profiles give them"
    )
)]
pub enum LineHeight {
    /// The single line height is the `hhea` line: the ascender minus the descender plus the
    /// line gap. The variant follows from the rule of the line height.
    ///
    /// - class: undocumented
    /// - status: derived
    TakesHheaLine,
    /// The single line height is the taller of the `hhea` line and the win line
    /// (`usWinAscent` plus `usWinDescent`), or the typographic line (the typo ascender minus
    /// the typo descender plus the typo line gap) when the font sets `USE_TYPO_METRICS`.
    ///
    /// - class: undocumented
    /// - status: measured
    TakesTallerLine,
    /// The single line height is that of [`Self::TakesTallerLine`], except that a font made
    /// for East Asian text takes its win line where its `hhea` line without the gap is taller.
    ///
    /// - class: undocumented
    /// - status: measured
    TakesTallerLineEastAsianWin,
}
quirk!(LineHeight: TakesHheaLine, TakesTallerLine, TakesTallerLineEastAsianWin);

/// Where the baseline of a text line goes whose multiple spacing is above single spacing.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum MultipleBaseline {
    /// The baseline sits the ascent, rounded to the device, below the top of the line. The
    /// variant follows from the rule of the line height.
    ///
    /// - class: undocumented
    /// - status: derived
    RoundedAscent,
    /// The text keeps the line's rounded height less the rounded part of the spacing above
    /// single spacing, which goes below it, and the baseline sits the rounded descent above
    /// the bottom of that text, but no higher than the rounded ascent below the top of the
    /// line. On the first line of a paragraph with space before, the line's box holds that
    /// space, which the rule adds to the ascent and to the height. On the last line of a
    /// paragraph whose space after follows it, at single spacing as well as above it, the box
    /// holds the space after too, below the extra spacing, and the rule adds it to the height
    /// and to the extra. The variant follows from the font's ascent and descent, the device
    /// and the rule of the multiple baseline.
    ///
    /// - class: undocumented
    /// - status: derived
    DescentAboveExtra,
}
quirk!(MultipleBaseline: RoundedAscent, DescentAboveExtra);

/// How the ascent part rounds in the baseline of a first line whose box holds its paragraph's
/// own space before under `MultipleBaseline::DescentAboveExtra`: the baseline lies the larger of
/// the ascent part and the descent part below the box's rounded top.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum SpaceBeforeAscent {
    /// The space before and the ascent round together. The variant follows from the rule of
    /// the multiple baseline.
    ///
    /// - class: undocumented
    /// - status: derived
    RoundedTogether,
    /// The space before and the ascent round each on their own, as below the space before of a
    /// first line of multiple spacing whose box does not hold it, so the variant follows from
    /// that rule.
    ///
    /// - class: undocumented
    /// - status: derived
    RoundedApart,
}
quirk!(SpaceBeforeAscent: RoundedTogether, RoundedApart);

/// What the box of a paragraph's first line holds, for the rounding of its baseline, at the top
/// of a page that a natural break starts because the line did not fit at the foot of the page
/// before, where the break drops the paragraph's own space before, or at the top of a page that a
/// page break in a paragraph without text starts, which drops the part of the next paragraph's
/// space before that is larger than that paragraph's space after. A space that a page break at
/// the end of a paragraph with text, a kept paragraph or a page break before leaves out is no
/// dropped space.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum DroppedSpaceBox {
    /// Nothing: the line rounds as the first line of a paragraph whose space before the page
    /// left out.
    ///
    /// - class: undocumented
    /// - status: derived
    LeftOut,
    /// The dropped space, above the page's top: the box's top is the body's top less the space,
    /// and the line rounds as a first line whose box holds its space before, at the body's top
    /// on its page. The line's top stays the body's top. The rule follows from the box that
    /// holds a paragraph's space before.
    ///
    /// - class: undocumented
    /// - status: measured
    HeldAbove,
}
quirk!(DroppedSpaceBox: LeftOut, HeldAbove);

/// Where the baseline of a text line of single spacing goes whose height, or the height of its
/// box with the space before, rounds down to the device grid.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum SingleBaseline {
    /// The bottom of the line is its rounded top plus its rounded height, and the baseline sits
    /// the descent above it, cut to whole twips and rounded. The variant follows from the rule
    /// of the line height.
    ///
    /// - class: undocumented
    /// - status: derived
    CutDescent,
    /// The exact line sits in the middle of its rounded height: the baseline sits the ascent,
    /// less half of what the height loses as it rounds, below the line's rounded top, rounded
    /// to the device grid.
    ///
    /// - class: undocumented
    /// - status: measured
    Centered,
    /// On the first line of a paragraph that sets its own space before, even where a new page
    /// leaves that space out, the bottom of the line is its rounded top plus its rounded
    /// height, and the baseline sits the exact descent, rounded, above it. Every other line
    /// takes the form of `Centered`.
    ///
    /// - class: undocumented
    /// - status: measured
    RoundedDescentBelowSpace,
}
quirk!(SingleBaseline: CutDescent, Centered, RoundedDescentBelowSpace);

/// Where the baseline of a text line of exact spacing goes whose box, the line with its
/// paragraph's own space before on the first line, rounds down to the device grid.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ExactBaseline {
    /// The page rounds the line's exact bottom, and the baseline sits the rounded part of the
    /// line below the baseline above it, as on every other exact line. The variant follows
    /// from the rule of the line height.
    ///
    /// - class: undocumented
    /// - status: derived
    RoundedBottom,
    /// The line takes the forms of a single line whose box rounds down below the box's rounded
    /// top, as the device's variant of `SingleBaseline` gives them, with the baseline four
    /// fifths down the line.
    ///
    /// - class: undocumented
    /// - status: measured
    BoxForms,
}
quirk!(ExactBaseline: RoundedBottom, BoxForms);

/// Where the baseline goes of a text line of automatic spacing below single spacing whose
/// baseline lies off the dot grid below the line's top, with no space before above it in its
/// box.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum LowMultipleBaseline {
    /// The page rounds the line's exact top plus its exact baseline once.
    ///
    /// - class: undocumented
    /// - status: derived
    RoundedOnce,
    /// The line's height decides. Where its exact height lies less than half a dot past a whole
    /// dot, the page rounds the line's exact top, and the baseline sits its exact offset less
    /// half that part of a dot, rounded, below it: the line loses the part of a dot half above
    /// and half below its baseline. Otherwise the page rounds the line's exact bottom, and the
    /// baseline sits the part of the line below it, rounded, above that bottom.
    ///
    /// - class: undocumented
    /// - status: measured
    HeightFraction,
}
quirk!(LowMultipleBaseline: RoundedOnce, HeightFraction);

/// Where the bottom goes of a line of exact spacing whose baseline the page places up from its
/// bottom, when the line is the last line of its paragraph outside table cells and the
/// paragraph's space after follows it.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ExactSpacedBottom {
    /// The page rounds the line's exact top plus its exact height once, as on every other line
    /// of exact spacing.
    ///
    /// - class: undocumented
    /// - status: derived
    SumRounded,
    /// The page rounds the line's exact top and its exact height each on their own, and the
    /// line's bottom lies at their sum.
    ///
    /// - class: undocumented
    /// - status: measured
    PartsRounded,
}
quirk!(ExactSpacedBottom: SumRounded, PartsRounded);

/// How wide Word draws a table's single lines on the device, and where.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum TableLines {
    /// A line is its width rounded to the nearest dot, at least one. A vertical line at the
    /// table's left edge, or in a centered or right-aligned table, starts at its exact start
    /// rounded; inside a left-aligned table, it is centered on its grid line taken from the
    /// text column's edge rounded to the device. The last row's bottom line starts at the
    /// row's bottom rounded. The variant follows from the rules of table borders.
    ///
    /// - class: undocumented
    /// - status: derived
    RoundsStarts,
    /// A line is its width rounded down to whole dots, at least one. Each vertical line is
    /// centered on its grid line, and the center is rounded to the nearest dot. A left-aligned
    /// table takes its grid lines from the text column's edge rounded to the nearest dot, a
    /// half down, and with the half border by which its grid lies right of its indent rounded
    /// up to whole twips. The last row's bottom line ends at the nearest dot of the row's
    /// bottom plus its exact width, and an end on exactly half a dot takes the dot on the side
    /// of the row's twips rest there, the dot below without one. Of a vertical line an odd
    /// number of dots wide, the extra dot lies on the left.
    ///
    /// - class: undocumented
    /// - status: measured
    RoundsCenters,
}
quirk!(TableLines: RoundsStarts, RoundsCenters);

/// Where a table's border of more than one line lands on the device, such as `double`, `triple`
/// and the gap styles: its vertical lines and the lines of its rows.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum CompoundTableLines {
    /// Each line is placed on the device as a single line of its width is, at its own place,
    /// so that a gap can come out one dot wider or narrower than the lines.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    EachLine,
    /// The border is placed as one line as wide as all its parts on the device, each part, a
    /// line or a gap, as thick as a line of its size, where a single line of that width lies;
    /// its lines then lie in it one after the other with their gaps between them, so that a
    /// gap as wide as the lines comes out as wide as they do. The parts of a 3-D style, whose
    /// lines touch, are placed each at its own place.
    ///
    /// - class: undocumented
    /// - status: measured
    WholeBorder,
}
quirk!(CompoundTableLines: EachLine, WholeBorder);

/// Where Word draws the vertical lines of a centered table whose outer edge sits at its place
/// (from mode 15) and whose cells run from left to right.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum CenteredTableLines {
    /// Each line from its exact grid line, as [`TableLines`] draws the lines of a table that
    /// takes no rounded edge.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Exact,
    /// From the outer edge of the table's left border rounded to the nearest dot: each line's
    /// center lies as far right of that dot as its grid line lies right of the table's first
    /// grid line, plus half the left border rounded up to whole twips, and is then rounded to
    /// the nearest dot, as [`TableLines::RoundsCenters`] rounds it. A table whose outer edge
    /// lies on exactly half a dot takes the dot of its place under
    /// [`CenteredTablePlace::FixedPointHalf`], and keeps its exact grid lines without it.
    ///
    /// - class: undocumented
    /// - status: measured
    FromOuterEdge,
}
quirk!(CenteredTableLines: Exact, FromOuterEdge);

/// Where a centered table whose outer edge sits at its place (from mode 15) and whose cells
/// run from left to right keeps that edge, on a target that takes the start of a line through
/// fixed-point points ([`LineStartHalves::FixedPoint`]). It decides the dot of the edge, and of
/// the text edges of its cells, where the exact place lies on exactly half a dot.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum CenteredTablePlace {
    /// At its exact place, half the free width right of the text column's left edge less half
    /// its left border; a cell's text edge counts its parts from the page column's edge as in
    /// any other table.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Exact,
    /// In fixed-point points: the text column's left edge, plus half of the column's width
    /// less the table's grid width less its left border, each of the three in fixed-point
    /// points on its own and the half taken toward zero. The edge's dot, a half up, is the dot
    /// of [`CenteredTableLines::FromOuterEdge`] also on exactly half a dot, and a cell's text
    /// edge is the sum there of that edge, the text edge's distance from it less the cell's
    /// left margin, and the margin, each part in fixed-point points.
    ///
    /// - class: undocumented
    /// - status: measured
    FixedPointHalf,
}
quirk!(CenteredTablePlace: Exact, FixedPointHalf);

/// Where Word draws the vertical lines of a centered table before mode 15, where the text of
/// its first cell and not the outer edge of its left border sits at its place, and whose cells
/// run from left to right. A nested table takes the rules of mode 15 and
/// [`CenteredTableLines`].
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum CenteredTableLinesBefore15 {
    /// Each line from its exact grid line, as [`TableLines`] draws the lines of a table that
    /// takes no rounded edge.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Exact,
    /// From the left edge of the text column rounded to the nearest dot: each line's center
    /// lies as far right of that dot as its grid line lies right of the column edge, with the
    /// half twip of an odd free width dropped toward the left, and is then rounded to the
    /// nearest dot, an exact half away from the column edge's dot. A column edge on exactly
    /// half a dot takes the dot that [`TableEdgeHalves`] says.
    ///
    /// - class: undocumented
    /// - status: measured
    FromColumnEdge,
}
quirk!(CenteredTableLinesBefore15: Exact, FromColumnEdge);

/// Which dot the left edge of the page's text column takes when it lies exactly half a dot past
/// a whole dot, for the lines that a table in that column draws from that edge's dot: those of
/// a left-aligned table under [`TableLines::RoundsCenters`] and those of a centered table before
/// mode 15 under [`CenteredTableLinesBefore15::FromColumnEdge`] (`grid::Device::table_line_edge`
/// and `grid::Device::column_edge_dot`), and for the place of a floating table placed at an
/// offset across (`w:tblpX`), which is its column's edge. A floating table aligned across, such
/// as a centered one, and a nested table, whose column's edge is a cell's text edge, take the
/// dot of `BelowOrExact` under both variants.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum TableEdgeHalves {
    /// The dot below for a left-aligned table, and no dot for a centered table before mode 15,
    /// which keeps its exact grid lines.
    ///
    /// - class: undocumented
    /// - status: derived
    BelowOrExact,
    /// The dot that the fixed-point arithmetic of a line's start gives
    /// ([`LineStartHalves::FixedPoint`]): the edge goes to the nearest 1/65,536 pt and that to
    /// the nearest dot, each with a half up, so an edge half a dot past a whole dot goes the way
    /// that the first step rounded it, and an edge that the first step leaves on the half takes
    /// the dot above. For a left-aligned table and for a centered table before mode 15 alike,
    /// and for a floating table at an offset, in modes 15 and 14.
    ///
    /// - class: undocumented
    /// - status: measured
    FixedPoint,
}
quirk!(TableEdgeHalves: BelowOrExact, FixedPoint);

/// Where the text of a centered table's cells starts before mode 15, where the text of its
/// first cell and not the outer edge of its left border sits at its place, in a table whose
/// cells run from left to right. A nested table takes the rules of mode 15.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum CenteredTableTextBefore15 {
    /// From the table's exact place, half its free width right of the text column's left
    /// edge, which lies on half a twip when the free width is an odd number of twips.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Exact,
    /// From the table's place on a whole twip: the half twip of an odd free width is dropped
    /// toward the left. The text and the edge of its space then round to the device as in any
    /// cell. The table's lines keep their own rule, [`CenteredTableLinesBefore15`], and turned
    /// text keeps the exact place.
    ///
    /// - class: undocumented
    /// - status: derived
    WholeTwip,
}
quirk!(CenteredTableTextBefore15: Exact, WholeTwip);

/// Where the upright text of a table's cells starts from mode 15, where the outer edge of the
/// table's left border sits at its place, in a left-aligned or a centered table whose cells run
/// from left to right.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum EdgeTableText {
    /// From the exact grid lines: the first lies half the left border right of the outer edge.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Exact,
    /// From grid lines whose first lies half the left border, rounded up to whole twips, right
    /// of the outer edge, as the table's lines take it under [`TableLines::RoundsCenters`] and
    /// [`CenteredTableLines::FromOuterEdge`]. The text and the edge of its space then round to
    /// the device as in any cell. Turned text keeps the exact place, and so does the text of a
    /// cell whose left margin is less than half its left line, which starts half the line right
    /// of the exact grid line under [`CellTextRoom::CombinedBorderMinimum`].
    ///
    /// - class: undocumented
    /// - status: derived
    WholeTwipBorder,
}
quirk!(EdgeTableText: Exact, WholeTwipBorder);

/// How tall a line of a turned frame's text is (`layout::line::height`): the text of a cell
/// whose text direction is `btLr` or `tbRl`, or of a text box whose body turns its text, is laid
/// out upright in a frame that is then turned onto the cell or the box, and its lines stack
/// across it.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum TurnedLineRoom {
    /// As tall as an upright line of the same text, as the frame's layout gives it. This keeps
    /// F-Office's existing line height rather than asserting a behavior of the targets that
    /// choose it.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Upright,
    /// Taller by a share of the line's largest font size (`params::TURNED_LINE_ROOM`), half
    /// above the text and half below it, before the line spacing rule applies: a multiple of
    /// single spacing stacks the lines at that multiple of the taller line, an at-least value
    /// is compared with the taller line, and an exact value keeps its height and its baseline.
    ///
    /// - class: undocumented
    /// - status: measured
    SizeShare,
}
quirk!(TurnedLineRoom: Upright, SizeShare);

/// Where a turned cell's lines lie across the cell (`layout::table::turned`): the text of a
/// cell whose text direction is `btLr` or `tbRl` is laid out upright in a frame, whose lines
/// round to whole dots down the frame, and the frame is then turned onto the cell, so that
/// those dots run across the page.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum TurnedAcrossDots {
    /// The frame starts at the top of the row on the page, so that its lines round to the
    /// page's dots down the page. Turned, a line's place across moves with the fraction of a
    /// dot at which the row's top lies, by up to a dot from row to row. Under `PageDots`, the
    /// cells that it leaves out keep these places.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    FrameDots,
    /// For text that reads up (`btLr`) in a cell aligned to the top, the frame starts at a top
    /// that lies as far into a dot as the cell's text start lies across the page, and its
    /// ties go down the frame with no rule of whole twips, so that every such line lies on a
    /// whole dot across the page: one rounding of the cell's side and the line's place in the
    /// cell, whatever the row's place down the page. Such a line's place across is then
    /// written as the target's PDF writer writes a text object's start at that dot, with the
    /// page's offset across. Every other turned cell keeps the places of `FrameDots`.
    ///
    /// - class: undocumented
    /// - status: derived
    PageDots,
}
quirk!(TurnedAcrossDots: FrameDots, PageDots);

/// Where an inline picture of a turned cell's text is drawn (`layout::table::turned`): the
/// text of a cell whose text direction is `btLr` or `tbRl` is laid out upright in a frame that
/// is then turned onto the cell.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum TurnedPicture {
    /// Upright where the frame drew it, with the room of an upright picture on its line: the
    /// frame's turn moves its text but not the picture. This keeps F-Office's existing drawing
    /// rather than asserting a behavior of the targets that choose it.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    InFrame,
    /// Upright on the page, so that on its turned line it takes its height along the line and
    /// its width across. Its box keeps its size, and its centre moves with the frame from the
    /// centre of its room; for text that reads up (`btLr`) the room lies at its mirror place
    /// along the frame, as far from the frame's end as the line puts it from the start.
    ///
    /// - class: undocumented
    /// - status: measured
    Upright,
}
quirk!(TurnedPicture: InFrame, Upright);

/// How Word draws a table's lines of the dash styles `dotted`, `dashed`, `dotDash` and
/// `dotDotDash`.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum BorderDashes {
    /// Each line is drawn solid, as a line of the style `single`. This is F-Office's own layout;
    /// the PDFs of a target can draw the dots of a dotted line as filled shapes of their own.
    ///
    /// - class: undocumented
    /// - status: derived
    DrawsSolid,
    /// Each piece of a line, between the junctions where it meets the lines across it, is
    /// drawn as the dashes of its style: from a dash at the piece's left or top end, with the
    /// dashes and the gaps in widths of the line as drawn, and the last dash cut at the
    /// piece's end. A junction square, as long as the line is wide, is drawn whole. A line
    /// across is also cut where it passes from one cell to the next with no line down between
    /// them, also where the two cells' lines leave a gap shorter than the line is wide: the
    /// piece over the next cell starts as far right of that cell's start as the line is wide,
    /// and the room between the two pieces stays empty, so that the dashes start again in each
    /// cell. The lines of a table with cell spacing stay solid.
    ///
    /// - class: undocumented
    /// - status: measured
    DashesCellPieces,
}
quirk!(BorderDashes: DrawsSolid, DashesCellPieces);

/// How Word draws a side of the 3-D border styles `threeDEmboss` and `threeDEngrave`.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ThreeDBorders {
    /// Each side is drawn as one line of its width in its color, as a line of the style
    /// `single`. This is F-Office's own layout.
    ///
    /// - class: undocumented
    /// - status: derived
    OneLine,
    /// Each side of a page or a paragraph border is drawn as three bands that touch: an outer
    /// band, the line as wide as a `single` line of its width, and an inner band. The light,
    /// middle and dark shades of the line's color take the bands in an order that is fixed on
    /// the page: read left to right or top to bottom, `threeDEmboss` is light, middle and dark
    /// on every side, and `threeDEngrave` dark, middle and light. At the corners of a page
    /// border, the bands of two 3-D sides nest: each band of the top or the bottom ends at the
    /// outer edge of the side's band of the same depth, and covers it. A table's line stays one
    /// line.
    ///
    /// - class: undocumented
    /// - status: measured
    Bands,
}
quirk!(ThreeDBorders: OneLine, Bands);

/// How Word draws a side of the large gap border styles `thinThickLargeGap`,
/// `thickThinLargeGap` and `thinThickThinLargeGap`.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum LargeGapBorders {
    /// Each side is drawn as one line of its width, as a line of the style `single`. This is
    /// F-Office's own layout.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    OneLine,
    /// Each side is drawn as lines of fixed widths with gaps of the side's width between them,
    /// and is as wide as all of them: from the top or the left, `thinThickLargeGap` is a 1.5 pt
    /// line, a gap and a 0.75 pt line, `thickThinLargeGap` a 0.75 pt line, a gap and a 1.5 pt
    /// line, and `thinThickThinLargeGap` a 0.75 pt line, a gap, a 1.5 pt line, a gap and a
    /// 0.75 pt line, in paragraph, table, cell and page borders alike.
    ///
    /// - class: undocumented
    /// - status: measured
    Parts,
}
quirk!(LargeGapBorders: OneLine, Parts);

/// How Word draws a page border's side of an art style, such as `apples`.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum ArtPageBorders {
    /// The side is not drawn, with a warning that its style is not supported. This is
    /// F-Office's own layout.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    NotDrawn,
    /// The side is drawn with the target's own pictures of the style, which the caller gives
    /// beside the fonts: a corner square of the size in whole device dots at each end, and
    /// between them as many pictures as fit at one dot longer than the square each, all of one
    /// length in whole dots, with the dots left over given one each to the last pictures. Each
    /// picture is stretched along the side, and its black takes the side's color.
    ///
    /// - class: undocumented
    /// - status: measured
    Pictures,
}
quirk!(ArtPageBorders: NotDrawn, Pictures);

/// How Word puts the lines of a page border on the device.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum PageBorderLines {
    /// Each line's thickness is rounded to the nearest dot, at least one.
    ///
    /// - class: undocumented
    /// - status: derived
    Nearest,
    /// Each part, a line or a gap, is rounded down to whole dots, at least one, as a paragraph
    /// border's parts are, and the parts lie one after the other from the side's outer edge.
    ///
    /// - class: undocumented
    /// - status: measured
    Down,
}
quirk!(PageBorderLines: Nearest, Down);

/// How the first cell sets a table's grid place before the edge-aligned mode.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum TableIndent {
    /// The first grid line lies one specified left margin left of the indent, including
    /// an absent indent treated as zero.
    ///
    /// - class: undocumented
    /// - status: derived
    FirstMargin,
    /// An explicit indent fixes the first cell's text start after its border minimum.
    /// Without an explicit indent, the first grid line stays at the column edge.
    ///
    /// - class: undocumented
    /// - status: measured
    ExplicitTextStart,
    /// As [`TableIndent::ExplicitTextStart`], and so also in a table with cell spacing, also
    /// of zero: there an explicit indent puts the first grid line the cell's left margin, the
    /// spacing before the cell's box and the box's whole left line left of the indent, so that
    /// the text starts at the indent when it starts after the whole line ([`SpacedCellText`]).
    /// Without an explicit indent, the first grid line stays at the column edge.
    ///
    /// - class: undocumented
    /// - status: derived
    SpacedTextStart,
}
quirk!(TableIndent: FirstMargin, ExplicitTextStart, SpacedTextStart);

impl TableIndent {
    /// Whether an explicit indent fixes the first cell's place, in a table with cell spacing
    /// (`spaced`) or without.
    #[must_use]
    pub const fn fixes_text_start(self, spaced: bool) -> bool {
        match self {
            Self::FirstMargin => false,
            Self::ExplicitTextStart => !spaced,
            Self::SpacedTextStart => true,
        }
    }
}

/// How far a right-to-left table (`w:bidiVisual`) at its leading edge, or floating at an offset,
/// lies from its place before the edge-aligned mode, from that mode on.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum RightToLeftEdge {
    /// Half the line between its first two cells, the first cell's own where it is wider: the
    /// rule of a table from the left, read on the mirrored first cell.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    BetweenCells,
    /// Half the first cell's line at the leading edge, its own or else the table's, plus half
    /// the last cell's line that the file calls left, its own or else the table's vertical line
    /// between cells (`w:insideV`), whatever the lines between the other cells; in a row of one
    /// cell, that is the line at the leading edge again. A floating table placed at an offset
    /// from its anchor lies left of its place before that mode by half the last cell's line
    /// alone. A floating table aligned to its anchor keeps the default placement.
    ///
    /// - class: undocumented
    /// - status: measured
    LeadingAndInside,
}
quirk!(RightToLeftEdge: BetweenCells, LeadingAndInside);

/// How side borders constrain a cell's explicitly set horizontal margins.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum CellTextRoom {
    /// Explicit margins set both the text start and the line width.
    ///
    /// - class: undocumented
    /// - status: derived
    Margins,
    /// The left start leaves at least half the left border, while the width leaves the
    /// larger of the margin sum and half the sum of the side borders.
    ///
    /// - class: undocumented
    /// - status: measured
    CombinedBorderMinimum,
}
quirk!(CellTextRoom: Margins, CombinedBorderMinimum);

/// How Word reads a left or right cell margin that no cell, row, table or table style sets.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum UnsetCellMargins {
    /// The cell has no margin on that side: its text starts right after the whole of its left
    /// line, and its lines end at its right grid line.
    ///
    /// - class: undocumented
    /// - status: derived
    AfterLeftLine,
    /// The side's margin is 10 twips, 0.5 pt, and the cell places its text as a cell whose
    /// margins are set, with or without lines on its sides.
    ///
    /// - class: undocumented
    /// - status: measured
    DefaultSides,
}
quirk!(UnsetCellMargins: AfterLeftLine, DefaultSides);

/// Which line the row below the header rows (`w:tblHeader`) that repeat at the top of a page
/// meets there: that of the row before it in the table, or that of the last header row.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum RowBelowHeaders {
    /// The row meets the row before it in the table, whose bottom line stands at the foot of
    /// the page before: it takes the wider of its own top line and that line, as it does on
    /// one page with the row before it, for its room and for the line drawn above it. The
    /// variant follows from the rules of table rows.
    ///
    /// - class: undocumented
    /// - status: derived
    RowBefore,
    /// The row meets the last header row as it meets the row before it on one page: the line
    /// drawn above it is the wider of its own top line and that header row's bottom line, from
    /// the header row's bottom down, in every mode. Below `HEADER_LINE_ROOM_MODE`, the row's
    /// content starts below that line or below its own top line and its top margin, whichever
    /// is lower; from that mode on, it keeps the room of the line between it and the row before
    /// it in the table.
    ///
    /// - class: undocumented
    /// - status: measured
    LastHeader,
}
quirk!(RowBelowHeaders: RowBefore, LastHeader);

/// Which cells of the row above give the room of the line between two rows over a cell of the
/// lower row.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum RowLineRoom {
    /// The cell of the row above that covers the cell's first grid column: the line between
    /// the rows over the cell is the wider of the cell's own top line and that cell's bottom
    /// line. The variant follows from the rules of table rows.
    ///
    /// - class: undocumented
    /// - status: derived
    FirstColumn,
    /// Every cell of the row above that covers one of the cell's grid columns: each of them draws
    /// its own bottom line along its width, the heavier of it and the cell's own top line, and
    /// the cell's own top line stands alone over the grid columns that no cell above covers. The
    /// room of the line between the rows over the cell is that of the widest of those lines.
    ///
    /// - class: undocumented
    /// - status: measured
    CellsAbove,
}
quirk!(RowLineRoom: FirstColumn, CellsAbove);

/// The room that a cell takes for the line between its row and the row above when it goes on
/// with the merged cell above it (`w:vMerge`), where no line is drawn
/// (`layout/table/shape.rs`, the slot's top room).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum MergedTopRoom {
    /// No room: the row takes the room of the line from its other cells only. The variant
    /// follows from the rules of table rows.
    ///
    /// - class: undocumented
    /// - status: derived
    NoRoom,
    /// The room of the heavier of the cell's own top line and the bottom line of the cell
    /// above it, as a cell that merges nothing takes, although no line is drawn there.
    ///
    /// - class: undocumented
    /// - status: derived
    UndrawnLine,
}
quirk!(MergedTopRoom: NoRoom, UndrawnLine);

/// Which fill a merged cell (`w:vMerge`) draws in its rows after the first
/// (`layout/table/rows.rs`, the fills of a row's cells).
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum MergedCellFill {
    /// Each row's part takes the shading of the cell of that row, as a cell that merges
    /// nothing does. This keeps F-Office's existing fills rather than asserting a behavior of
    /// the targets that choose it.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    EachRow,
    /// The whole merged cell takes the shading of its first cell, its own or the one that its
    /// table style gives it, and the shadings of the cells that go on with it draw nothing.
    ///
    /// - class: undocumented
    /// - status: measured
    FirstCell,
}
quirk!(MergedCellFill: EachRow, FirstCell);

/// Which border of the table a row's first and last cell take on their outer sides, the left
/// side of the first and the right side of the last, where the cell and the regions of the
/// table style set none of their own (`layout/table/shape.rs`, the borders of a cell).
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum RowEndBorders {
    /// The table's outer left and right borders only at the grid's first and last column; a
    /// row that starts after `w:gridBefore` or ends before the grid's last column takes the
    /// inside border (`w:insideV`) there.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    GridEdges,
    /// The table's outer left border on the row's first cell and its outer right border on the
    /// row's last cell, wherever the row starts or ends in the grid.
    ///
    /// - class: undocumented
    /// - status: measured
    RowEnds,
}
quirk!(RowEndBorders: GridEdges, RowEnds);

/// Where a merged cell (`w:vMerge`) whose content is centered or at the bottom places that
/// content on the page where it starts, when a page break comes between its rows and its
/// content stays on that page (`layout/table/rows.rs`).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum SplitMergeAlign {
    /// In the whole merged cell, as if the rows that move to the next page stood below the
    /// page's end: the row that does not fit is laid out there first, ends the merged cell and
    /// aligns its content, and only then moves.
    ///
    /// - class: undocumented
    /// - status: derived
    WholeCell,
    /// In the merged cell's part on the page: its rows there, from its first row's top down to
    /// the page's last row.
    ///
    /// - class: undocumented
    /// - status: derived
    PagePart,
}
quirk!(SplitMergeAlign: WholeCell, PagePart);

/// How the content that a merged cell (`w:vMerge`) carries to the next page moves to the top of
/// the merged cell's part there (`layout/table/merges.rs`).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum CarriedMergeMove {
    /// By the exact distance from where the content was laid out to that top: its lines keep the
    /// parts of a dot that the distance gives.
    ///
    /// - class: undocumented
    /// - status: derived
    Exact,
    /// Its lines by that distance rounded to the nearest dot of the device, so that each of
    /// them keeps a whole dot of the page; the bottom of the merged cell's content, which sets
    /// the height of its rows, by the exact distance.
    ///
    /// - class: undocumented
    /// - status: derived
    ToDot,
}
quirk!(CarriedMergeMove: Exact, ToDot);

/// What a row of a table in the cell of a row that splits does when its minimum height
/// (`w:trHeight` without `w:hRule="exact"`) does not fit in the cell's part on the page
/// (`layout/table/nested.rs`).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum NestedRowMinimum {
    /// It splits between its lines, whatever its minimum height.
    ///
    /// - class: undocumented
    /// - status: derived
    Splits,
    /// It moves whole to the cell's part on the next page, as a row of the body does; a row at
    /// the top of a new part splits.
    ///
    /// - class: undocumented
    /// - status: derived
    MovesWhole,
}
quirk!(NestedRowMinimum: Splits, MovesWhole);

/// Whether a floating table of the body (`w:tblpPr`, outside the flow) that is taller than the
/// room below its top breaks across pages (`layout/table/floating.rs`).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum FloatingTableBreaks {
    /// It stays whole at its place and runs past the page's foot.
    ///
    /// - class: undocumented
    /// - status: derived
    Whole,
    /// Its rows break at the body's end as the rows of a table in the flow do, and its rest
    /// starts at the top of the body of the next page, at its own place across. The paragraphs
    /// after it go on on its last page, from the top of the body, around its part there.
    ///
    /// - class: undocumented
    /// - status: derived
    AcrossPages,
}
quirk!(FloatingTableBreaks: Whole, AcrossPages);

/// Whether widow and orphan control applies to the paragraphs of a cell in the parts of a row
/// that splits on the pages after its first, where it applies in the part on the first page
/// (`layout/table/split.rs`).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum LaterPartWidows {
    /// It does not: a line of a later part stays alone at its foot or top.
    ///
    /// - class: undocumented
    /// - status: derived
    Ignored,
    /// It does, as in the first part: a paragraph leaves neither its first line alone at the
    /// foot of a later part nor its last line alone at the top of the next.
    ///
    /// - class: undocumented
    /// - status: derived
    Applied,
}
quirk!(LaterPartWidows: Ignored, Applied);

/// Whether the filled cells (`w:shd`) of a row that splits between pages are filled in the
/// parts of the row (`layout/table/split.rs`).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum SplitRowFills {
    /// They are not: the parts of the row draw their cells' lines and no fill.
    ///
    /// - class: undocumented
    /// - status: derived
    Unfilled,
    /// Each part fills its filled cells as a whole row does, from below the part's top line
    /// down to the part's end, also a cell whose content ended on an earlier page.
    ///
    /// - class: undocumented
    /// - status: derived
    EachPart,
}
quirk!(SplitRowFills: Unfilled, EachPart);

/// Where the lines of a merged cell (`w:vMerge`) whose content is centered or at the bottom
/// take their dots, once the merged cell ends in a row of the page where it starts
/// (`layout/table/rows.rs`).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum MergedCellLines {
    /// Where they lie when the content is laid out at the merged cell's top, moved down as one
    /// block by the shift of the alignment rounded to the nearest dot.
    ///
    /// - class: undocumented
    /// - status: derived
    MovedAsBlock,
    /// Where they lie when the content is laid out from the merged cell's exact aligned top,
    /// as the content of a cell of one row is: each line takes its own dot, so two lines can
    /// lie a dot nearer or further apart than at the merged cell's top.
    ///
    /// - class: undocumented
    /// - status: derived
    FromAlignedTop,
}
quirk!(MergedCellLines: MovedAsBlock, FromAlignedTop);

/// Whether a hidden paragraph mark hides the last empty paragraph of a cell or the document.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum HiddenLastMark {
    /// A hidden paragraph mark hides an empty paragraph also when it is the last of the
    /// document, and the last paragraph of a table cell keeps its line, because its mark ends
    /// the cell. Whether every target does so is not known.
    ///
    /// - class: undocumented
    /// - status: unknown
    HidesEmptyParagraph,
}
quirk!(HiddenLastMark: HidesEmptyParagraph);

/// Whether the last paragraph of a header or a footer keeps its space after when it shows
/// something and its paragraph mark is hidden, where no paragraph comes after it to join
/// (`layout/paragraph.rs`).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum HiddenHeaderFooterEnd {
    /// It keeps it, as with a mark that shows: the header ends, and the footer starts, its
    /// space after further from the body.
    ///
    /// - class: undocumented
    /// - status: derived
    KeepsSpaceAfter,
    /// It drops it, as when it joins an empty paragraph without space after: the header ends,
    /// and the footer starts, at its last line.
    ///
    /// - class: undocumented
    /// - status: derived
    DropsSpaceAfter,
}
quirk!(HiddenHeaderFooterEnd: KeepsSpaceAfter, DropsSpaceAfter);

/// Which cell margin a row of exact height adds to its height (`layout/table.rs`).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ExactRowMargin {
    /// The largest top margin of its cells: the row is its exact height plus that margin, and
    /// the bottom margins lie inside it.
    ///
    /// - class: undocumented
    /// - status: derived
    AddsTopMargin,
    /// The largest bottom margin of its cells: the row is its exact height plus that margin,
    /// and the top margins lie inside it.
    ///
    /// - class: undocumented
    /// - status: measured
    AddsBottomMargin,
}
quirk!(ExactRowMargin: AddsTopMargin, AddsBottomMargin);

/// Whether a paragraph in a table cell with a `w:framePr` that makes a frame, other than a drop
/// cap, lies in a frame.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum CellFrames {
    /// It lies in a frame, as a framed paragraph of the body does. This is F-Office's own
    /// layout.
    ///
    /// - class: undocumented
    /// - status: derived
    Framed,
    /// It makes no frame and stays in the cell's flow at the cell's width, with its other
    /// properties: alone, between plain paragraphs, two of one frame, empty, and a frame that
    /// holds a table, in the modes 14 and 15.
    ///
    /// - class: undocumented
    /// - status: measured
    InFlow,
}
quirk!(CellFrames: Framed, InFlow);

/// The room that the line of a display equation gives a run in a part of a stacked fraction in a
/// font with a `MATH` table.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum DisplayFractionRoom {
    /// The room of the run's font lines, above and below. This is F-Office's own layout.
    ///
    /// - class: undocumented
    /// - status: derived
    FontLines,
    /// The room of the ink of the run's glyphs as drawn, raised with their baseline, with the
    /// math font's `MathLeading` at the equation's size above it, as the parts of an inline
    /// fraction and a display's n-ary operator take.
    ///
    /// - class: undocumented
    /// - status: measured
    Ink,
}
quirk!(DisplayFractionRoom: FontLines, Ink);

/// The glyph that a delimiter of an equation (`m:d`) that grows around content that is not line
/// high draws, and the room that its line gives it.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum GrownDelimiters {
    /// The base glyph at the size of the paragraph's runs, on the content's baseline, in the
    /// room of its font's lines. This is F-Office's own layout.
    ///
    /// - class: undocumented
    /// - status: derived
    BaseGlyph,
    /// The first vertical variant of the glyph in the math font's `MATH` table whose height
    /// reaches twice the larger of the content's ink above and below the math axis, less
    /// `params::MATH_DELIMITER_SHORTFALL`, with the middle of its ink on the axis; the line
    /// gives it the room of its ink, with the math font's `MathLeading` above it.
    ///
    /// - class: undocumented
    /// - status: measured
    Variant,
}
quirk!(GrownDelimiters: BaseGlyph, Variant);

/// The room that the line of an inline equation or a display gives a run in a superscript or a
/// subscript (`m:sup`, `m:sub`) outside a stacked fraction, in a font with a `MATH` table.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ScriptRoom {
    /// The room of the run's font lines on the line's baseline: the rise or drop of the script
    /// does not size the line. This is F-Office's own layout.
    ///
    /// - class: undocumented
    /// - status: derived
    FontLines,
    /// The room of the run's font lines on the line's baseline, and also the room of the ink of
    /// its glyphs as drawn, raised or lowered with the script, with the math font's
    /// `MathLeading` at the equation's size above it, as the parts of an inline fraction take.
    ///
    /// - class: undocumented
    /// - status: measured
    Ink,
}
quirk!(ScriptRoom: FontLines, Ink);

/// The size of an inline VML object.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[cfg_attr(
    not(feature = "development"),
    expect(
        clippy::enum_variant_names,
        reason = "the variants keep the names that the profiles give them"
    )
)]
pub enum VmlObjectSize {
    /// An inline VML object takes the size of its CSS style. How Word fits an object that is
    /// too large for its page is not known.
    ///
    /// - class: undocumented
    /// - status: unknown
    TakesStyleSize,
    /// An outlined inline VML rectangle with an anchor lock takes room in 96 dpi steps on
    /// a line without text, and its box is placed from that room's bottom.
    ///
    /// - class: undocumented
    /// - status: measured
    TakesAnchorStrokeRoom,
    /// Each outlined inline VML rectangle, oval and rounded rectangle without a text box, with
    /// or without an anchor lock, takes the room of its outline in 96 dpi steps across and down,
    /// on lines with or without text, and its box stands that room's half outline right of and
    /// below the room's top left corner; on a line without text it is placed from the room's
    /// bottom as under `TakesAnchorStrokeRoom`.
    ///
    /// - class: undocumented
    /// - status: measured
    TakesStrokeRoom,
}
quirk!(VmlObjectSize: TakesStyleSize, TakesAnchorStrokeRoom, TakesStrokeRoom);

/// Where a single line on a section's line grid lies in the steps that it fills.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum GridSingleLine {
    /// The line's exact ascent and descent give its height, and its text lies in the middle of
    /// the steps that hold that height.
    ///
    /// - class: undocumented
    /// - status: fitted
    Middle,
    /// The line fills the steps that hold its height. The top of its steps and their height
    /// each take the nearest dot, from a pitch held in binary fixed-point points cut toward
    /// zero: a half goes down the page where those points hold the pitch exactly, else up. Its
    /// ascent and descent each round to the device's dots on their own, and its baseline lies
    /// the rounded ascent plus half of what the rounded height adds to them, a half away from
    /// zero, below the top's dot.
    ///
    /// - class: undocumented
    /// - status: fitted
    PartsRounded,
}
quirk!(GridSingleLine: Middle, PartsRounded);

/// What the part of an inline object above the baseline counts against in its line, for an
/// object of a run that is not raised: its height, less the lowering of a lowered run.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ObjectAscent {
    /// The single line of the line's text: the line grows only where the part is taller than
    /// the single line. This is F-Office's layout before the rule of the other variant.
    ///
    /// - class: undocumented
    /// - status: derived
    SingleLine,
    /// The ascent of the line's text: where the part is taller than the ascent, the baseline
    /// lies that part below the line's top, and the line grows by the difference above it,
    /// unscaled in automatic multiple spacing above single spacing.
    ///
    /// - class: undocumented
    /// - status: derived
    Ascent,
}
quirk!(ObjectAscent: SingleLine, Ascent);

/// Whether an inline object alone on its line and taller than its font line, whose run draws an
/// underline below it, keeps room below the baseline for that underline.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum UnderlinedObjectRoom {
    /// None: the object's bottom sits on the baseline and the line ends there, whatever the
    /// underline. This is F-Office's layout before the rule.
    ///
    /// - class: undocumented
    /// - status: derived
    None,
    /// The object run's font descent, below the baseline, so that the line and the body below it
    /// stand that much lower, whatever the kind of underline. An object with no underline, a
    /// short object and a line that holds text keep their room.
    ///
    /// - class: undocumented
    /// - status: measured
    FontDescent,
}
quirk!(UnderlinedObjectRoom: None, FontDescent);

/// Which single line sizes an inline object's line and scales automatic multiple spacing above
/// single spacing on a line with inline objects: the paragraph mark's (or text's alone), or the
/// inline objects' own runs. They differ when an inline object's run is in another font or size
/// than the paragraph mark or surrounding text — as a logo run in a styled title, a wrapped
/// inline rule under a larger heading mark, or a short object in a larger run beside smaller text.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ObjectLineMultiple {
    /// The paragraph mark's single line sizes object-alone lines and scales multiple spacing
    /// below tall objects alone; an inline object's run does not expand a text line. This is
    /// F-Office's layout before the rule and matches Word in compatibility modes 14 and below.
    ///
    /// - class: undocumented
    /// - status: derived
    Mark,
    /// From compatibility mode 15, the inline objects' own run faces size object-alone lines
    /// (replacing the paragraph mark or line break), scale multiple spacing above single spacing
    /// below tall objects alone, and expand a text line's single line when an object run's single
    /// line exceeds the text's while keeping the text's descent below the baseline. Where the
    /// object run matches the mark or is no taller than the text, nothing changes.
    ///
    /// - class: undocumented
    /// - status: measured
    ObjectRun,
}
quirk!(ObjectLineMultiple: Mark, ObjectRun);

/// What automatic multiple spacing above single spacing does with the room that runs raised or
/// lowered by `w:position` add to a line's single line: how much taller the line's single line
/// is with the runs' shifts than without them.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum RaisedRunSpacing {
    /// The spacing scales the room with the single line. This is F-Office's layout before the
    /// rule of the other variant.
    ///
    /// - class: undocumented
    /// - status: derived
    Scaled,
    /// The spacing scales the single line without the shifts, and the room comes once,
    /// unscaled, as a list label's rise does: a raised run's above the text, a lowered run's
    /// below it, with the baseline at the line's ascent.
    ///
    /// - class: undocumented
    /// - status: derived
    Once,
}
quirk!(RaisedRunSpacing: Scaled, Once);

/// What automatic multiple spacing above single spacing does with a line's face room: how much
/// taller the box of the largest ascent and the largest descent of the line's text is than the
/// largest single line of one of its faces, as where one font has the larger ascent and another
/// the larger descent.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum FaceRoomSpacing {
    /// The spacing scales the whole box. This is F-Office's layout before the rule of the
    /// other variant.
    ///
    /// - class: undocumented
    /// - status: derived
    Scaled,
    /// The spacing scales the largest single line of one face, and the room comes once,
    /// unscaled, as a list label's rise does, with the baseline at the line's ascent.
    ///
    /// - class: undocumented
    /// - status: measured
    Once,
}
quirk!(FaceRoomSpacing: Scaled, Once);

/// Which face of a paragraph mark sizes the lines that the mark sizes: the line of an empty
/// paragraph, and a last line of only spaces and tabs.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum MarkFace {
    /// The mark's ASCII face, at `w:sz`, whatever the mark sets. This is F-Office's layout
    /// before the rule of the other variant.
    ///
    /// - class: undocumented
    /// - status: derived
    Ascii,
    /// The mark's complex script face, at `w:szCs`, when the mark has complex formatting
    /// (`w:rtl` or `w:cs`), as the text of such a run takes it; else the ASCII face.
    ///
    /// - class: undocumented
    /// - status: measured
    ComplexFormatting,
}
quirk!(MarkFace: Ascii, ComplexFormatting);

/// Where a line goes that has no room beside a tight or through wrap (`wp:wrapTight`,
/// `wp:wrapThrough`, and a VML `w10:wrap` of those types). Beside a square wrap the line goes
/// to the bottom of the box with its distance below on every target.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum BlockedLines {
    /// To the bottom of the drawing's box with the wrap's distance below it, or of the
    /// polygon's bounds when they reach lower, as beside a square wrap. This is F-Office's
    /// layout before the rule of the other variant.
    ///
    /// - class: undocumented
    /// - status: derived
    BelowBox,
    /// Down from the line's own top, one step at a time, until the line no longer meets the
    /// bounds of the wrap's polygon with the wrap distances. The step is the line's single line
    /// under multiple spacing, and its height under single, exact and at-least spacing.
    ///
    /// - class: undocumented
    /// - status: derived
    LineSteps,
}
quirk!(BlockedLines: BelowBox, LineSteps);

/// The height of a drawing that the band of its wrap takes below the drawing's top: the band of
/// top and bottom wrap, and the box of square wrap that a line without room beside it goes
/// below. The drawing itself keeps its exact height.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum BandHeight {
    /// The drawing's exact height. This is F-Office's layout before the rule of the other
    /// variant.
    ///
    /// - class: undocumented
    /// - status: derived
    Exact,
    /// The drawing's height cut toward zero to whole twips, as the offset of its place is.
    ///
    /// - class: undocumented
    /// - status: derived
    WholeTwips,
}
quirk!(BandHeight: Exact, WholeTwips);

/// Where a floating table placed from the page or from the margin (`w:tblpPr` with
/// `w:vertAnchor` page or margin, and no alignment down) lies: its top below its anchor. A table
/// placed from the text keeps its offset on every variant.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum FloatingTableTop {
    /// At its offset (`w:tblpY`) below its anchor. This is F-Office's layout before the rule of
    /// the other variant.
    ///
    /// - class: undocumented
    /// - status: derived
    AtOffset,
    /// One twip above its offset below its anchor.
    ///
    /// - class: undocumented
    /// - status: derived
    TwipHigher,
}
quirk!(FloatingTableTop: AtOffset, TwipHigher);

/// Where a floating table with an offset across (`w:tblpPr` with `w:tblpX` and no alignment
/// across) lies: its cells right of its anchor. A table aligned across, or placed without an
/// offset across, keeps its place on every variant.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum FloatingTableLeft {
    /// At its offset (`w:tblpX`) right of its anchor. This is F-Office's layout before the rule
    /// of the other variant.
    ///
    /// - class: undocumented
    /// - status: derived
    AtOffset,
    /// One twip left of its offset right of its anchor.
    ///
    /// - class: undocumented
    /// - status: derived
    TwipLeft,
}
quirk!(FloatingTableLeft: AtOffset, TwipLeft);

/// Where a frame with an offset across (`w:framePr` with `w:x` and no `w:xAlign`) lies: its
/// text right of its anchor. A frame aligned across, or placed without an offset across, keeps
/// its place on every variant.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum FrameLeft {
    /// At its offset (`w:x`) right of its anchor. This is F-Office's layout before the rule of
    /// the other variant.
    ///
    /// - class: undocumented
    /// - status: derived
    AtOffset,
    /// One twip left of its offset right of its anchor.
    ///
    /// - class: undocumented
    /// - status: derived
    TwipLeft,
}
quirk!(FrameLeft: AtOffset, TwipLeft);

/// How far inside the left edge of a DrawingML text box's outline its text keeps its left
/// inset: half the outline's width. The right and bottom insets keep the exact half on every
/// variant, the top inset takes the half that [`BoxTextTop`] says, and a VML text box keeps its
/// insets as [`VmlBoxOutline`] says.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum BoxOutlineLeft {
    /// The exact half of the outline's width. This is F-Office's layout before the rule of the
    /// other variant.
    ///
    /// - class: undocumented
    /// - status: derived
    ExactHalf,
    /// Half the outline's width cut to whole twips: a line of 15 twips keeps the text 7 twips
    /// in.
    ///
    /// - class: undocumented
    /// - status: derived
    WholeTwipsHalf,
}
quirk!(BoxOutlineLeft: ExactHalf, WholeTwipsHalf);

/// Where the text of a DrawingML text box starts below the box's top: below the top inset and
/// half the outline's width, counted from the box's top. The box's outline and fill stay at its
/// exact top on every variant, and a VML text box and a SmartArt box keep the exact top and
/// half outline.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum BoxTextTop {
    /// The box's exact top and the exact half of the outline's width. This is F-Office's layout
    /// before the rule of the other variant.
    ///
    /// - class: undocumented
    /// - status: derived
    ExactTop,
    /// The box's top rounded to the nearest whole twip, and half the outline's width cut to
    /// whole twips: a box whose top lies 0.6 of a twip past a whole twip starts its text from
    /// the next whole twip, and an outline of 15 twips keeps the text 7 twips below the top
    /// edge.
    ///
    /// - class: undocumented
    /// - status: derived
    NearestTwipTop,
}
quirk!(BoxTextTop: ExactTop, NearestTwipTop);

/// Where the last line of a DrawingML text box's text sits, when the box lies outside drawing
/// groups, its text starts at the box's top, does not fit the box to it, holds no table and only
/// lines of single spacing without space before or after, and ends in a line with room below
/// it. The other lines, and the last line of a VML text box, a SmartArt
/// box or a box whose text moves for its anchor, keep the place of their spacing on every
/// variant.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum BoxLastLine {
    /// The place of its spacing, as every other line. This is F-Office's layout before the rule
    /// of the other variant.
    ///
    /// - class: undocumented
    /// - status: derived
    Spaced,
    /// Below its rounded top by the larger of its exact ascent, rounded, and its bottom less its
    /// rounded descent. Its bottom lies below its top by the rounded sum of its exact height
    /// and the room below it, less that room rounded, and the room runs to the box's text top
    /// with the box's height cut to whole twips, less the bottom inset: a line of Calibri 14 pt
    /// whose room below it ends a third of a dot past a whole dot sits one dot lower than its
    /// spacing puts it. This holds for a line whose height rounds up to whole dots too, which
    /// its spacing puts from its rounded exact bottom.
    ///
    /// - class: undocumented
    /// - status: derived
    RoomBelow,
}
quirk!(BoxLastLine: Spaced, RoomBelow);

/// Where the baseline of a line of automatic spacing below single spacing sits in the text of a
/// SmartArt graphic's shape (its saved drawing's `dsp:txBody`), such as the 90% line spacing of
/// most SmartArt text. The line's height is the spacing's share of its single line on every
/// variant.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum SmartArtLowSpacing {
    /// As in Word's own text: the spacing scales the line's ascent as it scales the line, so
    /// that the line loses height above and below its baseline in the ratio of its ascent and
    /// descent. This is F-Office's layout before the rule of the other variant.
    ///
    /// - class: undocumented
    /// - status: derived
    ScaledAscent,
    /// The line keeps its text's full descent below its baseline, and loses all of its height
    /// above it: a line of Calibri 10 pt at 90% has its baseline a tenth of its descent, 0.27
    /// pt, higher than the spacing of Word's own text puts it.
    ///
    /// - class: undocumented
    /// - status: derived
    FullDescent,
}
quirk!(SmartArtLowSpacing: ScaledAscent, FullDescent);

/// Where a VML text box with an outline keeps its insets: from the outline's middle, or inside
/// the outline.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum VmlBoxOutline {
    /// From the outline's middle. This is F-Office's layout before the rule of the other
    /// variant.
    ///
    /// - class: undocumented
    /// - status: derived
    Middle,
    /// Inside the outline: the left and top insets move in by half the outline's width rounded
    /// up to whole twips, and the right and bottom insets by the rest of its width, so that the
    /// text area loses the whole outline. A line of 15 twips moves the text 8 twips right and
    /// down and narrows it by 15 twips.
    ///
    /// - class: undocumented
    /// - status: derived
    InsideRoundedHalf,
}
quirk!(VmlBoxOutline: Middle, InsideRoundedHalf);

/// How wide a frame without a width (`w:framePr` without `w:w`) of one line is: the frame that
/// fits its line. A frame with a width, and a frame of more than one line, which is as wide as
/// its area, keep their widths on every variant.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum FrameFittedWidth {
    /// As wide as its line. This is F-Office's layout before the rule of the other variant.
    ///
    /// - class: undocumented
    /// - status: derived
    Line,
    /// About half a twip wider than its line at its nominal size, by `FRAME_FITTED_ROOM`, so
    /// that a frame aligned right lies that much further left and a centered frame half of it.
    ///
    /// - class: undocumented
    /// - status: derived
    HalfTwipWider,
}
quirk!(FrameFittedWidth: Line, HalfTwipWider);

/// Whether the descent of a list label counts in its line's descent.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ListLabelDescent {
    /// The descent of a list label stays out of its line's descent, unless the line holds
    /// nothing else. Why the label's descent does not count is not known.
    ///
    /// - class: undocumented
    /// - status: unknown
    LeftOutOfLine,
    /// The descent of a list label counts in its line's descent as the text's does, and on a
    /// line that holds nothing else, with the paragraph mark's, as the rule of the line height
    /// for the other pieces of a line gives. No target chooses it.
    ///
    /// - class: undocumented
    /// - status: derived
    Counted,
}
quirk!(ListLabelDescent: LeftOutOfLine, Counted);

/// How multiple line spacing treats the part by which a list label rises above the paragraph
/// mark's ascent on a line that holds nothing but the label.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum LabelAloneRise {
    /// It comes on top of the line unscaled, as a list label's rise above the text does on a
    /// line with text. This is F-Office's layout before the rule of the other variant.
    ///
    /// - class: undocumented
    /// - status: derived
    Unscaled,
    /// The spacing scales it with the rest of the line, as if the label were the line's text.
    ///
    /// - class: undocumented
    /// - status: measured
    Scaled,
}
quirk!(LabelAloneRise: Unscaled, Scaled);

/// Whether a page of a section with vertical alignment is aligned when it holds footnotes.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum AlignmentWithNotes {
    /// Every page of a section with vertical alignment is aligned, also one that holds
    /// footnotes: its body moves down into the room above the footnotes (ECMA-376 Part 1,
    /// 17.6.23).
    ///
    /// - class: specification
    /// - status: specified
    AlignsPage,
    /// A page that holds footnotes keeps its body at the top margin; the other pages of the
    /// section are aligned.
    ///
    /// - class: undocumented
    /// - status: measured
    TopWithNotes,
}
quirk!(AlignmentWithNotes: AlignsPage, TopWithNotes);

/// What the characters that F-Office takes as invisible do: the zero width space, joiners and
/// marks, the bidirectional controls, the word joiner and the invisible operators, the
/// variation selectors and the byte order mark.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum InvisibleCharacters {
    /// Every one of them takes no room, draws nothing and does not size its line.
    ///
    /// - class: undocumented
    /// - status: unknown
    TakeNoRoom,
    /// The format characters (U+200B to U+200F, U+202A to U+202E and U+FEFF) take no room,
    /// draw nothing and do not size their line. The word joiner and the invisible operators
    /// (U+2060 to U+2064) are drawn as any character: their font's glyph with its advance. A
    /// variation selector (U+FE00 to U+FE0F) joins the character before it in its paragraph,
    /// takes no room and draws nothing, while its run sizes the line; as the first character
    /// of its paragraph it is drawn as its font's missing glyph with that glyph's advance.
    /// Text of an equation leaves every one of them out, under both variants.
    ///
    /// - class: undocumented
    /// - status: measured
    OperatorsDrawnSelectorsJoined,
}
quirk!(InvisibleCharacters: TakeNoRoom, OperatorsDrawnSelectorsJoined);

/// How far a bold that Word makes itself, for a font family without a bold face, widens each
/// glyph.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum SyntheticBoldWidth {
    /// Each glyph except a space widens by a fiftieth of the font size: the variant follows
    /// from the fitted parameter `params::SYNTHETIC_BOLD_PARTS`.
    ///
    /// - class: undocumented
    /// - status: derived
    WidensByFiftieth,
    /// Each glyph keeps the width of the regular face.
    ///
    /// - class: undocumented
    /// - status: measured
    KeepsWidths,
    /// Each glyph keeps the regular face's advance, and line breaking, the edge check and the
    /// segment rule count one font unit of the face more in the exact advance of each glyph,
    /// spaces too: the font size divided by the face's units per em. The edge check moves such
    /// a glyph one dot right when its right edge ends one dot less than the limit short of its
    /// exact edge, or more.
    ///
    /// - class: undocumented
    /// - status: unknown
    CountsAFontUnit,
}
quirk!(SyntheticBoldWidth: WidensByFiftieth, KeepsWidths, CountsAFontUnit);

/// Which width in whole thousandths of an em the PDF writer writes for a glyph, from which its
/// steps inside a text object start.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum WrittenWidths {
    /// The writer writes the font's advance in thousandths of an em, a half rounded up. The
    /// variant follows from the rule of the written widths.
    ///
    /// - class: undocumented
    /// - status: derived
    RoundsAdvance,
    /// The writer writes the glyph's advance at 1000 pixels per em, one pixel to the thousandth
    /// of an em, as bi-level rendering with the font's TrueType instructions gives it: the
    /// linear advance where the font says that the advance scales linearly, else the hinted
    /// one. A font that F-Office cannot hint keeps the rounding of its advance. The variant
    /// follows from the font's instructions and the rule of the written widths.
    ///
    /// - class: undocumented
    /// - status: derived
    HintedAdvanceAt1000,
}
quirk!(WrittenWidths: RoundsAdvance, HintedAdvanceAt1000);

/// The line that a document's own Helvetica lays out with, where the document names it.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum HelveticaLine {
    /// A line of 1.2 em, 0.970 em above the baseline and 0.230 em below it, also over the
    /// caller's own file of Helvetica. The variant follows from Word's line of Helvetica in
    /// the target's font environment.
    ///
    /// - class: undocumented
    /// - status: derived
    TwelveTenthsEm,
    /// The line of the face that draws Helvetica, as for any font. The target draws Helvetica
    /// with Arial, and its faces of Helvetica carry Arial's metrics. The variant follows from
    /// those faces and the line height rule.
    ///
    /// - class: undocumented
    /// - status: derived
    TakesFaceLine,
}
quirk!(HelveticaLine: TwelveTenthsEm, TakesFaceLine);

/// What the target draws of an object that lies wholly outside its page: a floating drawing,
/// such as a text box, or a table cell.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum OffPageObjects {
    /// The object is drawn where the layout puts it, off the page, and its text is in the
    /// PDF, as for any object.
    ///
    /// - class: specification
    /// - status: specified
    Drawn,
    /// The object is left out: the page shows nothing of it, and its text is not in the PDF.
    /// The layout still counts it, so a cell left out keeps its row's height. An object that
    /// reaches into the page is drawn, also its text that lies beyond the page's sides, but
    /// of a text box, the lines that start at or below the page's bottom are left out, and all
    /// its lines when its text area, the box inside its insets, ends at or above the page's
    /// top.
    ///
    /// - class: undocumented
    /// - status: measured
    LeftOut,
}
quirk!(OffPageObjects: Drawn, LeftOut);

/// The page of a document whose body has no section properties at all: no `w:sectPr` in the
/// body or in a paragraph. The target then takes the page of its own default template. A
/// `w:sectPr` that gives no page size, even an empty one, gets the page of a section that says
/// nothing on every target.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum PageWithoutSection {
    /// The page of a section that says nothing: US Letter (`DEFAULT_PAGE_SIZE`) with margins
    /// of one inch (`DEFAULT_MARGIN`).
    ///
    /// - class: undocumented
    /// - status: derived
    Letter,
    /// An A4 page (`A4_PAGE_SIZE`) with margins of one inch (`DEFAULT_MARGIN`).
    ///
    /// - class: undocumented
    /// - status: measured
    A4,
}
quirk!(PageWithoutSection: Letter, A4);

/// The Latin fonts of the theme of the target's own default template. A document without a
/// theme part takes them for its theme font references, among them the minor font that the
/// template's run defaults name when the document has no `w:rPrDefault`.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum TemplateFonts {
    /// Aptos for the minor (body) font and Aptos Display for the major (heading) font.
    ///
    /// - class: undocumented
    /// - status: measured
    Aptos,
    /// Calibri for the minor (body) font and Calibri Light for the major (heading) font.
    ///
    /// - class: undocumented
    /// - status: measured
    Calibri,
}
quirk!(TemplateFonts: Aptos, Calibri);

/// What the target does with a document whose settings ask it to update the styles from the
/// template (`w:linkStyles`) and name no attached template.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum LinkedStyles {
    /// The default paragraph style is that of the target's own template, with each of the
    /// template's defaults that differs from the document's default. The document defaults
    /// and the other styles stay the document's.
    ///
    /// - class: undocumented
    /// - status: measured
    Template,
    /// The styles stay the document's.
    ///
    /// - class: undocumented
    /// - status: measured
    Document,
}
quirk!(LinkedStyles: Template, Document);

/// Which style a paragraph takes whose `w:pStyle` names a style ID that is not a paragraph
/// style of the styles part: a character, table or numbering style, or an ID that the part
/// does not define.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ParagraphStyleReference {
    /// The paragraph takes the chain of the style that the ID names, whatever its kind; an ID
    /// that the part does not define adds nothing, so the paragraph has the document defaults.
    /// This keeps F-Office's reading rather than asserting a behavior of the targets that
    /// choose it.
    ///
    /// - class: undocumented
    /// - status: derived
    AnyStyle,
    /// The paragraph takes the default paragraph style, as a paragraph without `w:pStyle`
    /// does.
    ///
    /// - class: undocumented
    /// - status: measured
    ParagraphStyle,
}
quirk!(ParagraphStyleReference: AnyStyle, ParagraphStyle);

/// The size at which an inline VML shape without a picture, a line or a horizontal rule, with or
/// without an anchor lock, is drawn, and the room that it takes on its line, across and down,
/// from the width and height of its CSS style.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum InlineVmlSize {
    /// The shape is drawn at its CSS size and takes that size as its room. This keeps F-Office's
    /// reading rather than asserting a behavior of the targets that choose it.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    AsWritten,
    /// The shape is drawn at its CSS size in the nearest twip, a half up, and takes as its room
    /// the larger of that and its CSS size in the nearest whole pixel of 96 dots an inch
    /// (0.75 pt), a half up. The drawing keeps the room's top left corner.
    ///
    /// - class: undocumented
    /// - status: measured
    PixelRoom,
}
quirk!(InlineVmlSize: AsWritten, PixelRoom);

/// The size at which an inline VML picture is drawn, and the room that it takes on its line,
/// across and down, from the width and height of its CSS style and the natural size of its
/// image.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum VmlPictureRoom {
    /// The picture is drawn at its CSS size and takes that size as its room. This keeps
    /// F-Office's reading rather than asserting a behavior of the targets that choose it.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    AsWritten,
    /// An upright, uncropped picture of a PNG, JPEG or EMF image in a `w:pict`, or in a
    /// `w:object` without an `o:OLEObject`, takes as its room its image's natural size times a
    /// scale in whole thousandths, a half up, of its CSS size in the nearest twip, across and
    /// down, and its PNG or JPEG image is drawn at that size on the device's dots, each edge
    /// then in the nearest twip. The natural size is the image's pixels at its own density, or at 96 dots
    /// an inch when it has none, or an EMF image's frame, each in the nearest twip, a half up.
    /// A picture of another image, and the preview of an embedded object, keep their CSS size.
    ///
    /// - class: undocumented
    /// - status: measured
    NaturalScale,
}
quirk!(VmlPictureRoom: AsWritten, NaturalScale);

/// The size at which the preview of an embedded object, the picture of a `w:object` with an
/// `o:OLEObject` in its line, is drawn, and the room that it takes on its line, across and down,
/// from the width and height of its CSS style and the object's original size (`w:dxaOrig`,
/// `w:dyaOrig`).
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum VmlPreviewRoom {
    /// The preview is drawn at its CSS size and takes that size as its room. This keeps
    /// F-Office's reading rather than asserting a behavior of the targets that choose it.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    AsWritten,
    /// An upright, uncropped preview whose object gives its original size takes as its room
    /// that size times a scale in whole thousandths, a half up, of its CSS size in the nearest
    /// twip, across and down, and its PNG or JPEG image is drawn at that size on the device's
    /// dots, each edge then in the nearest twip. A preview without an original size, and one that is
    /// turned or cropped, keep their CSS size.
    ///
    /// - class: undocumented
    /// - status: measured
    OriginalScale,
}
quirk!(VmlPreviewRoom: AsWritten, OriginalScale);

/// What a floating VML shape of the type 136 with a `v:textpath` (plain text that fills its
/// shape, as Word writes a watermark) draws, and how an alignment of it places it.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum VmlTextPath {
    /// The reader reads no text path: the shape draws its own look, and an alignment aligns its
    /// box as any shape's. This keeps F-Office's reading rather than asserting a behavior of the
    /// targets that choose it.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    ShapeLook,
    /// The shape draws its string in place of a look: one filled path for each letter, at the
    /// letters' advances without kerning stretched across the box's width, with the em as tall
    /// as the box and the baseline the face's descent above the box's bottom, turned clockwise
    /// about the box's center by the shape's rotation, in the shape's fill color mixed with
    /// white by its opacity. An alignment aligns the box that holds both the turned letters
    /// and the shape's box turned by the nearest whole quarter turn, which swaps its width and
    /// height from 45 to 135 and from 225 to 315 degrees; a shape placed by offsets keeps its
    /// own box.
    ///
    /// - class: undocumented
    /// - status: fitted
    InkAligned,
}
quirk!(VmlTextPath: ShapeLook, InkAligned);

/// The area between the margins from which a floating drawing counts its vertical place, its
/// alignment and its size, when it counts from the margins: a drawing of a header or a footer,
/// or one of the body outside a table cell.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum StoryMarginArea {
    /// The section's own top and bottom margins, whatever the header and the footer reach.
    /// This keeps F-Office's reading rather than asserting a behavior of the targets that
    /// choose it.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    SectionMargins,
    /// The area of the page's body: from below a header that reaches past the top margin, and
    /// up to above a footer that reaches past the bottom margin. A drawing of a header or a
    /// footer without wrapping also ends the area above the footnotes of the page, and one
    /// that wraps the text does not; a drawing of the body ends it above them in both cases.
    ///
    /// - class: undocumented
    /// - status: fitted
    BodyArea,
}
quirk!(StoryMarginArea: SectionMargins, BodyArea);

/// The device width of a glyph in a kerned run (`w:kern` at or below the run's size), in a
/// target that steps glyphs by whole dots (`GridAdvances::RightEdgeSteps`).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum KernedDeviceWidths {
    /// The device width that the glyph has in a run without kerning.
    ///
    /// - class: undocumented
    /// - status: measured
    Own,
    /// The device width that the glyph has in a run without kerning, with the bias, plus the
    /// pair's kerning with the next glyph in whole dots on its own, as character spacing steps
    /// (`DeviceAdvance::ExtrasOnTheirOwn`): the glyph's own step in the edge check, and the step
    /// to the glyph after it.
    ///
    /// - class: undocumented
    /// - status: measured
    OwnWithKerningOnItsOwn,
    /// The advance rounded, for every glyph: a kerned run reads neither the face's
    /// instructions nor the measured table.
    ///
    /// - class: undocumented
    /// - status: measured
    Rounded,
    /// No device width, and no bias, in a GPOS-kerned face in a document of `KERNED_STEP_MODE`
    /// or a later mode, or of an earlier mode with the OpenType features setting: the glyph
    /// steps by its exact distance to the next glyph, its advance with its kerning, at the
    /// nearest dot, a half up, and its own step in the edge check is its advance so rounded.
    /// In an earlier mode without the setting, a kerned run steps as with
    /// `OwnWithKerningOnItsOwn`, and in a legacy-kern face in a document of that mode or with the
    /// setting as with `Rounded` ([`Self::in_run`]). A glyph of a run without kerning keeps its
    /// device width and the bias.
    ///
    /// - class: undocumented
    /// - status: measured
    Nearest,
    /// As `Nearest` in a document of `KERNED_STEP_MODE` or a later mode and in a GPOS-kerned
    /// face. In an earlier mode, and in a legacy-kern face in every mode, a kerned run steps as
    /// with `Own`: its device widths and the bias ([`Self::in_run`]).
    ///
    /// - class: undocumented
    /// - status: measured
    NearestOrOwn,
}
quirk!(KernedDeviceWidths: Own, OwnWithKerningOnItsOwn, Rounded, Nearest, NearestOrOwn);

/// How the glyphs of a run step whose standard ligatures are on, in a document of a mode that
/// joins them.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum LigatureSteps {
    /// As the run's kerning and face say: by device widths without kerning, and as a kerned run
    /// of its face with it. This keeps F-Office's existing steps rather than asserting a
    /// behavior of the targets that choose it.
    ///
    /// - class: undocumented
    /// - status: derived
    AsTheirRun,
    /// As a kerned run of a face under its own name ([`KernedDeviceWidths::in_run`]), whether
    /// the run kerns or not and whether its face stands in for the run's font or not. Its pairs
    /// kern only where the run kerns.
    ///
    /// - class: undocumented
    /// - status: measured
    AsKernedRun,
}
quirk!(LigatureSteps: AsTheirRun, AsKernedRun);

impl KernedDeviceWidths {
    /// The variant by which a kerned run in a face whose pair kerning comes from `source`
    /// steps in a document whose mode rules are `rules`: `Nearest` and `NearestOrOwn` step as
    /// `Nearest` only where the mode rules say so for each of them and in a GPOS-kerned face.
    /// Elsewhere `Nearest` steps as `Rounded` in a legacy-kern face where the mode rules say
    /// so, and as `OwnWithKerningOnItsOwn` where they do not, and `NearestOrOwn` steps as
    /// `Own`; the other variants step as themselves in every document and face.
    #[must_use]
    pub fn in_run(
        self,
        rules: crate::mode::ModeRules,
        source: f_office_fonts::KerningSource,
    ) -> Self {
        let in_document = match self {
            Self::Nearest => rules.steps_kerned_runs_at_nearest_dot_with_open_type_features(),
            _ => rules.steps_kerned_runs_at_nearest_dot(),
        };
        let nearest = in_document && source == f_office_fonts::KerningSource::Gpos;
        match self {
            Self::Nearest | Self::NearestOrOwn if nearest => Self::Nearest,
            Self::Nearest if in_document => Self::Rounded,
            Self::Nearest => Self::OwnWithKerningOnItsOwn,
            Self::NearestOrOwn => Self::Own,
            other => other,
        }
    }
}

/// Which table gives a pair of a kerned run its value in a document of a compatibility mode
/// before `KERNED_KERN_FEATURE_MODE`.
/// It decides only in a face whose `kern` feature of `GPOS` and `kern` table give a pair other
/// values, such as Aptos and Segoe UI.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum KerningTableRead {
    /// The face's kerning source in every mode: the `kern` feature of `GPOS` where the face has
    /// one, and its `kern` table otherwise. It follows from the face's own tables.
    ///
    /// - class: undocumented
    /// - status: derived
    FaceSource,
    /// The `kern` table alone where the document does not kern by the `kern` feature, before
    /// `KERNED_KERN_FEATURE_MODE` and without the OpenType features setting, and the face's
    /// kerning source where it does ([`Self::in_mode`], `ModeRules::kerns_by_the_kern_feature`):
    /// a face without a `kern` table kerns no pair there.
    ///
    /// - class: undocumented
    /// - status: measured
    KernTableBeforeMode,
}
quirk!(KerningTableRead: FaceSource, KernTableBeforeMode);

impl KerningTableRead {
    /// The table that the pairs of a kerned run read in a document of the mode rules `rules`.
    #[must_use]
    pub fn in_mode(self, rules: crate::mode::ModeRules) -> crate::KerningTable {
        match self {
            Self::KernTableBeforeMode if !rules.kerns_by_the_kern_feature() => {
                crate::KerningTable::KernTable
            }
            _ => crate::KerningTable::FaceSource,
        }
    }
}

/// Which dot a line's start past its column's edge takes when it ends exactly half a dot past
/// a whole dot (`grid::Device::line_start`), and so the text after a tab to a left stop, whose
/// stop's distance from the column's edge goes to its dot as a line's start does
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum LineStartHalves {
    /// The higher dot, as every other half. On the device of 288 dots per inch, no whole number
    /// of twips ends in half a dot.
    ///
    /// - class: undocumented
    /// - status: derived
    Up,
    /// The dot that the fixed-point arithmetic of `params::LINE_START_FRACTION_BITS` gives:
    /// the length goes to the nearest 1/65536 pt and that to the nearest dot, each with a half
    /// up, so a half goes the way of the first rounding. A start left of the column's edge,
    /// below zero, takes the mirror of the dot of its size: each rounding takes a half away from
    /// zero, so a start that lies exactly half a dot left of a whole dot past the edge takes the
    /// dot to its left.
    ///
    /// - class: undocumented
    /// - status: measured
    FixedPoint,
}
quirk!(LineStartHalves: Up, FixedPoint);

/// How the fixed-point arithmetic of `LineStartHalves::FixedPoint` counts the start of a
/// paragraph's first line past its column's edge when the line has an indent of its own (a
/// first-line indent, a hanging indent or a label's shift) on top of the left indent
/// (`grid::Device::first_line_start`).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum FirstLineIndentHalves {
    /// As one length, the left indent and the first line's own indent summed.
    ///
    /// - class: undocumented
    /// - status: derived
    Summed,
    /// As two parts: the left indent and the first line's own indent each go to fixed-point
    /// points on their own, a half up, and their sum to the nearest dot, a half up, so that a
    /// start that lies exactly half a dot past a whole dot goes the way that the two roundings
    /// leave it.
    ///
    /// - class: undocumented
    /// - status: measured
    Parts,
}
quirk!(FirstLineIndentHalves: Summed, Parts);

/// The width of each column of a section of equal columns (`w:cols` without its own column
/// widths): the text area's width less the spaces between the columns, divided by the number
/// of columns. A later column's left edge is the left margin plus the widths and spaces of the
/// columns before it, so the width moves the edges of the later columns.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum ColumnWidths {
    /// The exact quotient, in half-EMUs. This keeps F-Office's existing columns rather than
    /// asserting a behavior of the targets that choose it.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Exact,
    /// The quotient rounded down to a whole number of twips.
    ///
    /// - class: undocumented
    /// - status: measured
    WholeTwips,
}
quirk!(ColumnWidths: Exact, WholeTwips);

/// Where the columns of a right-to-left section (`w:sectPr/w:bidi`) of more than one column lie
/// on the page (`layout::columns`).
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum RightToLeftSectionColumns {
    /// From the left margin, as in a left-to-right section. This keeps F-Office's existing
    /// columns rather than asserting a behavior of the targets that choose it.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    FromLeft,
    /// From the right margin: each column lies at the mirror of its left-to-right place across
    /// the text area and keeps its width, so the first column is the rightmost and the space
    /// after a column lies to its left.
    ///
    /// - class: undocumented
    /// - status: measured
    FromRight,
}
quirk!(RightToLeftSectionColumns: FromLeft, FromRight);

/// Which dot the left edge of a later column of the page takes when it lies exactly half a dot
/// past a whole dot: the edge is the left margin plus each earlier column's width and the space
/// after it, and the lines of the column, left-aligned or not, start from its dot.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum ColumnEdgeHalves {
    /// The dot of the whole edge as one length, as a line's start past the page's edge takes
    /// it (`LineStartHalves`).
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    WholeEdge,
    /// In a document of a mode before `COLUMN_EDGE_WHOLE_MODE`, the dot of the parts of the
    /// edge, as `grid::Device::parts_dot` sums them: the left margin, and each earlier column's
    /// width with the space after it as one length. From that mode on, as `WholeEdge`.
    ///
    /// - class: undocumented
    /// - status: measured
    ColumnParts,
}
quirk!(ColumnEdgeHalves: WholeEdge, ColumnParts);

/// Whether and where a target draws the line that a section's `w:sep` asks for between its text
/// columns (`layout::columns`).
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum ColumnSeparator {
    /// No line. This keeps F-Office's existing pages rather than asserting a behavior of the
    /// targets that choose it.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    NotDrawn,
    /// On each page, in each space between two neighboring columns that both hold a line of the
    /// body outside tables on the page, a black filled rectangle `COLUMN_SEPARATOR_WIDTH` wide
    /// whose left edge lies on the dot nearest to half that width left of the space's middle,
    /// from the dot nearest to the columns' top to the dot nearest to the bottom of the lowest
    /// such line of the page's columns. The lines of the paragraph that ends the section do not
    /// count when they draw nothing.
    ///
    /// - class: undocumented
    /// - status: measured
    SpaceMiddle,
}
quirk!(ColumnSeparator: NotDrawn, SpaceMiddle);

/// What the paragraph borders of a run of paragraphs that show nothing and whose marks are
/// hidden become, before the paragraph that shows something after them, which the run joins
/// (`layout::paragraph`).
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum HiddenMarkBorders {
    /// They go with the paragraphs, which take no room. This keeps F-Office's existing pages
    /// rather than asserting a behavior of the targets that choose it.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Dropped,
    /// From compatibility mode 15 (`HIDDEN_MARK_BORDERS_MODE`), when the paragraph after the
    /// run has a border or a fill of its own, its border lines are those of the run's first
    /// paragraph, in place of its own, and its fill stays its own; before that mode, or before
    /// a paragraph without a border or a fill, they go.
    ///
    /// - class: undocumented
    /// - status: measured
    ByMode,
}
quirk!(HiddenMarkBorders: Dropped, ByMode);

/// Which dot a line of a column of the page takes when a drawing on its left moves its start to
/// the drawing's wrap edge, the drawing's edge with its distance from the text (`layout::line`).
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum WrapEdgeDot {
    /// The dot of the column's left edge plus the dot of the line's start past it, the wrap
    /// edge's distance from that edge with the line's indent, as every other line takes it.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    ColumnAndDistance,
    /// The dot of the wrap edge as one length from the page's left edge, and the line's indent
    /// past it as a line's start past its column's edge, on a line that starts left to right.
    ///
    /// - class: undocumented
    /// - status: measured
    WrapEdge,
}
quirk!(WrapEdgeDot: ColumnAndDistance, WrapEdge);
/// Where the device's right-edge steps put the first glyph of a footnote's reference mark.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum NoteMarkPlace {
    /// Stepped from the glyph before and checked at its right edge, as every other glyph.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Stepped,
    /// At the dot nearest to its exact place, as the edge check counts that place from the
    /// glyph that started the steps; the glyphs after it step from it.
    ///
    /// - class: undocumented
    /// - status: measured
    NearestExact,
}
quirk!(NoteMarkPlace: Stepped, NearestExact);
/// How the device's right-edge steps go on after a footnote's own mark at the start of the
/// footnote's text.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum NoteStartSteps {
    /// Stepped on from the mark's last glyph, as after any glyph.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Continued,
    /// Started again at the mark's device end: the next glyph takes its step from the mark's
    /// last glyph without the edge check's move and starts a new segment of the steps, and the
    /// edge check counts the exact places after it from that dot.
    ///
    /// - class: undocumented
    /// - status: measured
    SteppedAfterMark,
}
quirk!(NoteStartSteps: Continued, SteppedAfterMark);

/// Which dot the rounded top of a line takes when it lies exactly half a dot past a whole dot:
/// of a line of single spacing whose height rounds down so that the page rounds its top on its
/// own, and of a line of multiple spacing whose box's top is the body's top on its page
/// (`grid::Device::top_dot`). The part of an exact line below its baseline, which the page
/// takes from the line's rounded bottom, rounds the same way. A line's top in a header keeps
/// its own rule, a half up the page.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum TopHalves {
    /// The dot farther from the page's top, as every other half down the page. On the device of
    /// 288 dots per inch no whole number of twips lies on half a dot; on the device of 300 dots
    /// per inch a top of 12 twips past a multiple of 24 does.
    ///
    /// - class: undocumented
    /// - status: derived
    AwayFromTop,
    /// For a top that is a whole number of twips, the dot that the fixed-point arithmetic of a
    /// line's start gives (`LineStartHalves::FixedPoint`): the top goes to the nearest 1/65536 pt
    /// and that to the nearest dot, each with a half up, so a top half a dot past a whole dot
    /// goes the way that the first step rounded it. Another top keeps the dot farther from the
    /// page's top.
    ///
    /// - class: undocumented
    /// - status: measured
    FixedPoint,
}
quirk!(TopHalves: AwayFromTop, FixedPoint);

/// To which dot the length of a run's shift goes where its glyphs are drawn: the run's rise or
/// drop from `w:position` with that of its script, when it lies exactly half a dot past a whole
/// dot (`grid::Device::shift_dots`). The height of the run's line does not read it.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ShiftDots {
    /// The nearest dot, a half up the page: a raising half a dot past a whole dot goes to the
    /// dot above it, and a lowering so to the dot above it too. This is F-Office's layout
    /// before the rule of the other variant.
    ///
    /// - class: undocumented
    /// - status: derived
    HalfUp,
    /// The nearest dot, a half away from the baseline: a raising half a dot past a whole dot
    /// goes to the dot above it, and a lowering so to the dot below it.
    ///
    /// - class: undocumented
    /// - status: measured
    HalfAwayFromBaseline,
}
quirk!(ShiftDots: HalfUp, HalfAwayFromBaseline);

/// In which unit the target holds the height of a line of automatic spacing at or above single
/// spacing, and so the tops that it adds down the page (`layout::line::height`).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum LineHeightUnit {
    /// F-Office's half-EMUs: the line's ascent and descent each rounded to the nearest
    /// half-EMU, and their sum times the spacing too.
    ///
    /// - class: undocumented
    /// - status: derived
    HalfEmus,
    /// Whole 1/4096 pt (`params::HEIGHT_PARTS_PER_POINT`) for a line whose ascent and descent
    /// come from faces of `params::WHOLE_HEIGHT_UNITS_PER_EM` units per em: the exact single
    /// line times the spacing in 240ths, rounded to a whole part, a half up, with the tops
    /// added exactly, so that a top rounds to its dot as the exact sum does. The rows of a
    /// table carry that sum from row to row, where their twips rest goes on: a row whose
    /// content sets its end ends at the exact bottom of that content. A line of at-least
    /// spacing whose minimum is at most its single line takes single spacing's height so. Every
    /// other line keeps F-Office's half-EMUs.
    ///
    /// - class: undocumented
    /// - status: measured
    Whole4096ths,
}
quirk!(LineHeightUnit: HalfEmus, Whole4096ths);

/// In which unit the target adds a length of whole twips to a place down the page whose
/// lengths from the body's top are all whole twips: the top margin, the spaces between the
/// paragraphs, and the heights of lines of exact spacing or of at-least spacing whose minimum
/// sets them (`layout::line::height::twips_rest`).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum TwipLengthUnit {
    /// F-Office's half-EMUs, in which every length of whole twips is exact.
    ///
    /// - class: undocumented
    /// - status: derived
    HalfEmus,
    /// The nearest whole 1/4096 pt (`params::HEIGHT_PARTS_PER_POINT`), a half up. A length of
    /// n twips is n × 204.8 parts, so unless 5 divides n it lies 0.2 or 0.4 of a part past or
    /// short of its exact value, and the cursor carries that part down the page in its twips
    /// rest. A place on half a dot then takes the dot on the side of the rest, and a long sum
    /// can carry a place across half a dot. A line whose height is whole 1/4096 pt
    /// (`LineHeightUnit::Whole4096ths`) adds no error, and the rest goes on below it. Below a
    /// length of another kind, such as a line of a face whose height is not in those parts or
    /// a header that reaches below the top margin, a place keeps its exact sum.
    ///
    /// - class: undocumented
    /// - status: measured
    Nearest4096ths,
}
quirk!(TwipLengthUnit: HalfEmus, Nearest4096ths);

/// The length on which the target decides whether the box of an exact line, with the space
/// before that it holds, rounds down to the device grid, so that the box forms of
/// `ExactBaseline::BoxForms` place its baseline (`layout::line::height::exact_box_rounds_down`).
/// Only a box that lies exactly on half a dot can round one way on one length and the other way
/// on another.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ExactBoxLength {
    /// The box's exact length in F-Office's half-EMUs: a box on half a dot rounds up, and its
    /// bottom decides.
    ///
    /// - class: undocumented
    /// - status: derived
    Exact,
    /// The box's length as the target enters its lengths of whole twips (`TwipLengthUnit`): a
    /// box of whole twips on half a dot rounds down when the twips rests of its space before
    /// and its height sum below 0, so that its entered length lies below the half, and up
    /// otherwise. Every other box rounds as its exact length does. On the first line of a
    /// paragraph that sets its own space before, a box that rounds down takes its shorter dot,
    /// and the baseline sits the part below the baseline of `ExactFifthHalves` above that
    /// rounded bottom.
    ///
    /// - class: undocumented
    /// - status: measured
    Entered,
}
quirk!(ExactBoxLength: Exact, Entered);

/// Which dot the part of an exact line below its baseline, a fifth of the line, takes when it
/// lies exactly half a dot past a whole dot, where the line's bottom decides its baseline, and
/// under `ExactBoxLength::Entered` in a box that rounds down below space before
/// (`layout::line::height::exact_below`).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ExactFifthHalves {
    /// The dot of a top on half a dot (`TopHalves`).
    ///
    /// - class: undocumented
    /// - status: derived
    AsTops,
    /// The dot of a fifth of the line's height as the target enters it (`TwipLengthUnit`),
    /// in whole parts of a point, rounded down: the shorter of its two dots when that fifth
    /// lies below the half, so that the baseline lies the lower of its two places below the
    /// bottom's dot, and the longer one when it lies on or past the half.
    ///
    /// - class: undocumented
    /// - status: measured
    Entered,
}
quirk!(ExactFifthHalves: AsTops, Entered);

/// Which dot the exact bottom of a footer line takes when it lies exactly half a dot past a
/// whole dot, for a line of single spacing whose baseline the page rounds from its bottom (its
/// height rounds up): the line's baseline is that dot less the rounded descent
/// (`grid::Device::footer_bottom_dot`). A footer's last line ends at the page height less the
/// footer distance, a whole number of twips.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum FooterHalves {
    /// The dot farther from the page's top, as every other half in the body and in a footer.
    ///
    /// - class: undocumented
    /// - status: derived
    AwayFromTop,
    /// For a bottom that is a whole number of twips, the dot of the fixed-point arithmetic of
    /// `TopHalves::FixedPoint`: the bottom goes to the nearest 1/65536 pt and that to the nearest
    /// dot, each with a half up, so a bottom half a dot past a whole dot goes the way that the
    /// first step rounded it: up the page at x.7 and x.9 pt, down at x.1, x.3 and x.5 pt.
    /// Derived from the measured arithmetic of `TopHalves::FixedPoint`, applied to a footer's
    /// bottom.
    ///
    /// - class: undocumented
    /// - status: derived
    FixedPoint,
}
quirk!(FooterHalves: AwayFromTop, FixedPoint);

/// Which dot a place of a header line that the page rounds takes when it lies exactly half a dot
/// past a whole dot: the top of a line of single spacing whose height rounds down, the exact
/// bottom of one whose height rounds up, the top of a box that holds its paragraph's space after,
/// and the places that round lines of other spacing (`grid::Device::header_dot`). A header's
/// first line without space before has its top at the header distance, a whole number of twips.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum HeaderHalves {
    /// The dot nearer the page's top, as every half in a header (`Ties::TowardTop`).
    ///
    /// - class: undocumented
    /// - status: derived
    TowardTop,
    /// For a place that is a whole number of twips, the dot of the fixed-point arithmetic of
    /// `TopHalves::FixedPoint`, as a body line's top: the place goes to the nearest 1/65536 pt
    /// and that to the nearest dot, each with a half up, so a place half a dot past a whole dot
    /// goes the way that the first step rounded it: up the page at x.7 and x.9 pt, down at x.1,
    /// x.3 and x.5 pt.
    /// Another place keeps the dot nearer the page's top.
    /// Derived from the measured arithmetic of `TopHalves::FixedPoint`, applied to a header
    /// line's places.
    ///
    /// - class: undocumented
    /// - status: derived
    FixedPoint,
}
quirk!(HeaderHalves: TowardTop, FixedPoint);

/// Where an aligned line's ends lie: where a centered or a right-aligned line starts
/// (`layout::line`), and where the device draws the last visible glyph of a filled justified line
/// of left-to-right text under `GridAdvances::RightEdgeSteps`, when a space trails the glyph and
/// the glyph comes right after the glyph before it, stepped from it or starting a segment of the
/// steps (`layout::line::draw`). One quirk holds the two, because one rule explains both on Word
/// for Windows: the line's ends lie on the dots that its free space leaves.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum AlignedEnds {
    /// At their exact places: a centered or a right-aligned line starts at its start at its
    /// indent plus the free space of the line, or half of it, from the exact width of the line,
    /// and the last glyph of a justified line lies at the place that the device's steps give it,
    /// as every other glyph does. This keeps F-Office's existing places rather than asserting a
    /// behavior of the targets that choose it.
    ///
    /// - class: undocumented
    /// - status: derived
    Exact,
    /// On the dots of the free space:
    ///
    /// - a centered or a right-aligned line's glyphs take their places from a start on the dot
    ///   of the line's start at its indent, the line's width is the dot where its written text
    ///   ends, and the line moves right by the free whole dots, or by half of them, rounded down.
    ///   The text after a tab to a right or a center stop starts so too, from the stop's dot;
    /// - the device's steps place the space that trails a justified line's last visible glyph
    ///   from the glyph, with the space's own edge check and segment start. When that place
    ///   lies more than one dot past the nearest dot of the space's exact place, the lower dot
    ///   at an exact half, the glyph is drawn one dot left of its steps' place; when it lies
    ///   more than one dot short of it, one dot right. The space keeps its place. A glyph at
    ///   which a segment starts, which goes to the nearest dot of its counted place plus the
    ///   carry, moves so too, but by the dot of the line's own right edge, which lies past the
    ///   space's exact place by the part of the free space that the equal shares of the spaces
    ///   leave. That edge takes its dot as a line's start does, by its length from the edge that
    ///   the line counts its start from: the nearest dot, and at an exact half the dot of
    ///   `LineStartHalves`, so that with `LineStartHalves::FixedPoint` an edge 0.7 or 0.9 pt past
    ///   a whole point takes the lower dot.
    ///
    /// - class: undocumented
    /// - status: measured
    OnDots,
}
quirk!(AlignedEnds: Exact, OnDots);

/// Where the glyph places of a centered or right-aligned line count from under
/// `AlignedEnds::OnDots`, which matters for the text after a tab or a list label's gap:
/// that text starts a segment at the nearest dot of its exact place.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum AlignedLineSegments {
    /// From the dot of the line's start at its indent, so that a tab's stop counts from that
    /// dot. This is F-Office's layout before the rule of the other variant.
    ///
    /// - class: undocumented
    /// - status: derived
    FromStartDot,
    /// From the line's exact start at its indent, as a start-aligned line's places count: its
    /// first glyph still lands on the dot of that start, and the text after a tab lands on the
    /// dot of the stop's exact place, the dot of the column's edge plus the stop's distance
    /// from it. The line then moves right by the free whole dots, or half of them.
    ///
    /// - class: undocumented
    /// - status: derived
    FromExactStart,
}
quirk!(AlignedLineSegments: FromStartDot, FromExactStart);

/// Where the written text of a centered or right-aligned line ends under
/// `AlignedEnds::OnDots` when it ends with a tab or a list label's gap that no glyph
/// follows, such as the tab after the label of an empty list paragraph (`layout::line`).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum AlignedTabEnd {
    /// Nowhere: the device's steps give such a line no written end, and the line keeps its
    /// exact start. This is F-Office's layout before the rule of the other variant.
    ///
    /// - class: undocumented
    /// - status: derived
    Unended,
    /// At the dot where a glyph after the tab would lie: the nearest dot of the tab's exact
    /// end, moved by the stop's nudge. The line then moves by the free whole dots between that
    /// dot and the space's right edge, or by half of them, as other such lines do.
    ///
    /// - class: undocumented
    /// - status: derived
    StopDot,
}
quirk!(AlignedTabEnd: Unended, StopDot);

/// Where a start-aligned line of a right-to-left paragraph (`w:bidi`) starts when it does not
/// end the paragraph, on a target with `AlignedEnds::OnDots` (`layout::line`).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum RightToLeftLineStart {
    /// At its exact start, as other lines of such a paragraph: its glyphs take their places
    /// from the exact start that the line's free space gives, and lie
    /// `RIGHT_TO_LEFT_LINE_DOTS` dots right of their steps, moved with the column's right edge
    /// on the device grid.
    ///
    /// - class: undocumented
    /// - status: derived
    Exact,
    /// As a right-aligned line under `AlignedEnds::OnDots`: its glyphs take their
    /// places from the dot of the line's start at its indent, and the line moves right by the
    /// free whole dots between the dot where its written text then ends and the dot of the
    /// space's right edge. Its glyphs then lie `RIGHT_TO_LEFT_LINE_DOTS` dots right of those
    /// places.
    ///
    /// - class: undocumented
    /// - status: unknown
    WholeDots,
}
quirk!(RightToLeftLineStart: Exact, WholeDots);

/// The dot of the right edge of a line's space, up to which a start-aligned line of a
/// right-to-left paragraph moves where the quirk `RightToLeftLineStart::WholeDots` places it
/// (`layout::line`).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum RightToLeftLineEdge {
    /// The edge of a right-aligned line, as the quirk `AlignedLineEdge` gives it.
    ///
    /// - class: undocumented
    /// - status: derived
    AsAligned,
    /// The dot of the column's right edge less the dot of the space's distance from that edge,
    /// each taken to a dot as a line's start. The indent at the line's end does not enter the
    /// edge. A space in a table cell takes the edge of a right-aligned line.
    ///
    /// - class: undocumented
    /// - status: derived
    FromColumnRight,
}
quirk!(RightToLeftLineEdge: AsAligned, FromColumnRight);

/// How the device draws a line of a right-to-left paragraph (`w:bidi`) whose spaces a justified
/// paragraph stretches or shrinks (`layout::line`).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum RightToLeftJustifiedLine {
    /// As other lines of such a paragraph: its glyphs lie `RIGHT_TO_LEFT_LINE_DOTS` dots right
    /// of their steps, moved with the column's right edge on the device grid, and each
    /// stretched space spans its stretched width on the side of the glyph after it in reading
    /// order.
    ///
    /// - class: undocumented
    /// - status: derived
    Mirrored,
    /// Each stretched space spans its own step on the side of the glyph before it in reading
    /// order, with the stretch on its other side. The line is drawn from the dot of its start
    /// and moves by the dots between the dot where its steps end and the dot of the right edge
    /// of `RightToLeftLineEdge`, left when they end past it, and its glyphs lie
    /// `RIGHT_TO_LEFT_LINE_DOTS` dots right of their steps.
    ///
    /// - class: undocumented
    /// - status: derived
    EndsAtEdge,
}
quirk!(RightToLeftJustifiedLine: Mirrored, EndsAtEdge);

/// How the device's steps take each glyph of a stretch of right-to-left text to the next one in
/// reading order (`layout::line`), and how the edge check counts the glyph's right edge.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum RightToLeftSteps {
    /// As a glyph of left-to-right text: by its device width, rounded with the bias.
    ///
    /// - class: undocumented
    /// - status: derived
    DeviceWidths,
    /// By its advance at the drawn size rounded to the nearest dot, without its device width
    /// and without the bias; the step into the stretch's first glyph and the step out of its
    /// last glyph round so too. The glyph is still drawn at its device width from the right
    /// end of its place, so that a glyph whose device width is one dot above its advance
    /// rounded reaches one dot into the place of the glyph after it.
    ///
    /// - class: undocumented
    /// - status: derived
    Nearest,
}
quirk!(RightToLeftSteps: DeviceWidths, Nearest);

/// Where the device draws a glyph of right-to-left text that the font's layout tables place to
/// the right or left of its step, such as a mark or a letter that a font draws off its place
/// (`layout::line`).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum RightToLeftPlacements {
    /// Its exact placement off its step. This keeps F-Office's existing places rather than
    /// asserting a behavior of the targets that choose it.
    ///
    /// - class: undocumented
    /// - status: derived
    Exact,
    /// Its placement in whole dots off its step, so that the glyph lies on a dot as its step
    /// does, counted at the device's em, the size in whole dots: for a glyph that takes no room
    /// in its line, a mark, the placement without the advance that its font gives it, rounded
    /// toward zero, less that advance rounded to the nearest dot; for another glyph the
    /// placement rounded to the nearest dot.
    ///
    /// - class: undocumented
    /// - status: derived
    Rounded,
}
quirk!(RightToLeftPlacements: Exact, Rounded);

/// Where the device draws a glyph that the font's layout tables place up or down from the
/// baseline, such as a mark over or under its letter, and how the PDF writer writes the text
/// object that holds it (`layout::line`).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum VerticalPlacements {
    /// At its exact placement, in its text object with the glyphs around it. This keeps
    /// F-Office's existing places rather than asserting a behavior of the targets that choose
    /// it.
    ///
    /// - class: undocumented
    /// - status: derived
    Exact,
    /// At its placement in whole dots, counted at the device's em, the size in whole dots, and
    /// rounded toward zero; and in right-to-left text the writer writes each glyph of a text
    /// object as an object of its own when one of its glyphs lies one dot or more off the
    /// baseline.
    ///
    /// - class: undocumented
    /// - status: derived
    WholeDots,
}
quirk!(VerticalPlacements: Exact, WholeDots);

/// Where the device's steps count the exact places of a stretch of right-to-left text from, in
/// reading order, when the stretch starts the steps of its line (`layout::line`). The steps take
/// the stretch's glyphs from its right end, and each glyph that starts the steps again goes to
/// the nearest dot of its exact place as they count it.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum RightToLeftCount {
    /// From the stretch's exact left edge, so that the exact places of the text after the
    /// stretch go on from its exact right edge.
    ///
    /// - class: undocumented
    /// - status: derived
    LeftEdge,
    /// From a dot: each glyph's exact distance from the stretch's right end, in reading order,
    /// goes to whole dots.
    ///
    /// - class: undocumented
    /// - status: derived
    RightEnd,
}
quirk!(RightToLeftCount: LeftEdge, RightEnd);

/// Where a centered line that ends its right-to-left paragraph lies on a target whose device
/// steps glyphs by whole dots (`layout::line`). The other lines of a centered right-to-left
/// paragraph keep their exact places.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum RightToLeftCenteredLine {
    /// At its exact place, the middle of its space.
    ///
    /// - class: undocumented
    /// - status: derived
    Exact,
    /// As a centered line under `AlignedEnds::OnDots` from the other side: its right end lies
    /// on the dot of its space's right edge, moved left by half the free whole dots, rounded
    /// down, between the dot where its text then ends, its exact width counted from that dot,
    /// and the dot of its space's left edge.
    ///
    /// - class: undocumented
    /// - status: derived
    OnDots,
}
quirk!(RightToLeftCenteredLine: Exact, OnDots);

/// Where the spaces at the end of a line of a left-to-right paragraph lie that belong to runs
/// with `w:rtl` right after the line's written text (`layout::bidi`).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum RightToLeftEndSpace {
    /// At the line's visual end, with the paragraph's direction, as the other spaces at the end
    /// of a line (rule L1 of the Unicode Bidirectional Algorithm).
    ///
    /// - class: specification
    /// - status: specified
    ParagraphLevel,
    /// At the right-to-left level of their runs on a line that also holds text of a run without
    /// `w:rtl`: in visual order they lie at the left of the run's last word on the line, and
    /// count as the line's written text, which an aligned line measures and a justified line
    /// stretches with them. On a line whose text all belongs to runs with `w:rtl`, at the line's
    /// visual end, as with `ParagraphLevel`. A word of a run with `w:rtl` then fits on a line
    /// that already holds text of a run without `w:rtl` only with the spaces of runs with
    /// `w:rtl` at its end: the line breaks before the word when the word's end with those spaces
    /// passes the line's width. On a line that already holds a left-to-right letter, such as a
    /// Latin one, the spaces between right-to-left letters count in the fit in the same way,
    /// whether or not their runs have `w:rtl`: a word that ends with a right-to-left letter fits
    /// only with the spaces at its end when the next word starts with one, though those of runs
    /// without `w:rtl` lie at the line's visual end. In the fit of a justified line, all these
    /// spaces are spaces of the line: those at the word's end shrink as its other spaces, and
    /// those right before the word stay written text of the line without the word, so that they
    /// leave it no room to stretch and are among its gaps.
    ///
    /// - class: undocumented
    /// - status: derived
    RunLevelBesideLeftToRight,
}
quirk!(RightToLeftEndSpace: ParagraphLevel, RunLevelBesideLeftToRight);

/// The dot of the right edge of a line's space, up to which a centered or a right-aligned line
/// moves where the quirk `AlignedEnds::OnDots` starts it on a dot (`layout::line`).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum AlignedLineEdge {
    /// The dot of the line's start at its indent plus the space's width, which goes to a dot
    /// with the halves of a line's start.
    ///
    /// - class: undocumented
    /// - status: derived
    FromLineStart,
    /// The dot of the column's left edge plus the distance from that edge to the space's right
    /// edge, the column's width less the space's distance from the column's right edge. Where
    /// a line's start goes to a dot through fixed-point points, each of the two lengths goes
    /// to fixed-point points on its own and their difference to the nearest dot, a half up.
    /// The left indent does not enter the edge. A space in an upright table cell counts from
    /// the edges of the cell's text area, its left edge on the dot of the cell's text edge; a
    /// cell whose text runs down or up the page keeps the edge from the line's start.
    ///
    /// - class: undocumented
    /// - status: derived
    FromColumnEdge,
}
quirk!(AlignedLineEdge: FromLineStart, FromColumnEdge);

impl TemplateFonts {
    /// The minor (body) Latin font.
    #[must_use]
    pub const fn minor(self) -> &'static str {
        match self {
            Self::Aptos => "Aptos",
            Self::Calibri => "Calibri",
        }
    }

    /// The major (heading) Latin font.
    #[must_use]
    pub const fn major(self) -> &'static str {
        match self {
            Self::Aptos => "Aptos Display",
            Self::Calibri => "Calibri Light",
        }
    }
}

/// How the text of a text box is drawn.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum TextBoxContent {
    /// The text of a text box is laid out as text. Word draws some text boxes as pictures, and
    /// when is not known.
    ///
    /// - class: undocumented
    /// - status: unknown
    LaidOutAsText,
}
quirk!(TextBoxContent: LaidOutAsText);

/// Where the target cuts the text of a text box: the lines of a text box whose box is too small
/// for them, or the part of a line that runs past it (`layout::floating`).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum TextBoxClip {
    /// The text runs past the box, as the default `overflow` of `vertOverflow` and
    /// `horzOverflow` of `bodyPr` gives it (ECMA-376 Part 1, 21.1.2.1.1).
    ///
    /// - class: specification
    /// - status: specified
    Overflow,
    /// The text shows only inside a rectangle: across, between the inner edges of the box's
    /// outline (half the outline's width inside the box's sides); down, between the top and
    /// the bottom of its text area, inside the insets. It is cut there whatever the overflow
    /// attributes say. Derived from the box, its outline and its insets.
    ///
    /// - class: undocumented
    /// - status: derived
    InsideOutline,
}
quirk!(TextBoxClip: Overflow, InsideOutline);

/// Which columns the text of a text box takes when the section that holds the box's anchor has
/// more than one (`layout::floating`).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum TextBoxColumns {
    /// The section's columns: the box's text area splits into them, and its text fills the
    /// first, since a text box's text never ends a column.
    ///
    /// - class: undocumented
    /// - status: derived
    SectionColumns,
    /// One column across the box's whole text area, as a header's, whatever the section's
    /// columns.
    ///
    /// - class: undocumented
    /// - status: measured
    OneColumn,
}
quirk!(TextBoxColumns: SectionColumns, OneColumn);

/// Where a floating drawing placed down from its line (`relativeFrom="line"` of
/// `wp:positionV`) counts from (`layout::floating`).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum FromLine {
    /// From the top of its anchor paragraph, as a drawing placed from the paragraph.
    ///
    /// - class: undocumented
    /// - status: derived
    ParagraphTop,
    /// From the top of the line that holds its anchor, as ECMA-376 says (Part 1,
    /// `ST_RelFromV`); on the paragraph's first line, from the paragraph's top, above its own
    /// space before.
    ///
    /// - class: specification
    /// - status: derived
    LineTop,
}
quirk!(FromLine: ParagraphTop, LineTop);

/// Where the target cuts what a table cell draws, such as the text of a cell that is taller
/// than its row of exact height, or a line that runs past the cell's side
/// (`layout::table::clips`).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum CellClip {
    /// What a cell draws shows everywhere.
    ///
    /// - class: undocumented
    /// - status: derived
    Unclipped,
    /// What a cell draws shows only inside one rectangle: its text, its fills, its
    /// paragraphs' shading and boxes, its pictures in line and its nested tables. The sides
    /// lie on the inner edges of the cell's lines, or on the cell's grid line where a side has
    /// no line, and the top at the top of the cell's text area when the cell has a top margin.
    /// The rectangle spans every row of a merged cell and every column of a spanned cell.
    ///
    /// - class: undocumented
    /// - status: derived
    InsideLines,
}
quirk!(CellClip: Unclipped, InsideLines);

/// Where a floating drawing anchored in a table cell lies when its place reaches past the cell,
/// or when it is aligned down from the margins (`layout::floating`).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum CellDrawingBounds {
    /// Where its place puts it: across from its offset or alignment, past the cell's sides too,
    /// and down from the area of the margins when it is aligned there. This is F-Office's
    /// layout before the rule of the other variant.
    ///
    /// - class: undocumented
    /// - status: derived
    Unbounded,
    /// A drawing that wraps text lies inside its cell: across between the inner edges of the
    /// cell's side lines, as their exact places give them, its left side first when it is
    /// wider than the cell; down, not above the cell's text top. A drawing aligned down from
    /// the margins, to their top, center or bottom, lies at the cell's text top. Neither
    /// depends on `layoutInCell`.
    ///
    /// - class: undocumented
    /// - status: derived
    InsideCell,
}
quirk!(CellDrawingBounds: Unbounded, InsideCell);

/// Where the fill of a table cell starts and ends across, next to the cell's left and right
/// lines, in a table without cell spacing (`layout/table/rows.rs`, the fills of a row's cells).
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum CellFillSides {
    /// From the cell's grid line to its grid line, under half of each side line.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    GridLines,
    /// Between the side lines that the cell has as its own borders, on whole dots: on each
    /// side, the place from which a line on that grid line is centered, measured from the
    /// column edge rounded to the device grid with the table's half border rounded up to
    /// whole twips, moved toward the cell's inside by half the width of the cell's own border
    /// there rounded down to whole twips, and rounded to the device grid as that line's center
    /// is. A side without a border of its own keeps the place itself, also under a line that
    /// the cell beside it draws there.
    ///
    /// - class: undocumented
    /// - status: derived
    InsideLines,
}
quirk!(CellFillSides: GridLines, InsideLines);

/// Where the fill of a table cell starts and ends down, next to the lines above and below it
/// (`layout/table/rows.rs`, the fills of a row's cells).
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum CellFillRows {
    /// From the row's top plus the width of its top line, or from the row's top for a cell
    /// that continues a merged region, to the row's end, at those exact places.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Exact,
    /// From and to the same places, each moved to the nearest device dot, a half up, so that
    /// each edge lies on the drawn edge of the line beside it or a whole number of dots from it.
    ///
    /// - class: undocumented
    /// - status: derived
    WholeDots,
}
quirk!(CellFillRows: Exact, WholeDots);

/// Where the band of a filled table cell's top margin, which the target paints again after the
/// row's borders, lies down (`layout/table/borders.rs`, the top bands of a row).
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum CellTopBand {
    /// From the content's top, the row's top plus its top line's width, on the nearest dot,
    /// down by the cell's top margin to the nearest dot; no band for a top margin of 0.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    BelowMargin,
    /// From the drawn lower edge of the cell's top line down to the nearest dot of the line's
    /// drawn top plus the line's width plus the cell's top margin, a half up, whenever that has
    /// a height: for a top margin of 0, the one dot that a line loses when the device rounds its
    /// width down. A cell that continues a merged region at the top of a page, and so has a top
    /// line of its own, has one too; a cell without a top line keeps the band below its margin.
    ///
    /// - class: undocumented
    /// - status: derived
    FromLineEdge,
}
quirk!(CellTopBand: BelowMargin, FromLineEdge);

/// Where the text of a cell of a table with cell spacing starts and ends across, next to the
/// left and right lines of the cell's own box (`layout/table.rs`, the text column of a slot).
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum SpacedCellText {
    /// Between the middles of the box's left and right lines, inside the cell margins, as the
    /// text of a cell without spacing runs between its grid lines.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    LineMiddles,
    /// Inside the box's whole left and right lines, inside the cell margins: the text starts
    /// the whole width of the box's left line right of the box's outer edge, and ends the whole
    /// width of its right line left of the box's other outer edge.
    ///
    /// - class: undocumented
    /// - status: derived
    InsideLines,
}
quirk!(SpacedCellText: LineMiddles, InsideLines);

impl SpacedCellText {
    /// The part of a box's side line of width `line` that the text leaves room for, in a table
    /// whose cell spacing is `spacing`. A table whose cell spacing is zero keeps the text between
    /// the middles of the lines under every variant.
    #[must_use]
    pub fn side_room(
        self,
        line: f_office_units::Length,
        spacing: f_office_units::Length,
    ) -> f_office_units::Length {
        match self {
            Self::InsideLines if spacing > f_office_units::Length::ZERO => line,
            Self::LineMiddles | Self::InsideLines => line.div_toward_zero(2),
        }
    }
}

/// How wide the columns of a table with cell spacing are (`layout/table/shape.rs`, the column
/// widths of a table).
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum SpacedColumns {
    /// The table's grid columns, as in a table without cell spacing.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Grid,
    /// In a table of fixed layout (`w:tblLayout` `fixed`), a column that a cell of one column
    /// gives a width in twips is that width plus twice the spacing, and the first and the last
    /// column one spacing more: each cell's box is as wide as the cell, and the boxes stand
    /// twice the spacing apart and from the table's edges, also with a spacing of zero. A
    /// column that no such cell gives a width keeps its grid column, and so does every column
    /// of a table whose layout fits its columns to their content.
    ///
    /// - class: undocumented
    /// - status: derived
    CellWidths,
}
quirk!(SpacedColumns: Grid, CellWidths);

/// Where a table with cell spacing that goes on to a later page draws its own outline
/// (`layout/table`, the rows at a page's top and foot).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum SpacedTableBreaks {
    /// Only around the whole table: the table's top line above its first row and its bottom
    /// line below its last row. A part of the table at the top of a later page puts its boxes
    /// one spacing below the page's top, a part at a page's foot ends with its boxes, and the
    /// part of a row that splits ends on the next page with its content. This is F-Office's
    /// layout before the rule of the other variant.
    ///
    /// - class: undocumented
    /// - status: derived
    AroundTable,
    /// Around each page's part of the table, as around a table of its own: at a page's top
    /// the part draws the table's top line and puts its boxes one spacing below it, and at a
    /// page's foot it draws the table's bottom line one spacing below its last boxes' bottom
    /// lines, with the table's side lines down to it. The lines of a row that splits stay on
    /// the page only where its boxes' bottom lines, the spacing and the table's bottom line fit
    /// below them, and the row's part on the next page ends, as a whole row does, with its
    /// boxes' bottom lines and the spacing below them.
    ///
    /// - class: undocumented
    /// - status: derived
    AroundPagePart,
}
quirk!(SpacedTableBreaks: AroundTable, AroundPagePart);

/// Which widths the columns of a table of automatic layout take when its saved grid disagrees
/// with its cells (`layout/table/shape.rs`, the column widths of a table).
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum AutofitGrid {
    /// The saved grid (`w:tblGrid`).
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Saved,
    /// In a table at the top level whose layout fits its columns to their content (no
    /// `w:tblLayout` `fixed`), without cell spacing and without a preferred width in twips or a
    /// percent, each grid column takes the widest width in twips of a cell of one column that
    /// starts there, when every column has such a cell, these widths differ from the saved grid,
    /// every cell's least width fits within the widths of the columns that it spans, no cell
    /// holds a table, and their sum fits the room. The least width of a cell is the widest word
    /// of its paragraphs, with the paragraph's left indent (or its first line's start, when that
    /// lies further right) and its right indent, and the cell's left and right margins. The room
    /// runs from the table's start (its indent, for a left-aligned table, with the shift of its
    /// first cell) to the text column's right edge: from mode 15 less half the last cell's right
    /// line, and before mode 15 with the last cell's right margin added. Any other table keeps
    /// its saved grid.
    ///
    /// - class: undocumented
    /// - status: measured
    FittingCells,
}
quirk!(AutofitGrid: Saved, FittingCells);

/// Which side lines a style region of a table style (`w:tblStylePr`) gives the cells that it
/// formats (`layout/table/shape.rs`, the borders of a cell).
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum StyleRegionBorders {
    /// Each cell of the region takes the region's top, left, bottom and right lines as its
    /// own, and the region's lines between rows and columns give it nothing.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    EachCell,
    /// The region's cells form blocks: a cell takes the region's line of a side only where the
    /// cell across that side is outside the region or there is none, and else the region's line
    /// between rows (`w:insideH`) or between columns (`w:insideV`), when the region sets it.
    ///
    /// - class: undocumented
    /// - status: measured
    Blocks,
}
quirk!(StyleRegionBorders: EachCell, Blocks);

/// The room and the spaces of an empty paragraph that ends a section before a continuous
/// section.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ContinuousSectionEnd {
    /// An empty paragraph that is the only block of its section keeps its line before a
    /// continuous section. Why it does is not known. Another one that holds nothing takes no
    /// room and has no part in the spacing, and one that holds bookmarks keeps its line.
    ///
    /// - class: undocumented
    /// - status: unknown
    OnlyBlockKeepsLine,
    /// As `OnlyBlockKeepsLine` for the only block of its section and in a section of more
    /// than one column. In a section of one column, the empty paragraph that holds nothing or
    /// only bookmarks after a paragraph of its section shows nothing, with a list label or a
    /// paragraph border too, and is in no group of borders, but keeps its part in the
    /// spacing: the space after of the paragraph before it stays, and the next paragraph has
    /// only the part of its space before beyond the empty paragraph's space after, also at the
    /// top of the next page when it has no room or its keep chain moves it there, and in the
    /// room test of that chain. After a table, it keeps its line from the mode of
    /// `SECTION_END_AFTER_TABLE_LINE_MODE`, and before that mode it shows nothing.
    ///
    /// - class: undocumented
    /// - status: derived
    KeepsSpacesWithoutLine,
}
quirk!(ContinuousSectionEnd: OnlyBlockKeepsLine, KeepsSpacesWithoutLine);

/// How much of its space before a paragraph with `w:pageBreakBefore` keeps at the top of the
/// page that it starts, in the compatibility modes before Word 2013, which keep any of it
/// (`mode::ModeRules::drops_space_after_page_break`).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum PageBreakBeforeSpace {
    /// All of it. The variant follows from the rule of page breaks.
    ///
    /// - class: undocumented
    /// - status: derived
    KeepsSpaceBefore,
    /// The part of it that is larger than the space after of the paragraph before the break,
    /// which stays on the page before, as at the top of a section that starts a new page, so
    /// the variant follows from that rule.
    ///
    /// - class: undocumented
    /// - status: derived
    AboveSpaceAfter,
}
quirk!(PageBreakBeforeSpace: KeepsSpaceBefore, AboveSpaceAfter);

/// What a `SAVEDATE` or `PRINTDATE` field without a date picture shows.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum SavedDateWithoutPicture {
    /// The field keeps its stored result, the last result that the file holds, because the
    /// form that the target gives it then is not known.
    ///
    /// - class: undocumented
    /// - status: unknown
    KeepsStoredResult,
    /// The field shows the date and time of the save or print: month, day and year without
    /// leading zeros, the hour of 12 without one, minutes and seconds of two digits and AM or
    /// PM, such as `11/25/2026 9:18:00 PM`. The time has whole minutes, so its seconds show
    /// `00`.
    ///
    /// - class: undocumented
    /// - status: measured
    DateAndTime,
}
quirk!(SavedDateWithoutPicture: KeepsStoredResult, DateAndTime);

/// The text that the target writes in its PDFs for a character of a symbol font, at U+F020 to
/// U+F0FF.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum SymbolText {
    /// The character of the low byte, such as "§" for U+F0A7, but "•" for the Symbol bullet
    /// and the replacement character for a character that the font lacks. The variant follows
    /// from the parameters `params::SYMBOL_AREA` and `params::SYMBOL_BULLET`.
    ///
    /// - class: undocumented
    /// - status: derived
    LowByte,
    /// The Unicode character that a table of 12 Symbol and 14 Wingdings codes gives for the
    /// font and the code, such as "â–ª" for Wingdings A7, and otherwise the character of the
    /// symbol area itself, even where the font lacks it. A character of one byte in the
    /// Symbol or Wingdings font takes the table's text for its symbol, and otherwise reads
    /// as with `LowByte`.
    ///
    /// - class: undocumented
    /// - status: measured
    TableOrSymbol,
}
quirk!(SymbolText: LowByte, TableOrSymbol);

/// Which character Word writes in its PDFs for a paired bracket of a run that reads from right
/// to left (`w:rtl`). Word draws such a bracket with the mirrored glyph on every target.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum MirroredBracketText {
    /// The mirrored character, whose glyph Word draws: "(" for a ")" of the file.
    ///
    /// - class: undocumented
    /// - status: derived
    Mirrored,
    /// The character of the file: ")" for a ")" of the file, though the glyph drawn is "(".
    ///
    /// - class: undocumented
    /// - status: measured
    AsInFile,
}
quirk!(MirroredBracketText: Mirrored, AsInFile);

/// Which characters Word writes in its PDFs for a glyph of Arabic text that the font's layout
/// tables shaped.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ShapedGlyphText {
    /// The lowest code point of the Arabic blocks that the font maps to the glyph, such as a
    /// presentation form for a letter in a joined form, or a ligature's own presentation form
    /// for the whole group; the letters of the group when the font maps none to it.
    ///
    /// - class: undocumented
    /// - status: derived
    LowestMappedCharacter,
    /// The characters of the document that the glyph stands for: its letter, and both letters
    /// of a lam with an alef that the font draws as one glyph.
    ///
    /// - class: undocumented
    /// - status: derived
    ClusterLetters,
}
quirk!(ShapedGlyphText: LowestMappedCharacter, ClusterLetters);

/// What a field of the body shows when Word prints the document.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum BodyFieldResults {
    /// Compute the existing fields and unlocked REF paragraph-number results.
    ///
    /// - class: undocumented
    /// - status: measured
    ComputesFieldsAndReferences,
    /// Word computes a field of the body when it prints: `PAGE`, `NUMPAGES`, `PAGEREF`, the
    /// date fields, `DOCPROPERTY` and `STYLEREF` show the values of their rules, and an `IF`
    /// field and the other fields show their stored results.
    ///
    /// - class: undocumented
    /// - status: derived
    ComputesFields,
    /// Word computes no field of the body when it prints: a field with a stored result shows
    /// that result. A field without one shows its value, as with the other variant.
    ///
    /// - class: undocumented
    /// - status: measured
    ShowsStoredResults,
}
quirk!(BodyFieldResults: ComputesFields, ComputesFieldsAndReferences, ShowsStoredResults);

/// How a TOC-result hyperlink uses its selected character style.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum TocLinkStyle {
    /// Omit a directly selected built-in link style and equal direct color, underline
    /// and bold values, while preserving differing direct values.
    ///
    /// - class: undocumented
    /// - status: measured
    OmitsSelectedStyle,
    /// Keep the selected character style and every direct value, as every other run keeps
    /// them: the run's character style applies, and its direct properties apply above it
    /// (ECMA-376 Part 1, 17.7.2).
    ///
    /// - class: specification
    /// - status: specified
    KeepsSelectedStyle,
}
quirk!(TocLinkStyle: OmitsSelectedStyle, KeepsSelectedStyle);

/// What a field of a header or footer shows when Word prints the document.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[cfg_attr(
    not(feature = "development"),
    expect(
        clippy::enum_variant_names,
        reason = "the variants keep the names that the profiles give them"
    )
)]
pub enum HeaderFieldResults {
    /// Word computes a field of a header or footer when it prints, as in the body with
    /// `BodyFieldResults::ComputesFields`, and an `IF` field also when it has a stored result.
    ///
    /// - class: undocumented
    /// - status: derived
    ComputesFields,
    /// Word computes a field of a header or footer as with `ComputesFields`, and the paragraph
    /// number of a `STYLEREF` field with `\n` too, as the paragraph number of a `REF` field
    /// with `\n`: 0 when the paragraph that the field finds has no list number, and else the
    /// rendered pattern of the paragraph's level without trailing periods.
    ///
    /// - class: undocumented
    /// - status: derived
    ComputesFieldsAndNumbers,
    /// Word computes the fields of a header or footer whose value comes from the pages, `PAGE`,
    /// `NUMPAGES`, `PAGEREF` and `STYLEREF`, and evaluates `IF` fields. Every other field with a
    /// stored result shows that result, such as a date field or `DOCPROPERTY`. A field without
    /// one shows its value, as with the other variant.
    ///
    /// - class: undocumented
    /// - status: measured
    ComputesPageFields,
}
quirk!(HeaderFieldResults: ComputesFields, ComputesFieldsAndNumbers, ComputesPageFields);

/// The time zone in which a date property is written.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum PropertyDateZone {
    /// A date property is written in UTC, as the file stores it, and a field without a date
    /// picture keeps its stored result.
    ///
    /// - class: undocumented
    /// - status: unknown
    Utc,
    /// A date property is written as its date in the time zone of the machine, at midnight: the
    /// time of day drops, and the date is the day before or after when the zone moves the time
    /// past midnight. A field without a date picture writes it as `d/M/yyyy`, such as
    /// `15/1/2026`.
    ///
    /// - class: undocumented
    /// - status: measured
    LocalDate,
}
quirk!(PropertyDateZone: Utc, LocalDate);

/// Which steps the page form of the writer's offset (`writer.offset` `"page_steps"`, with
/// `writer.offset_page_steps_hundred_thousandths`) takes on a page, by the page's size and its
/// section's orientation (`profile::writer_offsets`).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum PageOffsetSizes {
    /// The profile's steps on every page, whatever its size: also the behavior of a
    /// writer that writes no place in steps of the page form, where a page's size moves no
    /// place.
    ///
    /// - class: undocumented
    /// - status: derived
    OneFactor,
    /// The steps that the page's paper form gives. A page of one of the sizes of
    /// `params::PAGE_4961_7016_STEPS` and the others, in that size's orientation, takes that
    /// size's steps across and down. A Letter page of
    /// 5,100 by 6,600 dots takes the steps across of `params::PAGE_5100_6600_ACROSS_STEPS`
    /// and the profile's steps, Letter's factor, down;
    /// a page of 6,600 by 5,100 dots takes Letter's factor across and down. Every other page
    /// takes, on each axis, the page entry of the paper form that the class rule gives it
    /// (`params::PAPER_FORM_CLASS_RULE`, `f_office_paint::paper_forms`).
    ///
    /// - class: undocumented
    /// - status: fitted
    PaperForms,
}
quirk!(PageOffsetSizes: OneFactor, PaperForms);

/// How the PDF writer takes the product of a place and its page's steps in the page form of its
/// offset (`writer.offset = "PageSteps"`), before it rounds the product to parts of a step
/// (`f_office_paint::OffsetProduct`, `profile::writer_offsets`).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum PageOffsetProduct {
    /// The exact product of the place and the steps over the page's side.
    ///
    /// - class: undocumented
    /// - status: derived
    Exact,
    /// The product of the place's whole written dot and the page entry, `parts (s + c / D)`
    /// with `s` steps to the dot and `D` the page's side in whole dots, each held as the
    /// nearest binary32 number, so that a product near a rounding boundary of the parts takes
    /// the side that its binary32 number lies on. The written dots per inch are the profile's
    /// `writer.page_steps_per_inch`.
    ///
    /// - class: undocumented
    /// - status: derived
    Binary32,
}
quirk!(PageOffsetProduct: Exact, Binary32);

/// How the edge check of right-edge steps and the restarts of their segments count a glyph's
/// character spacing (`w:spacing w:val`) in its exact advance (`grid::EdgeSteps`).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum CharacterSpacingCount {
    /// As the length that the document gives.
    ///
    /// - class: undocumented
    /// - status: derived
    Exact,
    /// As the nearest whole number of units of `params::CHARACTER_SPACING_UNITS_PER_POINT` to
    /// it, half away from zero, so that a spaced glyph's exact advance is a little longer or
    /// shorter than its advance and its spacing. The device's steps keep the spacing as the
    /// document gives it.
    ///
    /// - class: undocumented
    /// - status: unknown
    NearestUnit,
}
quirk!(CharacterSpacingCount: Exact, NearestUnit);

/// How a glyph that starts a segment of right-edge steps (`GlyphSegments::FromRestart`)
/// counts its exact place from the segment's first glyph (`grid::EdgeSteps`).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum RestartCount {
    /// With the advances of the glyphs before it in the segment as their sum in whole
    /// half-EMUs.
    ///
    /// - class: undocumented
    /// - status: derived
    RoundedAdvances,
    /// At the exact place that the edge check counts: with what rounding to whole half-EMUs took
    /// from each of those advances added and, on a justified line, the excess of each
    /// stretched space's exact share that the edge check counted in the segment
    /// (`EdgeShares::ExactFree`).
    ///
    /// - class: undocumented
    /// - status: unknown
    EdgeCheckPlaces,
}
quirk!(RestartCount: RoundedAdvances, EdgeCheckPlaces);

/// Which shares of a justified line's free space the edge check of right-edge steps counts in
/// the exact places of the glyphs after its stretched spaces (`grid::EdgeSteps`). The device's
/// steps and the drawn places keep the shares that the line spreads under both.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum EdgeShares {
    /// The shares that the line spreads: each stretched space takes the free space over the
    /// stretched spaces, toward zero to a whole half-EMU.
    ///
    /// - class: undocumented
    /// - status: derived
    Spread,
    /// In the steps' first count, from the line's first glyph until they start again after a
    /// stretched space, the shares of the free space that the exact advances of the line's
    /// glyphs leave, rounded to whole parts of `params::SHARE_PARTS_PER_POINT` as the
    /// compatibility mode says (`ModeRules::share_rounding`). From that start on, the shares
    /// that the line spreads. Where the mode rounds the sum of the shares over the line, the
    /// restart of a segment does not end that count, and only a tab or another gap does.
    ///
    /// - class: undocumented
    /// - status: unknown
    ExactFree,
}
quirk!(EdgeShares: Spread, ExactFree);

/// Which length the PDF writer of a target that steps glyphs by whole dots
/// (`GridAdvances::RightEdgeSteps`) gives a text object as its character spacing (`Tc`), so
/// that the steps near it need no adjustment (`grid::TextObject`).
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum WriterSpacing {
    /// The excess of the steps over their widths that at least 20 of each 23 steps share
    /// exactly (`params::WRITER_SPACING_SHARE`), unrounded, and else 0. This keeps the
    /// arithmetic that F-Office had before the quirk.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    SharedStep,
    /// The excess of the object's first step over its first glyph's written width, written
    /// to a thousandth of a point (`params::WRITER_SPACING_STEPS`), when each of its first 7
    /// steps (`params::WRITER_SPACING_LOOKAHEAD`) lies less than a hundredth of a point from it
    /// (`params::WRITER_SPACING_BAND`), and else 0.
    ///
    /// - class: undocumented
    /// - status: measured
    FirstStep,
}
quirk!(WriterSpacing: SharedStep, FirstStep);

/// Which character spacing the PDF writer of a target that steps glyphs by whole dots
/// (`GridAdvances::RightEdgeSteps`) draws a text object's glyphs with, where `WriterSpacing`
/// gives the object the length that it decides its adjustments with (`grid::TextObject`).
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum WrittenSpacing {
    /// The length that the writer decides its adjustments with. This keeps the arithmetic
    /// that F-Office had before the quirk.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    AsCounted,
    /// The spacing as the writer counts it, before `WriterSpacing::FirstStep` rounds it to a
    /// thousandth of a point, printed in points with `params::WRITER_SPACING_DIGITS`
    /// significant digits and at least `params::WRITER_SPACING_LEAST_DECIMALS` decimals, a
    /// dropped half away from zero: an excess of -1.512 pt draws as -1.51 pt, one of 0.01784 pt
    /// as 0.0178 pt. The writer still decides each adjustment with the length that
    /// `WriterSpacing` gives, so it does not make up what the printing drops.
    ///
    /// - class: undocumented
    /// - status: measured
    PrintedDigits,
}
quirk!(WrittenSpacing: AsCounted, PrintedDigits);

/// How much space `w:autoSpaceDE` and `w:autoSpaceDN` add between an East Asian character and an
/// adjacent Latin letter or digit, and whether the layout device steps that space in whole dots on
/// its own (`layout::measure::auto_space`, `layout::line::draw::steps_extra`).
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum EastAsianAutoSpace {
    /// A quarter em of the first glyph's face for every face, summed into the glyph's advance.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    QuarterEm,
    /// A quarter em for an East Asian face or when `w:balanceSingleByteDoubleByteWidth` is set,
    /// and half of `OS/2` `xAvgCharWidth` scaled to the font size for an unbalanced non-East-Asian
    /// face, stepped in whole dots on its own by the layout device.
    ///
    /// - class: undocumented
    /// - status: measured
    AverageWidthHalf,
}
quirk!(EastAsianAutoSpace: QuarterEm, AverageWidthHalf);

/// How a target draws the glyphs of a run with a character scale (`w:w`), which it lays out
/// with advances of the scale (`text::look::scale`) on every target (`grid::Device::glyph_turn`).
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum ScaledGlyphs {
    /// At their normal width, upright.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Upright,
    /// Narrowed or widened by the factor N/A: A is the face's average width (`OS/2`
    /// `xAvgCharWidth`) at the drawn size in whole dots of the layout device, a half up, and N
    /// is A times the scale, rounded down, about each glyph's origin.
    ///
    /// - class: undocumented
    /// - status: derived
    AverageWidthDots,
}
quirk!(ScaledGlyphs: Upright, AverageWidthDots);

/// The size at which the device counts the steps of a glyph in a run with a character scale
/// (`w:w`), whose advances the layout scales at the run's nominal size.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum ScaledSteps {
    /// At the size that the device draws, the nominal size at whole dots per em, as the steps
    /// of every other glyph.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    DrawnSize,
    /// At the run's nominal size: the run's first glyph takes its place from the edge check,
    /// and each later glyph lies as many whole dots further as its exact distance from the
    /// first glyph at the nominal size holds, rounded down, with no change for the drawn size.
    ///
    /// - class: undocumented
    /// - status: derived
    NominalSum,
}
quirk!(ScaledSteps: DrawnSize, NominalSum);

/// What a paragraph's top or bottom border of `w:val="none"` with a space does: a **none
/// border**, which draws no line (`props::Border::none`). A border of `nil` is no border on
/// every target.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum NoneBorders {
    /// The paragraph has no such border: the side takes no space and splits no group of
    /// bordered paragraphs.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Dropped,
    /// The side keeps its space, as a border that draws a line of no width: below the group
    /// for a bottom border, above it for a top border.
    ///
    /// - class: undocumented
    /// - status: derived
    KeepSpace,
}
quirk!(NoneBorders: Dropped, KeepSpace);

/// The unit in which a target holds the width of the line of a paragraph's, a table's or a
/// cell's border, `w:sz`, before it takes the thin lines and the gaps of a compound style from
/// it and rounds each line down to whole dots. A table border's cut width is also the room that
/// it takes in the rows.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum BorderWidthUnit {
    /// Eighths of a point, as `w:sz` gives the width.
    ///
    /// - class: specification
    /// - status: derived
    #[default]
    EighthPoints,
    /// Whole twips, cut toward zero: a line of 3 eighths, 7.5 twips, is 7 twips and draws 2
    /// dots on a device of 600 dots an inch, where its exact width would round down to 3. An
    /// odd number of eighths loses half a twip, and the line draws one dot less wherever its
    /// exact width lies less than 5/24 of a dot above a whole dot, such as 25, 27, 49 and 51
    /// eighths. The thin lines and the gaps of a medium gap style come from the cut line.
    ///
    /// - class: undocumented
    /// - status: derived
    WholeTwips,
}
quirk!(BorderWidthUnit: EighthPoints, WholeTwips);

/// What a target draws of the border of the empty paragraph that ends a section before a section
/// that starts on a new page, which stays on its page also when it does not fit there: the
/// **section end border**.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum SectionEndBorders {
    /// The border, as for any paragraph.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Drawn,
    /// No line of it: the paragraph has no border, with a bottom line or four sides, where the
    /// paragraph and its border fit, where only its line fits and where its line does not fit.
    /// A paragraph with text that ends the section, and an empty paragraph that ends none, draw
    /// theirs.
    ///
    /// - class: undocumented
    /// - status: measured
    Dropped,
}
quirk!(SectionEndBorders: Drawn, Dropped);

/// The font that Word draws a missing font with when nothing stands for it: no font table
/// alternate, no first font of a list, no font of an East Asian character set, no family
/// substitute of the target and no base family of a suffixed font name.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum MissingFontFallback {
    /// Calibri in a document with a theme, and Cambria without one.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    ByTheme,
    /// Cambria when the font table has no entry for the font or its entry's font class
    /// (`w:family`) is `roman`, and Calibri for an entry of another class or of none, with or
    /// without a theme.
    ///
    /// - class: undocumented
    /// - status: derived
    ByFontTable,
}
quirk!(MissingFontFallback: ByTheme, ByFontTable);

/// The font that Word draws the complex script text of a run with, such as Arabic and Hebrew
/// letters, when the run's complex script font is missing and neither a font table alternate
/// nor the first font of a list stands for it.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum MissingComplexFont {
    /// Arial. This keeps F-Office's existing choice rather than asserting a behavior of the
    /// targets that choose it.
    ///
    /// - class: undocumented
    /// - status: derived
    Arial,
    /// By the font's font table entry, which counts only for a name of at most 31 UTF-16 code
    /// units: Times New Roman without an entry; for an entry of the class `roman`, Sakkal
    /// Majalla when it names the Arabic script and Times New Roman otherwise; for an entry of
    /// another class or of none, Arial when it names a complex script and Calibri otherwise.
    /// The entry names a script by its character set or by the code pages of its font
    /// signature.
    ///
    /// - class: undocumented
    /// - status: measured
    ByFontTable,
}
quirk!(MissingComplexFont: Arial, ByFontTable);

/// The face that Word draws a character with when the face of the character's slot lacks it
/// (its substitute face).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum SubstituteFaces {
    /// Only an East Asian character of the East Asian slot changes face: it takes the first
    /// face of the East Asian list that has it, and every other character keeps the slot's
    /// face. This keeps F-Office's existing choice rather than asserting a
    /// behavior of the targets that choose it.
    ///
    /// - class: undocumented
    /// - status: derived
    EastAsianList,
    /// A character of a block of the target's table takes the table's face: by the block and
    /// the slot face's family for Hangul (Batang under Times New Roman and four East Asian
    /// faces) and the parenthesized numbers (Yu Gothic under Times New Roman and two East Asian
    /// faces), and otherwise by the
    /// block and the face's PANOSE class (monospaced, sans or roman). A character outside the
    /// table's blocks, of a Latin slot or of the East Asian slot but not of an East Asian
    /// script, takes the first face of its group that has it, by the class of its slot's face: a shape
    /// (an arrow, box drawing, a block element, a geometric shape or a spacing modifier letter)
    /// the class face, then Cambria Math, then Segoe UI Symbol; a symbol (general punctuation,
    /// a letterlike symbol, a number form, a mathematical operator or a technical symbol)
    /// Cambria Math, then MS Gothic under a sans face or MS Mincho under the others, then Segoe
    /// UI Symbol. Spaces, control and format characters, private use and pictorial faces stay
    /// out. Other characters take
    /// the East Asian list. A character of the East Asian slot whose face has no East Asian
    /// code page and is not Times New Roman takes MS Mincho when MS Mincho has it, whether
    /// the slot's face has it or not.
    ///
    /// - class: undocumented
    /// - status: measured
    ByBlock,
}
quirk!(SubstituteFaces: EastAsianList, ByBlock);

/// What Word draws a missing **suffixed font name** with: a family that the target has, a space
/// and the suffix of a Windows character set (`CE`, `CYR`, `Greek`, `Baltic` or `TUR`), such as
/// `Times New Roman CYR`.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum SuffixedFontNames {
    /// Nothing stands for the name: it is a missing font like any other.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Missing,
    /// The family before the suffix stands for the name, after the target's family
    /// substitute. When the name's font table entry gives the suffix's character set
    /// (`w:charset`), the run's characters outside Windows code page 1252 take other faces:
    /// letters Calibri, the marks of General Punctuation Arial, and the numero sign Cambria
    /// Math.
    ///
    /// - class: undocumented
    /// - status: derived
    DrawBase,
}
quirk!(SuffixedFontNames: Missing, DrawBase);

/// Which clustered column charts a target draws, and where it puts the **plot area** of each
/// in its frame (`chart::Columns`, `layout/chart.rs`).
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum ChartPlotArea {
    /// Only Word's default chart: a title, a legend at the bottom, the automatic layout and
    /// the automatic scale with no value below zero; its plot area from the numbers of that
    /// chart in Calibri (`CHART_PLOT_RIGHT` to `CHART_BOTTOM_PER_SIZE`).
    ///
    /// - class: undocumented
    /// - status: measured
    #[default]
    DefaultChart,
    /// Each drawn case of the chart model: the legend at the bottom, the top, the left or the
    /// right or none, a title or none, the automatic or a manual layout, and a scale that the
    /// axis sets or that goes below zero; its plot area from the lines and the ascent of the
    /// labels' font (`CHART_LINES_*`). A chart with an
    /// axis title or with value labels in a number format other than General, and any other
    /// chart outside that scope that `DefaultChart` draws, keeps the plot area of
    /// `DefaultChart`. It also draws a line chart without a legend in the plot area of the
    /// clustered column chart with the same data, with the lines and markers that its series
    /// set or that the chart's style gives them, each marker on the device's dots.
    ///
    /// - class: undocumented
    /// - status: measured
    FontLines,
}
quirk!(ChartPlotArea: DefaultChart, FontLines);

/// How many major units the automatic scale of a clustered column chart's value axis may take
/// (`chart::Columns`, `layout/chart.rs`).
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum ChartAxisRoom {
    /// At most `CHART_AXIS_STEPS`, whatever the room of the plot area and the size of the
    /// labels. This is F-Office's earlier layout, which no measurement on these targets has
    /// checked against large labels or short plot areas.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Values,
    /// At most as many as the labels' single lines that fit the plot area's height less
    /// `CHART_AXIS_LABEL_ROOM`, at least one, and at most `CHART_AXIS_STEPS`, for a chart whose
    /// plot area comes from the lines of its labels' font (`ChartPlotArea::FontLines`): larger
    /// labels and a shorter plot area take fewer and larger units.
    ///
    /// - class: undocumented
    /// - status: measured
    LabelLines,
}
quirk!(ChartAxisRoom: Values, LabelLines);

/// Whether a drawn clustered column chart draws the data labels that show its series' values
/// (`chart::SeriesLabels::Values`: the values alone at the default position or the outer end,
/// in General).
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum ChartDataLabels {
    /// None: the chart is drawn without its data labels, with a warning.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    LeftOut,
    /// Each label in a text box with the insets of its labels' `a:bodyPr`, centered on its bar
    /// and a fixed gap from the bar's end: the baseline lies the gap, the box's top inset and the
    /// face's win descent above the end of a bar at or above the axis' crossing, and the gap, the
    /// top inset and the ascent of the face's single line below the end of a bar under it. The
    /// bottom inset does not move a label.
    ///
    /// - class: undocumented
    /// - status: unknown
    OuterEnd,
}
quirk!(ChartDataLabels: LeftOut, OuterEnd);

/// Which **automatic title** a chart shows that has no title of its own (`c:title`) and does
/// not delete its automatic title (`c:autoTitleDeleted` missing or `0`).
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum ChartAutomaticTitle {
    /// Not known: F-Office does not draw such a chart.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Unknown,
    /// At most the name of the chart's only series: a chart of more than one series, in all of
    /// its groups, of one series without a name (`c:tx`), or without `c:autoTitleDeleted`
    /// shows no title. A chart of one named series that writes `c:autoTitleDeleted` with the
    /// value `0` shows the series' name, which F-Office does not draw.
    ///
    /// - class: undocumented
    /// - status: measured
    OnlySeriesName,
}
quirk!(ChartAutomaticTitle: Unknown, OnlySeriesName);

/// The **style look** of a chart that names no chart style or style 2: what its elements
/// without properties of their own draw.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum ChartStyleLook {
    /// Not known: a bar series without a fill gives no chart, and a gridline, an axis or the
    /// chart area without properties draws no line.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Unknown,
    /// The look of chart style 2: a bar series without a fill takes the style's color of its
    /// place, as a line series does; the major gridlines, both axis lines and the chart area's
    /// outline without properties are the theme's first line style, in the text color tinted
    /// to 75 % and then the style's own modifiers of its placeholder color; the chart area
    /// without properties is filled with the background color; and the tick marks outside an
    /// axis are a third of the label face's win ascent at the label size long, from the axis
    /// line's middle, in the axis line's look.
    ///
    /// - class: undocumented
    /// - status: measured
    StyleTwo,
}
quirk!(ChartStyleLook: Unknown, StyleTwo);

/// The **title text** of a chart: how a chart draws the text of its own title (`c:title`).
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum ChartTitleText {
    /// Not known: a title of its own keeps its room above the plot area and its text is not
    /// drawn, and a title whose size is neither in its first run nor in its own text properties
    /// gives no chart.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Unknown,
    /// Each paragraph of the title's rich text, or the cached text of its reference, is one
    /// line, centered on the frame by the sum of its advances. The first line's baseline lies
    /// the title's single line less its win descent below 7.50 pt under the frame's top, and
    /// each further line one single line lower. The face, the bold and the size are those of
    /// the title's first run, else of its rich text's paragraph default, else of its own text
    /// properties, else of the chart's text; a title that writes none of them is bold at 10 pt.
    ///
    /// - class: undocumented
    /// - status: measured
    Drawn,
}
quirk!(ChartTitleText: Unknown, Drawn);

/// The **title placeholder** of a chart: the text of a title of its own (`c:title`) that has
/// no text (`c:tx`), which depends on the language of Word's interface.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum ChartTitlePlaceholder {
    /// Not known: the title keeps its room above the plot area and has no text.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Unknown,
    /// The English interface: the cached name of the chart's series when it has one named
    /// series (`c:tx`) in all of its groups, and else "Chart Title". A chart of one named series
    /// whose name caches no text keeps the title's room and draws no text.
    ///
    /// - class: undocumented
    /// - status: measured
    English,
}
quirk!(ChartTitlePlaceholder: Unknown, English);

/// The **scatter charts**: whether a chart whose plot area holds a scatter group
/// (`c:scatterChart`) is drawn, and how its x axis takes its units.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum ChartScatter {
    /// Not known: a chart with a scatter group gives no chart.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Unknown,
    /// A scatter group of straight lines and markers (`c:scatterStyle val="lineMarker"`) is
    /// drawn as the line chart of its y values, with its x values on a value axis across the
    /// bottom. The x axis takes the automatic scale of the y axis over the x values, with at
    /// most as many units as the frame's width less 22 pt holds at 7.5 advances of the
    /// labels' zero each, and at least one and at most ten. The plot area ends half the width of
    /// the last x label left of the line chart's, each x label is centered on its value's
    /// place, and each point lies at its x value's share across the plot area.
    ///
    /// - class: undocumented
    /// - status: measured
    Drawn,
}
quirk!(ChartScatter: Unknown, Drawn);

/// The **horizontal bar charts**: whether a chart whose plot area holds a bar group of
/// horizontal bars (`c:barChart` with `c:barDir val="bar"`) is drawn, and how.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum ChartHorizontalBars {
    /// Not known: a chart of horizontal bars gives no chart.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Unknown,
    /// A clustered group of horizontal bars is drawn as its column chart twin turned: the
    /// plot area keeps the twin's top and bottom, its left edge lies after the widest category
    /// label as the twin's lies after the widest value label, and it ends half the width of the
    /// last value label left of the twin's right edge. The value axis across the bottom takes
    /// its units as a scatter chart's x axis does, from the frame's width and the labels' zero.
    /// The categories' bands run up from the bottom, the series' bars stand in each band from
    /// the bottom up with the bars, gaps and overlaps of a column, and the legend stands beside
    /// the twin's plot area and names the series in the reverse order. A data label at the outer end starts the data label gap and
    /// its box's left inset beyond its bar's end, or ends them before the end of a bar below the
    /// crossing, and its box is centered on the bar up and down with the face's single line.
    ///
    /// - class: undocumented
    /// - status: derived
    Turned,
}
quirk!(ChartHorizontalBars: Unknown, Turned);

/// The **pie charts**: whether a chart whose plot area holds a pie group (`c:pieChart`) is
/// drawn, and how.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum ChartPies {
    /// Not known: a pie chart gives no chart.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Unknown,
    /// A pie of automatic layout is drawn as the largest circle centered in its plot area: the
    /// frame less 11 pt on each side, a title's lines in its own face and 20 pt at the top, and
    /// the legend's room on its side, with no label's line on any edge. Each point of the first
    /// series is a slice that starts where the one before it ends, the first at the group's
    /// first slice angle clockwise from the top, and spans its share of the series' sum
    /// clockwise, in the point's own fill or the series'. The legend names the points. When
    /// the data labels may stand outside the circle (at the outer end, the best fit or the
    /// default position), the circle's radius with 11 pt is 7/8 of the largest circle's with
    /// it; labels at the center stand with their text box's center at half the radius on the
    /// slice's bisector.
    ///
    /// - class: undocumented
    /// - status: measured
    Inscribed,
}
quirk!(ChartPies: Unknown, Inscribed);

/// The **3-D pie charts**: whether a chart whose plot area holds a 3-D pie group
/// (`c:pie3DChart`) is drawn, and how.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum ChartPies3D {
    /// Not known: a 3-D pie chart gives no chart.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Unknown,
    /// The plot area of a 3-D pie of automatic layout, which is a pie's, is one picture of
    /// pixels at 200 per inch with eight samples a pixel: the pie of thickness 0.24 of its
    /// radius in perspective, at the view's tilt with an angle of view of half its
    /// perspective down the picture, looked at in the center of its bottom face from as near
    /// as the figure fits the picture with 1.39% of its width and height at each side. Its
    /// slices are cut as a pie's with the view's turn as the first slice angle.
    ///
    /// - class: undocumented
    /// - status: measured
    Picture,
}
quirk!(ChartPies3D: Unknown, Picture);

/// The **outer shadows of shapes**: whether a shape's own outer shadow (`a:outerShdw`) of the
/// shape's size and not skewed is drawn, and how.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum ShapeShadows {
    /// Not known: the shadow is not drawn, with a warning.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Unknown,
    /// A shadow with a blur or an alpha below 100% is one picture of pixels before the shape:
    /// the shape's fill and line moved by the shadow's distance in its direction, blurred by a
    /// Gaussian of a third of the blur radius, in the shadow's color, its alpha the shadow's.
    /// The picture has 200 pixels per inch over the least whole number that lets the radius
    /// span at most 8 pixels, and its box is the moved outline, each edge rounded to 0.12 pt,
    /// grown by the radius rounded up to 0.12 pt and 0.12 pt more. An opaque shadow without a
    /// blur is the shape's fill and line moved, in the shadow's color.
    ///
    /// - class: undocumented
    /// - status: measured
    Picture,
}
quirk!(ShapeShadows: Unknown, Picture);

/// The **outer shadows of pictures**: whether a picture's own outer shadow (`a:outerShdw` of
/// `pic:spPr`) of the picture's size and not skewed is drawn, and how.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum PictureShadows {
    /// Not known: the shadow is not drawn, with a warning.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Unknown,
    /// The shadow is that of the picture's frame, drawn as a shape's shadow is
    /// ([`ShapeShadows::Picture`]): the picture's box filled and its line, whole, whatever
    /// the picture's pixels show.
    ///
    /// - class: undocumented
    /// - status: derived
    Frame,
}
quirk!(PictureShadows: Unknown, Frame);

/// The **aspect ratio of pictures**: whether a picture of a drawing (`wp:inline` or `wp:anchor`)
/// keeps its frame's aspect (`wp:extent`) or fits its drawn size's aspect (`pic:spPr/a:xfrm/a:ext`)
/// inside the frame cut to whole twips from its top left corner.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum PictureAspect {
    /// Keeps the frame's aspect (`wp:extent`), scaled to fit inside whole twips.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    FrameExtent,
    /// Fits the aspect of `pic:spPr/a:xfrm/a:ext` (when positive on both axes) inside the frame
    /// (`wp:extent`) cut to whole twips, from the frame's top left corner; its line, shadow,
    /// and rotation follow that fitted box.
    ///
    /// - class: undocumented
    /// - status: measured
    DrawnExtent,
}
quirk!(PictureAspect: FrameExtent, DrawnExtent);

/// The **shadows of text**: whether the shadow of a run's text (`w14:shadow`) takes room in its
/// line, and how much.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum TextShadows {
    /// Not known: the shadow takes no room.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Unknown,
    /// The shadow takes the share (size / 72 pt)^0.7 of its blur radius and its distance, at
    /// the run's line size (the full size of a superscript), whatever its face. Its line's
    /// ascent grows by the scaled blur less the scaled offset down and its descent by the
    /// scaled blur plus that offset, neither by less than 0, for a sharp shadow as for a blurred
    /// one, and a multiple spacing scales that room with the line.
    ///
    /// - class: undocumented
    /// - status: measured
    Scaled,
}
quirk!(TextShadows: Unknown, Scaled);

/// The **turns of pictures**: how a picture whose shape is rotated (`a:xfrm rot` of its
/// `pic:spPr`) is drawn, and the box that it takes on its line and in the text around it.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum PictureTurns {
    /// Not known: a picture rotated by whole quarter turns is drawn turned in the room of its
    /// unturned frame, and one rotated by another angle is left out, with a warning.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Unknown,
    /// A picture is drawn rotated by its angle about the centre of its box. The box is the
    /// frame turned by the nearest whole quarter turn, a half to the next one: the frame, or
    /// the frame with its width and height swapped about its centre when that quarter turn is
    /// odd (from 45° to below 135° after a half turn). An inline picture takes the box with its
    /// effect extent around it as its room on the line, and a floating picture with square or
    /// top and bottom wrapping keeps the text out of the box with its effect extent and wrap
    /// distances around it.
    ///
    /// - class: undocumented
    /// - status: derived
    SwappedBox,
}
quirk!(PictureTurns: Unknown, SwappedBox);

/// The **clip of an inline picture**: what of a picture in a line shows where the picture,
/// turned or in a line lower than it, reaches past its line.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum InlinePictureClip {
    /// Not known: the picture shows whole.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Unknown,
    /// The picture shows nothing above or below its line's box: from the top of the line's
    /// space before, on a paragraph's first line, to the bottom of its space after, on its last
    /// line, where the next line's box starts. A picture in a text box or a frame is not cut to
    /// its line but to the box, on all four sides: a text box's text area, inside its insets and
    /// its line, and a frame's box.
    ///
    /// - class: undocumented
    /// - status: derived
    LineBox,
}
quirk!(InlinePictureClip: Unknown, LineBox);

/// The **order of the axis line across**: when a chart of lines or of scatter points paints the
/// line of its axis across the bottom against its series' lines and markers.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum ChartAxisOrder {
    /// Not known: after the series' lines and markers, as after a column chart's bars.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Unknown,
    /// Before the series' lines and markers of a line chart or a scatter chart, so that a line
    /// at the axis' lowest value covers the axis line; after a column chart's bars.
    ///
    /// - class: undocumented
    /// - status: measured
    BeforeLines,
}
quirk!(ChartAxisOrder: Unknown, BeforeLines);

/// The **smooth lines** of a line chart's or a scatter chart's series (`c:smooth` true): whether
/// they are drawn, and the curves that they take.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum ChartSmoothLines {
    /// Not known: a chart with a smoothed series gives no chart, and so does a scatter group of
    /// smooth lines and markers (`c:scatterStyle val="smoothMarker"`).
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Unknown,
    /// A smoothed series is drawn through its points by a cubic Bézier curve between each two
    /// points, in page space. The curve leaves each point along its tangent: at an inner point
    /// the difference of its two neighbors over `CHART_SMOOTH_INNER_PARTS`, at the series' first
    /// and last point the difference of it and its neighbor over `CHART_SMOOTH_END_PARTS`. Each
    /// curve's control points lie its two tangents away from its ends, scaled down together so
    /// that the longer one reaches no farther than its chord over `CHART_SMOOTH_REACH_PARTS`.
    /// The series' own `c:smooth` decides, and a scatter group of smooth lines and markers is
    /// drawn as one of straight lines and markers.
    ///
    /// - class: undocumented
    /// - status: measured
    Curves,
}
quirk!(ChartSmoothLines: Unknown, Curves);

/// The **strokes of a line chart's series lines**: which caps, joins, widths and dashes of a
/// series' line (`a:ln` of its `c:spPr`) are drawn, and how.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum ChartLineStrokes {
    /// Not known: only a line with its width, round caps, round joins and no dash is drawn,
    /// and another gives no chart.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Unknown,
    /// A cap or a join that the line leaves out is round, and a width that it leaves out is
    /// the chart style's, as a series without properties takes them. A preset dash
    /// (`a:prstDash`) is drawn from a dash at the line's start, with the preset's dashes and
    /// gaps in widths of the line: each dash one width shorter and each gap one width longer,
    /// so that with its round caps a dash covers its length; a dot is a dash of length 0, a disc.
    /// The dashes run on along the line through its points.
    ///
    /// - class: undocumented
    /// - status: derived
    StyleRound,
}
quirk!(ChartLineStrokes: Unknown, StyleRound);

/// The **looks of a line chart's markers**: which forms of a series' marker (`c:marker`) are
/// drawn, and how.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum ChartMarkerLooks {
    /// Not known: only a marker that writes its symbol and its whole look (a solid fill, and an
    /// outline of a solid fill with its width), or a marker of a series without properties that
    /// writes no look, is drawn, and another gives no chart.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Unknown,
    /// A part that the marker leaves out is the chart style's: no symbol is the style's symbol
    /// of the series' place, no fill or no outline is the series' color, and an outline without
    /// a width is as wide as the theme's first line style. An outline of `a:noFill` is not
    /// painted, and an outline's `a:prstDash val="solid"` is a solid outline.
    ///
    /// - class: undocumented
    /// - status: derived
    StyleParts,
}
quirk!(ChartMarkerLooks: Unknown, StyleParts);

/// The **deleted value axis** of a drawn chart (`c:delete val="1"` of `c:valAx`): whether a
/// chart of clustered columns, clustered horizontal bars or lines whose value axis is deleted is
/// drawn, and how.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum ChartDeletedAxis {
    /// Not known: a chart whose value axis is deleted gives no chart.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Unknown,
    /// The deleted axis draws no labels, no line and no tick marks, and gridlines only where
    /// its `c:majorGridlines` is written. The value scale and the plot area's top and bottom
    /// stay those of the chart with the axis shown, and the plot area takes the value labels'
    /// room: a chart of columns or lines starts its plot area as far inside the frame's left
    /// edge as it ends inside the right edge, and a chart of horizontal bars ends its plot area
    /// there at the right and has the bottom of a plot area without a band of labels below it.
    ///
    /// - class: undocumented
    /// - status: derived
    PlotRoom,
}
quirk!(ChartDeletedAxis: Unknown, PlotRoom);

/// The **low category labels** of a drawn chart (`c:tickLblPos val="low"` of `c:catAx`):
/// whether a chart of clustered columns or lines whose category labels stand at the value axis'
/// lowest value is drawn, and how.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum ChartLowLabels {
    /// Not known: a chart whose category labels stand low gives no chart.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Unknown,
    /// The category labels stand below the plot area wherever the category axis crosses, as
    /// the labels next to an axis that crosses at the value axis' lowest value stand, and the
    /// plot area keeps their band below it.
    ///
    /// - class: undocumented
    /// - status: derived
    BelowPlot,
}
quirk!(ChartLowLabels: Unknown, BelowPlot);

/// The **axis titles** of a drawn chart (`c:title` of `c:catAx` or `c:valAx`): whether a chart
/// of clustered columns or lines with a title on an axis is drawn, and how.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum ChartAxisTitles {
    /// Not known: a chart with an axis title gives no chart, or Word's default chart without
    /// the title where the target's plot area draws it.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Unknown,
    /// A title of one line at the automatic place takes its face's single line, its win line
    /// and its external leading, and a gap from its side of the plot area. The value axis' title reads upward near the frame's left edge,
    /// centered on the plot area's height; the category axis' title stands upright near the
    /// frame's bottom, above a legend there, centered on the plot area's width.
    ///
    /// - class: undocumented
    /// - status: measured
    BesidePlot,
}
quirk!(ChartAxisTitles: Unknown, BesidePlot);

/// The **blank points** of a drawn chart: whether a chart whose series' cache leaves out a value
/// or a category's text (no `c:pt` at an index below `c:ptCount`) is drawn, and how.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum ChartBlankPoints {
    /// Not known: a chart with a blank point gives no chart.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Unknown,
    /// A blank value of a chart of columns, horizontal bars, lines or a pie is drawn as the
    /// chart's `c:dispBlanksAs` says: as a gap, where the other bars, slices and points keep
    /// their places and a line stops at the blank and starts again after it, or as the value
    /// zero, which the chart also takes without the element. A category without a text has an
    /// empty label.
    ///
    /// - class: undocumented
    /// - status: measured
    AsDisplayed,
}
quirk!(ChartBlankPoints: Unknown, AsDisplayed);

/// The **stacked bars** of a drawn chart: whether a bar or column chart whose grouping is
/// `stacked` or `percentStacked` is drawn, and how its segments, value axis and centered data
/// labels are placed.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum ChartStackedBars {
    /// Not known: a bar or column chart whose grouping is not `clustered` gives no chart.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Unknown,
    /// Stacked and 100%-stacked bar and column charts are drawn: positive series values stack
    /// away from zero and negative values stack on the negative side, using the cluster width
    /// and overlap of `c:gapWidth` and `c:overlap`; 100%-stacked charts divide each category's
    /// values by the sum of their magnitudes and cap the automatic value axis at 100% and
    /// -100%; horizontal stacked bars keep the forward series order in the legend; and default
    /// or `ctr` value data labels are centered in each bar segment.
    ///
    /// - class: undocumented
    /// - status: measured
    Stacked,
}
quirk!(ChartStackedBars: Unknown, Stacked);

/// The **pulled-out pie slices** of a drawn chart: whether a 2-D or 3-D pie whose series or
/// points set `c:explosion` above zero is drawn, and how its radius and slice shifts are placed.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum ChartPieExplosion {
    /// Not known: a pie with `c:explosion` above zero gives no chart.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Unknown,
    /// Pulled-out slices of 2-D and 3-D pies are drawn: per-point `c:explosion` overrides
    /// series-level `c:explosion` (including `0`); 2-D pies shrink radius by the series
    /// explosion `R / (1 + e_series / 100)` and shift each slice and its data label by
    /// `r * (e_i / 100)` along its bisector; 3-D pies scale slice radius and thickness by
    /// `1 / (1 + e_max / 100)` about their vertical midplane, shift each slice by `r * (e_i / 100)`,
    /// and place `ctr` labels at the shifted slice midpoint.
    ///
    /// - class: undocumented
    /// - status: measured
    PulledOut,
}
quirk!(ChartPieExplosion: Unknown, PulledOut);

/// How a bar or column chart assigns style colors when `c:varyColors` is not explicitly off
/// (`0` or `false`): whether omitted or on `c:varyColors` still colors multi-series charts by
/// series and single-series charts by category (with category legend entries).
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum ChartBarVaryColors {
    /// Not known: only bar or column charts that write `c:varyColors` off take style colors;
    /// bare series without `c:varyColors` off give no chart (`ChartReason::SeriesFill`).
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Unknown,
    /// Multi-series bar and column charts ignore `c:varyColors` (omitted or on) and assign each
    /// bare series the style color of its series index; single-series bar and column charts with
    /// `c:varyColors` omitted or on color each bar by its point fill or category style color and
    /// list the categories in forward order in the legend.
    ///
    /// - class: undocumented
    /// - status: measured
    Varied,
}
quirk!(ChartBarVaryColors: Unknown, Varied);

/// The **doughnut charts**: whether a chart whose plot area holds a doughnut group
/// (`c:doughnutChart`) is drawn, and how.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum ChartDoughnuts {
    /// Not known: a doughnut chart gives no chart (`ChartReason::OtherGroup`).
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Unknown,
    /// A doughnut inscribes its outer circle in its plot area (automatic pie plot, or the manual
    /// layout's edge box while the legend stays beside the automatic plot), shrinks the automatic
    /// outer radius by `CHART_PIE_OUTSIDE_LABEL_SHARE` when data labels are shown, cuts a hole of
    /// `holeSize` percent of the outer radius (`0` when `c:holeSize` is omitted), splits the
    /// remaining band into equal concentric rings from the first series innermost to the last
    /// outermost, and centers each data label on its ring's midpoint along the slice's bisector.
    ///
    /// - class: undocumented
    /// - status: measured
    Annulus,
}
quirk!(ChartDoughnuts: Unknown, Annulus);

/// The **combination charts**: whether a chart whose plot area holds both a vertical column group
/// (`c:barChart` with `c:barDir val="col"`) and a standard line group (`c:lineChart`) sharing one
/// category axis and one value axis is drawn, and how.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum ChartComboCharts {
    /// Not known: a chart with more than one chart group gives no chart
    /// (`ChartReason::NotOneGroup`).
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Unknown,
    /// Columns and lines sharing one category and value axis are drawn together: the value axis
    /// spans both groups (including stacked bar sums), bars paint before the category axis line
    /// and lines/markers paint over them, bare style-2 colors index by `c:idx` across the total
    /// series count, and the legend lists bar series before line series using the line-key area
    /// with wide bar keys (`CHART_LINE_KEY_STROKE` × square side).
    ///
    /// - class: undocumented
    /// - status: measured
    SharedAxes,
}
quirk!(ChartComboCharts: Unknown, SharedAxes);

/// Explicit **axis crossings** (`c:crosses` and `c:crossesAt`) of a drawn chart: whether and how
/// a chart whose category or value axis writes a crossing other than `autoZero` is drawn.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum ChartAxisCrossings {
    /// Not known: a chart whose category or value axis writes a crossing other than `autoZero`
    /// gives no chart (`ChartReason::SetCrossing`).
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Unknown,
    /// The category axis' `c:crosses` (`autoZero`, `min`) or `c:crossesAt` places the category
    /// axis (and bar baseline) along the value axis clamped to `[low, high]`, and a value axis
    /// crossing of `autoZero`, `min`, or `c:crossesAt <= 1` keeps the value axis at category 1
    /// (the plot area's start edge).
    ///
    /// - class: undocumented
    /// - status: measured
    Set,
}
quirk!(ChartAxisCrossings: Unknown, Set);

/// The **number formats of chart labels**: how a drawn chart writes the values of its value
/// labels and data labels under their number format (`c:numFmt` of the axis or the data labels,
/// else the `c:formatCode` of the series' cache).
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum ChartLabelFormats {
    /// Not known: only General is written, with every digit of the cached value; data labels
    /// in another format are not drawn, and a chart whose value labels are in another format
    /// takes no rule of its plot area but that of Word's default chart.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Unknown,
    /// Each label writes its value as its format code says: its sections, digit placeholders,
    /// decimal point, digit groups, percent signs, literal text, blanks and colors, with the
    /// value rounded half away from zero after its first 15 significant digits, and the
    /// decimal and group separators of the machine whatever the chart's language. General
    /// writes a value in at most 11 characters. A code with a part that F-Office does not
    /// write leaves its labels out.
    ///
    /// - class: undocumented
    /// - status: derived
    Codes,
}
quirk!(ChartLabelFormats: Unknown, Codes);

/// The **clip of a line chart's lines**: whether the series lines of a line chart show only
/// inside the clip of a scatter chart's series lines.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum ChartLineClip {
    /// Not known: a line chart's series lines are not clipped.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Unknown,
    /// A line chart's series lines, and not its markers, show only inside the clip of a scatter
    /// chart's series lines: on the layout device's dots, from the plot area's left edge and
    /// top to its right edge and bottom each `CHART_SCATTER_CLIP_ROOM` further out, so that a
    /// line on the plot area's top loses the half of its width above it.
    ///
    /// - class: undocumented
    /// - status: measured
    PlotArea,
}
quirk!(ChartLineClip: Unknown, PlotArea);

/// The height that an inline DrawingML drawing (`wp:inline`) takes on its line: its extent's
/// height plus its effect extent above and below it (`layout::measure`).
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum InlineRoom {
    /// The height as the markup gives it, in EMU.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Exact,
    /// The extent's height cut to whole twips, toward zero, as Word cuts a picture's drawn size
    /// and a floating drawing's offset, plus the effect extent above and below it as it is. A
    /// VML object keeps its height.
    ///
    /// - class: undocumented
    /// - status: derived
    WholeTwips,
}
quirk!(InlineRoom: Exact, WholeTwips);

/// Where a paragraph's top and bottom border lines and their spaces lie for the rounding of the
/// baselines of the lines next to them (`layout::line::height`).
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum BorderSpace {
    /// Outside the boxes of the lines: the border's width and space move the cursor, and the
    /// first and last lines round their baselines as without a border.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Outside,
    /// In the boxes of the lines, as space: on a paragraph outside table cells, the box of its
    /// first line holds its top border's width and space as space before, and the box of its
    /// last line holds its bottom border's space and width as space after, which the rules of a
    /// line's held spaces then round. Below single spacing of automatic spacing, the last line's
    /// box holds the bottom room without the paragraph's space after. The cursor moves as with
    /// `Outside`.
    ///
    /// - class: undocumented
    /// - status: measured
    Held,
}
quirk!(BorderSpace: Outside, Held);

/// Where the top border line of a paragraph of the body, or of a table in it, lies down the page,
/// on a paragraph whose first line has no extra room from an at-least minimum and whose line
/// [`BorderTextEdge::Rounded`] does not place. Headers, footers, notes and text boxes keep the
/// nearest dot.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum TopBorderPlace {
    /// At the place before the border, rounded to the nearest dot, and each further line of a
    /// compound border at its own offset, rounded the same way.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Nearest,
    /// From the start of the paragraph's content below it: the place after the border's width
    /// and space, rounded up to a dot, less the border's space and each of its lines and gaps
    /// rounded down to whole dots, a line or a gap at least one dot. The side lines of a box
    /// start at the top line's top.
    ///
    /// - class: undocumented
    /// - status: measured
    FromContentStart,
}
quirk!(TopBorderPlace: Nearest, FromContentStart);

/// Where the top and bottom border lines of a paragraph of single or at-least spacing lie down
/// the page, in every story.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum BorderTextEdge {
    /// From the exact places: a top line by [`TopBorderPlace`], or above a first line with extra
    /// room from an at-least minimum on the text's single line, the line's baseline as the page
    /// places it less the line's ascent and the border's width and space rounded to the nearest
    /// dot together; a bottom line at the nearest dot below the border's space, its further lines
    /// by [`BottomBorderParts`].
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Exact,
    /// From the rounded text edge: the paragraph's outer edge, the place before a top line or
    /// below a bottom line, rounded to the nearest dot, and the text edge whole dots inside it.
    /// Below the top edge, they are the border's width and space with the first line's extra
    /// room from an at-least minimum, rounded to the nearest dot, but no more than the line's
    /// height with the border's width and space, rounded to the nearest dot, less the line's
    /// ascent and descent, each rounded to the nearest dot. Above the bottom edge, they are the
    /// border's width and space rounded to the nearest dot, but no more than the last line's
    /// height with the border's width and space, rounded to the nearest dot, less its extra room,
    /// ascent and descent, each rounded to the nearest dot. The border's space and each of its
    /// lines and gaps, rounded down to whole dots, a line or a gap at least one dot, stack out
    /// from the text edge. The text's lines stay where they are.
    ///
    /// - class: undocumented
    /// - status: derived
    Rounded,
}
quirk!(BorderTextEdge: Exact, Rounded);

/// Where the top border line of a paragraph of automatic multiple spacing, other than single,
/// lies down the page, in every story (`layout::paragraph`).
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum MultipleTopBorder {
    /// As [`TopBorderPlace`] places it.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    ByTopBorderPlace,
    /// From the rounded text edge with the first term of [`BorderTextEdge::Rounded`] alone: the
    /// place before the line rounded to the nearest dot, and the text edge the border's width and
    /// space, rounded to the nearest dot, below it, from where the border's space and each of
    /// its lines and gaps, rounded down to whole dots, a line or a gap at least one dot, stack
    /// up. The text's lines stay where they are.
    ///
    /// - class: undocumented
    /// - status: measured
    FromTextEdge,
}
quirk!(MultipleTopBorder: ByTopBorderPlace, FromTextEdge);

/// Where the bottom border line of a paragraph of automatic multiple spacing above single
/// spacing lies down the page, below a last line whose baseline the multiple spacing places, in
/// every story (`layout::paragraph`).
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum MultipleBottomBorder {
    /// At the nearest dot below the border's space, its further lines by
    /// [`BottomBorderParts`].
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Nearest,
    /// From the rounded text edge of [`BorderTextEdge::Rounded`] with the part that the spacing
    /// adds to the last line, below its text, in both terms of the room, and the space after
    /// that follows the paragraph joined to the border's width and space: the place below the
    /// border's space and width and that space after rounded to the nearest dot, and the text
    /// edge whole dots above it, the three with the part that the spacing adds, rounded to the
    /// nearest dot, less that part rounded to the nearest dot, but no more than the line's
    /// height with the three, rounded to the nearest dot, less that part, the line's ascent and
    /// its descent, each rounded to the nearest dot. The border's space and each of its lines and
    /// gaps, rounded down to whole dots, a line or a gap at least one dot, stack down from the
    /// text edge. The text's lines stay where they are.
    ///
    /// - class: undocumented
    /// - status: derived
    FromTextEdge,
}
quirk!(MultipleBottomBorder: Nearest, FromTextEdge);

/// Whether the space after that follows a paragraph of single or at-least spacing takes part in
/// the place of its bottom border line from the rounded text edge of
/// [`BorderTextEdge::Rounded`] (`layout::paragraph`).
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum BottomBorderSpaceAfter {
    /// It takes no part: the outer edge lies below the border's space and width.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Apart,
    /// It joins the border's space and width: the outer edge lies below the three, rounded to
    /// the nearest dot, and the room up to the text edge takes the three in place of the
    /// border's space and width in both of its terms.
    ///
    /// - class: undocumented
    /// - status: derived
    Joined,
}
quirk!(BottomBorderSpaceAfter: Apart, Joined);

/// Where a paragraph takes each side of its border from, when its own `w:pBdr`, its paragraph
/// style's and the styles that one is based on each name some of the sides (`props::NamedSides`,
/// `layout::decisions`).
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum BorderSides {
    /// All four sides from the nearest level that has a `w:pBdr`, as that element names them;
    /// `w:start` and `w:end` stand for a left and a right side without a line.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    WholeElement,
    /// Each side on its own, from the nearest level that names it with `w:top`, `w:bottom`,
    /// `w:left` or `w:right`; a side named without a line, such as one of `nil` or `none`, draws
    /// none and hides the side of every level below it, an empty `w:pBdr` names no side, and
    /// `w:start` and `w:end` name none.
    ///
    /// - class: undocumented
    /// - status: measured
    EachSide,
}
quirk!(BorderSides: WholeElement, EachSide);

/// Whether the target draws the side between the paragraphs of a group with equal borders
/// (`w:between` of `w:pBdr`).
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum BetweenBorders {
    /// The side between the paragraphs is dropped: it draws no line and takes no room, and two
    /// paragraphs whose borders differ only in it join.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Dropped,
    /// Between each two paragraphs of a group whose borders have the side, its line lies one
    /// space below the upper paragraph and one space above the lower one: the step between
    /// their lines grows by the line's width and twice its space, on top of the spacing that
    /// the group keeps. The line runs between the ends of a top or bottom line.
    ///
    /// - class: undocumented
    /// - status: measured
    Drawn,
}
quirk!(BetweenBorders: Dropped, Drawn);

/// Where the further lines of a paragraph's bottom border lie below its first line, on a border
/// of a style that draws more than one line, such as `double`.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum BottomBorderParts {
    /// Each line at its own offset from the place below the border's space, rounded to the
    /// nearest dot.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Nearest,
    /// Stacked from the first line's top: each line and each gap rounded down to whole dots, a
    /// line or a gap at least one dot.
    ///
    /// - class: undocumented
    /// - status: measured
    Stacked,
}
quirk!(BottomBorderParts: Nearest, Stacked);

/// Where the fill of a shaded paragraph of the body, outside table cells, starts and ends next
/// to the paragraph's own top and bottom border lines.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum FillAtLines {
    /// Under the lines: the fill starts above the top line and ends below the bottom line.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Under,
    /// Inside the lines: the fill starts at the bottom edge of the top line as drawn and ends
    /// at the top edge of the bottom line as drawn, and fills the borders' spaces. A side
    /// without its own line keeps the place of `Under`.
    ///
    /// - class: undocumented
    /// - status: measured
    Inside,
}
quirk!(FillAtLines: Under, Inside);

/// Where the space after that follows a line in a table cell lies for the rounding of the
/// line's baseline (`layout::line::height`).
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum CellSpaceAfter {
    /// Outside the line's box, which rounds its baseline as without it; outside table cells the
    /// box holds the space after as `MultipleBaseline` says.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Outside,
    /// In the line's box, as outside table cells: the box of the last line of a paragraph in a
    /// table cell holds the paragraph's space after that follows it, inner paragraph or the
    /// cell's last, under the rules of a line's held spaces.
    ///
    /// - class: undocumented
    /// - status: measured
    Held,
}
quirk!(CellSpaceAfter: Outside, Held);

/// Where the space after that follows a line of at-least spacing lies for the rounding of the
/// line's baseline (`layout::line::height`).
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum AtLeastSpaceAfter {
    /// Outside the line's box, which rounds its baseline as without it.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Outside,
    /// In the line's box, as on a line of automatic spacing at or above single spacing: the box
    /// of the last line of a paragraph holds the paragraph's space after that follows it, under
    /// the same conditions, and the baseline lies the larger of the ascent part and the
    /// descent part below the box's rounded top. Where the minimum sets the line's height, its
    /// extra lies above the text, and the ascent part rounds that extra and the text's ascent
    /// each on its own, below the space before taken as the rounded space and line less the
    /// rounded line. Where the minimum is at most the single line, the line takes the box
    /// of single spacing, and holds the space after as a line of single spacing does. The
    /// variant follows from the rule of a line's held spaces.
    ///
    /// - class: undocumented
    /// - status: measured
    Held,
}
quirk!(AtLeastSpaceAfter: Outside, Held);

/// Where the pieces of a line go whose paragraph's text alignment is `center`
/// (`w:textAlignment`, ECMA-376 Part 1, 17.3.1.39), in `layout::line::centered`.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum CenteredLine {
    /// On one baseline, as without a text alignment.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    OnBaseline,
    /// With the middles of their win lines on one line, on a line of automatic single spacing
    /// whose pieces are glyphs of faces not made for East Asian text, neither raised, lowered,
    /// scripts nor math: the highest win top of the pieces, a list label's included, lies where
    /// the line's highest win top lies without the alignment, and the line ends at the lowest
    /// win bottom of its text, as a list label's descent stays out of a line
    /// (`ListLabelDescent`).
    ///
    /// - class: undocumented
    /// - status: derived
    MiddlesShared,
}
quirk!(CenteredLine: OnBaseline, MiddlesShared);

/// Where the baseline of a line of automatic multiple spacing above single spacing goes whose
/// paragraph's text alignment is `center` (`w:textAlignment`, ECMA-376 Part 1, 17.3.1.39) and
/// whose pieces are glyphs of one face's line and pixel heights, in `layout::line::height`.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum CenteredMultiple {
    /// Where the line's box puts it without the alignment.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    OnBaseline,
    /// The page puts the middle of the face's win line where the box would put the baseline
    /// with the line's ascent less half the win line's ascent less its descent, or, where that
    /// is lower, with half the win line in place of the descent; each part rounds to the device
    /// as the box's parts round. The baseline lies below that middle by half the face's pixel
    /// ascent less its pixel descent at the device's pel height, rounded up to whole dots. On
    /// the device of 600 dpi only: a device of 1,200 dpi puts some lines one dot apart.
    ///
    /// - class: undocumented
    /// - status: derived
    MiddleRounded,
}
quirk!(CenteredMultiple: OnBaseline, MiddleRounded);

/// What the target does with the compatibility option `w:doNotExpandShiftReturn` (ECMA-376
/// Part 1, 17.15.3.5), which keeps a justified paragraph's lines that end in a soft line break
/// from being justified (`layout::line::shift`).
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum SoftBreakLine {
    /// Such a line is justified whatever the option says.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Justified,
    /// Where the option is set, such a line is aligned as the paragraph's last line, as
    /// ECMA-376 says: its spaces keep their width, and it starts at the paragraph's start edge.
    ///
    /// - class: compatibility option
    /// - status: specified
    OptionFollowed,
}
quirk!(SoftBreakLine: Justified, OptionFollowed);

/// What the target does with the compatibility option `w:doNotUseHTMLParagraphAutoSpacing`
/// (ECMA-376 Part 4, 14.8.3.15), which turns automatic paragraph spacing into fixed values
/// (`props::HtmlAutoSpacing`).
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum FixedAutoSpacing {
    /// Automatic spacing is 14 pt above and below whatever the option says.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Ignored,
    /// Where the option is set, automatic spacing is 5 pt above and below (ECMA-376 says 5 pt
    /// above and 10 pt below), the space after a paragraph and the space before the next add,
    /// written or automatic, and no automatic space is left out: not above the first paragraph
    /// of the document, not at the top or end of a table cell, not between two paragraphs of
    /// one list.
    ///
    /// - class: compatibility option
    /// - status: derived
    OptionFollowed,
}
quirk!(FixedAutoSpacing: Ignored, OptionFollowed);

/// What the automatic space after of a list paragraph does at the end of a table cell, where
/// automatic spacing is read as HTML user agents space paragraphs (`props::HtmlAutoSpacing`).
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum CellEndListSpace {
    /// It adds nothing to the cell, as the automatic space after of every last paragraph.
    ///
    /// - class: undocumented
    /// - status: derived
    #[default]
    Dropped,
    /// It stays below the paragraph and makes the cell taller, whatever the next row holds
    /// and also in the last row; the automatic space after of a paragraph outside a list
    /// still adds nothing.
    ///
    /// - class: undocumented
    /// - status: derived
    Kept,
}
quirk!(CellEndListSpace: Dropped, Kept);

/// The side of the square of a check box form field, between the middles of its strokes, in a
/// cell as wide and as high as the single line of its face: it follows from the cell, the
/// stroke (`params::CHECK_BOX_STROKE`) and the device dot.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum CheckBoxSide {
    /// The cell less three strokes: the square's outer edge lies one stroke inside the cell.
    ///
    /// - class: undocumented
    /// - status: derived
    ThreeStrokes,
    /// The cell less three strokes and one device dot.
    ///
    /// - class: undocumented
    /// - status: derived
    ThreeStrokesAndDot,
}
quirk!(CheckBoxSide: ThreeStrokes, ThreeStrokesAndDot);

/// How a paragraph's list level (`w:ilvl` of `w:numPr`, `ST_DecimalNumber`) reads.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ListLevelReading {
    /// The value is the level: a value of 0 or more names that level, and a negative value is
    /// missing. This is F-Office's own reading.
    ///
    /// - class: undocumented
    /// - status: derived
    AsWritten,
    /// The value modulo 256, one octet, reads through a table: 0 to 8 name that level, 9 to 12
    /// give the paragraph no number and no level, 13 and 14 name level 8, 15 names level 0, and
    /// 16 to 255 name level 8.
    ///
    /// - class: undocumented
    /// - status: measured
    ByOctet,
}
quirk!(ListLevelReading: AsWritten, ByOctet);

/// How a list label, a page number and a note's number are written in the formats of
/// `ST_NumberFormat` that write other signs than decimal digits, Latin letters, roman numerals
/// and English words, such as East Asian numerals, other scripts' digits and letters, and
/// ordinals.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum NumberForms {
    /// In decimal digits, but a number in dashes, `- 1 -`. This keeps F-Office's existing
    /// labels rather than asserting a behavior of the targets that choose it.
    ///
    /// - class: undocumented
    /// - status: derived
    Digits,
    /// In each format's own signs: digit by digit, counting with signs of units, a list of
    /// signs then decimal digits, a cycle of signs, signs repeated after each round, Hebrew
    /// numerals, or ordinals, with the format's limits and cycles.
    ///
    /// - class: undocumented
    /// - status: measured
    Signs,
}
quirk!(NumberForms: Digits, Signs);

/// Which of two normal notes of one number in a part a reference of that number finds.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum RepeatedNoteId {
    /// The later note replaces the earlier one. This is F-Office's own reading.
    ///
    /// - class: undocumented
    /// - status: derived
    LaterReplaces,
    /// The first note stays, and the later one is not kept: of the footnotes `2` and then
    /// `02`, the reference `2` finds the first.
    ///
    /// - class: undocumented
    /// - status: measured
    FirstStays,
}
quirk!(RepeatedNoteId: LaterReplaces, FirstStays);

/// Whether the space after the last paragraph of a footnote separator takes room at the foot
/// of the page, above the footnotes.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum SeparatorSpaceAfter {
    /// The separator's room ends at its last line. This is F-Office's earlier layout.
    ///
    /// - class: undocumented
    /// - status: derived
    Dropped,
    /// The written separator, which the settings list, keeps the space after its last
    /// paragraph below its last line, so its rule stands that much higher; the separator that
    /// Word draws itself when the settings list none keeps none.
    ///
    /// - class: undocumented
    /// - status: measured
    Kept,
}
quirk!(SeparatorSpaceAfter: Dropped, Kept);

/// With different headers of odd and even pages, where the first page of a section that starts
/// its page numbers again lies: on a right-hand page when its first number is odd and on a
/// left-hand page when it is even, with a blank page before it when the next page has the other
/// side. The quirk says what gives the next page its side.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum RestartSide {
    /// The page's place in the document: the first, third and every odd page is a right-hand
    /// page. This is F-Office's earlier layout.
    ///
    /// - class: undocumented
    /// - status: derived
    Place,
    /// The number of the page before it: after a page of an even number the next page is a
    /// right-hand page, and after one of an odd number a left-hand page, wherever the pages
    /// lie in the document.
    ///
    /// - class: undocumented
    /// - status: measured
    PreviousNumber,
}
quirk!(RestartSide: Place, PreviousNumber);

/// What a line meets beside a tight or through wrap (`wp:wrapTight`, `wp:wrapThrough`) whose
/// polygon is not a rectangle along the axes: where it goes beside the drawing, and where the
/// steps of a line without room end.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum PolygonWrap {
    /// The bounds of the polygon with the wrap distances, on every line. This is F-Office's
    /// earlier layout.
    ///
    /// - class: undocumented
    /// - status: derived
    Bounds,
    /// The polygon's outline on the line's band from its top to its bottom: the line keeps out
    /// of the outline's leftmost and rightmost points on that band, with the wrap distances,
    /// and a line without a free piece there steps down until it has one.
    ///
    /// - class: undocumented
    /// - status: measured
    Outline,
}
quirk!(PolygonWrap: Bounds, Outline);

/// Where the steps of a line without room beside a tight or through wrap end
/// (`BlockedLines::LineSteps`): the step that brings the line's top to the wrap's bottom or
/// past it.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum StepEnd {
    /// The first step whose top lies at the wrap's bottom or below it. This is F-Office's
    /// earlier layout.
    ///
    /// - class: undocumented
    /// - status: derived
    AtBottom,
    /// The first step whose top lies below the wrap's bottom: a step that brings the top
    /// exactly to the bottom still meets the wrap, and the line takes one step more.
    ///
    /// - class: undocumented
    /// - status: measured
    PastBottom,
}
quirk!(StepEnd: AtBottom, PastBottom);

/// Over which band from a line's top it meets the wraps beside which text flows (their bounds,
/// the outline of a tight or through wrap under `PolygonWrap::Outline`, and whether a step of a
/// blocked line has room).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum LineWrapBand {
    /// The whole line, from its top to its bottom, under every line spacing. This is
    /// F-Office's earlier layout.
    ///
    /// - class: undocumented
    /// - status: derived
    WholeLine,
    /// Under automatic multiple spacing above single spacing, the line's single line from its
    /// top, without the extra below its text; the whole line under other spacing.
    ///
    /// - class: undocumented
    /// - status: measured
    SingleLine,
}
quirk!(LineWrapBand: WholeLine, SingleLine);

/// Which spacing the footnote separator that Word draws itself, when the settings list no
/// separators, takes from the style `Normal` and the document defaults.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum OwnSeparatorSpacing {
    /// The separator is a paragraph without properties, so it takes all of `Normal` and the
    /// defaults. This is F-Office's earlier reading.
    ///
    /// - class: undocumented
    /// - status: derived
    Inherited,
    /// The separator has no space before or after and single lines, whatever `Normal` and the
    /// defaults give; it takes their other properties, such as a left indent and a run size.
    /// Whether it takes their other paragraph properties, such as automatic spacing, is not
    /// measured.
    ///
    /// - class: undocumented
    /// - status: measured
    Plain,
}
quirk!(OwnSeparatorSpacing: Inherited, Plain);

/// Which lines a paragraph's widow control (`w:widowControl`) counts when a drawing beside the
/// paragraph breaks its lines again, narrower or wider than at the column's whole width.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum WidowForecast {
    /// The lines at the column's whole width, as the paragraph's start forecasts them: a last
    /// line that the drawing's narrower lines push to the next page stays alone there. This is
    /// F-Office's earlier layout.
    ///
    /// - class: undocumented
    /// - status: derived
    WholeWidth,
    /// The lines as the drawings break them: from the line where a drawing breaks the rest of
    /// the lines again, the paragraph forecasts its widow break again, and when only its last
    /// line would go to the next page, the line before it goes too, once. The moved text breaks
    /// again at the next page's width, and is not forecast again there for widow control.
    ///
    /// - class: undocumented
    /// - status: measured
    AsWrapped,
}
quirk!(WidowForecast: WholeWidth, AsWrapped);

/// Whether the columns of a section that starts on an earlier page and ends at a continuous
/// section break are balanced on the section's last page.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum LastPageBalance {
    /// Only a section that starts and ends on one page is balanced; the last page of a longer
    /// one fills its first column before the next. This is F-Office's earlier layout.
    ///
    /// - class: undocumented
    /// - status: derived
    OnePage,
    /// The last page of a longer section is balanced alone, by the rule of a section on one
    /// page, with the page's top as the top of its columns; the pages before stay as they fill.
    ///
    /// - class: undocumented
    /// - status: derived
    LastPage,
}
quirk!(LastPageBalance: OnePage, LastPage);

/// What the own space before of a paragraph that goes on at the top of the next column does
/// there, when the top of that column is the top of its page.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ColumnTopSpace {
    /// It stays above the line at the top of every next column. This is F-Office's earlier
    /// layout.
    ///
    /// - class: undocumented
    /// - status: derived
    Stays,
    /// It goes at the top of a column whose top is the top of the page, as at the top of a
    /// page; it stays at the top of a column that starts below other text of its page.
    ///
    /// - class: undocumented
    /// - status: measured
    GoesAtPageTop,
}
quirk!(ColumnTopSpace: Stays, GoesAtPageTop);

/// What a table in the flow of the body whose rows all go, as the target prints the changes
/// accepted, does at the top of a page to the space before of the paragraph after it.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum DeletedTableTop {
    /// It is a table without height, after which the paragraph keeps its space before, as after
    /// any table. This is F-Office's earlier layout.
    ///
    /// - class: undocumented
    /// - status: derived
    AsTable,
    /// Before compatibility mode 15, the paragraph after it has no space before there, as after
    /// a page break; from mode 15, the table is not there for it, and the paragraph has the space
    /// before that it would have without the table (`DELETED_TABLE_TOP_MODE`).
    ///
    /// - class: undocumented
    /// - status: measured
    ByMode,
}
quirk!(DeletedTableTop: AsTable, ByMode);

/// Whether the last line of a paragraph with a bottom border needs room for the border's space
/// and width at the foot of a page.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum FootBorderRoom {
    /// The line stays on the page when its text fits, and the border may reach below the end of
    /// the body. This is F-Office's earlier layout.
    ///
    /// - class: undocumented
    /// - status: derived
    Hangs,
    /// The line stays on the page only when its text and the border's space and width below it
    /// fit above the end of the body; else it starts the next page with the border. The part of
    /// multiple spacing above single spacing still hangs below the end, as for any line.
    ///
    /// - class: undocumented
    /// - status: measured
    Fits,
}
quirk!(FootBorderRoom: Hangs, Fits);

/// Where the text after a tab to a right, center or decimal stop goes when the text, placed at
/// the stop, would end past the line's end, whether the stop lies before, at or past that end.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum AlignedTabOverrun {
    /// It stays at the stop, and its word that ends past the line's end goes to the next line
    /// with the tab, as the line breaking of other text does. This is F-Office's earlier
    /// layout, which no measurement has checked.
    ///
    /// - class: undocumented
    /// - status: derived
    RunsPast,
    /// It keeps its place at the stop when it ends inside its limit, and otherwise moves left
    /// until it ends at the limit, never left of the tab's start; it stays on the line either
    /// way. The limit is the end of the text area of the column or cell when the stop lies past
    /// the line's end and inside the area, which a right indent leaves between the two, and
    /// the line's end otherwise.
    ///
    /// - class: undocumented
    /// - status: measured
    EndsAtAreaEnd,
}
quirk!(AlignedTabOverrun: RunsPast, EndsAtAreaEnd);

/// Whether a line may break right after a footnote reference, between its mark and the text
/// that follows it without a space, such as a closing parenthesis.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum NoteReferenceBreak {
    /// A line may break after the reference: its mark ends its word. This is F-Office's
    /// layout before the rule of the other variant.
    ///
    /// - class: undocumented
    /// - status: derived
    After,
    /// The reference's mark is text of its word: a line breaks around it only where its text
    /// allows a break, as around the same digit written as a superscript run.
    ///
    /// - class: undocumented
    /// - status: derived
    AsText,
}
quirk!(NoteReferenceBreak: After, AsText);

/// What a page or column break (`w:br` of the type `page` or `column`) does in the text of a
/// table cell, where no page or column starts.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum CellBreak {
    /// The break ends its line, and the text after it starts the next line of the cell. This is
    /// F-Office's layout before the rule of the other variant.
    ///
    /// - class: undocumented
    /// - status: derived
    EndsLine,
    /// The break does nothing: the text on its two sides stays on one line, and a paragraph that
    /// holds only breaks has the one empty line of a paragraph without text.
    ///
    /// - class: undocumented
    /// - status: measured
    Ignored,
}
quirk!(CellBreak: EndsLine, Ignored);

/// What a `STYLEREF` field in a header or footer shows of a no-break space in the text that it
/// takes from the page.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum StyleRefNoBreakSpace {
    /// The no-break space, which keeps the words on its two sides on one line. This is
    /// F-Office's layout before the rule of the other variant.
    ///
    /// - class: undocumented
    /// - status: derived
    Kept,
    /// A plain space, where a line may break.
    ///
    /// - class: undocumented
    /// - status: derived
    Plain,
}
quirk!(StyleRefNoBreakSpace: Kept, Plain);

/// What a `STYLEREF` field in a header or footer shows of the spaces at the end of the text of
/// the paragraph that it finds.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum StyleRefTrailingSpaces {
    /// The spaces, so a centered or right-aligned line of the field ends where they start.
    /// This is F-Office's layout before the rule of the other variant.
    ///
    /// - class: undocumented
    /// - status: derived
    Kept,
    /// None of them: the field's text ends at the paragraph's last character that is not a
    /// space.
    ///
    /// - class: undocumented
    /// - status: derived
    Dropped,
}
quirk!(StyleRefTrailingSpaces: Kept, Dropped);

/// Where a tab goes whose next stop is a custom left stop past the line's end.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum LeftStopPastEnd {
    /// To the stop, and the line runs on past its end. This is F-Office's layout before the
    /// rule of the other variant.
    ///
    /// - class: undocumented
    /// - status: derived
    ToStop,
    /// To the line's end: on a line that holds something, the tab starts the next line, and
    /// there it ends at the line's end, its leader with it, so that the text after it starts
    /// the line after that.
    ///
    /// - class: undocumented
    /// - status: derived
    ToLineEnd,
}
quirk!(LeftStopPastEnd: ToStop, ToLineEnd);

/// The **leading page break**: which line of a paragraph that starts with a page break, and
/// holds text after it, takes the paragraph's first-line start (its first-line indent or its
/// hanging start) and its list label.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum LeadingPageBreak {
    /// The break's own line, as on any paragraph: the text after the break starts where the
    /// other lines start, and the list label stays on the break's line on the page before.
    /// This is F-Office's layout before the rule of the other variant.
    ///
    /// - class: undocumented
    /// - status: derived
    OnBreakLine,
    /// The line after the leading page breaks: after all of them in a compatibility mode
    /// below 15, after the first of them from mode 15 (`LEADING_BREAK_MODE`). It starts at the
    /// first-line start and draws the list label, and the first break's line holds nothing.
    ///
    /// - class: undocumented
    /// - status: measured
    AfterBreak,
}
quirk!(LeadingPageBreak: OnBreakLine, AfterBreak);

/// The **fixed space widths**: how wide an en space (U+2002) and an em space (U+2003) are, in
/// the layout and in the device's steps.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum FixedSpaceWidths {
    /// The advance of the space's own glyph in its font. This is F-Office's layout before the
    /// rule of the other variant.
    ///
    /// - class: undocumented
    /// - status: derived
    OwnGlyphs,
    /// The advance of the font's dash of the same name: the en dash (U+2013) for an en space
    /// and the em dash (U+2014) for an em space, where the font has the dash, and else the
    /// space's own.
    ///
    /// - class: undocumented
    /// - status: measured
    DashWidths,
}
quirk!(FixedSpaceWidths: OwnGlyphs, DashWidths);

/// What a justified line does where the settings ask for the justification of `WordPerfect`
/// (`w:wpJustification`) and the compatibility mode does not shrink the spaces of justified
/// lines: from the mode of Word 2013 the mode's own shrink holds, and the option changes
/// nothing.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum WordPerfectJustification {
    /// The option changes nothing: the line takes a word only at its natural width. This is
    /// F-Office's layout before the rule of the other variant.
    ///
    /// - class: undocumented
    /// - status: derived
    Ignored,
    /// The line takes a word while its natural width up to the word's end runs past its width
    /// by at most `WORDPERFECT_LINE_SHRINK` of that natural width, and narrows its characters to
    /// fit: where its letters and spaces all have one advance, every character by the same
    /// length; else first every space by up to a quarter of its width, then every character by
    /// the same length.
    ///
    /// - class: undocumented
    /// - status: measured
    ShrinksLine,
}
quirk!(WordPerfectJustification: Ignored, ShrinksLine);

/// What a justified line of a paragraph aligned with kashidas (`w:jc` `lowKashida`) does with
/// its free space in a compatibility mode below `KASHIDA_WORDS_MODE`.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum KashidaJustification {
    /// The line widens its spaces only, as a line aligned `both` does. This is F-Office's layout
    /// before the rule of the other variant.
    ///
    /// - class: undocumented
    /// - status: derived
    SpacesOnly,
    /// The line lengthens one joint of each of its last words that can take a kashida, with
    /// tatweel glyphs: as many words as their tatweels' advances on the device fit into the
    /// line's room on the device, strictly. The room is the line's width less the advances of
    /// its glyphs on the device, in whole dots. Each kashida is one tatweel's advance wide, and
    /// the spaces take the rest of the free space; where every such word takes one, the
    /// kashidas share the free space and the spaces keep their width. A word lengthens its last
    /// joint after a seen, sheen, sad or dad, or else the joint before the letter that ends one
    /// of its joined groups, by the class of that letter.
    ///
    /// - class: undocumented
    /// - status: measured
    LastWords,
}
quirk!(KashidaJustification: SpacesOnly, LastWords);

/// What a justified line of a paragraph aligned with kashidas (`w:jc` `lowKashida`) does with
/// its free space from the compatibility mode `KASHIDA_WORDS_MODE`.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum SeenKashidas {
    /// The line widens its spaces only, as a line aligned `both` does. This is F-Office's layout
    /// before the rule of the other variant.
    ///
    /// - class: undocumented
    /// - status: derived
    SpacesOnly,
    /// The line lengthens every letter joint after a seen, sheen, sad or dad with tatweel glyphs,
    /// all by one width in whole dots: the line's room on the device shared among them, the last
    /// in reading order taking what the equal shares leave, but at most `SEEN_KASHIDA_SPACES`
    /// widths of a space of the joint's face. The room is the line's width less the advances of
    /// its glyphs on the device, in whole dots. What those kashidas leave of the room, or all of
    /// it on a line without such a joint, goes to the letter joints before the last letter of a
    /// joined group that ends as an alef or a heh (alef and its forms, beh, teh, theh, peh, kaf,
    /// keheh, gaf, lam; teh marbuta, heh, heh with yeh, dal, thal) and is no ligature, and to the
    /// line's stretched spaces together: each such joint takes `FINAL_KASHIDA_SHARE` times what
    /// each space takes, not rounded to whole dots. The spaces take the rest of the free space.
    /// The line breaks with its spaces at their natural width: it takes no word by shrinking
    /// them.
    ///
    /// - class: undocumented
    /// - status: measured
    SeenAndFinalJoints,
}
quirk!(SeenKashidas: SpacesOnly, SeenAndFinalJoints);

/// The variant of every quirk for one target, as its profile names them.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct Quirks {
    /// See [`Markup`].
    pub(crate) markup: Markup,
    /// See [`GridAdvances`].
    pub(crate) grid_advances: GridAdvances,
    /// See [`PictureImage`].
    pub(crate) picture_image: PictureImage,
    /// See [`SuperscriptRise`].
    pub(crate) superscript_rise: SuperscriptRise,
    /// See [`ScriptPlacement`].
    pub(crate) script_placement: ScriptPlacement,
    /// See [`ScriptSize`].
    pub(crate) script_size: ScriptSize,
    /// See [`LineHeight`].
    pub(crate) line_height: LineHeight,
    /// See [`MultipleBaseline`].
    pub(crate) multiple_baseline: MultipleBaseline,
    /// See [`SpaceBeforeAscent`].
    pub(crate) space_before_ascent: SpaceBeforeAscent,
    /// See [`DroppedSpaceBox`].
    pub(crate) dropped_space_box: DroppedSpaceBox,
    /// See [`SingleBaseline`].
    pub(crate) single_baseline: SingleBaseline,
    /// See [`ExactBaseline`].
    pub(crate) exact_baseline: ExactBaseline,
    /// See [`LowMultipleBaseline`].
    pub(crate) low_multiple_baseline: LowMultipleBaseline,
    /// See [`ExactSpacedBottom`].
    pub(crate) exact_spaced_bottom: ExactSpacedBottom,
    /// See [`TableLines`].
    pub(crate) table_lines: TableLines,
    /// See [`CompoundTableLines`].
    pub(crate) compound_table_lines: CompoundTableLines,
    /// See [`CenteredTableLines`].
    pub(crate) centered_table_lines: CenteredTableLines,
    /// See [`CenteredTablePlace`].
    pub(crate) centered_table_place: CenteredTablePlace,
    /// See [`CenteredTableLinesBefore15`].
    pub(crate) centered_table_lines_before_15: CenteredTableLinesBefore15,
    /// See [`TableEdgeHalves`].
    pub(crate) table_edge_halves: TableEdgeHalves,
    /// See [`CenteredTableTextBefore15`].
    pub(crate) centered_table_text_before_15: CenteredTableTextBefore15,
    /// See [`EdgeTableText`].
    pub(crate) edge_table_text: EdgeTableText,
    /// See [`TurnedLineRoom`].
    pub(crate) turned_line_room: TurnedLineRoom,
    /// See [`TurnedAcrossDots`].
    pub(crate) turned_across_dots: TurnedAcrossDots,
    /// See [`TurnedPicture`].
    pub(crate) turned_picture: TurnedPicture,
    /// See [`BorderDashes`].
    pub(crate) border_dashes: BorderDashes,
    /// See [`ThreeDBorders`].
    pub(crate) three_d_borders: ThreeDBorders,
    /// See [`LargeGapBorders`].
    pub(crate) large_gap_borders: LargeGapBorders,
    /// See [`ArtPageBorders`].
    pub(crate) art_page_borders: ArtPageBorders,
    /// See [`PageBorderLines`].
    pub(crate) page_border_lines: PageBorderLines,
    /// See [`TableIndent`].
    pub(crate) table_indent: TableIndent,
    /// See [`RightToLeftEdge`].
    pub(crate) right_to_left_edge: RightToLeftEdge,
    /// See [`CellTextRoom`].
    pub(crate) cell_text_room: CellTextRoom,
    /// See [`UnsetCellMargins`].
    pub(crate) unset_cell_margins: UnsetCellMargins,
    /// See [`RowBelowHeaders`].
    pub(crate) row_below_headers: RowBelowHeaders,
    /// See [`RowLineRoom`].
    pub(crate) row_line_room: RowLineRoom,
    /// See [`MergedTopRoom`].
    pub(crate) merged_top_room: MergedTopRoom,
    /// See [`MergedCellFill`].
    pub(crate) merged_cell_fill: MergedCellFill,
    /// See [`RowEndBorders`].
    pub(crate) row_end_borders: RowEndBorders,
    /// See [`SplitMergeAlign`].
    pub(crate) split_merge_align: SplitMergeAlign,
    /// See [`CarriedMergeMove`].
    pub(crate) carried_merge_move: CarriedMergeMove,
    /// See [`NestedRowMinimum`].
    pub(crate) nested_row_minimum: NestedRowMinimum,
    /// See [`FloatingTableBreaks`].
    pub(crate) floating_table_breaks: FloatingTableBreaks,
    /// See [`LaterPartWidows`].
    pub(crate) later_part_widows: LaterPartWidows,
    /// See [`SplitRowFills`].
    pub(crate) split_row_fills: SplitRowFills,
    /// See [`MergedCellLines`].
    pub(crate) merged_cell_lines: MergedCellLines,
    /// See [`HiddenLastMark`].
    pub(crate) hidden_last_mark: HiddenLastMark,
    /// See [`HiddenHeaderFooterEnd`].
    pub(crate) hidden_header_footer_end: HiddenHeaderFooterEnd,
    /// See [`ExactRowMargin`].
    pub(crate) exact_row_margin: ExactRowMargin,
    /// See [`CellFrames`].
    pub(crate) cell_frames: CellFrames,
    /// See [`DisplayFractionRoom`].
    pub(crate) display_fraction_room: DisplayFractionRoom,
    /// See [`GrownDelimiters`].
    pub(crate) grown_delimiters: GrownDelimiters,
    /// See [`ScriptRoom`].
    pub(crate) script_room: ScriptRoom,
    /// See [`VmlObjectSize`].
    pub(crate) vml_object_size: VmlObjectSize,
    /// See [`GridSingleLine`].
    pub(crate) grid_single_line: GridSingleLine,
    /// See [`ObjectAscent`].
    pub(crate) object_ascent: ObjectAscent,
    /// See [`UnderlinedObjectRoom`].
    pub(crate) underlined_object_room: UnderlinedObjectRoom,
    /// See [`ObjectLineMultiple`].
    pub(crate) object_line_multiple: ObjectLineMultiple,
    /// See [`RaisedRunSpacing`].
    pub(crate) raised_run_spacing: RaisedRunSpacing,
    /// See [`FaceRoomSpacing`].
    pub(crate) face_room_spacing: FaceRoomSpacing,
    /// See [`MarkFace`].
    pub(crate) mark_face: MarkFace,
    /// See [`BlockedLines`].
    pub(crate) blocked_lines: BlockedLines,
    /// See [`BandHeight`].
    pub(crate) band_height: BandHeight,
    /// See [`FloatingTableTop`].
    pub(crate) floating_table_top: FloatingTableTop,
    /// See [`FloatingTableLeft`].
    pub(crate) floating_table_left: FloatingTableLeft,
    /// See [`FrameLeft`].
    pub(crate) frame_left: FrameLeft,
    /// See [`BoxOutlineLeft`].
    pub(crate) box_outline_left: BoxOutlineLeft,
    /// See [`BoxTextTop`].
    pub(crate) box_text_top: BoxTextTop,
    /// See [`BoxLastLine`].
    pub(crate) box_last_line: BoxLastLine,
    /// See [`SmartArtLowSpacing`].
    pub(crate) smartart_low_spacing: SmartArtLowSpacing,
    /// See [`VmlBoxOutline`].
    pub(crate) vml_box_outline: VmlBoxOutline,
    /// See [`FrameFittedWidth`].
    pub(crate) frame_fitted_width: FrameFittedWidth,
    /// See [`ListLabelDescent`].
    pub(crate) list_label_descent: ListLabelDescent,
    /// See [`LabelAloneRise`].
    pub(crate) label_alone_rise: LabelAloneRise,
    /// See [`AlignmentWithNotes`].
    pub(crate) alignment_with_notes: AlignmentWithNotes,
    /// See [`InvisibleCharacters`].
    pub(crate) invisible_characters: InvisibleCharacters,
    /// See [`TextBoxContent`].
    pub(crate) text_box_content: TextBoxContent,
    /// See [`TextBoxClip`].
    pub(crate) text_box_clip: TextBoxClip,
    /// See [`TextBoxColumns`].
    pub(crate) text_box_columns: TextBoxColumns,
    /// See [`FromLine`].
    pub(crate) from_line: FromLine,
    /// See [`CellClip`].
    pub(crate) cell_clip: CellClip,
    /// See [`CellDrawingBounds`].
    pub(crate) cell_drawing_bounds: CellDrawingBounds,
    /// See [`CellFillSides`].
    pub(crate) cell_fill_sides: CellFillSides,
    /// See [`CellFillRows`].
    pub(crate) cell_fill_rows: CellFillRows,
    /// See [`CellTopBand`].
    pub(crate) cell_top_band: CellTopBand,
    /// See [`SpacedCellText`].
    pub(crate) spaced_cell_text: SpacedCellText,
    /// See [`SpacedColumns`].
    pub(crate) spaced_columns: SpacedColumns,
    /// See [`SpacedTableBreaks`].
    pub(crate) spaced_table_breaks: SpacedTableBreaks,
    /// See [`AutofitGrid`].
    pub(crate) autofit_grid: AutofitGrid,
    /// See [`StyleRegionBorders`].
    pub(crate) style_region_borders: StyleRegionBorders,
    /// See [`ContinuousSectionEnd`].
    pub(crate) continuous_section_end: ContinuousSectionEnd,
    /// See [`PageBreakBeforeSpace`].
    pub(crate) page_break_before_space: PageBreakBeforeSpace,
    /// See [`SavedDateWithoutPicture`].
    pub(crate) saved_date_without_picture: SavedDateWithoutPicture,
    /// See [`SymbolText`].
    pub(crate) symbol_text: SymbolText,
    /// See [`MirroredBracketText`].
    pub(crate) mirrored_bracket_text: MirroredBracketText,
    /// See [`ShapedGlyphText`].
    pub(crate) shaped_glyph_text: ShapedGlyphText,
    /// See [`BodyFieldResults`].
    pub(crate) body_field_results: BodyFieldResults,
    /// See [`TocLinkStyle`].
    pub(crate) toc_link_style: TocLinkStyle,
    /// See [`HeaderFieldResults`].
    pub(crate) header_field_results: HeaderFieldResults,
    /// See [`PropertyDateZone`].
    pub(crate) property_date_zone: PropertyDateZone,
    /// See [`SyntheticBoldWidth`].
    pub(crate) synthetic_bold_width: SyntheticBoldWidth,
    /// See [`WrittenWidths`].
    pub(crate) written_widths: WrittenWidths,
    /// See [`HelveticaLine`].
    pub(crate) helvetica_line: HelveticaLine,
    /// See [`OffPageObjects`].
    pub(crate) off_page_objects: OffPageObjects,
    /// See [`GlyphSegments`].
    pub(crate) glyph_segments: GlyphSegments,
    /// See [`DeviceAdvance`].
    pub(crate) device_advance: DeviceAdvance,
    /// See [`ComputedFieldFormat`].
    pub(crate) computed_field_format: ComputedFieldFormat,
    /// See [`ComputedFieldDecorations`].
    pub(crate) computed_field_decorations: ComputedFieldDecorations,
    /// See [`BuiltInList`].
    pub(crate) built_in_list: BuiltInList,
    /// See [`GlyphEdgeCheck`].
    pub(crate) glyph_edge_check: GlyphEdgeCheck,
    /// See [`SpacedLastGlyph`].
    pub(crate) spaced_last_glyph: SpacedLastGlyph,
    /// See [`StretchedSpaceShare`].
    pub(crate) stretched_space_share: StretchedSpaceShare,
    /// See [`NoBreakSpaceShare`].
    pub(crate) no_break_space_share: NoBreakSpaceShare,
    /// See [`FontSideChange`].
    pub(crate) font_side_change: FontSideChange,
    /// See [`FormatCharacterObjects`].
    pub(crate) format_character_objects: FormatCharacterObjects,
    /// See [`RightToLeftObjectCount`].
    pub(crate) right_to_left_object_count: RightToLeftObjectCount,
    /// See [`HyperlinkObjects`].
    pub(crate) hyperlink_objects: HyperlinkObjects,
    /// See [`FieldBuffer`].
    pub(crate) field_buffer: FieldBuffer,
    /// See [`CommentBuffer`].
    pub(crate) comment_buffer: CommentBuffer,
    /// See [`BookmarkText`].
    pub(crate) bookmark_text: BookmarkText,
    /// See [`ZeroRevision`].
    pub(crate) zero_revision: ZeroRevision,
    /// See [`RemovedTextObjects`].
    pub(crate) removed_text_objects: RemovedTextObjects,
    /// See [`ControlObjects`].
    pub(crate) control_objects: ControlObjects,
    /// See [`InsertionRevision`].
    pub(crate) insertion_revision: InsertionRevision,
    /// See [`NonBreakingHyphen`].
    pub(crate) non_breaking_hyphen: NonBreakingHyphen,
    /// See [`HintedFontSide`].
    pub(crate) hinted_font_side: HintedFontSide,
    /// See [`HintedSlot`].
    pub(crate) hinted_slot: HintedSlot,
    /// See [`ThemeEastAsian`].
    pub(crate) theme_east_asian: ThemeEastAsian,
    /// See [`WriterAdjustments`].
    pub(crate) writer_adjustments: WriterAdjustments,
    /// See [`PageWithoutSection`].
    pub(crate) page_without_section: PageWithoutSection,
    /// See [`TemplateFonts`].
    pub(crate) template_fonts: TemplateFonts,
    /// See [`LinkedStyles`].
    pub(crate) linked_styles: LinkedStyles,
    /// See [`ParagraphStyleReference`].
    pub(crate) paragraph_style_reference: ParagraphStyleReference,
    /// See [`InlineVmlSize`].
    pub(crate) inline_vml_size: InlineVmlSize,
    /// See [`VmlPictureRoom`].
    pub(crate) vml_picture_room: VmlPictureRoom,
    /// See [`VmlPreviewRoom`].
    pub(crate) vml_preview_room: VmlPreviewRoom,
    /// See [`VmlTextPath`].
    pub(crate) vml_text_path: VmlTextPath,
    /// See [`StoryMarginArea`].
    pub(crate) story_margin_area: StoryMarginArea,
    /// See [`KernedDeviceWidths`].
    pub(crate) kerned_device_widths: KernedDeviceWidths,
    /// See [`LigatureSteps`].
    pub(crate) ligature_steps: LigatureSteps,
    /// See [`KerningTableRead`].
    pub(crate) kerning_table_read: KerningTableRead,
    /// See [`LineStartHalves`].
    pub(crate) line_start_halves: LineStartHalves,
    /// See [`FirstLineIndentHalves`].
    pub(crate) first_line_indent_halves: FirstLineIndentHalves,
    /// See [`ColumnWidths`].
    pub(crate) column_widths: ColumnWidths,
    /// See [`RightToLeftSectionColumns`].
    pub(crate) right_to_left_section_columns: RightToLeftSectionColumns,
    /// See [`ColumnEdgeHalves`].
    pub(crate) column_edge_halves: ColumnEdgeHalves,
    /// See [`ColumnSeparator`].
    pub(crate) column_separator: ColumnSeparator,
    /// See [`HiddenMarkBorders`].
    pub(crate) hidden_mark_borders: HiddenMarkBorders,
    /// See [`WrapEdgeDot`].
    pub(crate) wrap_edge_dot: WrapEdgeDot,
    /// See [`NoteMarkPlace`].
    pub(crate) note_mark_place: NoteMarkPlace,
    /// See [`NoteStartSteps`].
    pub(crate) note_start_steps: NoteStartSteps,
    /// See [`TopHalves`].
    pub(crate) top_halves: TopHalves,
    /// See [`ShiftDots`].
    pub(crate) shift_dots: ShiftDots,
    /// See [`LineHeightUnit`].
    pub(crate) line_height_unit: LineHeightUnit,
    /// See [`TwipLengthUnit`].
    pub(crate) twip_length_unit: TwipLengthUnit,
    /// See [`ExactBoxLength`].
    pub(crate) exact_box_length: ExactBoxLength,
    /// See [`ExactFifthHalves`].
    pub(crate) exact_fifth_halves: ExactFifthHalves,
    /// See [`FooterHalves`].
    pub(crate) footer_halves: FooterHalves,
    /// See [`HeaderHalves`].
    pub(crate) header_halves: HeaderHalves,
    /// See [`AlignedEnds`].
    pub(crate) aligned_ends: AlignedEnds,
    /// See [`AlignedLineSegments`].
    pub(crate) aligned_line_segments: AlignedLineSegments,
    /// See [`AlignedTabEnd`].
    pub(crate) aligned_tab_end: AlignedTabEnd,
    /// See [`RightToLeftLineStart`].
    pub(crate) right_to_left_line_start: RightToLeftLineStart,
    /// See [`RightToLeftLineEdge`].
    pub(crate) right_to_left_line_edge: RightToLeftLineEdge,
    /// See [`RightToLeftJustifiedLine`].
    pub(crate) right_to_left_justified_line: RightToLeftJustifiedLine,
    /// See [`RightToLeftSteps`].
    pub(crate) right_to_left_steps: RightToLeftSteps,
    /// See [`RightToLeftPlacements`].
    pub(crate) right_to_left_placements: RightToLeftPlacements,
    /// See [`VerticalPlacements`].
    pub(crate) vertical_placements: VerticalPlacements,
    /// See [`RightToLeftCount`].
    pub(crate) right_to_left_count: RightToLeftCount,
    /// See [`RightToLeftCenteredLine`].
    pub(crate) right_to_left_centered_line: RightToLeftCenteredLine,
    /// See [`RightToLeftEndSpace`].
    pub(crate) right_to_left_end_space: RightToLeftEndSpace,
    /// See [`AlignedLineEdge`].
    pub(crate) aligned_line_edge: AlignedLineEdge,
    /// See [`PageOffsetSizes`].
    pub(crate) page_offset_sizes: PageOffsetSizes,
    /// See [`PageOffsetProduct`].
    pub(crate) page_offset_product: PageOffsetProduct,
    /// See [`CharacterSpacingCount`].
    pub(crate) character_spacing_count: CharacterSpacingCount,
    /// See [`RestartCount`].
    pub(crate) restart_count: RestartCount,
    /// See [`EdgeShares`].
    pub(crate) edge_shares: EdgeShares,
    /// See [`WriterSpacing`].
    pub(crate) writer_spacing: WriterSpacing,
    /// See [`WrittenSpacing`].
    pub(crate) written_spacing: WrittenSpacing,
    /// See [`ScaledGlyphs`].
    pub(crate) scaled_glyphs: ScaledGlyphs,
    /// See [`EastAsianAutoSpace`].
    pub(crate) east_asian_auto_space: EastAsianAutoSpace,
    /// See [`NoneBorders`].
    pub(crate) none_borders: NoneBorders,
    /// See [`BorderWidthUnit`].
    pub(crate) border_width_unit: BorderWidthUnit,
    /// See [`SectionEndBorders`].
    pub(crate) section_end_borders: SectionEndBorders,
    /// See [`MissingFontFallback`].
    pub(crate) missing_font_fallback: MissingFontFallback,
    /// See [`SuffixedFontNames`].
    pub(crate) suffixed_font_names: SuffixedFontNames,
    /// See [`ChartPlotArea`].
    pub(crate) chart_plot_area: ChartPlotArea,
    /// See [`InlineRoom`].
    pub(crate) inline_room: InlineRoom,
    /// See [`BorderSpace`].
    pub(crate) border_space: BorderSpace,
    /// See [`TopBorderPlace`].
    pub(crate) top_border_place: TopBorderPlace,
    /// See [`BorderTextEdge`].
    pub(crate) border_text_edge: BorderTextEdge,
    /// See [`MultipleTopBorder`].
    pub(crate) multiple_top_border: MultipleTopBorder,
    /// See [`MultipleBottomBorder`].
    pub(crate) multiple_bottom_border: MultipleBottomBorder,
    /// See [`BottomBorderSpaceAfter`].
    pub(crate) bottom_border_space_after: BottomBorderSpaceAfter,
    /// See [`BorderSides`].
    pub(crate) border_sides: BorderSides,
    /// See [`BetweenBorders`].
    pub(crate) between_borders: BetweenBorders,
    /// See [`BottomBorderParts`].
    pub(crate) bottom_border_parts: BottomBorderParts,
    /// See [`FillAtLines`].
    pub(crate) fill_at_lines: FillAtLines,
    /// See [`CellSpaceAfter`].
    pub(crate) cell_space_after: CellSpaceAfter,
    /// See [`AtLeastSpaceAfter`].
    pub(crate) at_least_space_after: AtLeastSpaceAfter,
    /// See [`CenteredLine`].
    pub(crate) centered_line: CenteredLine,
    /// See [`CenteredMultiple`].
    pub(crate) centered_multiple: CenteredMultiple,
    /// See [`SoftBreakLine`].
    pub(crate) soft_break_line: SoftBreakLine,
    /// See [`FixedAutoSpacing`].
    pub(crate) fixed_auto_spacing: FixedAutoSpacing,
    /// See [`CellEndListSpace`].
    pub(crate) cell_end_list_space: CellEndListSpace,
    /// See [`CheckBoxSide`].
    pub(crate) check_box_side: CheckBoxSide,
    /// See [`ListLevelReading`].
    pub(crate) list_level_reading: ListLevelReading,
    /// See [`RepeatedNoteId`].
    pub(crate) repeated_note_id: RepeatedNoteId,
    /// See [`SeparatorSpaceAfter`].
    pub(crate) separator_space_after: SeparatorSpaceAfter,
    /// See [`RestartSide`].
    pub(crate) restart_side: RestartSide,
    /// See [`PolygonWrap`].
    pub(crate) polygon_wrap: PolygonWrap,
    /// See [`StepEnd`].
    pub(crate) step_end: StepEnd,
    /// See [`LineWrapBand`].
    pub(crate) line_wrap_band: LineWrapBand,
    /// See [`OwnSeparatorSpacing`].
    pub(crate) own_separator_spacing: OwnSeparatorSpacing,
    /// See [`WidowForecast`].
    pub(crate) widow_forecast: WidowForecast,
    /// See [`LastPageBalance`].
    pub(crate) last_page_balance: LastPageBalance,
    /// See [`ColumnTopSpace`].
    pub(crate) column_top_space: ColumnTopSpace,
    /// See [`DeletedTableTop`].
    pub(crate) deleted_table_top: DeletedTableTop,
    /// See [`FootBorderRoom`].
    pub(crate) foot_border_room: FootBorderRoom,
    /// See [`FourComponentInks`].
    pub(crate) four_component_inks: FourComponentInks,
    /// See [`ComplexItalicFace`].
    pub(crate) complex_italic_face: ComplexItalicFace,
    /// See [`MissingComplexFont`].
    pub(crate) missing_complex_font: MissingComplexFont,
    /// See [`SubstituteFaces`].
    pub(crate) substitute_faces: SubstituteFaces,
    /// See [`ChartAxisRoom`].
    pub(crate) chart_axis_room: ChartAxisRoom,
    /// See [`ChartDataLabels`].
    pub(crate) chart_data_labels: ChartDataLabels,
    /// See [`ChartAutomaticTitle`].
    pub(crate) chart_automatic_title: ChartAutomaticTitle,
    /// See [`ChartStyleLook`].
    pub(crate) chart_style_look: ChartStyleLook,
    /// See [`ChartTitleText`].
    pub(crate) chart_title_text: ChartTitleText,
    /// See [`ChartTitlePlaceholder`].
    pub(crate) chart_title_placeholder: ChartTitlePlaceholder,
    /// See [`ChartScatter`].
    pub(crate) chart_scatter: ChartScatter,
    /// See [`ChartHorizontalBars`].
    pub(crate) chart_horizontal_bars: ChartHorizontalBars,
    /// See [`ChartPies`].
    pub(crate) chart_pies: ChartPies,
    /// See [`ChartPies3D`].
    pub(crate) chart_pies_3d: ChartPies3D,
    /// See [`ShapeShadows`].
    pub(crate) shape_shadows: ShapeShadows,
    /// See [`PictureShadows`].
    pub(crate) picture_shadows: PictureShadows,
    /// See [`PictureAspect`].
    pub(crate) picture_aspect: PictureAspect,
    /// See [`TextShadows`].
    pub(crate) text_shadows: TextShadows,
    /// See [`PictureTurns`].
    pub(crate) picture_turns: PictureTurns,
    /// See [`InlinePictureClip`].
    pub(crate) inline_picture_clip: InlinePictureClip,
    /// See [`ChartLineStrokes`].
    pub(crate) chart_line_strokes: ChartLineStrokes,
    /// See [`ChartMarkerLooks`].
    pub(crate) chart_marker_looks: ChartMarkerLooks,
    /// See [`ChartDeletedAxis`].
    pub(crate) chart_deleted_axis: ChartDeletedAxis,
    /// See [`ChartLowLabels`].
    pub(crate) chart_low_labels: ChartLowLabels,
    /// See [`ChartAxisTitles`].
    pub(crate) chart_axis_titles: ChartAxisTitles,
    /// See [`ChartBlankPoints`].
    pub(crate) chart_blank_points: ChartBlankPoints,
    /// See [`ChartStackedBars`].
    pub(crate) chart_stacked_bars: ChartStackedBars,
    /// See [`ChartPieExplosion`].
    pub(crate) chart_pie_explosion: ChartPieExplosion,
    /// See [`ChartBarVaryColors`].
    pub(crate) chart_bar_vary_colors: ChartBarVaryColors,
    /// See [`ChartDoughnuts`].
    pub(crate) chart_doughnuts: ChartDoughnuts,
    /// See [`ChartComboCharts`].
    pub(crate) chart_combo_charts: ChartComboCharts,
    /// See [`ChartAxisCrossings`].
    pub(crate) chart_axis_crossings: ChartAxisCrossings,
    /// See [`ChartLabelFormats`].
    pub(crate) chart_label_formats: ChartLabelFormats,
    /// See [`ChartAxisOrder`].
    pub(crate) chart_axis_order: ChartAxisOrder,
    /// See [`ChartSmoothLines`].
    pub(crate) chart_smooth_lines: ChartSmoothLines,
    /// See [`ChartLineClip`].
    pub(crate) chart_line_clip: ChartLineClip,
    /// See [`AlignedTabOverrun`].
    pub(crate) aligned_tab_overrun: AlignedTabOverrun,
    /// See [`NoteReferenceBreak`].
    pub(crate) note_reference_break: NoteReferenceBreak,
    /// See [`CellBreak`].
    pub(crate) cell_break: CellBreak,
    /// See [`StyleRefNoBreakSpace`].
    pub(crate) style_ref_no_break_space: StyleRefNoBreakSpace,
    /// See [`StyleRefTrailingSpaces`].
    pub(crate) style_ref_trailing_spaces: StyleRefTrailingSpaces,
    /// See [`LeftStopPastEnd`].
    pub(crate) left_stop_past_end: LeftStopPastEnd,
    /// See [`LeadingPageBreak`].
    pub(crate) leading_page_break: LeadingPageBreak,
    /// See [`FixedSpaceWidths`].
    pub(crate) fixed_space_widths: FixedSpaceWidths,
    /// See [`WordPerfectJustification`].
    pub(crate) word_perfect_justification: WordPerfectJustification,
    /// See [`KashidaJustification`].
    pub(crate) kashida_justification: KashidaJustification,
    /// See [`SeenKashidas`].
    pub(crate) seen_kashidas: SeenKashidas,
    /// See [`AutomaticHyphenation`].
    pub(crate) automatic_hyphenation: AutomaticHyphenation,
    /// See [`ScaledSteps`].
    pub(crate) scaled_steps: ScaledSteps,
    /// See [`UnderlineForms`].
    pub(crate) underline_forms: UnderlineForms,
    /// See [`PictureLinePlace`].
    pub(crate) picture_line_place: PictureLinePlace,
    /// See [`MetafileTopAscent`].
    pub(crate) metafile_top_ascent: MetafileTopAscent,
    /// See [`NumberForms`].
    pub(crate) number_forms: NumberForms,
}

/// The names of all quirks, as profiles name them.
pub const NAMES: [&str; 272] = [
    Markup::NAME,
    GridAdvances::NAME,
    PictureImage::NAME,
    SuperscriptRise::NAME,
    ScriptPlacement::NAME,
    ScriptSize::NAME,
    LineHeight::NAME,
    MultipleBaseline::NAME,
    SpaceBeforeAscent::NAME,
    DroppedSpaceBox::NAME,
    SingleBaseline::NAME,
    ExactBaseline::NAME,
    LowMultipleBaseline::NAME,
    ExactSpacedBottom::NAME,
    TableLines::NAME,
    CompoundTableLines::NAME,
    CenteredTableLines::NAME,
    CenteredTablePlace::NAME,
    CenteredTableLinesBefore15::NAME,
    TableEdgeHalves::NAME,
    CenteredTableTextBefore15::NAME,
    EdgeTableText::NAME,
    TurnedLineRoom::NAME,
    TurnedAcrossDots::NAME,
    TurnedPicture::NAME,
    BorderDashes::NAME,
    ThreeDBorders::NAME,
    LargeGapBorders::NAME,
    ArtPageBorders::NAME,
    PageBorderLines::NAME,
    CellTextRoom::NAME,
    UnsetCellMargins::NAME,
    RowBelowHeaders::NAME,
    RowLineRoom::NAME,
    MergedTopRoom::NAME,
    MergedCellFill::NAME,
    RowEndBorders::NAME,
    SplitMergeAlign::NAME,
    CarriedMergeMove::NAME,
    NestedRowMinimum::NAME,
    FloatingTableBreaks::NAME,
    LaterPartWidows::NAME,
    SplitRowFills::NAME,
    MergedCellLines::NAME,
    TableIndent::NAME,
    RightToLeftEdge::NAME,
    HiddenLastMark::NAME,
    HiddenHeaderFooterEnd::NAME,
    ExactRowMargin::NAME,
    CellFrames::NAME,
    DisplayFractionRoom::NAME,
    GrownDelimiters::NAME,
    ScriptRoom::NAME,
    VmlObjectSize::NAME,
    GridSingleLine::NAME,
    ObjectAscent::NAME,
    UnderlinedObjectRoom::NAME,
    ObjectLineMultiple::NAME,
    RaisedRunSpacing::NAME,
    FaceRoomSpacing::NAME,
    MarkFace::NAME,
    BlockedLines::NAME,
    BandHeight::NAME,
    FloatingTableTop::NAME,
    FloatingTableLeft::NAME,
    FrameLeft::NAME,
    BoxOutlineLeft::NAME,
    BoxTextTop::NAME,
    BoxLastLine::NAME,
    SmartArtLowSpacing::NAME,
    VmlBoxOutline::NAME,
    FrameFittedWidth::NAME,
    ListLabelDescent::NAME,
    LabelAloneRise::NAME,
    AlignmentWithNotes::NAME,
    InvisibleCharacters::NAME,
    TextBoxContent::NAME,
    TextBoxClip::NAME,
    TextBoxColumns::NAME,
    FromLine::NAME,
    CellClip::NAME,
    CellDrawingBounds::NAME,
    CellFillSides::NAME,
    CellFillRows::NAME,
    CellTopBand::NAME,
    SpacedCellText::NAME,
    SpacedColumns::NAME,
    SpacedTableBreaks::NAME,
    AutofitGrid::NAME,
    StyleRegionBorders::NAME,
    ContinuousSectionEnd::NAME,
    PageBreakBeforeSpace::NAME,
    SavedDateWithoutPicture::NAME,
    SymbolText::NAME,
    MirroredBracketText::NAME,
    ShapedGlyphText::NAME,
    BodyFieldResults::NAME,
    TocLinkStyle::NAME,
    HeaderFieldResults::NAME,
    PropertyDateZone::NAME,
    SyntheticBoldWidth::NAME,
    WrittenWidths::NAME,
    HelveticaLine::NAME,
    OffPageObjects::NAME,
    PageWithoutSection::NAME,
    GlyphSegments::NAME,
    DeviceAdvance::NAME,
    ComputedFieldFormat::NAME,
    ComputedFieldDecorations::NAME,
    BuiltInList::NAME,
    GlyphEdgeCheck::NAME,
    SpacedLastGlyph::NAME,
    StretchedSpaceShare::NAME,
    NoBreakSpaceShare::NAME,
    FontSideChange::NAME,
    FormatCharacterObjects::NAME,
    RightToLeftObjectCount::NAME,
    HyperlinkObjects::NAME,
    FieldBuffer::NAME,
    CommentBuffer::NAME,
    BookmarkText::NAME,
    ZeroRevision::NAME,
    RemovedTextObjects::NAME,
    ControlObjects::NAME,
    InsertionRevision::NAME,
    NonBreakingHyphen::NAME,
    HintedFontSide::NAME,
    HintedSlot::NAME,
    ThemeEastAsian::NAME,
    WriterAdjustments::NAME,
    TemplateFonts::NAME,
    LinkedStyles::NAME,
    ParagraphStyleReference::NAME,
    InlineVmlSize::NAME,
    VmlPictureRoom::NAME,
    VmlPreviewRoom::NAME,
    VmlTextPath::NAME,
    StoryMarginArea::NAME,
    KernedDeviceWidths::NAME,
    LigatureSteps::NAME,
    KerningTableRead::NAME,
    LineStartHalves::NAME,
    FirstLineIndentHalves::NAME,
    ColumnWidths::NAME,
    RightToLeftSectionColumns::NAME,
    ColumnEdgeHalves::NAME,
    ColumnSeparator::NAME,
    HiddenMarkBorders::NAME,
    WrapEdgeDot::NAME,
    NoteMarkPlace::NAME,
    NoteStartSteps::NAME,
    TopHalves::NAME,
    ShiftDots::NAME,
    LineHeightUnit::NAME,
    TwipLengthUnit::NAME,
    ExactBoxLength::NAME,
    ExactFifthHalves::NAME,
    FooterHalves::NAME,
    HeaderHalves::NAME,
    AlignedEnds::NAME,
    AlignedLineSegments::NAME,
    AlignedTabEnd::NAME,
    RightToLeftLineStart::NAME,
    RightToLeftLineEdge::NAME,
    RightToLeftJustifiedLine::NAME,
    RightToLeftSteps::NAME,
    RightToLeftPlacements::NAME,
    VerticalPlacements::NAME,
    RightToLeftCount::NAME,
    RightToLeftCenteredLine::NAME,
    RightToLeftEndSpace::NAME,
    AlignedLineEdge::NAME,
    PageOffsetSizes::NAME,
    PageOffsetProduct::NAME,
    CharacterSpacingCount::NAME,
    RestartCount::NAME,
    EdgeShares::NAME,
    WriterSpacing::NAME,
    WrittenSpacing::NAME,
    ScaledGlyphs::NAME,
    EastAsianAutoSpace::NAME,
    NoneBorders::NAME,
    BorderWidthUnit::NAME,
    SectionEndBorders::NAME,
    MissingFontFallback::NAME,
    SuffixedFontNames::NAME,
    ChartPlotArea::NAME,
    InlineRoom::NAME,
    BorderSpace::NAME,
    TopBorderPlace::NAME,
    BorderTextEdge::NAME,
    MultipleTopBorder::NAME,
    MultipleBottomBorder::NAME,
    BottomBorderSpaceAfter::NAME,
    BorderSides::NAME,
    BetweenBorders::NAME,
    BottomBorderParts::NAME,
    FillAtLines::NAME,
    CellSpaceAfter::NAME,
    AtLeastSpaceAfter::NAME,
    CenteredLine::NAME,
    CenteredMultiple::NAME,
    SoftBreakLine::NAME,
    FixedAutoSpacing::NAME,
    CellEndListSpace::NAME,
    CheckBoxSide::NAME,
    ListLevelReading::NAME,
    RepeatedNoteId::NAME,
    SeparatorSpaceAfter::NAME,
    RestartSide::NAME,
    PolygonWrap::NAME,
    StepEnd::NAME,
    LineWrapBand::NAME,
    OwnSeparatorSpacing::NAME,
    WidowForecast::NAME,
    LastPageBalance::NAME,
    ColumnTopSpace::NAME,
    DeletedTableTop::NAME,
    FootBorderRoom::NAME,
    FourComponentInks::NAME,
    ComplexItalicFace::NAME,
    ChartAxisRoom::NAME,
    ChartDataLabels::NAME,
    ChartAutomaticTitle::NAME,
    ChartStyleLook::NAME,
    ChartTitleText::NAME,
    ChartTitlePlaceholder::NAME,
    ChartScatter::NAME,
    ChartHorizontalBars::NAME,
    ChartPies::NAME,
    ChartPies3D::NAME,
    ShapeShadows::NAME,
    PictureShadows::NAME,
    PictureAspect::NAME,
    TextShadows::NAME,
    PictureTurns::NAME,
    InlinePictureClip::NAME,
    ChartLineStrokes::NAME,
    ChartMarkerLooks::NAME,
    ChartDeletedAxis::NAME,
    ChartLowLabels::NAME,
    ChartAxisTitles::NAME,
    ChartBlankPoints::NAME,
    ChartStackedBars::NAME,
    ChartPieExplosion::NAME,
    ChartBarVaryColors::NAME,
    ChartDoughnuts::NAME,
    ChartComboCharts::NAME,
    ChartAxisCrossings::NAME,
    ChartLabelFormats::NAME,
    ChartAxisOrder::NAME,
    ChartSmoothLines::NAME,
    ChartLineClip::NAME,
    AlignedTabOverrun::NAME,
    NoteReferenceBreak::NAME,
    CellBreak::NAME,
    StyleRefNoBreakSpace::NAME,
    StyleRefTrailingSpaces::NAME,
    LeftStopPastEnd::NAME,
    LeadingPageBreak::NAME,
    FixedSpaceWidths::NAME,
    WordPerfectJustification::NAME,
    KashidaJustification::NAME,
    SeenKashidas::NAME,
    MissingComplexFont::NAME,
    SubstituteFaces::NAME,
    AutomaticHyphenation::NAME,
    ScaledSteps::NAME,
    UnderlineForms::NAME,
    PictureLinePlace::NAME,
    MetafileTopAscent::NAME,
    NumberForms::NAME,
];

/// A quirk that a profile does not name, or names with a variant that the registry lacks. It
/// is not public, so that only quirks are public enums here.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub(crate) enum QuirkError {
    /// The profile names no variant of the quirk.
    Missing(&'static str),
    /// The profile names a variant that the quirk does not have.
    Variant(&'static str),
}

impl fmt::Display for QuirkError {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        match self {
            Self::Missing(quirk) => write!(f, "a profile names no variant of the quirk {quirk}"),
            Self::Variant(quirk) => {
                write!(f, "a profile names a variant that the quirk {quirk} lacks")
            }
        }
    }
}

impl std::error::Error for QuirkError {}

/// The variant of the quirk `Q` that `variant` gives by the quirk's name.
fn one<'a, Q: Quirk>(variant: &dyn Fn(&'static str) -> Option<&'a str>) -> Result<Q, QuirkError> {
    let name = variant(Q::NAME).ok_or(QuirkError::Missing(Q::NAME))?;
    Q::named(name).ok_or(QuirkError::Variant(Q::NAME))
}

impl Quirks {
    /// The quirks whose variants `variant` gives by quirk name.
    ///
    /// # Errors
    ///
    /// Returns an error when a quirk has no variant, or one that the registry lacks.
    #[expect(
        clippy::too_many_lines,
        reason = "one line for each quirk of the registry, which reads its variant by name"
    )]
    pub(crate) fn read<'a>(
        variant: &dyn Fn(&'static str) -> Option<&'a str>,
    ) -> Result<Self, QuirkError> {
        Ok(Self {
            markup: one(variant)?,
            grid_advances: one(variant)?,
            picture_image: one(variant)?,
            superscript_rise: one(variant)?,
            script_placement: one(variant)?,
            script_size: one(variant)?,
            line_height: one(variant)?,
            multiple_baseline: one(variant)?,
            space_before_ascent: one(variant)?,
            dropped_space_box: one(variant)?,
            single_baseline: one(variant)?,
            exact_baseline: one(variant)?,
            low_multiple_baseline: one(variant)?,
            exact_spaced_bottom: one(variant)?,
            table_lines: one(variant)?,
            compound_table_lines: one(variant)?,
            centered_table_lines: one(variant)?,
            centered_table_place: one(variant)?,
            centered_table_lines_before_15: one(variant)?,
            table_edge_halves: one(variant)?,
            centered_table_text_before_15: one(variant)?,
            edge_table_text: one(variant)?,
            turned_line_room: one(variant)?,
            turned_across_dots: one(variant)?,
            turned_picture: one(variant)?,
            border_dashes: one(variant)?,
            three_d_borders: one(variant)?,
            large_gap_borders: one(variant)?,
            art_page_borders: one(variant)?,
            page_border_lines: one(variant)?,
            cell_text_room: one(variant)?,
            unset_cell_margins: one(variant)?,
            row_below_headers: one(variant)?,
            row_line_room: one(variant)?,
            merged_top_room: one(variant)?,
            merged_cell_fill: one(variant)?,
            row_end_borders: one(variant)?,
            split_merge_align: one(variant)?,
            carried_merge_move: one(variant)?,
            nested_row_minimum: one(variant)?,
            floating_table_breaks: one(variant)?,
            later_part_widows: one(variant)?,
            split_row_fills: one(variant)?,
            merged_cell_lines: one(variant)?,
            table_indent: one(variant)?,
            right_to_left_edge: one(variant)?,
            hidden_last_mark: one(variant)?,
            hidden_header_footer_end: one(variant)?,
            exact_row_margin: one(variant)?,
            cell_frames: one(variant)?,
            display_fraction_room: one(variant)?,
            grown_delimiters: one(variant)?,
            script_room: one(variant)?,
            vml_object_size: one(variant)?,
            grid_single_line: one(variant)?,
            object_ascent: one(variant)?,
            underlined_object_room: one(variant)?,
            object_line_multiple: one(variant)?,
            raised_run_spacing: one(variant)?,
            face_room_spacing: one(variant)?,
            mark_face: one(variant)?,
            blocked_lines: one(variant)?,
            band_height: one(variant)?,
            floating_table_top: one(variant)?,
            floating_table_left: one(variant)?,
            frame_left: one(variant)?,
            box_outline_left: one(variant)?,
            box_text_top: one(variant)?,
            box_last_line: one(variant)?,
            smartart_low_spacing: one(variant)?,
            vml_box_outline: one(variant)?,
            frame_fitted_width: one(variant)?,
            list_label_descent: one(variant)?,
            label_alone_rise: one(variant)?,
            alignment_with_notes: one(variant)?,
            invisible_characters: one(variant)?,
            text_box_content: one(variant)?,
            text_box_clip: one(variant)?,
            text_box_columns: one(variant)?,
            from_line: one(variant)?,
            cell_clip: one(variant)?,
            cell_drawing_bounds: one(variant)?,
            cell_fill_sides: one(variant)?,
            cell_fill_rows: one(variant)?,
            cell_top_band: one(variant)?,
            spaced_cell_text: one(variant)?,
            spaced_columns: one(variant)?,
            spaced_table_breaks: one(variant)?,
            autofit_grid: one(variant)?,
            style_region_borders: one(variant)?,
            continuous_section_end: one(variant)?,
            page_break_before_space: one(variant)?,
            saved_date_without_picture: one(variant)?,
            symbol_text: one(variant)?,
            mirrored_bracket_text: one(variant)?,
            shaped_glyph_text: one(variant)?,
            body_field_results: one(variant)?,
            toc_link_style: one(variant)?,
            header_field_results: one(variant)?,
            property_date_zone: one(variant)?,
            synthetic_bold_width: one(variant)?,
            written_widths: one(variant)?,
            helvetica_line: one(variant)?,
            off_page_objects: one(variant)?,
            page_without_section: one(variant)?,
            glyph_segments: one(variant)?,
            device_advance: one(variant)?,
            computed_field_format: one(variant)?,
            computed_field_decorations: one(variant)?,
            built_in_list: one(variant)?,
            glyph_edge_check: one(variant)?,
            spaced_last_glyph: one(variant)?,
            stretched_space_share: one(variant)?,
            no_break_space_share: one(variant)?,
            font_side_change: one(variant)?,
            format_character_objects: one(variant)?,
            right_to_left_object_count: one(variant)?,
            hyperlink_objects: one(variant)?,
            field_buffer: one(variant)?,
            comment_buffer: one(variant)?,
            bookmark_text: one(variant)?,
            zero_revision: one(variant)?,
            removed_text_objects: one(variant)?,
            control_objects: one(variant)?,
            insertion_revision: one(variant)?,
            non_breaking_hyphen: one(variant)?,
            hinted_font_side: one(variant)?,
            hinted_slot: one(variant)?,
            theme_east_asian: one(variant)?,
            writer_adjustments: one(variant)?,
            template_fonts: one(variant)?,
            linked_styles: one(variant)?,
            paragraph_style_reference: one(variant)?,
            inline_vml_size: one(variant)?,
            vml_picture_room: one(variant)?,
            vml_preview_room: one(variant)?,
            vml_text_path: one(variant)?,
            story_margin_area: one(variant)?,
            kerned_device_widths: one(variant)?,
            ligature_steps: one(variant)?,
            kerning_table_read: one(variant)?,
            line_start_halves: one(variant)?,
            first_line_indent_halves: one(variant)?,
            column_widths: one(variant)?,
            right_to_left_section_columns: one(variant)?,
            column_edge_halves: one(variant)?,
            column_separator: one(variant)?,
            hidden_mark_borders: one(variant)?,
            wrap_edge_dot: one(variant)?,
            note_mark_place: one(variant)?,
            note_start_steps: one(variant)?,
            top_halves: one(variant)?,
            shift_dots: one(variant)?,
            line_height_unit: one(variant)?,
            twip_length_unit: one(variant)?,
            exact_box_length: one(variant)?,
            exact_fifth_halves: one(variant)?,
            footer_halves: one(variant)?,
            header_halves: one(variant)?,
            aligned_ends: one(variant)?,
            aligned_line_segments: one(variant)?,
            aligned_tab_end: one(variant)?,
            right_to_left_line_start: one(variant)?,
            right_to_left_line_edge: one(variant)?,
            right_to_left_justified_line: one(variant)?,
            right_to_left_steps: one(variant)?,
            right_to_left_placements: one(variant)?,
            vertical_placements: one(variant)?,
            right_to_left_count: one(variant)?,
            right_to_left_centered_line: one(variant)?,
            right_to_left_end_space: one(variant)?,
            aligned_line_edge: one(variant)?,
            page_offset_sizes: one(variant)?,
            page_offset_product: one(variant)?,
            character_spacing_count: one(variant)?,
            restart_count: one(variant)?,
            edge_shares: one(variant)?,
            writer_spacing: one(variant)?,
            written_spacing: one(variant)?,
            scaled_glyphs: one(variant)?,
            east_asian_auto_space: one(variant)?,
            none_borders: one(variant)?,
            border_width_unit: one(variant)?,
            section_end_borders: one(variant)?,
            missing_font_fallback: one(variant)?,
            suffixed_font_names: one(variant)?,
            chart_plot_area: one(variant)?,
            inline_room: one(variant)?,
            border_space: one(variant)?,
            top_border_place: one(variant)?,
            border_text_edge: one(variant)?,
            multiple_top_border: one(variant)?,
            multiple_bottom_border: one(variant)?,
            bottom_border_space_after: one(variant)?,
            border_sides: one(variant)?,
            between_borders: one(variant)?,
            bottom_border_parts: one(variant)?,
            fill_at_lines: one(variant)?,
            cell_space_after: one(variant)?,
            at_least_space_after: one(variant)?,
            centered_line: one(variant)?,
            centered_multiple: one(variant)?,
            soft_break_line: one(variant)?,
            fixed_auto_spacing: one(variant)?,
            cell_end_list_space: one(variant)?,
            check_box_side: one(variant)?,
            list_level_reading: one(variant)?,
            repeated_note_id: one(variant)?,
            separator_space_after: one(variant)?,
            restart_side: one(variant)?,
            polygon_wrap: one(variant)?,
            step_end: one(variant)?,
            line_wrap_band: one(variant)?,
            own_separator_spacing: one(variant)?,
            widow_forecast: one(variant)?,
            last_page_balance: one(variant)?,
            column_top_space: one(variant)?,
            deleted_table_top: one(variant)?,
            foot_border_room: one(variant)?,
            four_component_inks: one(variant)?,
            complex_italic_face: one(variant)?,
            chart_axis_room: one(variant)?,
            chart_data_labels: one(variant)?,
            chart_automatic_title: one(variant)?,
            chart_style_look: one(variant)?,
            chart_title_text: one(variant)?,
            chart_title_placeholder: one(variant)?,
            chart_scatter: one(variant)?,
            chart_horizontal_bars: one(variant)?,
            chart_pies: one(variant)?,
            chart_pies_3d: one(variant)?,
            shape_shadows: one(variant)?,
            picture_shadows: one(variant)?,
            picture_aspect: one(variant)?,
            text_shadows: one(variant)?,
            picture_turns: one(variant)?,
            inline_picture_clip: one(variant)?,
            chart_line_strokes: one(variant)?,
            chart_marker_looks: one(variant)?,
            chart_deleted_axis: one(variant)?,
            chart_low_labels: one(variant)?,
            chart_axis_titles: one(variant)?,
            chart_blank_points: one(variant)?,
            chart_stacked_bars: one(variant)?,
            chart_pie_explosion: one(variant)?,
            chart_bar_vary_colors: one(variant)?,
            chart_doughnuts: one(variant)?,
            chart_combo_charts: one(variant)?,
            chart_axis_crossings: one(variant)?,
            chart_label_formats: one(variant)?,
            chart_axis_order: one(variant)?,
            chart_smooth_lines: one(variant)?,
            chart_line_clip: one(variant)?,
            aligned_tab_overrun: one(variant)?,
            note_reference_break: one(variant)?,
            cell_break: one(variant)?,
            style_ref_no_break_space: one(variant)?,
            style_ref_trailing_spaces: one(variant)?,
            left_stop_past_end: one(variant)?,
            leading_page_break: one(variant)?,
            fixed_space_widths: one(variant)?,
            word_perfect_justification: one(variant)?,
            kashida_justification: one(variant)?,
            seen_kashidas: one(variant)?,
            missing_complex_font: one(variant)?,
            substitute_faces: one(variant)?,
            automatic_hyphenation: one(variant)?,
            scaled_steps: one(variant)?,
            underline_forms: one(variant)?,
            picture_line_place: one(variant)?,
            metafile_top_ascent: one(variant)?,
            number_forms: one(variant)?,
        })
    }
}

impl Quirks {
    /// The variant of each quirk, by its names in a profile, in the order of the registry.
    #[cfg(any(test, feature = "development"))]
    #[expect(
        clippy::too_many_lines,
        reason = "one line for each quirk of the registry, which names its variant"
    )]
    pub(crate) fn variants(&self) -> [Chosen; NAMES.len()] {
        [
            chosen(self.markup),
            chosen(self.grid_advances),
            chosen(self.picture_image),
            chosen(self.superscript_rise),
            chosen(self.script_placement),
            chosen(self.script_size),
            chosen(self.line_height),
            chosen(self.multiple_baseline),
            chosen(self.space_before_ascent),
            chosen(self.dropped_space_box),
            chosen(self.single_baseline),
            chosen(self.exact_baseline),
            chosen(self.low_multiple_baseline),
            chosen(self.exact_spaced_bottom),
            chosen(self.table_lines),
            chosen(self.compound_table_lines),
            chosen(self.centered_table_lines),
            chosen(self.centered_table_place),
            chosen(self.centered_table_lines_before_15),
            chosen(self.table_edge_halves),
            chosen(self.centered_table_text_before_15),
            chosen(self.edge_table_text),
            chosen(self.turned_line_room),
            chosen(self.turned_across_dots),
            chosen(self.turned_picture),
            chosen(self.border_dashes),
            chosen(self.three_d_borders),
            chosen(self.large_gap_borders),
            chosen(self.art_page_borders),
            chosen(self.page_border_lines),
            chosen(self.cell_text_room),
            chosen(self.unset_cell_margins),
            chosen(self.row_below_headers),
            chosen(self.row_line_room),
            chosen(self.merged_top_room),
            chosen(self.merged_cell_fill),
            chosen(self.row_end_borders),
            chosen(self.split_merge_align),
            chosen(self.carried_merge_move),
            chosen(self.nested_row_minimum),
            chosen(self.floating_table_breaks),
            chosen(self.later_part_widows),
            chosen(self.split_row_fills),
            chosen(self.merged_cell_lines),
            chosen(self.table_indent),
            chosen(self.right_to_left_edge),
            chosen(self.hidden_last_mark),
            chosen(self.hidden_header_footer_end),
            chosen(self.exact_row_margin),
            chosen(self.cell_frames),
            chosen(self.display_fraction_room),
            chosen(self.grown_delimiters),
            chosen(self.script_room),
            chosen(self.vml_object_size),
            chosen(self.grid_single_line),
            chosen(self.object_ascent),
            chosen(self.underlined_object_room),
            chosen(self.object_line_multiple),
            chosen(self.raised_run_spacing),
            chosen(self.face_room_spacing),
            chosen(self.mark_face),
            chosen(self.blocked_lines),
            chosen(self.band_height),
            chosen(self.floating_table_top),
            chosen(self.floating_table_left),
            chosen(self.frame_left),
            chosen(self.box_outline_left),
            chosen(self.box_text_top),
            chosen(self.box_last_line),
            chosen(self.smartart_low_spacing),
            chosen(self.vml_box_outline),
            chosen(self.frame_fitted_width),
            chosen(self.list_label_descent),
            chosen(self.label_alone_rise),
            chosen(self.alignment_with_notes),
            chosen(self.invisible_characters),
            chosen(self.text_box_content),
            chosen(self.text_box_clip),
            chosen(self.text_box_columns),
            chosen(self.from_line),
            chosen(self.cell_clip),
            chosen(self.cell_drawing_bounds),
            chosen(self.cell_fill_sides),
            chosen(self.cell_fill_rows),
            chosen(self.cell_top_band),
            chosen(self.spaced_cell_text),
            chosen(self.spaced_columns),
            chosen(self.spaced_table_breaks),
            chosen(self.autofit_grid),
            chosen(self.style_region_borders),
            chosen(self.continuous_section_end),
            chosen(self.page_break_before_space),
            chosen(self.saved_date_without_picture),
            chosen(self.symbol_text),
            chosen(self.mirrored_bracket_text),
            chosen(self.shaped_glyph_text),
            chosen(self.body_field_results),
            chosen(self.toc_link_style),
            chosen(self.header_field_results),
            chosen(self.property_date_zone),
            chosen(self.synthetic_bold_width),
            chosen(self.written_widths),
            chosen(self.helvetica_line),
            chosen(self.off_page_objects),
            chosen(self.page_without_section),
            chosen(self.glyph_segments),
            chosen(self.device_advance),
            chosen(self.computed_field_format),
            chosen(self.computed_field_decorations),
            chosen(self.built_in_list),
            chosen(self.glyph_edge_check),
            chosen(self.spaced_last_glyph),
            chosen(self.stretched_space_share),
            chosen(self.no_break_space_share),
            chosen(self.font_side_change),
            chosen(self.format_character_objects),
            chosen(self.right_to_left_object_count),
            chosen(self.hyperlink_objects),
            chosen(self.field_buffer),
            chosen(self.comment_buffer),
            chosen(self.bookmark_text),
            chosen(self.zero_revision),
            chosen(self.removed_text_objects),
            chosen(self.control_objects),
            chosen(self.insertion_revision),
            chosen(self.non_breaking_hyphen),
            chosen(self.hinted_font_side),
            chosen(self.hinted_slot),
            chosen(self.theme_east_asian),
            chosen(self.writer_adjustments),
            chosen(self.template_fonts),
            chosen(self.linked_styles),
            chosen(self.paragraph_style_reference),
            chosen(self.inline_vml_size),
            chosen(self.vml_picture_room),
            chosen(self.vml_preview_room),
            chosen(self.vml_text_path),
            chosen(self.story_margin_area),
            chosen(self.kerned_device_widths),
            chosen(self.ligature_steps),
            chosen(self.kerning_table_read),
            chosen(self.line_start_halves),
            chosen(self.first_line_indent_halves),
            chosen(self.column_widths),
            chosen(self.right_to_left_section_columns),
            chosen(self.column_edge_halves),
            chosen(self.column_separator),
            chosen(self.hidden_mark_borders),
            chosen(self.wrap_edge_dot),
            chosen(self.note_mark_place),
            chosen(self.note_start_steps),
            chosen(self.top_halves),
            chosen(self.shift_dots),
            chosen(self.line_height_unit),
            chosen(self.twip_length_unit),
            chosen(self.exact_box_length),
            chosen(self.exact_fifth_halves),
            chosen(self.footer_halves),
            chosen(self.header_halves),
            chosen(self.aligned_ends),
            chosen(self.aligned_line_segments),
            chosen(self.aligned_tab_end),
            chosen(self.right_to_left_line_start),
            chosen(self.right_to_left_line_edge),
            chosen(self.right_to_left_justified_line),
            chosen(self.right_to_left_steps),
            chosen(self.right_to_left_placements),
            chosen(self.vertical_placements),
            chosen(self.right_to_left_count),
            chosen(self.right_to_left_centered_line),
            chosen(self.right_to_left_end_space),
            chosen(self.aligned_line_edge),
            chosen(self.page_offset_sizes),
            chosen(self.page_offset_product),
            chosen(self.character_spacing_count),
            chosen(self.restart_count),
            chosen(self.edge_shares),
            chosen(self.writer_spacing),
            chosen(self.written_spacing),
            chosen(self.scaled_glyphs),
            chosen(self.east_asian_auto_space),
            chosen(self.none_borders),
            chosen(self.border_width_unit),
            chosen(self.section_end_borders),
            chosen(self.missing_font_fallback),
            chosen(self.suffixed_font_names),
            chosen(self.chart_plot_area),
            chosen(self.inline_room),
            chosen(self.border_space),
            chosen(self.top_border_place),
            chosen(self.border_text_edge),
            chosen(self.multiple_top_border),
            chosen(self.multiple_bottom_border),
            chosen(self.bottom_border_space_after),
            chosen(self.border_sides),
            chosen(self.between_borders),
            chosen(self.bottom_border_parts),
            chosen(self.fill_at_lines),
            chosen(self.cell_space_after),
            chosen(self.at_least_space_after),
            chosen(self.centered_line),
            chosen(self.centered_multiple),
            chosen(self.soft_break_line),
            chosen(self.fixed_auto_spacing),
            chosen(self.cell_end_list_space),
            chosen(self.check_box_side),
            chosen(self.list_level_reading),
            chosen(self.repeated_note_id),
            chosen(self.separator_space_after),
            chosen(self.restart_side),
            chosen(self.polygon_wrap),
            chosen(self.step_end),
            chosen(self.line_wrap_band),
            chosen(self.own_separator_spacing),
            chosen(self.widow_forecast),
            chosen(self.last_page_balance),
            chosen(self.column_top_space),
            chosen(self.deleted_table_top),
            chosen(self.foot_border_room),
            chosen(self.four_component_inks),
            chosen(self.complex_italic_face),
            chosen(self.chart_axis_room),
            chosen(self.chart_data_labels),
            chosen(self.chart_automatic_title),
            chosen(self.chart_style_look),
            chosen(self.chart_title_text),
            chosen(self.chart_title_placeholder),
            chosen(self.chart_scatter),
            chosen(self.chart_horizontal_bars),
            chosen(self.chart_pies),
            chosen(self.chart_pies_3d),
            chosen(self.shape_shadows),
            chosen(self.picture_shadows),
            chosen(self.picture_aspect),
            chosen(self.text_shadows),
            chosen(self.picture_turns),
            chosen(self.inline_picture_clip),
            chosen(self.chart_line_strokes),
            chosen(self.chart_marker_looks),
            chosen(self.chart_deleted_axis),
            chosen(self.chart_low_labels),
            chosen(self.chart_axis_titles),
            chosen(self.chart_blank_points),
            chosen(self.chart_stacked_bars),
            chosen(self.chart_pie_explosion),
            chosen(self.chart_bar_vary_colors),
            chosen(self.chart_doughnuts),
            chosen(self.chart_combo_charts),
            chosen(self.chart_axis_crossings),
            chosen(self.chart_label_formats),
            chosen(self.chart_axis_order),
            chosen(self.chart_smooth_lines),
            chosen(self.chart_line_clip),
            chosen(self.aligned_tab_overrun),
            chosen(self.note_reference_break),
            chosen(self.cell_break),
            chosen(self.style_ref_no_break_space),
            chosen(self.style_ref_trailing_spaces),
            chosen(self.left_stop_past_end),
            chosen(self.leading_page_break),
            chosen(self.fixed_space_widths),
            chosen(self.word_perfect_justification),
            chosen(self.kashida_justification),
            chosen(self.seen_kashidas),
            chosen(self.missing_complex_font),
            chosen(self.substitute_faces),
            chosen(self.automatic_hyphenation),
            chosen(self.scaled_steps),
            chosen(self.underline_forms),
            chosen(self.picture_line_place),
            chosen(self.metafile_top_ascent),
            chosen(self.number_forms),
        ]
    }
}

/// The variant that a profile takes of one quirk, by the names in a profile.
#[cfg(any(test, feature = "development"))]
#[derive(Clone, Copy, Debug)]
pub(crate) struct Chosen {
    /// The quirk's name.
    pub(crate) quirk: &'static str,
    /// The name of the variant taken.
    pub(crate) variant: &'static str,
    /// Whether a name is one of the quirk's variants.
    names: fn(&str) -> bool,
}

#[cfg(any(test, feature = "development"))]
impl Chosen {
    /// Whether the quirk has a variant of the name `name`.
    pub(crate) fn has(&self, name: &str) -> bool {
        (self.names)(name)
    }
}

/// The quirk and its variant `variant` by their names in a profile.
#[cfg(any(test, feature = "development"))]
fn chosen<Q: Quirk + PartialEq>(variant: Q) -> Chosen {
    Chosen {
        quirk: Q::NAME,
        variant: Q::VARIANTS
            .iter()
            .find(|(_, own)| *own == variant)
            .map_or("", |(name, _)| *name),
        names: |name| Q::named(name).is_some(),
    }
}

#[cfg(test)]
mod tests {
    use super::{Markup, Quirk, QuirkError, Quirks};

    #[test]
    fn finds_variants_by_name_and_refuses_missing_or_unknown_ones() {
        assert_eq!(
            Markup::named("PrintsMarkupArea"),
            Some(Markup::PrintsMarkupArea)
        );
        assert_eq!(
            Markup::named("PrintsNoMarkup"),
            Some(Markup::PrintsNoMarkup)
        );
        assert_eq!(Markup::named("Never"), None);
        assert_eq!(Quirks::read(&|_| None), Err(QuirkError::Missing("Markup")));
        assert_eq!(
            Quirks::read(&|_| Some("Nothing")),
            Err(QuirkError::Variant("Markup"))
        );
        assert!(QuirkError::Variant("X").to_string().contains("lacks"));
        assert!(QuirkError::Missing("X").to_string().contains("no variant"));
    }

    #[test]
    fn steps_a_kerned_run_at_the_nearest_dot_with_the_open_type_features_setting_on_nearest() {
        use super::KernedDeviceWidths::{
            Nearest, NearestOrOwn, Own, OwnWithKerningOnItsOwn, Rounded,
        };
        use crate::mode::{CompatibilityMode, ModeRules};
        use f_office_fonts::KerningSource;
        let mode_14 = ModeRules::of(CompatibilityMode::Mode14);
        let with_setting = mode_14.with_open_type_features(true);
        // Before mode 15, `Nearest` steps a GPOS-kerned run at the nearest dot with the
        // setting only; `NearestOrOwn` asks the mode alone.
        assert_eq!(
            Nearest.in_run(mode_14, KerningSource::Gpos),
            OwnWithKerningOnItsOwn
        );
        assert_eq!(Nearest.in_run(with_setting, KerningSource::Gpos), Nearest);
        assert_eq!(NearestOrOwn.in_run(with_setting, KerningSource::Gpos), Own);
        // A legacy-kern face rounds the advance with the setting and from mode 15, and steps by
        // its device widths with the kerning on its own before.
        assert_eq!(
            Nearest.in_run(with_setting, KerningSource::KernTable),
            Rounded
        );
        assert_eq!(
            Nearest.in_run(mode_14, KerningSource::KernTable),
            OwnWithKerningOnItsOwn
        );
        let mode_15 = ModeRules::of(CompatibilityMode::Mode15);
        assert_eq!(Nearest.in_run(mode_15, KerningSource::KernTable), Rounded);
        assert_eq!(NearestOrOwn.in_run(mode_15, KerningSource::Gpos), Nearest);
    }
}