A Tool For Enumerating FDArray Elements & Their CIDs

On this 29th day of February in the year 2012, which is a leap year, I decided that it would be a good idea to whip up a tool (written in Perl, of course) that enumerates the FDArray elements in a CID-keyed font, by name and index, and to list the CIDs that are assigned to it. Also reporting the ROS is useful. This tool, called fdarray-check.pl, makes use of the AFDKO tx tool, and massages its output into a form that is much more human-readable, and which can be repurposed.

I decided to develop this tool so that it would become easier to use the CIDs and CID ranges that correspond to the glyphs in each FDArray element of a CID-keyed font — whether it is a CIDFont resource, CFF, or OpenType/CFF font — which can then be used as the argument to the “-g” option that is supported by many AFDKO tools, such as tx and stemHist.

Using this tool is simple. A CID-keyed font is the argument, as demonstrated below by specifying a CID-keyed OpenType/CFF font:

% fdarray-check.pl KazurakiSP2N-Light.otf

Here is the output:

Detected ROS: Adobe-Identity-0
KazurakiSP2N-Light-Dingbats (0): 151-165,167-201,1861-1863,2014-2028,2030-2060,3720-3722
KazurakiSP2N-Light-Generic (1): 0
KazurakiSP2N-Light-Kana (2): 166,202-377,2029,2061-2236,3723-3775
KazurakiSP2N-Light-Kanji (3): 378-1860,2237-3719
KazurakiSP2N-Light-Proportional (4): 1-150
KazurakiSP2N-Light-ProportionalRot (5): 1864-2013

The tool also reports whether GIDs are not equal to CIDs, and starting from which GID/CID pair:

% fdarray-check.pl HeiseiKakuGoStd-W3.otf
NOTE: GIDs do not equal CIDs starting from GID+8359/CID+8720!
Detected ROS: Adobe-Japan1-3
HeiseiKakuGoStd-W3-AlphaNum (0): 7555-7584,8061-8137,8184-8185,8224-8228,8286-8302
HeiseiKakuGoStd-W3-Alphabetic (1): 780-841,1011-1124
HeiseiKakuGoStd-W3-Dingbats (2): 423-424,504-514,633-659,661-779,7478,7585-7612,7624-7632,7887-7890,7892-7917,7940-7957,8005-8053,8055-8060,8166-8183,8186-8190,8192-8195,8206-8222,8268-8283,8303-8312,8327-8358
HeiseiKakuGoStd-W3-DingbatsRot (3): 9263-9275
HeiseiKakuGoStd-W3-Generic (4): 0,422,425-500,629,7479-7554,8229-8263
HeiseiKakuGoStd-W3-GenericRot (5): 9276-9353
HeiseiKakuGoStd-W3-HKana (6): 326-389,391-421,515-598
HeiseiKakuGoStd-W3-HKanaRot (7): 9084-9262
HeiseiKakuGoStd-W3-HRoman (8): 231-325,390,501-503,599-628,630-632
HeiseiKakuGoStd-W3-HRomanRot (9): 8950-9081
HeiseiKakuGoStd-W3-Kana (10): 660,842-1010,7891,7918-7939,7958-7960,8264-8265,8313-8316
HeiseiKakuGoStd-W3-Kanji (11): 1125-7477,7613-7623,7633-7886,7961-8004,8054,8138-8165,8191,8196-8205,8223,8266-8267,8284-8285,8317-8326
HeiseiKakuGoStd-W3-Proportional (12): 1-230
HeiseiKakuGoStd-W3-ProportionalRot (13): 8720-8949

If the output of this tool is used as the argument of the “-g” option, which specifies GIDs, not CIDs, and if GIDs do not equal CIDs in the font, the results will be incorrect. The slash serves as a prefix that explicitly specifies CIDs, and the “-p” option will prefix the CIDs with a slash so that the output can be readily used with various AFDKO tools:

% fdarray-check.pl -p HeiseiKakuGoStd-W3.otf
NOTE: GIDs do not equal CIDs starting from GID+8359/CID+8720!
Detected ROS: Adobe-Japan1-3
HeiseiKakuGoStd-W3-AlphaNum (0): /7555-/7584,/8061-/8137,/8184-/8185,/8224-/8228,/8286-/8302
HeiseiKakuGoStd-W3-Alphabetic (1): /780-/841,/1011-/1124
HeiseiKakuGoStd-W3-Dingbats (2): /423-/424,/504-/514,/633-/659,/661-/779,/7478,/7585-/7612,/7624-/7632,/7887-/7890,/7892-/7917,/7940-/7957,/8005-/8053,/8055-/8060,/8166-/8183,/8186-/8190,/8192-/8195,/8206-/8222,/8268-/8283,/8303-/8312,/8327-/8358
HeiseiKakuGoStd-W3-DingbatsRot (3): /9263-/9275
HeiseiKakuGoStd-W3-Generic (4): /0,/422,/425-/500,/629,/7479-/7554,/8229-/8263
HeiseiKakuGoStd-W3-GenericRot (5): /9276-/9353
HeiseiKakuGoStd-W3-HKana (6): /326-/389,/391-/421,/515-/598
HeiseiKakuGoStd-W3-HKanaRot (7): /9084-/9262
HeiseiKakuGoStd-W3-HRoman (8): /231-/325,/390,/501-/503,/599-/628,/630-/632
HeiseiKakuGoStd-W3-HRomanRot (9): /8950-/9081
HeiseiKakuGoStd-W3-Kana (10): /660,/842-/1010,/7891,/7918-/7939,/7958-/7960,/8264-/8265,/8313-/8316
HeiseiKakuGoStd-W3-Kanji (11): /1125-/7477,/7613-/7623,/7633-/7886,/7961-/8004,/8054,/8138-/8165,/8191,/8196-/8205,/8223,/8266-/8267,/8284-/8285,/8317-/8326
HeiseiKakuGoStd-W3-Proportional (12): /1-/230
HeiseiKakuGoStd-W3-ProportionalRot (13): /8720-/8949

Lastly, if you attempt to use this tool with a name-keyed font, it returns an error and exits:

% fdarray-check.pl MinionPro-Regular.otf
ERROR: name-keyed font! Quitting...

Enjoy!

May 12, 2012 UPDATE: The fdarray-check.pl tool was updated to also report, in parentheses after the list of CIDs and CID ranges, the total number of CIDs in each FDArray element.

One Response to A Tool For Enumerating FDArray Elements & Their CIDs

  1. BTW, the output of this tool, when run against the “extreme” OpenType/CFF font that is featured in the 01/26/2012 CJK Type Blog post is quite interesting and revealing:

    % fdarray-check.pl UnicodeAll.otf
    Detected ROS: Adobe-Identity-0
    UnicodeAll-0 (0): 0-256
    UnicodeAll-1 (1): 257-512
    UnicodeAll-2 (2): 513-768
    UnicodeAll-3 (3): 769-1024
    UnicodeAll-4 (4): 1025-1280
    UnicodeAll-5 (5): 1281-1536
    UnicodeAll-6 (6): 1537-1792
    UnicodeAll-7 (7): 1793-2048
    UnicodeAll-8 (8): 2049-2304
    UnicodeAll-9 (9): 2305-2560
    UnicodeAll-10 (10): 2561-2816
    UnicodeAll-11 (11): 2817-3072
    UnicodeAll-12 (12): 3073-3328
    UnicodeAll-13 (13): 3329-3584
    UnicodeAll-14 (14): 3585-3840
    UnicodeAll-15 (15): 3841-4096
    UnicodeAll-16 (16): 4097-4352
    UnicodeAll-17 (17): 4353-4608
    UnicodeAll-18 (18): 4609-4864
    UnicodeAll-19 (19): 4865-5120
    UnicodeAll-20 (20): 5121-5376
    UnicodeAll-21 (21): 5377-5632
    UnicodeAll-22 (22): 5633-5888
    UnicodeAll-23 (23): 5889-6144
    UnicodeAll-24 (24): 6145-6400
    UnicodeAll-25 (25): 6401-6656
    UnicodeAll-26 (26): 6657-6912
    UnicodeAll-27 (27): 6913-7168
    UnicodeAll-28 (28): 7169-7424
    UnicodeAll-29 (29): 7425-7680
    UnicodeAll-30 (30): 7681-7936
    UnicodeAll-31 (31): 7937-8192
    UnicodeAll-32 (32): 8193-8448
    UnicodeAll-33 (33): 8449-8704
    UnicodeAll-34 (34): 8705-8960
    UnicodeAll-35 (35): 8961-9216
    UnicodeAll-36 (36): 9217-9472
    UnicodeAll-37 (37): 9473-9728
    UnicodeAll-38 (38): 9729-9984
    UnicodeAll-39 (39): 9985-10240
    UnicodeAll-40 (40): 10241-10496
    UnicodeAll-41 (41): 10497-10752
    UnicodeAll-42 (42): 10753-11008
    UnicodeAll-43 (43): 11009-11264
    UnicodeAll-44 (44): 11265-11520
    UnicodeAll-45 (45): 11521-11776
    UnicodeAll-46 (46): 11777-12032
    UnicodeAll-47 (47): 12033-12288
    UnicodeAll-48 (48): 12289-12544
    UnicodeAll-49 (49): 12545-12800
    UnicodeAll-50 (50): 12801-13056
    UnicodeAll-51 (51): 13057-13312
    UnicodeAll-52 (52): 13313-13568
    UnicodeAll-53 (53): 13569-13824
    UnicodeAll-54 (54): 13825-14080
    UnicodeAll-55 (55): 14081-14336
    UnicodeAll-56 (56): 14337-14592
    UnicodeAll-57 (57): 14593-14848
    UnicodeAll-58 (58): 14849-15104
    UnicodeAll-59 (59): 15105-15360
    UnicodeAll-60 (60): 15361-15616
    UnicodeAll-61 (61): 15617-15872
    UnicodeAll-62 (62): 15873-16128
    UnicodeAll-63 (63): 16129-16384
    UnicodeAll-64 (64): 16385-16640
    UnicodeAll-65 (65): 16641-16896
    UnicodeAll-66 (66): 16897-17152
    UnicodeAll-67 (67): 17153-17408
    UnicodeAll-68 (68): 17409-17664
    UnicodeAll-69 (69): 17665-17920
    UnicodeAll-70 (70): 17921-18176
    UnicodeAll-71 (71): 18177-18432
    UnicodeAll-72 (72): 18433-18688
    UnicodeAll-73 (73): 18689-18944
    UnicodeAll-74 (74): 18945-19200
    UnicodeAll-75 (75): 19201-19456
    UnicodeAll-76 (76): 19457-19712
    UnicodeAll-77 (77): 19713-19968
    UnicodeAll-78 (78): 19969-20224
    UnicodeAll-79 (79): 20225-20480
    UnicodeAll-80 (80): 20481-20736
    UnicodeAll-81 (81): 20737-20992
    UnicodeAll-82 (82): 20993-21248
    UnicodeAll-83 (83): 21249-21504
    UnicodeAll-84 (84): 21505-21760
    UnicodeAll-85 (85): 21761-22016
    UnicodeAll-86 (86): 22017-22272
    UnicodeAll-87 (87): 22273-22528
    UnicodeAll-88 (88): 22529-22784
    UnicodeAll-89 (89): 22785-23040
    UnicodeAll-90 (90): 23041-23296
    UnicodeAll-91 (91): 23297-23552
    UnicodeAll-92 (92): 23553-23808
    UnicodeAll-93 (93): 23809-24064
    UnicodeAll-94 (94): 24065-24320
    UnicodeAll-95 (95): 24321-24576
    UnicodeAll-96 (96): 24577-24832
    UnicodeAll-97 (97): 24833-25088
    UnicodeAll-98 (98): 25089-25344
    UnicodeAll-99 (99): 25345-25600
    UnicodeAll-100 (100): 25601-25856
    UnicodeAll-101 (101): 25857-26112
    UnicodeAll-102 (102): 26113-26368
    UnicodeAll-103 (103): 26369-26624
    UnicodeAll-104 (104): 26625-26880
    UnicodeAll-105 (105): 26881-27136
    UnicodeAll-106 (106): 27137-27392
    UnicodeAll-107 (107): 27393-27648
    UnicodeAll-108 (108): 27649-27904
    UnicodeAll-109 (109): 27905-28160
    UnicodeAll-110 (110): 28161-28416
    UnicodeAll-111 (111): 28417-28672
    UnicodeAll-112 (112): 28673-28928
    UnicodeAll-113 (113): 28929-29184
    UnicodeAll-114 (114): 29185-29440
    UnicodeAll-115 (115): 29441-29696
    UnicodeAll-116 (116): 29697-29952
    UnicodeAll-117 (117): 29953-30208
    UnicodeAll-118 (118): 30209-30464
    UnicodeAll-119 (119): 30465-30720
    UnicodeAll-120 (120): 30721-30976
    UnicodeAll-121 (121): 30977-31232
    UnicodeAll-122 (122): 31233-31488
    UnicodeAll-123 (123): 31489-31744
    UnicodeAll-124 (124): 31745-32000
    UnicodeAll-125 (125): 32001-32256
    UnicodeAll-126 (126): 32257-32512
    UnicodeAll-127 (127): 32513-32768
    UnicodeAll-128 (128): 32769-33024
    UnicodeAll-129 (129): 33025-33280
    UnicodeAll-130 (130): 33281-33536
    UnicodeAll-131 (131): 33537-33792
    UnicodeAll-132 (132): 33793-34048
    UnicodeAll-133 (133): 34049-34304
    UnicodeAll-134 (134): 34305-34560
    UnicodeAll-135 (135): 34561-34816
    UnicodeAll-136 (136): 34817-35072
    UnicodeAll-137 (137): 35073-35328
    UnicodeAll-138 (138): 35329-35584
    UnicodeAll-139 (139): 35585-35840
    UnicodeAll-140 (140): 35841-36096
    UnicodeAll-141 (141): 36097-36352
    UnicodeAll-142 (142): 36353-36608
    UnicodeAll-143 (143): 36609-36864
    UnicodeAll-144 (144): 36865-37120
    UnicodeAll-145 (145): 37121-37376
    UnicodeAll-146 (146): 37377-37632
    UnicodeAll-147 (147): 37633-37888
    UnicodeAll-148 (148): 37889-38144
    UnicodeAll-149 (149): 38145-38400
    UnicodeAll-150 (150): 38401-38656
    UnicodeAll-151 (151): 38657-38912
    UnicodeAll-152 (152): 38913-39168
    UnicodeAll-153 (153): 39169-39424
    UnicodeAll-154 (154): 39425-39680
    UnicodeAll-155 (155): 39681-39936
    UnicodeAll-156 (156): 39937-40192
    UnicodeAll-157 (157): 40193-40448
    UnicodeAll-158 (158): 40449-40704
    UnicodeAll-159 (159): 40705-40960
    UnicodeAll-160 (160): 40961-41216
    UnicodeAll-161 (161): 41217-41472
    UnicodeAll-162 (162): 41473-41728
    UnicodeAll-163 (163): 41729-41984
    UnicodeAll-164 (164): 41985-42240
    UnicodeAll-165 (165): 42241-42496
    UnicodeAll-166 (166): 42497-42752
    UnicodeAll-167 (167): 42753-43008
    UnicodeAll-168 (168): 43009-43264
    UnicodeAll-169 (169): 43265-43520
    UnicodeAll-170 (170): 43521-43776
    UnicodeAll-171 (171): 43777-44032
    UnicodeAll-172 (172): 44033-44288
    UnicodeAll-173 (173): 44289-44544
    UnicodeAll-174 (174): 44545-44800
    UnicodeAll-175 (175): 44801-45056
    UnicodeAll-176 (176): 45057-45312
    UnicodeAll-177 (177): 45313-45568
    UnicodeAll-178 (178): 45569-45824
    UnicodeAll-179 (179): 45825-46080
    UnicodeAll-180 (180): 46081-46336
    UnicodeAll-181 (181): 46337-46592
    UnicodeAll-182 (182): 46593-46848
    UnicodeAll-183 (183): 46849-47104
    UnicodeAll-184 (184): 47105-47360
    UnicodeAll-185 (185): 47361-47616
    UnicodeAll-186 (186): 47617-47872
    UnicodeAll-187 (187): 47873-48128
    UnicodeAll-188 (188): 48129-48384
    UnicodeAll-189 (189): 48385-48640
    UnicodeAll-190 (190): 48641-48896
    UnicodeAll-191 (191): 48897-49152
    UnicodeAll-192 (192): 49153-49408
    UnicodeAll-193 (193): 49409-49664
    UnicodeAll-194 (194): 49665-49920
    UnicodeAll-195 (195): 49921-50176
    UnicodeAll-196 (196): 50177-50432
    UnicodeAll-197 (197): 50433-50688
    UnicodeAll-198 (198): 50689-50944
    UnicodeAll-199 (199): 50945-51200
    UnicodeAll-200 (200): 51201-51456
    UnicodeAll-201 (201): 51457-51712
    UnicodeAll-202 (202): 51713-51968
    UnicodeAll-203 (203): 51969-52224
    UnicodeAll-204 (204): 52225-52480
    UnicodeAll-205 (205): 52481-52736
    UnicodeAll-206 (206): 52737-52992
    UnicodeAll-207 (207): 52993-53248
    UnicodeAll-208 (208): 53249-53504
    UnicodeAll-209 (209): 53505-53760
    UnicodeAll-210 (210): 53761-54016
    UnicodeAll-211 (211): 54017-54272
    UnicodeAll-212 (212): 54273-54528
    UnicodeAll-213 (213): 54529-54784
    UnicodeAll-214 (214): 54785-55040
    UnicodeAll-215 (215): 55041-55296
    UnicodeAll-216 (216): 55297-55552
    UnicodeAll-217 (217): 55553-55808
    UnicodeAll-218 (218): 55809-56064
    UnicodeAll-219 (219): 56065-56320
    UnicodeAll-220 (220): 56321-56576
    UnicodeAll-221 (221): 56577-56832
    UnicodeAll-222 (222): 56833-57088
    UnicodeAll-223 (223): 57089-57344
    UnicodeAll-224 (224): 57345-57600
    UnicodeAll-225 (225): 57601-57856
    UnicodeAll-226 (226): 57857-58112
    UnicodeAll-227 (227): 58113-58368
    UnicodeAll-228 (228): 58369-58624
    UnicodeAll-229 (229): 58625-58880
    UnicodeAll-230 (230): 58881-59136
    UnicodeAll-231 (231): 59137-59392
    UnicodeAll-232 (232): 59393-59648
    UnicodeAll-233 (233): 59649-59904
    UnicodeAll-234 (234): 59905-60160
    UnicodeAll-235 (235): 60161-60416
    UnicodeAll-236 (236): 60417-60672
    UnicodeAll-237 (237): 60673-60928
    UnicodeAll-238 (238): 60929-61184
    UnicodeAll-239 (239): 61185-61440
    UnicodeAll-240 (240): 61441-61696
    UnicodeAll-241 (241): 61697-61952
    UnicodeAll-242 (242): 61953-62208
    UnicodeAll-243 (243): 62209-62464
    UnicodeAll-244 (244): 62465-62720
    UnicodeAll-245 (245): 62721-62976
    UnicodeAll-246 (246): 62977-63232
    UnicodeAll-247 (247): 63233-63488
    UnicodeAll-248 (248): 63489-63744
    UnicodeAll-249 (249): 63745-64000
    UnicodeAll-250 (250): 64001-64256
    UnicodeAll-251 (251): 64257-64512
    UnicodeAll-252 (252): 64513-64768
    UnicodeAll-253 (253): 64769-65024
    UnicodeAll-254 (254): 65025-65280
    UnicodeAll-255 (255): 65281-65534