forked from Shreeshrii/tess5train-fonts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
language_specific.py
1414 lines (1346 loc) · 36.8 KB
/
language_specific.py
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
#!/usr/bin/env python3
# (C) Copyright 2014, Google Inc.
# (C) Copyright 2018, James R Barlow
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Set some language specific variables. Works in conjunction with
# tesstrain.sh
#
# =============================================================================
# Language specific info
# =============================================================================
import logging
import os
log = logging.getLogger(__name__)
# Array of all valid language codes.
VALID_LANGUAGE_CODES = (
"afr amh ara asm aze aze_cyrl bel ben bih bod bos bul cat "
"ceb ces chi_sim chi_tra chr cym cyr_lid dan deu div dzo "
"ell eng enm epo est eus fas fil fin fra frk frm gle glg "
"grc guj hat heb hin hrv hun hye iast iku ind isl ita ita_old "
"jav jav_java jpn kan kat kat_old kaz khm kir kmr kor kur_ara lao lat "
"lat_lid lav lit mal mar mkd mlt msa mya nep nld nor ori "
"pan pol por pus ron rus san sin slk slv snd spa spa_old "
"sqi srp srp_latn swa swe syr tam tel tgk tgl tha tir tur "
"uig ukr urd uzb uzb_cyrl vie yid gle_uncial "
)
# Codes for which we have webtext but no fonts:
UNUSABLE_LANGUAGE_CODES = ""
FRAKTUR_FONTS = [
"CaslonishFraxx Medium",
"Cloister Black, Light",
"Proclamate Light",
"UnifrakturMaguntia",
"Walbaum-Fraktur",
]
# List of fonts to train on
LATIN_FONTS = [
"Arial Bold",
"Arial Bold Italic",
"Arial Italic",
"Arial",
"Courier New Bold",
"Courier New Bold Italic",
"Courier New Italic",
"Courier New",
"Times New Roman, Bold",
"Times New Roman, Bold Italic",
"Times New Roman, Italic",
"Times New Roman,",
"Georgia Bold",
"Georgia Italic",
"Georgia",
"Georgia Bold Italic",
"Trebuchet MS Bold",
"Trebuchet MS Bold Italic",
"Trebuchet MS Italic",
"Trebuchet MS",
"Verdana Bold",
"Verdana Italic",
"Verdana",
"Verdana Bold Italic",
"Tex Gyre Bonum Bold",
"Tex Gyre Bonum Italic",
"Tex Gyre Bonum Bold Italic",
"Tex Gyre Schola Bold",
"Tex Gyre Schola Italic",
"Tex Gyre Schola Bold Italic",
"Tex Gyre Schola Regular",
"DejaVu Sans Ultra-Light",
]
# List of fonts for printed/neo-Latin ('lat' language code, different from Latin script)
NEOLATIN_FONTS = [
"GFS Bodoni",
"GFS Bodoni Bold",
"GFS Bodoni Italic",
"GFS Bodoni Bold Italic",
"GFS Didot",
"GFS Didot Bold",
"GFS Didot Italic",
"GFS Didot Bold Italic",
"Cardo",
"Cardo Bold",
"Cardo Italic",
"Wyld",
"Wyld Italic",
"EB Garamond",
"EB Garamond Italic",
"Junicode",
"Junicode Bold",
"Junicode Italic",
"Junicode Bold Italic",
"IM FELL DW Pica PRO",
"IM FELL English PRO",
"IM FELL Double Pica PRO",
"IM FELL French Canon PRO",
"IM FELL Great Primer PRO",
"IM FELL DW Pica PRO Italic",
"IM FELL English PRO Italic",
"IM FELL Double Pica PRO Italic",
"IM FELL French Canon PRO Italic",
"IM FELL Great Primer PRO Italic",
]
IRISH_UNCIAL_FONTS = [
"Bunchlo Arsa Dubh GC",
"Bunchlo Arsa GC",
"Bunchlo Arsa GC Bold",
"Bunchlo Dubh GC",
"Bunchlo GC",
"Bunchlo GC Bold",
"Bunchlo Nua GC Bold",
"Bunchló na Nod GC",
"Gadelica",
"Glanchlo Dubh GC",
"Glanchlo GC",
"Glanchlo GC Bold",
"Seanchló Dubh GC",
"Seanchló GC",
"Seanchló GC Bold",
"Seanchló na Nod GC",
"Seanchló Ársa Dubh GC",
"Seanchló Ársa GC",
"Seanchló Ársa GC Bold",
"Tromchlo Beag GC",
"Tromchlo Mor GC",
"Urchlo GC",
"Urchlo GC Bold",
]
EARLY_LATIN_FONTS = [
*FRAKTUR_FONTS,
*LATIN_FONTS,
# The Wyld font family renders early modern ligatures encoded in the private
# unicode area.
"Wyld",
"Wyld Italic",
# Fonts that render the Yogh symbol (U+021C, U+021D) found in Old English.
"GentiumAlt",
]
VIETNAMESE_FONTS = [
"Arial Unicode MS Bold",
"Arial Bold Italic",
"Arial Italic",
"Arial Unicode MS",
"FreeMono Bold",
"Courier New Bold Italic",
"FreeMono Italic",
"FreeMono",
"GentiumAlt Italic",
"GentiumAlt",
"Palatino Linotype Bold",
"Palatino Linotype Bold Italic",
"Palatino Linotype Italic",
"Palatino Linotype",
"Really No 2 LT W2G Light",
"Really No 2 LT W2G Light Italic",
"Really No 2 LT W2G Medium",
"Really No 2 LT W2G Medium Italic",
"Really No 2 LT W2G Semi-Bold",
"Really No 2 LT W2G Semi-Bold Italic",
"Really No 2 LT W2G Ultra-Bold",
"Really No 2 LT W2G Ultra-Bold Italic",
"Times New Roman, Bold",
"Times New Roman, Bold Italic",
"Times New Roman, Italic",
"Times New Roman,",
"Verdana Bold",
"Verdana Italic",
"Verdana",
"Verdana Bold Italic",
"VL Gothic",
"VL PGothic",
]
DEVANAGARI_FONTS = [
"FreeSans",
"Chandas",
"Kalimati",
"Uttara",
"Lucida Sans",
"gargi Medium",
"Lohit Devanagari",
"Arial Unicode MS Bold",
"Ascender Uni",
"Noto Sans Devanagari Bold",
"Noto Sans Devanagari",
"Samyak Devanagari Medium",
"Sarai",
"Saral LT Bold",
"Saral LT Light",
"Nakula",
"Sahadeva",
"Samanata",
"Santipur OT Medium",
]
KANNADA_FONTS = [
"Kedage Bold",
"Kedage Italic",
"Kedage",
"Kedage Bold Italic",
"Mallige Bold",
"Mallige Italic",
"Mallige",
"Mallige Bold Italic",
"Arial Unicode MS",
"Arial Unicode MS Bold",
"Ascender Uni",
"cheluvi Medium",
"Noto Sans Kannada Bold",
"Noto Sans Kannada",
"Lohit Kannada",
"Tunga",
"Tunga Bold",
]
TELUGU_FONTS = [
"Pothana2000",
"Vemana2000",
"Lohit Telugu",
"Arial Unicode MS Bold",
"Ascender Uni",
"Dhurjati",
"Gautami Bold",
"Gidugu",
"Gurajada",
"Lakki Reddy",
"Mallanna",
"Mandali",
"NATS",
"NTR",
"Noto Sans Telugu Bold",
"Noto Sans Telugu",
"Peddana",
"Ponnala",
"Ramabhadra",
"Ravi Prakash",
"Sree Krushnadevaraya",
"Suranna",
"Suravaram",
"Tenali Ramakrishna",
"Gautami",
]
TAMIL_FONTS = [
"TAMu_Kadambri",
"TAMu_Kalyani",
"TAMu_Maduram",
"TSCu_Paranar",
"TSCu_Times",
"TSCu_Paranar Bold",
"FreeSans",
"FreeSerif",
"Lohit Tamil",
"Arial Unicode MS Bold",
"Ascender Uni",
"Droid Sans Tamil Bold",
"Droid Sans Tamil",
"Karla Tamil Inclined Bold Italic",
"Karla Tamil Inclined Italic",
"Karla Tamil Upright Bold",
"Karla Tamil Upright",
"Noto Sans Tamil Bold",
"Noto Sans Tamil",
"Noto Sans Tamil UI Bold",
"Noto Sans Tamil UI",
"TSCu_Comic Normal",
"Lohit Tamil Classical",
]
THAI_FONTS = [
"FreeSerif",
"FreeSerif Italic",
"Garuda",
"Norasi",
"Lucida Sans Typewriter",
"Lucida Sans",
"Garuda Oblique",
"Norasi Oblique",
"Norasi Italic",
"Garuda Bold",
"Norasi Bold",
"Lucida Sans Typewriter Bold",
"Lucida Sans Semi-Bold",
"Garuda Bold Oblique",
"Norasi Bold Italic",
"Norasi Bold Oblique",
"AnuParp LT Thai",
"Arial Unicode MS Bold",
"Arial Unicode MS",
"Ascender Uni",
"Loma",
"Noto Serif Thai Bold",
"Noto Serif Thai",
"Purisa Light",
"Sirichana LT Bold",
"Sirichana LT",
"Sukothai LT Bold",
"Sukothai LT",
"UtSaHaGumm LT Thai",
"Tahoma",
]
KOREAN_FONTS = [
"Arial Unicode MS",
"Arial Unicode MS Bold",
"Baekmuk Batang Patched",
"Baekmuk Batang",
"Baekmuk Dotum",
"Baekmuk Gulim",
"Baekmuk Headline",
]
CHI_SIM_FONTS = [
"AR PL UKai CN",
"AR PL UMing Patched Light",
"Arial Unicode MS",
"Arial Unicode MS Bold",
"WenQuanYi Zen Hei Medium",
]
CHI_TRA_FONTS = [
"AR PL UKai TW",
"AR PL UMing TW MBE Light",
"AR PL UKai Patched",
"AR PL UMing Patched Light",
"Arial Unicode MS",
"Arial Unicode MS Bold",
"WenQuanYi Zen Hei Medium",
]
JPN_FONTS = [
"TakaoExGothic",
"TakaoExMincho",
"TakaoGothic",
"TakaoMincho",
"TakaoPGothic",
"TakaoPMincho",
"VL Gothic",
"VL PGothic",
"Noto Sans Japanese Bold",
"Noto Sans Japanese Light",
]
RUSSIAN_FONTS = [
"Arial Bold",
"Arial Bold Italic",
"Arial Italic",
"Arial",
"Courier New Bold",
"Courier New Bold Italic",
"Courier New Italic",
"Courier New",
"Times New Roman, Bold",
"Times New Roman, Bold Italic",
"Times New Roman, Italic",
"Times New Roman,",
"Georgia Bold",
"Georgia Italic",
"Georgia",
"Georgia Bold Italic",
"Trebuchet MS Bold",
"Trebuchet MS Bold Italic",
"Trebuchet MS Italic",
"Trebuchet MS",
"Verdana Bold",
"Verdana Italic",
"Verdana",
"Verdana Bold Italic",
"DejaVu Serif",
"DejaVu Serif Oblique",
"DejaVu Serif Bold",
"DejaVu Serif Bold Oblique",
"Lucida Bright",
"FreeSerif Bold",
"FreeSerif Bold Italic",
"DejaVu Sans Ultra-Light",
]
GREEK_FONTS = [
"Arial Unicode MS",
"Arial Unicode MS Bold",
"DejaVu Sans Mono",
"DejaVu Sans Mono Oblique",
"DejaVu Sans Mono Bold",
"DejaVu Sans Mono Bold Oblique",
"DejaVu Serif",
"DejaVu Serif Semi-Condensed",
"DejaVu Serif Oblique",
"DejaVu Serif Bold",
"DejaVu Serif Bold Oblique",
"DejaVu Serif Bold Semi-Condensed",
"FreeSerif Bold",
"FreeSerif Bold Italic",
"FreeSerif Italic",
"FreeSerif",
"GentiumAlt",
"GentiumAlt Italic",
"Linux Biolinum O Bold",
"Linux Biolinum O",
"Linux Libertine O Bold",
"Linux Libertine O",
"Linux Libertine O Bold Italic",
"Linux Libertine O Italic",
"Palatino Linotype Bold",
"Palatino Linotype Bold Italic",
"Palatino Linotype Italic",
"Palatino Linotype",
"UmePlus P Gothic",
"VL PGothic",
]
ANCIENT_GREEK_FONTS = [
"GFS Artemisia",
"GFS Artemisia Bold",
"GFS Artemisia Bold Italic",
"GFS Artemisia Italic",
"GFS Bodoni",
"GFS Bodoni Bold",
"GFS Bodoni Bold Italic",
"GFS Bodoni Italic",
"GFS Didot",
"GFS Didot Bold",
"GFS Didot Bold Italic",
"GFS Didot Italic",
"GFS DidotClassic",
"GFS Neohellenic",
"GFS Neohellenic Bold",
"GFS Neohellenic Bold Italic",
"GFS Neohellenic Italic",
"GFS Philostratos",
"GFS Porson",
"GFS Pyrsos",
"GFS Solomos",
]
ARABIC_FONTS = [
"Arabic Transparent Bold",
"Arabic Transparent",
"Arab",
"Arial Unicode MS Bold",
"Arial Unicode MS",
"ASVCodar LT Bold",
"ASVCodar LT Light",
"Badiya LT Bold",
"Badiya LT",
"Badr LT Bold",
"Badr LT",
"Dimnah",
"Frutiger LT Arabic Bold",
"Frutiger LT Arabic",
"Furat",
"Hassan LT Bold",
"Hassan LT Light",
"Jalal LT Bold",
"Jalal LT Light",
"Midan Bold",
"Midan",
"Mitra LT Bold",
"Mitra LT Light",
"Palatino LT Arabic",
"Palatino Sans Arabic Bold",
"Palatino Sans Arabic",
"Simplified Arabic Bold",
"Simplified Arabic",
"Times New Roman, Bold",
"Times New Roman,",
"Traditional Arabic Bold",
"Traditional Arabic",
]
HEBREW_FONTS = [
"Arial Bold",
"Arial Bold Italic",
"Arial Italic",
"Arial",
"Courier New Bold",
"Courier New Bold Italic",
"Courier New Italic",
"Courier New",
"Ergo Hebrew Semi-Bold",
"Ergo Hebrew Semi-Bold Italic",
"Ergo Hebrew",
"Ergo Hebrew Italic",
"Really No 2 LT W2G Light",
"Really No 2 LT W2G Light Italic",
"Really No 2 LT W2G Medium",
"Really No 2 LT W2G Medium Italic",
"Really No 2 LT W2G Semi-Bold",
"Really No 2 LT W2G Semi-Bold Italic",
"Really No 2 LT W2G Ultra-Bold",
"Really No 2 LT W2G Ultra-Bold Italic",
"Times New Roman, Bold",
"Times New Roman, Bold Italic",
"Times New Roman, Italic",
"Times New Roman,",
"Lucida Sans",
"Tahoma",
]
BENGALI_FONTS = [
"Bangla Medium",
"Lohit Bengali",
"Mukti Narrow",
"Mukti Narrow Bold",
"Jamrul Medium Semi-Expanded",
"Likhan Medium",
"Arial Unicode MS Bold",
"Ascender Uni",
"FreeSans",
"FreeSans Oblique",
"FreeSerif",
"FreeSerif Italic",
"Noto Sans Bengali Bold",
"Noto Sans Bengali",
"Ani",
"Lohit Assamese",
"Lohit Bengali",
"Mitra Mono",
]
KYRGYZ_FONTS = [
"Arial",
"Arial Bold",
"Arial Italic",
"Arial Bold Italic",
"Courier New",
"Courier New Bold",
"Courier New Italic",
"Courier New Bold Italic",
"Times New Roman,",
"Times New Roman, Bold",
"Times New Roman, Bold Italic",
"Times New Roman, Italic",
"DejaVu Serif",
"DejaVu Serif Oblique",
"DejaVu Serif Bold",
"DejaVu Serif Bold Oblique",
"Lucida Bright",
"FreeSerif Bold",
"FreeSerif Bold Italic",
]
PERSIAN_FONTS = [
"Amiri Bold Italic",
"Amiri Bold",
"Amiri Italic",
"Amiri",
"Andale Sans Arabic Farsi",
"Arial Unicode MS",
"Arial Unicode MS Bold",
"Lateef",
"Lucida Bright",
"Lucida Sans Oblique",
"Lucida Sans Semi-Bold",
"Lucida Sans",
"Lucida Sans Typewriter Bold",
"Lucida Sans Typewriter Oblique",
"Lucida Sans Typewriter",
"Scheherazade",
"Tahoma",
"Times New Roman,",
"Times New Roman, Bold",
"Times New Roman, Bold Italic",
"Times New Roman, Italic",
"Yakout Linotype Bold",
"Yakout Linotype",
]
AMHARIC_FONTS = [
"Abyssinica SIL",
"Droid Sans Ethiopic Bold",
"Droid Sans Ethiopic",
"FreeSerif",
"Noto Sans Ethiopic Bold",
"Noto Sans Ethiopic",
]
ARMENIAN_FONTS = [
"Arial Unicode MS",
"Arial Unicode MS Bold",
"Ascender Uni",
"FreeMono",
"FreeMono Italic",
"FreeSans",
"FreeSans Bold",
"FreeSans Oblique",
]
BURMESE_FONTS = [
"Myanmar Sans Pro",
"Noto Sans Myanmar Bold",
"Noto Sans Myanmar",
"Padauk Bold",
"Padauk",
"TharLon",
]
JAVANESE_FONTS = ["Prada"]
NORTH_AMERICAN_ABORIGINAL_FONTS = [
"Aboriginal Sans",
"Aboriginal Sans Bold Italic",
"Aboriginal Sans Italic",
"Aboriginal Sans Bold",
"Aboriginal Serif Bold",
"Aboriginal Serif Bold Italic",
"Aboriginal Serif Italic",
"Aboriginal Serif",
]
GEORGIAN_FONTS = [
"Arial Unicode MS Bold",
"Arial Unicode MS",
"BPG Algeti GPL\&GNU",
"BPG Chveulebrivi GPL\&GNU",
"BPG Courier GPL\&GNU",
"BPG Courier S GPL\&GNU",
"BPG DejaVu Sans 2011 GNU-GPL",
"BPG Elite GPL\&GNU",
"BPG Excelsior GPL\&GNU",
"BPG Glaho GPL\&GNU",
"BPG Gorda GPL\&GNU",
"BPG Ingiri GPL\&GNU",
"BPG Mrgvlovani Caps GNU\&GPL",
"BPG Mrgvlovani GPL\&GNU",
"BPG Nateli Caps GPL\&GNU Light",
"BPG Nateli Condenced GPL\&GNU Light",
"BPG Nateli GPL\&GNU Light",
"BPG Nino Medium Cond GPL\&GNU",
"BPG Nino Medium GPL\&GNU Medium",
"BPG Sans GPL\&GNU",
"BPG Sans Medium GPL\&GNU",
"BPG Sans Modern GPL\&GNU",
"BPG Sans Regular GPL\&GNU",
"BPG Serif GPL\&GNU",
"BPG Serif Modern GPL\&GNU",
"FreeMono",
"FreeMono Bold Italic",
"FreeSans",
"FreeSerif",
"FreeSerif Bold",
"FreeSerif Bold Italic",
"FreeSerif Italic",
]
OLD_GEORGIAN_FONTS = [
"Arial Unicode MS Bold",
"Arial Unicode MS",
"BPG Algeti GPL\&GNU",
"BPG Courier S GPL\&GNU",
"BPG DejaVu Sans 2011 GNU-GPL",
"BPG Elite GPL\&GNU",
"BPG Excelsior GPL\&GNU",
"BPG Glaho GPL\&GNU",
"BPG Ingiri GPL\&GNU",
"BPG Mrgvlovani Caps GNU\&GPL",
"BPG Mrgvlovani GPL\&GNU",
"BPG Nateli Caps GPL\&GNU Light",
"BPG Nateli Condenced GPL\&GNU Light",
"BPG Nateli GPL\&GNU Light",
"BPG Nino Medium Cond GPL\&GNU",
"BPG Nino Medium GPL\&GNU Medium",
"BPG Sans GPL\&GNU",
"BPG Sans Medium GPL\&GNU",
"BPG Sans Modern GPL\&GNU",
"BPG Sans Regular GPL\&GNU",
"BPG Serif GPL\&GNU",
"BPG Serif Modern GPL\&GNU",
"FreeSans",
"FreeSerif",
"FreeSerif Bold",
"FreeSerif Bold Italic",
"FreeSerif Italic",
]
KHMER_FONTS = [
"Khmer OS",
"Khmer OS System",
"Khmer OS Battambang",
"Khmer OS Bokor",
"Khmer OS Content",
"Khmer OS Fasthand",
"Khmer OS Freehand",
"Khmer OS Metal Chrieng",
"Khmer OS Muol Light",
"Khmer OS Muol Pali",
"Khmer OS Muol",
"Khmer OS Siemreap",
"Noto Sans Bold",
"Noto Sans",
"Noto Serif Khmer Bold",
"Noto Serif Khmer Light",
]
KURDISH_FONTS = [
"Amiri Bold Italic",
"Amiri Bold",
"Amiri Italic",
"Amiri",
"Arial Unicode MS",
"Arial Unicode MS Bold",
"Lateef",
"Lucida Bright",
"Lucida Sans Oblique",
"Lucida Sans Semi-Bold",
"Lucida Sans",
"Lucida Sans Typewriter Bold",
"Lucida Sans Typewriter Oblique",
"Lucida Sans Typewriter",
"Scheherazade",
"Tahoma",
"Times New Roman,",
"Times New Roman, Bold",
"Times New Roman, Bold Italic",
"Times New Roman, Italic",
"Unikurd Web",
"Yakout Linotype Bold",
"Yakout Linotype",
]
LAOTHIAN_FONTS = [
"Phetsarath OT",
"Arial Unicode MS",
"Arial Unicode MS Bold",
"Ascender Uni",
"Dhyana Bold",
"Dhyana",
"Lao Muang Don",
"Lao Muang Khong",
"Lao Sans Pro",
"Noto Sans Lao Bold",
"Noto Sans Lao",
"Noto Sans Lao UI Bold",
"Noto Sans Lao UI",
"Noto Serif Lao Bold",
"Noto Serif Lao",
"Phetsarath Bold",
"Phetsarath",
"Souliyo Unicode",
]
GUJARATI_FONTS = [
"Lohit Gujarati",
"Rekha Medium",
"Samyak Gujarati Medium",
"aakar Medium",
"padmaa Bold",
"padmaa Medium",
"Arial Unicode MS",
"Arial Unicode MS Bold",
"Ascender Uni",
"FreeSans",
"Noto Sans Gujarati Bold",
"Noto Sans Gujarati",
"Shruti",
"Shruti Bold",
]
MALAYALAM_FONTS = [
"AnjaliOldLipi",
"Arial Unicode MS",
"Arial Unicode MS Bold",
"Ascender Uni",
"Dyuthi",
"FreeSerif",
"Kalyani",
"Kartika",
"Kartika Bold",
"Lohit Malayalam",
"Meera",
"Noto Sans Malayalam Bold",
"Noto Sans Malayalam",
"Rachana",
"Rachana_w01",
"RaghuMalayalam",
"suruma",
]
ORIYA_FONTS = [
"Arial Unicode MS",
"Arial Unicode MS Bold",
"Ascender Uni",
"ori1Uni Medium",
"Samyak Oriya Medium",
"Lohit Oriya",
]
PUNJABI_FONTS = [
"Arial Unicode MS",
"Arial Unicode MS Bold",
"Ascender Uni",
"Saab",
"Lohit Punjabi",
"Noto Sans Gurmukhi",
"Noto Sans Gurmukhi Bold",
"FreeSans",
"FreeSans Bold",
"FreeSerif",
]
SINHALA_FONTS = [
"Noto Sans Sinhala Bold",
"Noto Sans Sinhala",
"OCRUnicode",
"Yagpo",
"LKLUG",
"FreeSerif",
]
SYRIAC_FONTS = [
"East Syriac Adiabene",
"East Syriac Ctesiphon",
"Estrangelo Antioch",
"Estrangelo Edessa",
"Estrangelo Midyat",
"Estrangelo Nisibin",
"Estrangelo Quenneshrin",
"Estrangelo Talada",
"Estrangelo TurAbdin",
"Serto Batnan Bold",
"Serto Batnan",
"Serto Jerusalem Bold",
"Serto Jerusalem Italic",
"Serto Jerusalem",
"Serto Kharput",
"Serto Malankara",
"Serto Mardin Bold",
"Serto Mardin",
"Serto Urhoy Bold",
"Serto Urhoy",
"FreeSans",
]
THAANA_FONTS = ["FreeSerif"]
TIBETAN_FONTS = [
"Arial Unicode MS",
"Arial Unicode MS Bold",
"Ascender Uni",
"DDC Uchen",
"Jomolhari",
"Kailasa",
"Kokonor",
"Tibetan Machine Uni",
"TibetanTsugRing",
"Yagpo",
]
# The following fonts will be rendered vertically in phase I.
VERTICAL_FONTS = [
"TakaoExGothic",
"TakaoExMincho",
"AR PL UKai Patched",
"AR PL UMing Patched Light",
"Baekmuk Batang Patched",
]
FLAGS_webtext_prefix = os.environ.get("FLAGS_webtext_prefix", "")
# Set language-specific values for several global variables, including
# ${TEXT_CORPUS}
# holds the text corpus file for the language, used in phase F
# ${FONTS[@]}
# holds a sequence of applicable fonts for the language, used in
# phase F & I. only set if not already set, i.e. from command line
# ${TRAINING_DATA_ARGUMENTS}
# non-default arguments to the training_data program used in phase T
# ${FILTER_ARGUMENTS}[ -]
# character-code-specific filtering to distinguish between scripts
# (eg. CJK) used by filter_borbidden_characters in phase F
# ${WORDLIST2DAWG_ARGUMENTS}
# specify fixed length dawg generation for non-space-delimited lang
# TODO(dsl): We can refactor these into functions that assign FONTS,
# TEXT_CORPUS, etc. separately.
def set_lang_specific_parameters(ctx, lang):
# The default text location is now given directly from the language code.
TEXT_CORPUS = f"{FLAGS_webtext_prefix}/{lang}.corpus.txt"
FILTER_ARGUMENTS = []
WORDLIST2DAWG_ARGUMENTS = ""
# These dawg factors represent the fraction of the corpus not covered by the
# dawg, and seem like reasonable defaults, but the optimal value is likely
# to be highly corpus-dependent, as well as somewhat language-dependent.
# Number dawg factor is the fraction of all numeric strings that are not
# covered, which is why it is higher relative to the others.
PUNC_DAWG_FACTOR = None
NUMBER_DAWG_FACTOR = 0.125
WORD_DAWG_FACTOR = 0.05
BIGRAM_DAWG_FACTOR = 0.015
TRAINING_DATA_ARGUMENTS = []
FRAGMENTS_DISABLED = "y"
RUN_SHAPE_CLUSTERING = False
AMBIGS_FILTER_DENOMINATOR = "100000"
LEADING = 32
MEAN_COUNT = 40 # Default for latin script.
# Language to mix with the language for maximum accuracy. Defaults to eng.
# If no language is good, set to the base language.
MIX_LANG = "eng"
FONTS = ctx.fonts
TEXT2IMAGE_EXTRA_ARGS = []
EXPOSURES = []
GENERATE_WORD_BIGRAMS = None
WORD_DAWG_SIZE = None
# Latin languages.
if lang == "enm":
TEXT2IMAGE_EXTRA_ARGS += ["--ligatures"] # Add ligatures when supported
if not FONTS:
FONTS = EARLY_LATIN_FONTS
elif lang == "frm":
TEXT_CORPUS = f"{FLAGS_webtext_prefix}/fra.corpus.txt"
# Make long-s substitutions for Middle French text
FILTER_ARGUMENTS += ["--make_early_language_variant=fra"]
TEXT2IMAGE_EXTRA_ARGS += ["--ligatures"] # Add ligatures when supported.
if not FONTS:
FONTS = EARLY_LATIN_FONTS
elif lang == "frk":
TEXT_CORPUS = f"{FLAGS_webtext_prefix}/deu.corpus.txt"
if not FONTS:
FONTS = FRAKTUR_FONTS
elif lang == "ita_old":
TEXT_CORPUS = f"{FLAGS_webtext_prefix}/ita.corpus.txt"
# Make long-s substitutions for Early Italian text
FILTER_ARGUMENTS += ["--make_early_language_variant=ita"]
TEXT2IMAGE_EXTRA_ARGS += ["--ligatures"] # Add ligatures when supported.
if not FONTS:
FONTS = EARLY_LATIN_FONTS
elif lang == "lat":
if not EXPOSURES:
EXPOSURES = "-3 -2 -1 0 1 2 3".split()
if not FONTS:
FONTS = NEOLATIN_FONTS
elif lang == "spa_old":
TEXT_CORPUS = f"{FLAGS_webtext_prefix}/spa.corpus.txt"
# Make long-s substitutions for Early Spanish text
FILTER_ARGUMENTS += ["--make_early_language_variant=spa"]
TEXT2IMAGE_EXTRA_ARGS += ["--ligatures"] # Add ligatures when supported.
if not FONTS:
FONTS = EARLY_LATIN_FONTS
elif lang == "srp_latn":
TEXT_CORPUS = f"{FLAGS_webtext_prefix}/srp.corpus.txt"
elif lang == "vie":
TRAINING_DATA_ARGUMENTS += ["--infrequent_ratio=10000"]
if not FONTS:
FONTS = VIETNAMESE_FONTS
# Highly inflective languages get a bigger dawg size.
# TODO(rays) Add more here!
elif lang == "hun":
WORD_DAWG_SIZE = 1_000_000
elif lang == "pol":
WORD_DAWG_SIZE = 1_000_000
# Latin with default treatment.
elif lang == "afr":
pass
elif lang == "aze":
pass
elif lang == "bos":
pass
elif lang == "cat":
pass
elif lang == "ceb":
pass
elif lang == "ces":
PUNC_DAWG_FACTOR = 0.004
elif lang == "cym":
pass
elif lang == "dan":
pass
elif lang == "deu":
WORD_DAWG_FACTOR = 0.125
elif lang == "eng":
WORD_DAWG_FACTOR = 0.03
elif lang == "epo":
pass
elif lang == "est":
pass
elif lang == "eus":
pass
elif lang == "fil":
pass