| 1 |
#!/usr/bin/env perl |
| 2 |
# |
| 3 |
# cjk-gs-integrate - setup Ghostscript for CID/TTF CJK fonts |
| 4 |
# |
| 5 |
# Copyright 2015-2021 by Norbert Preining |
| 6 |
# Copyright 2016-2021 by Japanese TeX Development Community |
| 7 |
# |
| 8 |
# This work is based on research and work by (in alphabetical order) |
| 9 |
# Masamichi Hosoda |
| 10 |
# Yusuke Kuroki |
| 11 |
# Yusuke Terada |
| 12 |
# Bruno Voisin |
| 13 |
# Munehiro Yamamoto |
| 14 |
# Hironobu Yamashita |
| 15 |
# and the Japanese TeX Q&A wiki page |
| 16 |
# |
| 17 |
# This file is licensed under GPL version 3 or any later version. |
| 18 |
# For copyright statements see end of file. |
| 19 |
# |
| 20 |
# For development see |
| 21 |
# https://github.com/texjporg/cjk-gs-support |
| 22 |
# |
| 23 |
# LIMITATIONS: |
| 24 |
# - Running the script (with default mode = actual setup/removing operations) |
| 25 |
# always overwrites "cidfmap.local" and "cidfmap.aliases" without asking, |
| 26 |
# whose file names might be common enough. If you choose to run the script, |
| 27 |
# leave these files untouched. (Do NOT edit these files by yourself!) |
| 28 |
# (This note also applies to MacTeX pre-shipped configuration files.) |
| 29 |
# |
| 30 |
# TODO: |
| 31 |
# - interoperability with kanji-config-updmap |
| 32 |
# |
| 33 |
# Note that symlink names should be consistent with ptex-fontmaps! |
| 34 |
|
| 35 |
use Getopt::Long qw(:config no_autoabbrev ignore_case_always); |
| 36 |
use File::Basename; |
| 37 |
use File::Path qw(make_path); |
| 38 |
use Cwd 'abs_path'; |
| 39 |
use strict; |
| 40 |
use warnings; |
| 41 |
use utf8; |
| 42 |
use feature 'state'; |
| 43 |
use Encode; |
| 44 |
use Encode::Alias; |
| 45 |
|
| 46 |
my $debug_msg_before_init; |
| 47 |
init_encode_locale (); |
| 48 |
|
| 49 |
binmode (STDIN, ':encoding(console_in)'); |
| 50 |
binmode (STDOUT, ':encoding(console_out)'); |
| 51 |
binmode (STDERR, ':encoding(console_out)'); |
| 52 |
|
| 53 |
@ARGV = map{ decode('locale', $_) }@ARGV; |
| 54 |
|
| 55 |
(my $prg = basename(decode('locale', $0))) =~ s/\.pl$//; |
| 56 |
my $version = '20210625.0'; |
| 57 |
|
| 58 |
if (win32()) { |
| 59 |
# some perl functions (symlink, -l test) does not work |
| 60 |
print_warning("Sorry, we have only partial support for Windows!\n"); |
| 61 |
|
| 62 |
require Win32::API; |
| 63 |
Win32::API->import (); |
| 64 |
require File::Compare; |
| 65 |
File::Compare->import (); |
| 66 |
} |
| 67 |
|
| 68 |
# The followings are installed by ptex-fontmaps (texjporg): |
| 69 |
# * 2004-H |
| 70 |
# * 2004-V |
| 71 |
# The followings are created by Adobe but not considered official |
| 72 |
# (see https://forums.adobe.com/thread/537415) |
| 73 |
# * GB-RKSJ-H |
| 74 |
# * GBT-RKSJ-H |
| 75 |
# * KSC-RKSJ-H |
| 76 |
# All others are provided in the latest Adobe CMap Resources: |
| 77 |
# https://github.com/adobe-type-tools/cmap-resources |
| 78 |
my %encode_list = ( |
| 79 |
Japan => [ qw/ |
| 80 |
2004-H |
| 81 |
2004-V |
| 82 |
78-EUC-H |
| 83 |
78-EUC-V |
| 84 |
78-H |
| 85 |
78-RKSJ-H |
| 86 |
78-RKSJ-V |
| 87 |
78-V |
| 88 |
78ms-RKSJ-H |
| 89 |
78ms-RKSJ-V |
| 90 |
83pv-RKSJ-H |
| 91 |
90ms-RKSJ-H |
| 92 |
90ms-RKSJ-V |
| 93 |
90msp-RKSJ-H |
| 94 |
90msp-RKSJ-V |
| 95 |
90pv-RKSJ-H |
| 96 |
90pv-RKSJ-V |
| 97 |
Add-H |
| 98 |
Add-RKSJ-H |
| 99 |
Add-RKSJ-V |
| 100 |
Add-V |
| 101 |
Adobe-Japan1-0 |
| 102 |
Adobe-Japan1-1 |
| 103 |
Adobe-Japan1-2 |
| 104 |
Adobe-Japan1-3 |
| 105 |
Adobe-Japan1-4 |
| 106 |
Adobe-Japan1-5 |
| 107 |
Adobe-Japan1-6 |
| 108 |
Adobe-Japan1-7 |
| 109 |
EUC-H |
| 110 |
EUC-V |
| 111 |
Ext-H |
| 112 |
Ext-RKSJ-H |
| 113 |
Ext-RKSJ-V |
| 114 |
Ext-V |
| 115 |
H |
| 116 |
Hankaku |
| 117 |
Hiragana |
| 118 |
Identity-H |
| 119 |
Identity-V |
| 120 |
Katakana |
| 121 |
NWP-H |
| 122 |
NWP-V |
| 123 |
RKSJ-H |
| 124 |
RKSJ-V |
| 125 |
Roman |
| 126 |
UniJIS-UCS2-H |
| 127 |
UniJIS-UCS2-HW-H |
| 128 |
UniJIS-UCS2-HW-V |
| 129 |
UniJIS-UCS2-V |
| 130 |
UniJIS-UTF16-H |
| 131 |
UniJIS-UTF16-V |
| 132 |
UniJIS-UTF32-H |
| 133 |
UniJIS-UTF32-V |
| 134 |
UniJIS-UTF8-H |
| 135 |
UniJIS-UTF8-V |
| 136 |
UniJIS2004-UTF16-H |
| 137 |
UniJIS2004-UTF16-V |
| 138 |
UniJIS2004-UTF32-H |
| 139 |
UniJIS2004-UTF32-V |
| 140 |
UniJIS2004-UTF8-H |
| 141 |
UniJIS2004-UTF8-V |
| 142 |
UniJISPro-UCS2-HW-V |
| 143 |
UniJISPro-UCS2-V |
| 144 |
UniJISPro-UTF8-V |
| 145 |
UniJISX0213-UTF32-H |
| 146 |
UniJISX0213-UTF32-V |
| 147 |
UniJISX02132004-UTF32-H |
| 148 |
UniJISX02132004-UTF32-V |
| 149 |
V |
| 150 |
WP-Symbol |
| 151 |
/ ], |
| 152 |
GB => [ qw/ |
| 153 |
Adobe-GB1-0 |
| 154 |
Adobe-GB1-1 |
| 155 |
Adobe-GB1-2 |
| 156 |
Adobe-GB1-3 |
| 157 |
Adobe-GB1-4 |
| 158 |
Adobe-GB1-5 |
| 159 |
GB-EUC-H |
| 160 |
GB-EUC-V |
| 161 |
GB-H |
| 162 |
GB-RKSJ-H |
| 163 |
GB-V |
| 164 |
GBK-EUC-H |
| 165 |
GBK-EUC-V |
| 166 |
GBK2K-H |
| 167 |
GBK2K-V |
| 168 |
GBKp-EUC-H |
| 169 |
GBKp-EUC-V |
| 170 |
GBT-EUC-H |
| 171 |
GBT-EUC-V |
| 172 |
GBT-H |
| 173 |
GBT-RKSJ-H |
| 174 |
GBT-V |
| 175 |
GBTpc-EUC-H |
| 176 |
GBTpc-EUC-V |
| 177 |
GBpc-EUC-H |
| 178 |
GBpc-EUC-V |
| 179 |
Identity-H |
| 180 |
Identity-V |
| 181 |
UniGB-UCS2-H |
| 182 |
UniGB-UCS2-V |
| 183 |
UniGB-UTF16-H |
| 184 |
UniGB-UTF16-V |
| 185 |
UniGB-UTF32-H |
| 186 |
UniGB-UTF32-V |
| 187 |
UniGB-UTF8-H |
| 188 |
UniGB-UTF8-V |
| 189 |
/ ], |
| 190 |
CNS => [ qw/ |
| 191 |
Adobe-CNS1-0 |
| 192 |
Adobe-CNS1-1 |
| 193 |
Adobe-CNS1-2 |
| 194 |
Adobe-CNS1-3 |
| 195 |
Adobe-CNS1-4 |
| 196 |
Adobe-CNS1-5 |
| 197 |
Adobe-CNS1-6 |
| 198 |
Adobe-CNS1-7 |
| 199 |
B5-H |
| 200 |
B5-V |
| 201 |
B5pc-H |
| 202 |
B5pc-V |
| 203 |
CNS-EUC-H |
| 204 |
CNS-EUC-V |
| 205 |
CNS1-H |
| 206 |
CNS1-V |
| 207 |
CNS2-H |
| 208 |
CNS2-V |
| 209 |
ETHK-B5-H |
| 210 |
ETHK-B5-V |
| 211 |
ETen-B5-H |
| 212 |
ETen-B5-V |
| 213 |
ETenms-B5-H |
| 214 |
ETenms-B5-V |
| 215 |
HKdla-B5-H |
| 216 |
HKdla-B5-V |
| 217 |
HKdlb-B5-H |
| 218 |
HKdlb-B5-V |
| 219 |
HKgccs-B5-H |
| 220 |
HKgccs-B5-V |
| 221 |
HKm314-B5-H |
| 222 |
HKm314-B5-V |
| 223 |
HKm471-B5-H |
| 224 |
HKm471-B5-V |
| 225 |
HKscs-B5-H |
| 226 |
HKscs-B5-V |
| 227 |
Identity-H |
| 228 |
Identity-V |
| 229 |
UniCNS-UCS2-H |
| 230 |
UniCNS-UCS2-V |
| 231 |
UniCNS-UTF16-H |
| 232 |
UniCNS-UTF16-V |
| 233 |
UniCNS-UTF32-H |
| 234 |
UniCNS-UTF32-V |
| 235 |
UniCNS-UTF8-H |
| 236 |
UniCNS-UTF8-V |
| 237 |
/ ], |
| 238 |
Korea => [ qw/ |
| 239 |
Adobe-Korea1-0 |
| 240 |
Adobe-Korea1-1 |
| 241 |
Adobe-Korea1-2 |
| 242 |
Identity-H |
| 243 |
Identity-V |
| 244 |
KSC-EUC-H |
| 245 |
KSC-EUC-V |
| 246 |
KSC-H |
| 247 |
KSC-Johab-H |
| 248 |
KSC-Johab-V |
| 249 |
KSC-RKSJ-H |
| 250 |
KSC-V |
| 251 |
KSCms-UHC-H |
| 252 |
KSCms-UHC-HW-H |
| 253 |
KSCms-UHC-HW-V |
| 254 |
KSCms-UHC-V |
| 255 |
KSCpc-EUC-H |
| 256 |
KSCpc-EUC-V |
| 257 |
UniKS-UCS2-H |
| 258 |
UniKS-UCS2-V |
| 259 |
UniKS-UTF16-H |
| 260 |
UniKS-UTF16-V |
| 261 |
UniKS-UTF32-H |
| 262 |
UniKS-UTF32-V |
| 263 |
UniKS-UTF8-H |
| 264 |
UniKS-UTF8-V |
| 265 |
/ ] ); |
| 266 |
|
| 267 |
# |
| 268 |
# location where links to fonts in texmf are created, relative to TEXMF |
| 269 |
my $otf_pathpart = "fonts/opentype/cjk-gs-integrate"; |
| 270 |
my $ttf_pathpart = "fonts/truetype/cjk-gs-integrate"; |
| 271 |
|
| 272 |
# location where cidfmap, cidfmap.local and cidfmap.aliases are placed |
| 273 |
# when found gs is tlgs (win32), then files will be placed in lib/ instead of Resource/Init/ |
| 274 |
my $cidfmap_pathpart = "Init/cidfmap"; |
| 275 |
my $cidfmap_local_pathpart = "Init/cidfmap.local"; |
| 276 |
my $cidfmap_aliases_pathpart = "Init/cidfmap.aliases"; |
| 277 |
|
| 278 |
# support for ps2otfps by Akira Kakuto |
| 279 |
my $akotfps_pathpart = "dvips/ps2otfps"; |
| 280 |
my $akotfps_datafilename = "psnames-for-otf"; |
| 281 |
my $akotfps_datacontent = ''; |
| 282 |
|
| 283 |
# dump output for data file (for easy editing for users) |
| 284 |
my $dump_datafile = "$prg-data.dat"; |
| 285 |
|
| 286 |
my $opt_output; |
| 287 |
my $opt_fontdef; |
| 288 |
my @opt_fontdef_add; |
| 289 |
my @opt_aliases; |
| 290 |
my $opt_filelist; |
| 291 |
my $opt_texmflink; |
| 292 |
my $opt_akotfps; |
| 293 |
my $opt_force = 0; |
| 294 |
my $opt_remove = 0; |
| 295 |
my $opt_cleanup = 0; |
| 296 |
my $opt_hardlink = 0; |
| 297 |
my $opt_winbatch; |
| 298 |
my $opt_dump_data; |
| 299 |
my $opt_only_aliases = 0; |
| 300 |
my $opt_listaliases = 0; |
| 301 |
my $opt_listallaliases = 0; |
| 302 |
my $opt_listfonts = 0; |
| 303 |
my $opt_info = 0; |
| 304 |
my $opt_machine = 0; |
| 305 |
my $opt_strictpsname = 0; |
| 306 |
my $dry_run = 0; |
| 307 |
my $opt_quiet = 0; |
| 308 |
my $opt_debug = 0; |
| 309 |
my $opt_help = 0; |
| 310 |
my $opt_markdown = 0; |
| 311 |
|
| 312 |
if (! GetOptions( |
| 313 |
"o|output=s" => \$opt_output, |
| 314 |
"f|fontdef=s" => \$opt_fontdef, |
| 315 |
"fontdef-add=s" => \@opt_fontdef_add, |
| 316 |
"a|alias=s" => \@opt_aliases, |
| 317 |
"filelist=s" => \$opt_filelist, |
| 318 |
"link-texmf:s" => \$opt_texmflink, |
| 319 |
"otfps:s" => \$opt_akotfps, |
| 320 |
"force" => \$opt_force, |
| 321 |
"remove" => \$opt_remove, |
| 322 |
"cleanup" => \$opt_cleanup, |
| 323 |
"hardlink" => \$opt_hardlink, |
| 324 |
"winbatch:s" => \$opt_winbatch, |
| 325 |
"dump-data:s" => \$opt_dump_data, |
| 326 |
"only-aliases" => \$opt_only_aliases, |
| 327 |
"list-aliases" => \$opt_listaliases, |
| 328 |
"list-all-aliases" => \$opt_listallaliases, |
| 329 |
"list-fonts" => \$opt_listfonts, |
| 330 |
"info" => \$opt_info, |
| 331 |
"machine-readable" => \$opt_machine, |
| 332 |
"strict-psname" => \$opt_strictpsname, # hidden option for debugging |
| 333 |
"n|dry-run" => \$dry_run, |
| 334 |
"q|quiet" => \$opt_quiet, |
| 335 |
"d|debug+" => \$opt_debug, |
| 336 |
"h|help" => \$opt_help, |
| 337 |
"markdown" => \$opt_markdown, |
| 338 |
"v|version" => sub { print &version(); exit(0); }, ) ) { |
| 339 |
die "Try \"$0 --help\" for more information.\n"; |
| 340 |
} |
| 341 |
|
| 342 |
if ($debug_msg_before_init) { |
| 343 |
print_debug ($debug_msg_before_init); |
| 344 |
} |
| 345 |
|
| 346 |
sub win32 { return ($^O=~/^MSWin(32|64)$/i); } |
| 347 |
sub macosx { return ($^O=~/^darwin$/i); } |
| 348 |
my $nul = (win32() ? 'nul' : '/dev/null') ; |
| 349 |
my $sep = (win32() ? ';' : ':'); |
| 350 |
my %fontdb; |
| 351 |
my %aliases; |
| 352 |
my %user_aliases; |
| 353 |
|
| 354 |
if ($opt_help || $opt_markdown) { |
| 355 |
Usage(); |
| 356 |
exit(0); |
| 357 |
} |
| 358 |
|
| 359 |
# check for the existence of kpsewhich, otherwise we cannot do anything |
| 360 |
if (system("kpsewhich --version >$nul 2>&1 <$nul" ) != 0) { |
| 361 |
print_error("We need `kpsewhich' being installed! Exiting.\n"); |
| 362 |
exit(1); |
| 363 |
} |
| 364 |
|
| 365 |
if ($opt_debug >= 2) { |
| 366 |
require Data::Dumper; |
| 367 |
no warnings qw(once); |
| 368 |
$Data::Dumper::Indent = 1; |
| 369 |
} |
| 370 |
|
| 371 |
my $zrlistttc = kpse_miscfont("zrlistttc.lua"); |
| 372 |
my $zrlistttc_available; |
| 373 |
my $cmdl = "texlua $zrlistttc 2>$nul"; |
| 374 |
$cmdl = encode('locale', $cmdl); |
| 375 |
chomp(my $zrlistttc_help = `$cmdl`); |
| 376 |
if ($?) { |
| 377 |
if ($opt_strictpsname) { |
| 378 |
print_error("The script 'zrlistttc.lua' not found, cannot proceed!\n"); |
| 379 |
exit(1); |
| 380 |
} |
| 381 |
# show info only for debugging |
| 382 |
print_debug("The script 'zrlistttc.lua' not found.\n"); |
| 383 |
print_debug("Sorry, we can't be safe enough to distinguish\n"); |
| 384 |
print_debug("uppercase / lowercase file names.\n"); |
| 385 |
$zrlistttc_available = 0; |
| 386 |
} else { |
| 387 |
$zrlistttc_available = 1; |
| 388 |
} |
| 389 |
|
| 390 |
if (macosx()) { |
| 391 |
# due to frequent incompatible changes in font file names by Apple, |
| 392 |
# our built-in database doesn't support OS X 10.11 El Capitan or |
| 393 |
# later versions |
| 394 |
my $macos_ver = `sw_vers -productVersion`; |
| 395 |
my $macos_ver_major = $macos_ver; |
| 396 |
$macos_ver_major =~ s/^(\d+)\.(\d+).*/$1/; |
| 397 |
my $macos_ver_minor = $macos_ver; |
| 398 |
$macos_ver_minor =~ s/^(\d+)\.(\d+).*/$2/; |
| 399 |
if ($macos_ver_major>=11 || ($macos_ver_major==10 && $macos_ver_minor>=8)) { |
| 400 |
if (!$opt_cleanup && !$opt_fontdef && !@opt_fontdef_add) { # if built-in only |
| 401 |
print_warning("Our built-in database does not support recent\n"); |
| 402 |
print_warning("versions of Mac OS (10.8 Mountain Lion or later)!\n"); |
| 403 |
print_warning("If you want to use Hiragino fonts bundled with\n"); |
| 404 |
print_warning("your OS, obtain external database file and\n"); |
| 405 |
print_warning("specify it with --fontdef-add option!\n"); |
| 406 |
print_warning("I'll continue with my built-in database ...\n"); |
| 407 |
} |
| 408 |
} |
| 409 |
} |
| 410 |
|
| 411 |
if (defined($opt_texmflink)) { |
| 412 |
my $foo; |
| 413 |
if ($opt_texmflink eq '') { |
| 414 |
# option was passed but didn't receive a value |
| 415 |
# -> use TEXMFLOCAL |
| 416 |
$foo = `kpsewhich -var-value=TEXMFLOCAL`; |
| 417 |
# We assume that the output of kpsewhich is |
| 418 |
# the same as perl's locale (or active code page). |
| 419 |
decode('locale', $foo); |
| 420 |
chomp($foo); |
| 421 |
} else { |
| 422 |
# option was passed with an argument |
| 423 |
# -> use it |
| 424 |
$foo = $opt_texmflink; |
| 425 |
} |
| 426 |
$opt_texmflink = $foo; |
| 427 |
} |
| 428 |
|
| 429 |
if (defined($opt_akotfps)) { |
| 430 |
my $foo; |
| 431 |
if ($opt_akotfps eq '') { |
| 432 |
if (defined($opt_texmflink)) { |
| 433 |
$foo = $opt_texmflink; |
| 434 |
} else { |
| 435 |
$foo = `kpsewhich -var-value=TEXMFLOCAL`; |
| 436 |
# We assume that the output of kpsewhich is |
| 437 |
# the same as perl's locale (or active code page). |
| 438 |
decode('locale', $foo); |
| 439 |
chomp($foo); |
| 440 |
} |
| 441 |
} else { |
| 442 |
$foo = $opt_akotfps; |
| 443 |
} |
| 444 |
$opt_akotfps = $foo; |
| 445 |
} |
| 446 |
|
| 447 |
if (defined($opt_winbatch)) { |
| 448 |
print_warning("ignoring --winbatch option due to being obsolete\n"); |
| 449 |
} |
| 450 |
if ($opt_hardlink) { |
| 451 |
print_warning("ignoring --hardlink option due to being obsolete\n"); |
| 452 |
} |
| 453 |
|
| 454 |
if (defined($opt_dump_data)) { |
| 455 |
if ($opt_dump_data ne '') { |
| 456 |
$dump_datafile = $opt_dump_data; |
| 457 |
} |
| 458 |
$opt_dump_data = 1; |
| 459 |
unlink encode('locale_fs', $dump_datafile) |
| 460 |
if (-f encode('locale_fs', $dump_datafile)); |
| 461 |
} else { |
| 462 |
$opt_dump_data = 0; |
| 463 |
} |
| 464 |
|
| 465 |
if ($opt_cleanup) { |
| 466 |
$opt_remove = 1; |
| 467 |
} |
| 468 |
|
| 469 |
if ($opt_info) { |
| 470 |
$opt_listfonts = 1; |
| 471 |
$opt_listaliases = 1; |
| 472 |
} |
| 473 |
|
| 474 |
# check exclusive options; unsafe due to make_all_available() |
| 475 |
if ($opt_listallaliases && $opt_listaliases) { |
| 476 |
print_error("Both --list-all-aliases and --list-aliases!? I'm confused!\n"); |
| 477 |
exit(1); |
| 478 |
} |
| 479 |
if ($opt_listallaliases && $opt_listfonts) { |
| 480 |
print_error("Options --list-all-aliases and --list-fonts cannot be used at the same time!\n"); |
| 481 |
exit(1); |
| 482 |
} |
| 483 |
if ($opt_cleanup && $opt_listfonts) { |
| 484 |
print_error("Options --cleanup and --list-fonts cannot be used at the same time!\n"); |
| 485 |
exit(1); |
| 486 |
} |
| 487 |
if ($opt_cleanup && $opt_listaliases) { |
| 488 |
print_error("Options --cleanup and --list-aliases cannot be used at the same time!\n"); |
| 489 |
exit(1); |
| 490 |
} |
| 491 |
|
| 492 |
main(@ARGV); |
| 493 |
|
| 494 |
# |
| 495 |
# only sub definitions from here on |
| 496 |
# |
| 497 |
sub main { |
| 498 |
# first, read font database to obtain %fontdb |
| 499 |
print_info("reading font database ...\n"); |
| 500 |
read_font_database(); |
| 501 |
if ($opt_dump_data) { |
| 502 |
# with --dump-data, dump only effective database and exit |
| 503 |
dump_font_database(); |
| 504 |
if (-f encode('locale_fs', $dump_datafile)) { |
| 505 |
print_info("*** Data dumped to $dump_datafile ***\n"); |
| 506 |
exit(0); |
| 507 |
} else { |
| 508 |
print_error("Failed to dump data to $dump_datafile!\n"); |
| 509 |
exit(1); |
| 510 |
} |
| 511 |
} |
| 512 |
# second, determine non-otf link name |
| 513 |
# this is actually required only by info_found_fonts() and do_nonotf_fonts() |
| 514 |
# operations, but it does no harm for other cases too |
| 515 |
determine_nonotf_link_name(); # see comments there |
| 516 |
|
| 517 |
# set 'available' flags and 'type' by kpsewhich search |
| 518 |
# if $opt_cleanup or $opt_listallaliases is given, treat all files |
| 519 |
# in the database as if they were actually available as OTF |
| 520 |
if (!$opt_cleanup && !$opt_listallaliases) { |
| 521 |
print_info("checking for files ...\n"); |
| 522 |
check_for_files(); |
| 523 |
} else { |
| 524 |
make_all_available(); |
| 525 |
} |
| 526 |
# obtain %aliases and %user_aliases |
| 527 |
compute_aliases(); |
| 528 |
|
| 529 |
# informative operations |
| 530 |
if ($opt_listfonts) { |
| 531 |
info_found_fonts(); |
| 532 |
} |
| 533 |
if ($opt_listaliases || $opt_listallaliases) { |
| 534 |
info_list_aliases(); |
| 535 |
} |
| 536 |
exit(0) if ($opt_listfonts || $opt_listaliases || $opt_listallaliases); |
| 537 |
# if $opt_machine is still alive after the above exit(0), it's useless |
| 538 |
if ($opt_machine) { |
| 539 |
print_error("Option --machine-readable should be used with at least one of the followings:\n"); |
| 540 |
print_error(" --list-aliases, --list-all-aliases, --list-fonts, --info\n"); |
| 541 |
print_error("terminating.\n"); |
| 542 |
exit(1); |
| 543 |
} |
| 544 |
|
| 545 |
# do actual setup/removing operations |
| 546 |
if (!$opt_output) { |
| 547 |
print_info("searching for Ghostscript resource\n"); |
| 548 |
my $gsres = find_gs_resource(); |
| 549 |
if (!$gsres) { |
| 550 |
print_error("Cannot find Ghostscript, terminating!\n"); |
| 551 |
exit(1); |
| 552 |
} else { |
| 553 |
$opt_output = $gsres; |
| 554 |
} |
| 555 |
} |
| 556 |
if (! -d encode('locale_fs', $opt_output)) { |
| 557 |
$dry_run || mkdir(encode('locale_fs', $opt_output)) || |
| 558 |
die("Cannot create directory $opt_output: $!"); |
| 559 |
} |
| 560 |
if ($opt_cleanup) { |
| 561 |
print_info("going to clean up $opt_output\n"); |
| 562 |
} else { |
| 563 |
print_info("output is going to $opt_output\n"); |
| 564 |
} |
| 565 |
if (!$opt_only_aliases) { |
| 566 |
if ($opt_cleanup) { |
| 567 |
# all font types are handled at the same time |
| 568 |
print_info("cleaning up all links, snippets and cidfmap.local ...\n"); |
| 569 |
do_all_fonts(); |
| 570 |
} else { |
| 571 |
# OTF and TTF/TTC/OTC must be handled separately, depending on the found files |
| 572 |
print_info(($opt_remove ? "removing" : "generating") . " links and snippets for CID fonts ...\n"); |
| 573 |
do_otf_fonts(); |
| 574 |
print_info(($opt_remove ? "removing" : "generating") . " links, snippets and cidfmap.local for non-CID fonts ...\n"); |
| 575 |
do_nonotf_fonts(); |
| 576 |
} |
| 577 |
} |
| 578 |
print_info(($opt_remove ? "removing" : "generating") . " snippets and cidfmap.aliases for font aliases ...\n"); |
| 579 |
do_aliases(); |
| 580 |
do_cmaps(); |
| 581 |
write_akotfps_datafile() if $opt_akotfps; |
| 582 |
if ($opt_texmflink && !$dry_run) { |
| 583 |
print_info("running mktexlsr ...\n"); |
| 584 |
system("mktexlsr"); |
| 585 |
} |
| 586 |
print_info("finished\n"); |
| 587 |
} |
| 588 |
|
| 589 |
sub do_all_fonts { |
| 590 |
# try to clean up all possible links/snippets/cidfmap which could have been |
| 591 |
# generated in the previous runs |
| 592 |
# previous versions of cjk-gs-integrate included following bugs: |
| 593 |
# * the database sometimes identified GB/CNS classes wrongly |
| 594 |
# * symlink names were sometimes invalid (some of which contained |
| 595 |
# white-spaces, due to the absence of proper database entry) or |
| 596 |
# inconsistent with ptex-fontmaps (Name <-> PSName or redundant Filename) |
| 597 |
# * confused symlinks between TTF/TTC/OTC (including ttf <-> ttc links) |
| 598 |
# also, current version generates OTC links into $otf_pathpart instead of |
| 599 |
# $ttf_pathpart, which was not true in the older versions |
| 600 |
# we'd like to clean up all such files |
| 601 |
my $fontdest = "$opt_output/Font"; |
| 602 |
my $ciddest = "$opt_output/CIDFont"; |
| 603 |
my $cidfsubst = "$opt_output/CIDFSubst"; |
| 604 |
for my $k (sort keys %fontdb) { |
| 605 |
# |
| 606 |
# remove snippets: note that $class = $fontdb{$k}{'class'} is not enough |
| 607 |
# due to previous bugs |
| 608 |
for my $class (%encode_list) { |
| 609 |
for my $enc (@{$encode_list{$class}}) { |
| 610 |
unlink encode('locale_fs', "$fontdest/$k-$enc") |
| 611 |
if (-f encode('locale_fs', "$fontdest/$k-$enc")); |
| 612 |
} |
| 613 |
} |
| 614 |
# |
| 615 |
# remove links; borrow link_font operation here for convenience |
| 616 |
# since we don't need target in cleanup mode, initialize with stub "none" |
| 617 |
# |
| 618 |
# for OTF/TTF fonts, first remove both $k[.otf,ttf] and $fontdb{$k}{'origname'}[.otf] |
| 619 |
# the links $k.otf and $fontdb{$k}{'origname'} are coming from previous bugs, |
| 620 |
# and the links $k.ttf are (sometimes) coming from inconsistency |
| 621 |
if ($fontdb{$k}{'origname'}) { # this test skips alias-only fonts (e.g. Ryumin-Light) |
| 622 |
link_font("none", $ciddest, $k); |
| 623 |
link_font("none", $cidfsubst, "$k.ttf"); |
| 624 |
link_font("none", "$opt_texmflink/$otf_pathpart", "$k.otf") |
| 625 |
if $opt_texmflink; |
| 626 |
link_font("none", "$opt_texmflink/$ttf_pathpart", "$k.ttf") |
| 627 |
if $opt_texmflink; |
| 628 |
link_font("none", $ciddest, $fontdb{$k}{'origname'}); |
| 629 |
link_font("none", "$opt_texmflink/$otf_pathpart", "$fontdb{$k}{'origname'}.otf") |
| 630 |
if $opt_texmflink; |
| 631 |
} |
| 632 |
# for OTF/TTF/TTC/OTC fonts, loop through all file candidates |
| 633 |
for my $f (keys %{$fontdb{$k}{'files'}}) { |
| 634 |
# check for subfont extension |
| 635 |
my $foo = $f; |
| 636 |
$foo =~ s/^(.*)\(\d*\)$/$1/; |
| 637 |
link_font("none", $cidfsubst, "$foo"); |
| 638 |
link_font("none", "$opt_texmflink/$otf_pathpart", "$foo") if $opt_texmflink; |
| 639 |
link_font("none", "$opt_texmflink/$ttf_pathpart", "$foo") if $opt_texmflink; |
| 640 |
} |
| 641 |
} |
| 642 |
update_master_cidfmap('cidfmap.local'); |
| 643 |
# we are in cleanup mode, also remove cidfmap.local itself |
| 644 |
if (-f encode('locale_fs', "$opt_output/$cidfmap_local_pathpart")) { |
| 645 |
unlink encode('locale_fs', "$opt_output/$cidfmap_local_pathpart"); |
| 646 |
} |
| 647 |
} |
| 648 |
|
| 649 |
sub do_otf_fonts { |
| 650 |
my $fontdest = "$opt_output/Font"; |
| 651 |
my $ciddest = "$opt_output/CIDFont"; |
| 652 |
make_dir($fontdest, "cannot create CID snippets there!"); |
| 653 |
make_dir($ciddest, "cannot link CID fonts there!"); |
| 654 |
make_dir("$opt_texmflink/$otf_pathpart", |
| 655 |
"cannot link fonts to it!") |
| 656 |
if $opt_texmflink; |
| 657 |
for my $k (sort keys %fontdb) { |
| 658 |
if ($fontdb{$k}{'available'} && $fontdb{$k}{'type'} eq 'OTF') { |
| 659 |
generate_font_snippet($fontdest, |
| 660 |
$k, $fontdb{$k}{'class'}, $fontdb{$k}{'target'}); |
| 661 |
link_font($fontdb{$k}{'target'}, $ciddest, $k); |
| 662 |
link_font($fontdb{$k}{'target'}, "$opt_texmflink/$otf_pathpart", "$fontdb{$k}{'origname'}.otf") |
| 663 |
if $opt_texmflink; |
| 664 |
} |
| 665 |
} |
| 666 |
} |
| 667 |
|
| 668 |
sub do_nonotf_fonts { |
| 669 |
my $fontdest = "$opt_output/Font"; |
| 670 |
my $cidfsubst = "$opt_output/CIDFSubst"; |
| 671 |
my $outp = ''; |
| 672 |
make_dir($fontdest, "cannot create CID snippets there!"); |
| 673 |
make_dir($cidfsubst, "cannot link TTF fonts there!"); |
| 674 |
make_dir("$opt_texmflink/$ttf_pathpart", |
| 675 |
"cannot link fonts to it!") |
| 676 |
if $opt_texmflink; |
| 677 |
for my $k (sort keys %fontdb) { |
| 678 |
if ($fontdb{$k}{'available'} && $fontdb{$k}{'type'} eq 'TTF') { |
| 679 |
$outp .= generate_cidfmap_entry($k, $fontdb{$k}{'class'}, $fontdb{$k}{'ttfname'}, -1); |
| 680 |
link_font($fontdb{$k}{'target'}, $cidfsubst, $fontdb{$k}{'ttfname'}); |
| 681 |
link_font($fontdb{$k}{'target'}, "$opt_texmflink/$ttf_pathpart", $fontdb{$k}{'ttfname'}) |
| 682 |
if $opt_texmflink; |
| 683 |
} elsif ($fontdb{$k}{'available'} && $fontdb{$k}{'type'} eq 'TTC') { |
| 684 |
$outp .= generate_cidfmap_entry($k, $fontdb{$k}{'class'}, $fontdb{$k}{'ttcname'}, $fontdb{$k}{'subfont'}); |
| 685 |
link_font($fontdb{$k}{'target'}, $cidfsubst, $fontdb{$k}{'ttcname'}); |
| 686 |
link_font($fontdb{$k}{'target'}, "$opt_texmflink/$ttf_pathpart", $fontdb{$k}{'ttcname'}) |
| 687 |
if $opt_texmflink; |
| 688 |
} elsif ($fontdb{$k}{'available'} && $fontdb{$k}{'type'} eq 'OTC') { |
| 689 |
# currently Ghostscript does not have OTC support; we don't know what to do |
| 690 |
print_debug("gs does not support OTC, not creating gs resource for $k\n"); |
| 691 |
link_font($fontdb{$k}{'target'}, "$opt_texmflink/$otf_pathpart", $fontdb{$k}{'otcname'}) |
| 692 |
if $opt_texmflink; |
| 693 |
} |
| 694 |
} |
| 695 |
return if $dry_run; |
| 696 |
if ($outp) { |
| 697 |
if (! -d encode('locale_fs', "$opt_output/Init")) { |
| 698 |
mkdir(encode('locale_fs', "$opt_output/Init")) || |
| 699 |
die("Cannot create directory $opt_output/Init: $!"); |
| 700 |
} |
| 701 |
# It seems that tlgs can handle UTF-8 TTF filename in cidfmap.local. |
| 702 |
open(FOO, ">:encoding(UTF-8)", |
| 703 |
encode('locale_fs', "$opt_output/$cidfmap_local_pathpart")) || |
| 704 |
die("Cannot open $opt_output/$cidfmap_local_pathpart: $!"); |
| 705 |
print FOO $outp; |
| 706 |
close(FOO); |
| 707 |
} |
| 708 |
update_master_cidfmap('cidfmap.local'); |
| 709 |
} |
| 710 |
|
| 711 |
sub do_aliases { |
| 712 |
my $fontdest = "$opt_output/Font"; |
| 713 |
my $ciddest = "$opt_output/CIDFont"; # required for Heisei* check only |
| 714 |
my $cidfsubst = "$opt_output/CIDFSubst"; |
| 715 |
my $outp = ''; |
| 716 |
# |
| 717 |
# alias handling |
| 718 |
# we use two levels of aliases |
| 719 |
# * one is for the default generic names (these are not actual fonts) |
| 720 |
# Ryumin-Light, GothicBBB-Medium, ... etc. |
| 721 |
# * the second level of aliases is for Morisawa OTF font names |
| 722 |
# RyuminPro-Light, GothicBBBPro-Medium, ... etc. |
| 723 |
# the order of fonts selected is |
| 724 |
# defined in the Provides(Priority): Name in the font definiton |
| 725 |
# |
| 726 |
$outp .= "\n\n% Aliases\n"; |
| 727 |
# |
| 728 |
my (@jal, @kal, @tal, @sal, @ai0al); |
| 729 |
# |
| 730 |
for my $al (sort keys %aliases) { |
| 731 |
my $target; |
| 732 |
my $class; |
| 733 |
if ($user_aliases{$al}) { |
| 734 |
$target = $user_aliases{$al}; |
| 735 |
# determine class |
| 736 |
if ($fontdb{$target}{'available'}) { |
| 737 |
$class = $fontdb{$target}{'class'}; |
| 738 |
} else { |
| 739 |
# must be an aliases, we checked this when initializing %user_aliases |
| 740 |
# reset the $al value |
| 741 |
# and since $class is still undefined we will use the next code below |
| 742 |
$al = $target; |
| 743 |
} |
| 744 |
} |
| 745 |
if (!$class) { |
| 746 |
if (!%{$aliases{$al}}) { |
| 747 |
print_warning("Alias candidate for $al is empty, skipping!\n"); |
| 748 |
next; |
| 749 |
} |
| 750 |
# search lowest number |
| 751 |
my @ks = keys(%{$aliases{$al}}); |
| 752 |
my $first = (sort { $a <=> $b} @ks)[0]; |
| 753 |
$target = $aliases{$al}{$first}; |
| 754 |
$class = $fontdb{$target}{'class'}; |
| 755 |
} |
| 756 |
# we also need to create font snippets in Font (or add configuration) |
| 757 |
# for the aliases! |
| 758 |
generate_font_snippet($fontdest, $al, $class, $target); |
| 759 |
if ($class eq 'Japan') { |
| 760 |
push @jal, "/$al /$target ;"; |
| 761 |
} elsif ($class eq 'Korea') { |
| 762 |
push @kal, "/$al /$target ;"; |
| 763 |
} elsif ($class eq 'GB') { |
| 764 |
push @sal, "/$al /$target ;"; |
| 765 |
} elsif ($class eq 'CNS') { |
| 766 |
push @tal, "/$al /$target ;"; |
| 767 |
} elsif ($class eq 'AI0') { |
| 768 |
push @ai0al, "/$al /$target ;"; |
| 769 |
} else { |
| 770 |
print STDERR "unknown class $class for $al\n"; |
| 771 |
} |
| 772 |
} |
| 773 |
# special case for native CID fonts in ancient days |
| 774 |
# if not readable, add aliases for substitution |
| 775 |
push @jal, "/HeiseiMin-W3 /Ryumin-Light ;" |
| 776 |
if (! -r encode('locale_fs', "$ciddest/HeiseiMin-W3")); |
| 777 |
push @jal, "/HeiseiKakuGo-W5 /GothicBBB-Medium ;" |
| 778 |
if (! -r encode('locale_fs', "$ciddest/HeiseiKakuGo-W5")); |
| 779 |
# |
| 780 |
$outp .= "\n% Japanese fonts\n" . join("\n", @jal) . "\n" if @jal; |
| 781 |
$outp .= "\n% Korean fonts\n" . join("\n", @kal) . "\n" if @kal; |
| 782 |
$outp .= "\n% Traditional Chinese fonts\n" . join("\n", @tal) . "\n" if @tal; |
| 783 |
$outp .= "\n% Simplified Chinese fonts\n" . join("\n", @sal) . "\n" if @sal; |
| 784 |
$outp .= "\n% Adobe-Identity-0 fonts\n" . join("\n", @ai0al) . "\n" if @ai0al; |
| 785 |
# |
| 786 |
return if $dry_run; |
| 787 |
if ($outp && !$opt_remove) { |
| 788 |
if (! -d encode('locale_fs', "$opt_output/Init")) { |
| 789 |
mkdir(encode('locale_fs', "$opt_output/Init")) || |
| 790 |
die("Cannot create directory $opt_output/Init: $!"); |
| 791 |
} |
| 792 |
open(FOO, ">:encoding(UTF-8)", |
| 793 |
encode('locale_fs', "$opt_output/$cidfmap_aliases_pathpart")) || |
| 794 |
die("Cannot open $opt_output/$cidfmap_aliases_pathpart: $!"); |
| 795 |
print FOO $outp; |
| 796 |
close(FOO); |
| 797 |
} |
| 798 |
update_master_cidfmap('cidfmap.aliases'); |
| 799 |
# if we are in cleanup mode, also remove cidfmap.aliases itself |
| 800 |
if (-f encode('locale_fs', "$opt_output/$cidfmap_aliases_pathpart")) { |
| 801 |
unlink encode('locale_fs', "$opt_output/$cidfmap_aliases_pathpart") |
| 802 |
if $opt_cleanup; |
| 803 |
} |
| 804 |
} |
| 805 |
|
| 806 |
sub do_cmaps { |
| 807 |
# add symlinking CMaps |
| 808 |
# for which we generate snippets but gs does not provide |
| 809 |
my $cmapdest = "$opt_output/CMap"; |
| 810 |
return if $dry_run; |
| 811 |
if ($opt_remove) { |
| 812 |
# we remove only if both of the following conditions are met: |
| 813 |
# (1) it is a link |
| 814 |
# (2) the link target is the same as kpsewhich result |
| 815 |
# otherwise it's unsafe to remove, as it may have been added |
| 816 |
# by others or distributed by gs itself |
| 817 |
for my $class (%encode_list) { |
| 818 |
for my $enc (@{$encode_list{$class}}) { |
| 819 |
if (-l encode('locale_fs', "$cmapdest/$enc")) { |
| 820 |
my $linkt = decode('locale_fs', |
| 821 |
readlink(encode('locale_fs', |
| 822 |
"$cmapdest/$enc"))); |
| 823 |
if ($linkt) { |
| 824 |
if ($linkt eq search_cmap($enc)) { |
| 825 |
unlink(encode('locale_fs', "$cmapdest/$enc")); |
| 826 |
} |
| 827 |
} |
| 828 |
} |
| 829 |
} |
| 830 |
} |
| 831 |
return; |
| 832 |
} |
| 833 |
# add mode |
| 834 |
if (! -d encode('locale_fs', "$cmapdest")) { |
| 835 |
print_debug("Creating directory $cmapdest ...\n"); |
| 836 |
make_dir("$cmapdest", "cannot create CMap directory"); |
| 837 |
} |
| 838 |
for my $class (%encode_list) { |
| 839 |
if ($class =~ m/^AI0-(.*)$/) { |
| 840 |
# skip AI0 font-specific CMap when the real font is unavailable |
| 841 |
next if (!$fontdb{$1}{'available'}); |
| 842 |
} |
| 843 |
for my $enc (@{$encode_list{$class}}) { |
| 844 |
if (! -f encode('locale_fs', "$cmapdest/$enc")) { |
| 845 |
print_debug("CMap $enc is not found in gs resource directory\n"); |
| 846 |
my $dest = search_cmap($enc); |
| 847 |
if ($dest) { |
| 848 |
print_debug("Symlinking CMap $dest ...\n"); |
| 849 |
link_font($dest, "$cmapdest", $enc); |
| 850 |
} else { |
| 851 |
print_debug("CMap $enc is not found by kpsewhich\n"); |
| 852 |
} |
| 853 |
} |
| 854 |
} |
| 855 |
} |
| 856 |
} |
| 857 |
|
| 858 |
my %cmap_cache; |
| 859 |
|
| 860 |
sub search_cmap { |
| 861 |
my ($cmap) = @_; |
| 862 |
# search CMap with kpsewhich and cache |
| 863 |
if (! exists $cmap_cache{$cmap}) { |
| 864 |
my $cmdl = "kpsewhich -format=cmap $cmap"; |
| 865 |
$cmdl = encode('locale', $cmdl); |
| 866 |
$cmap_cache{$cmap} = `$cmdl`; |
| 867 |
# We assume that the output of kpsewhich is |
| 868 |
# the same as perl's locale (or active code page). |
| 869 |
$cmap_cache{$cmap} = decode('locale', $cmap_cache{$cmap}); |
| 870 |
chomp($cmap_cache{$cmap}); |
| 871 |
$cmap_cache{$cmap} =~ s/[\r\n]+\z//; # perl's chomp() on git-bash cannot strip CR of CRLF ?? |
| 872 |
} |
| 873 |
return $cmap_cache{$cmap}; |
| 874 |
} |
| 875 |
|
| 876 |
sub update_master_cidfmap { |
| 877 |
# what we have to do is: |
| 878 |
# in add mode: |
| 879 |
# * add an entry for the given argument |
| 880 |
# * for tlgs.win32 pre-shipped cidfmap, prepend '%' to override |
| 881 |
# the default of "(cidfmap.TeXLive) .runlibfile", |
| 882 |
# in remove mode: |
| 883 |
# * remove an entry for the given argument |
| 884 |
# * for tlgs.win32 pre-shipped cidfmap, remove '%' to restore the default |
| 885 |
my $add = shift; |
| 886 |
my $cidfmap_master = "$opt_output/$cidfmap_pathpart"; |
| 887 |
print_info(sprintf("%s $add %s cidfmap file ...\n", |
| 888 |
($opt_remove ? "removing" : "adding"), ($opt_remove ? "from" : "to"))); |
| 889 |
if (-r encode('locale_fs', $cidfmap_master)) { |
| 890 |
open(FOO, "<:encoding(UTF-8)", encode('locale_fs', $cidfmap_master)) || |
| 891 |
die("Cannot open $cidfmap_master for reading: $!"); |
| 892 |
my $found = 0; |
| 893 |
my $found_tl = 0; |
| 894 |
my $newmaster = ""; |
| 895 |
# in add mode: just search for the entry and set $found |
| 896 |
# in remove mode: collect all lines that do not match |
| 897 |
# also, we handle "cidfmap.TeXLive" now |
| 898 |
while(<FOO>) { |
| 899 |
if (m/^\s*\(\Q$add\E\)\s\s*\.runlibfile\s*$/) { |
| 900 |
$found = 1; |
| 901 |
} elsif (m/^\s*\(cidfmap\.TeXLive\)\s\s*\.runlibfile\s*$/) { |
| 902 |
# if found, it has to be disabled in add mode in a way in which it can |
| 903 |
# be detected in the (future) remove mode |
| 904 |
next if $found_tl; # skip it as duplicate (though unlikely to happen) |
| 905 |
$found_tl = 1; |
| 906 |
$newmaster .= "\%" if (!$opt_remove); # in add mode, disable it |
| 907 |
$newmaster .= $_; # pass it as-is |
| 908 |
} elsif (m/^\s*\%\%*\s*\(cidfmap\.TeXLive\)\s\s*\.runlibfile\s*$/) { |
| 909 |
# if found, it should be the one disabled by myself in the previous run; |
| 910 |
# restore it in remove mode |
| 911 |
next if $found_tl; # skip it as duplicate (though unlikely to happen) |
| 912 |
$found_tl = 1; |
| 913 |
$_ =~ s/\%//g if $opt_remove; # in remove mode, enable it |
| 914 |
$newmaster .= $_; # pass it |
| 915 |
} else { |
| 916 |
$newmaster .= $_; |
| 917 |
} |
| 918 |
} |
| 919 |
close(FOO); |
| 920 |
# if the original master cidfmap has a new line at end of file, |
| 921 |
# then $newmaster should end with "\n". |
| 922 |
# otherwise we add a new line, since there is a possibility of %EOF comment |
| 923 |
# without trailing new line (e.g. TL before r44039) |
| 924 |
$newmaster =~ s/\n$//; |
| 925 |
$newmaster =~ s/$/\n/; |
| 926 |
if ($opt_remove) { |
| 927 |
if ($found || $found_tl) { |
| 928 |
return if $dry_run; |
| 929 |
open(FOO, ">:encoding(UTF-8)", encode('locale_fs', $cidfmap_master)) || |
| 930 |
die("Cannot clean up $cidfmap_master: $!"); |
| 931 |
print FOO $newmaster; |
| 932 |
close FOO; |
| 933 |
} |
| 934 |
} else { |
| 935 |
if ($found && !$found_tl) { |
| 936 |
print_info("$add already loaded in $cidfmap_master, no changes\n"); |
| 937 |
} else { |
| 938 |
return if $dry_run; |
| 939 |
open(FOO, ">:encoding(UTF-8)", encode('locale_fs', $cidfmap_master)) || |
| 940 |
die("Cannot open $cidfmap_master for appending: $!"); |
| 941 |
print FOO $newmaster; |
| 942 |
print FOO "($add) .runlibfile\n"; |
| 943 |
close(FOO); |
| 944 |
} |
| 945 |
} |
| 946 |
} else { |
| 947 |
return if $dry_run; |
| 948 |
return if $opt_remove; |
| 949 |
open(FOO, ">:encoding(UTF-8)", encode('locale_fs', $cidfmap_master)) || |
| 950 |
die("Cannot open $cidfmap_master for writing: $!"); |
| 951 |
print FOO "($add) .runlibfile\n"; |
| 952 |
close(FOO); |
| 953 |
} |
| 954 |
} |
| 955 |
|
| 956 |
sub generate_cidfmap_entry { |
| 957 |
my ($n, $c, $f, $sf) = @_; |
| 958 |
return "" if $opt_remove; |
| 959 |
# $f is already the link target name 'ttfname' (or 'ttcname' or 'otcname') |
| 960 |
# as determined by minimal priority number |
| 961 |
# extract subfont |
| 962 |
my $s = "/$n << /FileType /TrueType |
| 963 |
/Path pssystemparams /GenericResourceDir get |
| 964 |
(CIDFSubst/$f) concatstrings\n"; |
| 965 |
if ($sf >= 0) { # in this script, $sf < 0 represents TTF |
| 966 |
$s .= " /SubfontID $sf\n"; |
| 967 |
} |
| 968 |
$s .= " /CSI [($c"; |
| 969 |
if ($c eq "Japan") { |
| 970 |
$s .= "1) 6]"; |
| 971 |
} elsif ($c eq "GB") { |
| 972 |
$s .= "1) 5]"; |
| 973 |
} elsif ($c eq "CNS") { |
| 974 |
$s .= "1) 5]"; |
| 975 |
} elsif ($c eq "Korea") { |
| 976 |
$s .= "1) 2]"; |
| 977 |
} elsif ($c eq "AI0") { |
| 978 |
print_warning("cannot use class AI0 for non-OTF $n, skipping.\n"); |
| 979 |
return ''; |
| 980 |
} else { |
| 981 |
print_warning("unknown class $c for $n, skipping.\n"); |
| 982 |
return ''; |
| 983 |
} |
| 984 |
$s .= " >> ;\n"; |
| 985 |
return $s; |
| 986 |
} |
| 987 |
|
| 988 |
sub generate_font_snippet { |
| 989 |
my ($fd, $n, $c, $f) = @_; |
| 990 |
return if $dry_run; |
| 991 |
if ($opt_akotfps) { |
| 992 |
add_akotfps_data($n); |
| 993 |
return; |
| 994 |
} |
| 995 |
if ($c eq "AI0") { |
| 996 |
$c = "AI0-$n"; |
| 997 |
} |
| 998 |
for my $enc (@{$encode_list{$c}}) { |
| 999 |
if ($opt_remove) { |
| 1000 |
unlink encode('locale_fs', "$fd/$n-$enc") |
| 1001 |
if (-f encode('locale_fs', "$fd/$n-$enc")); |
| 1002 |
next; |
| 1003 |
} |
| 1004 |
open(FOO, ">:encoding(UTF-8)", encode('locale_fs', "$fd/$n-$enc")) || |
| 1005 |
die("cannot open $fd/$n-$enc for writing: $!"); |
| 1006 |
print FOO "%!PS-Adobe-3.0 Resource-Font |
| 1007 |
%%DocumentNeededResources: $enc (CMap) |
| 1008 |
%%IncludeResource: $enc (CMap) |
| 1009 |
%%BeginResource: Font ($n-$enc) |
| 1010 |
($n-$enc) |
| 1011 |
($enc) /CMap findresource |
| 1012 |
[($n) /CIDFont findresource] |
| 1013 |
composefont |
| 1014 |
pop |
| 1015 |
%%EndResource |
| 1016 |
%%EOF |
| 1017 |
"; |
| 1018 |
close(FOO); |
| 1019 |
} |
| 1020 |
} |
| 1021 |
|
| 1022 |
sub add_akotfps_data { |
| 1023 |
my ($fn) = @_; |
| 1024 |
return if $dry_run; |
| 1025 |
if (!$opt_remove) { |
| 1026 |
$akotfps_datacontent .= "$fn\n"; |
| 1027 |
} |
| 1028 |
} |
| 1029 |
|
| 1030 |
# |
| 1031 |
# link_font operation |
| 1032 |
# $opt_force is *not* treated first to warn only |
| 1033 |
# at really critical cases |
| 1034 |
# case 1: |
| 1035 |
# exists, is link, link targets agree |
| 1036 |
# $opt_force is ignored |
| 1037 |
# remove or remove+add according to $opt_remove |
| 1038 |
# case 2: |
| 1039 |
# exists, is link, dangling symlink |
| 1040 |
# $opt_force is ignored |
| 1041 |
# remove or remove+add according to $opt_remove |
| 1042 |
# case 3: |
| 1043 |
# exists, is link, link target different |
| 1044 |
# if $opt_force |
| 1045 |
# warn, remove or remove+add according to $opt_remove |
| 1046 |
# else |
| 1047 |
# error message |
| 1048 |
# case 4: |
| 1049 |
# exists, not a link |
| 1050 |
# if $opt_force |
| 1051 |
# warn, remove or remove+add according to $opt_remove |
| 1052 |
# else |
| 1053 |
# error message |
| 1054 |
# case 5: |
| 1055 |
# not exists |
| 1056 |
# $opt_force is ignored |
| 1057 |
# do nothing or add according to $opt_remove |
| 1058 |
# |
| 1059 |
sub link_font { |
| 1060 |
my ($f, $cd, $n) = @_; |
| 1061 |
return if $dry_run; |
| 1062 |
if (!$n) { |
| 1063 |
$n = basename($f); |
| 1064 |
} |
| 1065 |
my $target = "$cd/$n"; |
| 1066 |
my $do_unlink = 0; |
| 1067 |
if (-l encode('locale_fs', $target)) { |
| 1068 |
if ($opt_cleanup) { |
| 1069 |
$do_unlink = 1; |
| 1070 |
} else { |
| 1071 |
my $linkt = decode('locale_fs', readlink(encode('locale_fs', $target))); |
| 1072 |
if ($linkt) { |
| 1073 |
if ($linkt eq $f) { |
| 1074 |
# case 1: exists, link, targets agree |
| 1075 |
$do_unlink = 1; |
| 1076 |
} elsif (-r encode('locale_fs', $linkt)) { |
| 1077 |
# case 3: exists, link, targets different |
| 1078 |
if ($opt_force) { |
| 1079 |
print_info("Removing link $target due to --force!\n"); |
| 1080 |
$do_unlink = 1; |
| 1081 |
} else { |
| 1082 |
print_error("Link $target already existing, but target different from $f, exiting!\n"); |
| 1083 |
exit(1); |
| 1084 |
} |
| 1085 |
} else { |
| 1086 |
# case 2: dangling symlink or link-to-link |
| 1087 |
print_warning("Removing dangling symlink $target to $linkt\n"); |
| 1088 |
$do_unlink = 1; |
| 1089 |
} |
| 1090 |
} else { |
| 1091 |
print_error("This should not happen, we have a link but cannot read the target?\n"); |
| 1092 |
exit(1); |
| 1093 |
} |
| 1094 |
} |
| 1095 |
} elsif (-r encode('locale_fs', $target)) { |
| 1096 |
# case 4: exists, but not link (NTFS hardlink on win32 falls into this) |
| 1097 |
if (-s encode('locale_fs', $target)) { |
| 1098 |
if ($opt_force) { |
| 1099 |
print_info("Removing $target due to --force!\n"); |
| 1100 |
$do_unlink = 1; |
| 1101 |
} elsif (win32()) { |
| 1102 |
my $result = compare (encode ('locale_fs', $f), |
| 1103 |
encode ('locale_fs', $target)); |
| 1104 |
if ($result == -1) { |
| 1105 |
print_error("file compare failed: ${f}, ${target}\n"); |
| 1106 |
exit(1); |
| 1107 |
} elsif ($result) { |
| 1108 |
print_error("$target already existing and different content, exiting!\n"); |
| 1109 |
exit(1); |
| 1110 |
} |
| 1111 |
print_debug("$target already existing but same content, skipping!\n"); |
| 1112 |
return; |
| 1113 |
} else { |
| 1114 |
print_error("$target already existing, exiting!\n"); |
| 1115 |
exit(1); |
| 1116 |
} |
| 1117 |
} else { |
| 1118 |
# NTFS symlink on win32 has file size 0, we're safe to remove it |
| 1119 |
$do_unlink = 1; |
| 1120 |
} |
| 1121 |
} # case 5: otherwise it is not existing! |
| 1122 |
|
| 1123 |
# if we are still here and $do_unlink is set, remove it |
| 1124 |
maybe_unlink($target) if $do_unlink; |
| 1125 |
# recreate link if we are not in the remove case |
| 1126 |
if (!$opt_remove) { |
| 1127 |
maybe_symlink($f, $target) || die("Cannot link font $f to $target: $!"); |
| 1128 |
} |
| 1129 |
} |
| 1130 |
|
| 1131 |
sub make_dir { |
| 1132 |
my ($d, $w) = @_; |
| 1133 |
if (-r encode('locale_fs', $d)) { |
| 1134 |
if (! -d encode('locale_fs', $d)) { |
| 1135 |
print_error("$d is not a directory, $w\n"); |
| 1136 |
exit(1); |
| 1137 |
} |
| 1138 |
} else { |
| 1139 |
$dry_run || make_path(encode('locale', $d)); |
| 1140 |
} |
| 1141 |
} |
| 1142 |
|
| 1143 |
# perl symlink function does not work on windows, so we use Win32 API. |
| 1144 |
sub maybe_symlink { |
| 1145 |
my ($realname, $targetname) = @_; |
| 1146 |
if (win32()) { |
| 1147 |
# Try symbolic link, hard link, copy by Win32 API |
| 1148 |
|
| 1149 |
# On Windows, the creation of a symbolic link requires a privilege. |
| 1150 |
# Therefore, if the creation of the symbolic link fails, |
| 1151 |
# create a hard link. |
| 1152 |
# However, the creation of the hard link requires the write permission |
| 1153 |
# to the original existing file. |
| 1154 |
# Thus, if the hard link also fails, copy the file. |
| 1155 |
|
| 1156 |
if (win32_symlink ($realname, $targetname)) { |
| 1157 |
print_debug ("Symbolic link succeeded: ${targetname}\n"); |
| 1158 |
return 1; |
| 1159 |
} |
| 1160 |
|
| 1161 |
if (win32_hardlink ($realname, $targetname)) { |
| 1162 |
print_debug ("Hard link succeeded: ${targetname}\n"); |
| 1163 |
return 1; |
| 1164 |
} |
| 1165 |
|
| 1166 |
if (win32_copy ($realname, $targetname)) { |
| 1167 |
print_debug ("Copy succeeded: ${targetname}\n"); |
| 1168 |
return 1; |
| 1169 |
} |
| 1170 |
|
| 1171 |
print_warning ("Link/copy failed: ${targetname}\n"); |
| 1172 |
} else { |
| 1173 |
symlink ($realname, $targetname); |
| 1174 |
} |
| 1175 |
} |
| 1176 |
|
| 1177 |
sub maybe_unlink { |
| 1178 |
my ($targetname) = @_; |
| 1179 |
unlink (encode('locale_fs', $targetname)); |
| 1180 |
} |
| 1181 |
|
| 1182 |
# For Windows: Create symbolic link |
| 1183 |
sub win32_symlink { |
| 1184 |
my ($existingfilename, $newfilename) = @_; |
| 1185 |
|
| 1186 |
# We use CreateSymbolicLinkW API directly for creating symbolic link |
| 1187 |
# because perl's symlink function may not work in Windows. |
| 1188 |
state $createsymboliclinkw = load_createsymboliclinkw (); |
| 1189 |
|
| 1190 |
$existingfilename =~ s|/|\\|g; |
| 1191 |
$newfilename =~ s|/|\\|g; |
| 1192 |
|
| 1193 |
my $r = $createsymboliclinkw->Call ( |
| 1194 |
encode ('UTF-16LE', $newfilename), |
| 1195 |
encode ('UTF-16LE', $existingfilename), |
| 1196 |
0 |
| 1197 |
); |
| 1198 |
if (ord($r) != 0) { |
| 1199 |
return 1; |
| 1200 |
} |
| 1201 |
my $msg = decode ('locale', |
| 1202 |
Win32::FormatMessage (Win32::GetLastError ())); |
| 1203 |
$msg =~ s/[\r\n]+\z//; |
| 1204 |
print_debug ("CreateSymbolicLinkW failed: ${msg}\n"); |
| 1205 |
|
| 1206 |
return 0; |
| 1207 |
} |
| 1208 |
|
| 1209 |
# For Windows: Create hard link |
| 1210 |
sub win32_hardlink { |
| 1211 |
my ($existingfilename, $newfilename) = @_; |
| 1212 |
|
| 1213 |
# We use CreateHardLinkW API directly for creating hard link |
| 1214 |
# because -W API is not affected by the perl's active code page. |
| 1215 |
state $createhardlinkw = load_createhardlinkw (); |
| 1216 |
|
| 1217 |
$existingfilename =~ s|/|\\|g; |
| 1218 |
$newfilename =~ s|/|\\|g; |
| 1219 |
|
| 1220 |
my $r = $createhardlinkw->Call ( |
| 1221 |
encode ('UTF-16LE', $newfilename), |
| 1222 |
encode ('UTF-16LE', $existingfilename), |
| 1223 |
0 |
| 1224 |
); |
| 1225 |
if ($r) { |
| 1226 |
return 1; |
| 1227 |
} |
| 1228 |
my $msg = decode ('locale', |
| 1229 |
Win32::FormatMessage (Win32::GetLastError ())); |
| 1230 |
$msg =~ s/[\r\n]+\z//; |
| 1231 |
print_debug ("CreateHardLinkW failed: ${msg}\n"); |
| 1232 |
|
| 1233 |
return 0; |
| 1234 |
} |
| 1235 |
|
| 1236 |
# For Windows: Copy file |
| 1237 |
sub win32_copy { |
| 1238 |
my ($existingfilename, $newfilename) = @_; |
| 1239 |
|
| 1240 |
# We use CopyFileW API directly for copying file |
| 1241 |
# because -W API is not affected by the perl's active code page. |
| 1242 |
state $copyfilew = load_copyfilew (); |
| 1243 |
|
| 1244 |
$existingfilename =~ s|/|\\|g; |
| 1245 |
$newfilename =~ s|/|\\|g; |
| 1246 |
|
| 1247 |
my $r = $copyfilew->Call ( |
| 1248 |
encode ('UTF-16LE', $existingfilename), |
| 1249 |
encode ('UTF-16LE', $newfilename), |
| 1250 |
1 |
| 1251 |
); |
| 1252 |
if ($r) { |
| 1253 |
return 1; |
| 1254 |
} |
| 1255 |
my $msg = decode ('locale', |
| 1256 |
Win32::FormatMessage (Win32::GetLastError ())); |
| 1257 |
$msg =~ s/[\r\n]+\z//; |
| 1258 |
print_debug ("CopyFileW failed: ${msg}\n"); |
| 1259 |
|
| 1260 |
return 0; |
| 1261 |
} |
| 1262 |
|
| 1263 |
# For Windows: Load CreateSymbolicLinkW API |
| 1264 |
sub load_createsymboliclinkw { |
| 1265 |
my $createsymboliclinkw = Win32::API::More->new ( |
| 1266 |
'kernel32.dll', |
| 1267 |
'BOOLEAN CreateSymbolicLinkW( |
| 1268 |
LPCWSTR lpSymlinkFileName, |
| 1269 |
LPCWSTR lpTargetFileName, |
| 1270 |
DWORD dwFlags |
| 1271 |
)' |
| 1272 |
) or die ('Failed: Win32::API::More->new CreateSymbolicLinkW'); |
| 1273 |
|
| 1274 |
return $createsymboliclinkw; |
| 1275 |
} |
| 1276 |
# For Windows: Load CreateHardLinkW API |
| 1277 |
sub load_createhardlinkw { |
| 1278 |
my $createhardlinkw = Win32::API::More->new ( |
| 1279 |
'kernel32.dll', |
| 1280 |
'BOOL CreateHardLinkW( |
| 1281 |
LPCWSTR lpFileName, |
| 1282 |
LPCWSTR lpExistingFileName, |
| 1283 |
UINT_PTR lpSecurityAttributes |
| 1284 |
)' |
| 1285 |
) or die ('Failed: Win32::API::More->new CreateHardLinkW'); |
| 1286 |
|
| 1287 |
return $createhardlinkw; |
| 1288 |
} |
| 1289 |
|
| 1290 |
# For Windows: Load CopyFileW API |
| 1291 |
sub load_copyfilew { |
| 1292 |
my $copyfilew = Win32::API::More->new ( |
| 1293 |
'kernel32.dll', |
| 1294 |
'BOOL CopyFileW( |
| 1295 |
LPCWSTR lpExistingFileName, |
| 1296 |
LPCWSTR lpNewFileName, |
| 1297 |
BOOL bFailIfExists |
| 1298 |
)' |
| 1299 |
) or die ('Failed: Win32::API::More->new CopyFileW'); |
| 1300 |
|
| 1301 |
return $copyfilew; |
| 1302 |
} |
| 1303 |
|
| 1304 |
# write to psnames-for-otfps |
| 1305 |
sub write_akotfps_datafile { |
| 1306 |
return if $dry_run; |
| 1307 |
make_dir("$opt_akotfps/$akotfps_pathpart", |
| 1308 |
"cannot create $akotfps_datafilename in it!"); |
| 1309 |
open(FOO, ">:encoding(UTF-8)", |
| 1310 |
encode('locale_fs', |
| 1311 |
"$opt_akotfps/$akotfps_pathpart/$akotfps_datafilename")) || |
| 1312 |
die("cannot open $opt_akotfps/$akotfps_pathpart/$akotfps_datafilename for writing: $!"); |
| 1313 |
print FOO "% psnames-for-otf |
| 1314 |
% |
| 1315 |
% PostSctipt names for OpenType fonts |
| 1316 |
% |
| 1317 |
% This file is used by a program ps2otfps |
| 1318 |
% in order to add needed information to a ps file |
| 1319 |
% created by the dvips |
| 1320 |
% |
| 1321 |
$akotfps_datacontent"; |
| 1322 |
close(FOO); |
| 1323 |
} |
| 1324 |
|
| 1325 |
# |
| 1326 |
# dump found files |
| 1327 |
sub info_found_fonts { |
| 1328 |
print "List of found fonts:\n\n"; |
| 1329 |
for my $k (sort keys %fontdb) { |
| 1330 |
my @foundfiles; |
| 1331 |
if ($fontdb{$k}{'available'}) { |
| 1332 |
print "Font: $k\n"; |
| 1333 |
print "Type: $fontdb{$k}{'type'}\n"; |
| 1334 |
print "Class: $fontdb{$k}{'class'}\n"; |
| 1335 |
my $fn = $fontdb{$k}{'target'}; |
| 1336 |
if ($fontdb{$k}{'type'} eq 'TTC' || $fontdb{$k}{'type'} eq 'OTC') { |
| 1337 |
$fn .= "($fontdb{$k}{'subfont'})"; |
| 1338 |
} |
| 1339 |
print "File: $fn\n"; |
| 1340 |
if ($fontdb{$k}{'type'} eq 'TTF') { |
| 1341 |
print "Link: $fontdb{$k}{'ttfname'}\n"; |
| 1342 |
} elsif ($fontdb{$k}{'type'} eq 'TTC') { |
| 1343 |
print "Link: $fontdb{$k}{'ttcname'}\n"; |
| 1344 |
} elsif ($fontdb{$k}{'type'} eq 'OTC') { |
| 1345 |
print "Link: $fontdb{$k}{'otcname'}\n"; |
| 1346 |
} |
| 1347 |
my @ks = sort { $fontdb{$k}{'files'}{$a}{'priority'} |
| 1348 |
<=> |
| 1349 |
$fontdb{$k}{'files'}{$b}{'priority'} } |
| 1350 |
keys %{$fontdb{$k}{'files'}}; |
| 1351 |
# remove the top element which is the winner and shown above |
| 1352 |
shift @ks; |
| 1353 |
if (@ks) { |
| 1354 |
print "Other candidates in decreasing order:\n"; |
| 1355 |
for my $f (@ks) { |
| 1356 |
print " ", $fontdb{$k}{'files'}{$f}{'target'}, "\n"; |
| 1357 |
} |
| 1358 |
} |
| 1359 |
print "\n"; |
| 1360 |
} |
| 1361 |
} |
| 1362 |
} |
| 1363 |
|
| 1364 |
# |
| 1365 |
# dump aliases |
| 1366 |
sub info_list_aliases { |
| 1367 |
print "List of ", ($opt_listallaliases ? "all" : "available"), " aliases and their options (in decreasing priority):\n" unless $opt_machine; |
| 1368 |
my (@jal, @kal, @tal, @sal, @ai0al); |
| 1369 |
for my $al (sort keys %aliases) { |
| 1370 |
my $cl; |
| 1371 |
my @ks = sort { $a <=> $b} keys(%{$aliases{$al}}); |
| 1372 |
my $foo = ''; |
| 1373 |
$foo = "$al:\n" unless $opt_machine; |
| 1374 |
for my $p (@ks) { |
| 1375 |
my $t = $aliases{$al}{$p}; |
| 1376 |
my $fn = ($opt_listallaliases ? "-" : $fontdb{$t}{'target'} ); |
| 1377 |
# should always be the same ;-) |
| 1378 |
$cl = $fontdb{$t}{'class'}; |
| 1379 |
if (!$opt_listallaliases && ($fontdb{$t}{'type'} eq 'TTC' || $fontdb{$t}{'type'} eq 'OTC')) { |
| 1380 |
$fn .= "($fontdb{$t}{'subfont'})"; |
| 1381 |
} |
| 1382 |
if ($opt_machine) { |
| 1383 |
$foo .= "$al:$p:$aliases{$al}{$p}:$fn\n"; |
| 1384 |
} else { |
| 1385 |
$foo .= "\t($p) $aliases{$al}{$p} ($fn)\n"; |
| 1386 |
} |
| 1387 |
} |
| 1388 |
if ($cl eq 'Japan') { |
| 1389 |
push @jal, $foo; |
| 1390 |
} elsif ($cl eq 'Korea') { |
| 1391 |
push @kal, $foo; |
| 1392 |
} elsif ($cl eq 'GB') { |
| 1393 |
push @sal, $foo; |
| 1394 |
} elsif ($cl eq 'CNS') { |
| 1395 |
push @tal, $foo; |
| 1396 |
} elsif ($cl eq 'AI0') { |
| 1397 |
push @ai0al, $foo; |
| 1398 |
} else { |
| 1399 |
print STDERR "unknown class $cl for $al\n"; |
| 1400 |
} |
| 1401 |
} |
| 1402 |
if ($opt_machine) { |
| 1403 |
print @jal if @jal; |
| 1404 |
print @kal if @kal; |
| 1405 |
print @sal if @sal; |
| 1406 |
print @tal if @tal; |
| 1407 |
print @ai0al if @ai0al; |
| 1408 |
} else { |
| 1409 |
print "Aliases for Japanese fonts:\n", @jal, "\n" if @jal; |
| 1410 |
print "Aliases for Korean fonts:\n", @kal, "\n" if @kal; |
| 1411 |
print "Aliases for Simplified Chinese fonts:\n", @sal, "\n" if @sal; |
| 1412 |
print "Aliases for Traditional Chinese fonts:\n", @tal, "\n" if @tal; |
| 1413 |
print "Aliases for Adobe-Identity-0 fonts:\n", @ai0al, "\n" if @ai0al; |
| 1414 |
} |
| 1415 |
} |
| 1416 |
|
| 1417 |
# |
| 1418 |
# make all fonts available for listing all aliases |
| 1419 |
sub make_all_available { |
| 1420 |
for my $k (keys %fontdb) { |
| 1421 |
$fontdb{$k}{'available'} = 1; |
| 1422 |
$fontdb{$k}{'type'} = 'OTF'; |
| 1423 |
delete $fontdb{$k}{'files'} if (!$opt_cleanup); |
| 1424 |
} |
| 1425 |
} |
| 1426 |
|
| 1427 |
# |
| 1428 |
# checks all file names listed in %fontdb |
| 1429 |
# and sets |
| 1430 |
sub check_for_files { |
| 1431 |
my @foundfiles; |
| 1432 |
if ($opt_filelist) { |
| 1433 |
open(FOO, "<", encode('locale_fs', $opt_filelist)) || |
| 1434 |
die("Cannot open $opt_filelist: $!"); |
| 1435 |
@foundfiles = <FOO>; |
| 1436 |
close(FOO) || warn "Cannot close $opt_filelist: $!"; |
| 1437 |
} else { |
| 1438 |
# first collect all files: |
| 1439 |
my @fn; |
| 1440 |
for my $k (keys %fontdb) { |
| 1441 |
for my $f (keys %{$fontdb{$k}{'files'}}) { |
| 1442 |
# check for subfont extension |
| 1443 |
if ($f =~ m/^(.*)\(\d*\)$/) { |
| 1444 |
push @fn, $1; |
| 1445 |
} else { |
| 1446 |
push @fn, $f; |
| 1447 |
} |
| 1448 |
} |
| 1449 |
} |
| 1450 |
# |
| 1451 |
# collect extra directories for search |
| 1452 |
my @extradirs; |
| 1453 |
if (win32()) { |
| 1454 |
push @extradirs, "c:/windows/fonts//"; |
| 1455 |
} else { |
| 1456 |
# other dirs to check, for normal unix? |
| 1457 |
for my $d (qw!/Library/Fonts /System/Library/Fonts |
| 1458 |
/System/Library/Assets /System/Library/AssetsV2 |
| 1459 |
/Network/Library/Fonts /usr/share/fonts!) { |
| 1460 |
push @extradirs, "$d//" |
| 1461 |
if (-d encode('locale_fs', $d)); # recursive search |
| 1462 |
} |
| 1463 |
# the path contains white space, so hack required |
| 1464 |
for my $d (qw!/Library/Application__Support/Apple/Fonts!) { |
| 1465 |
my $sd = $d; |
| 1466 |
$sd =~ s/__/ /; |
| 1467 |
push @extradirs, "$sd//" |
| 1468 |
if (-d encode('locale_fs', "$sd")); # recursive search |
| 1469 |
} |
| 1470 |
# office for mac 2016 |
| 1471 |
for my $d (qw!/Applications/Microsoft__Word.app |
| 1472 |
/Applications/Microsoft__Excel.app |
| 1473 |
/Applications/Microsoft__PowerPoint.app!) { |
| 1474 |
my $sd = $d; |
| 1475 |
$sd =~ s/__/ /; |
| 1476 |
push @extradirs, "$sd/Contents/Resources/Fonts/" |
| 1477 |
if (-d encode('locale_fs', "$sd/Contents/Resources/Fonts")); |
| 1478 |
push @extradirs, "$sd/Contents/Resources/DFonts/" |
| 1479 |
if (-d encode('locale_fs', "$sd/Contents/Resources/DFonts")); |
| 1480 |
} |
| 1481 |
my $home = $ENV{'HOME'}; |
| 1482 |
push @extradirs, "$home/Library/Fonts//" |
| 1483 |
if (-d encode('locale_fs', "$home/Library/Fonts")); |
| 1484 |
} |
| 1485 |
# |
| 1486 |
if (@extradirs) { |
| 1487 |
# TODO: we want that files in OSFONTDIR are found first, before |
| 1488 |
# links that we have created in TEXMFLOCAL |
| 1489 |
# Thus, instead of setting OSFONTDIR which is at the *END* of |
| 1490 |
# the kpsewhich variables OPENTYPEFONTS and TTFONTS, we'd like to |
| 1491 |
# put all these fonts at the front of them |
| 1492 |
# |
| 1493 |
# There are problems with case-insensitive file systems like HFS |
| 1494 |
# on MacOS, as we might catch different names (batang/Batang) |
| 1495 |
# and identify them wrongly. |
| 1496 |
# https://github.com/texjporg/cjk-gs-support/issues/9 |
| 1497 |
# For now until we have dealt with that, do not set the |
| 1498 |
# two variables (HY 2016/09/27) and think about a different approach. |
| 1499 |
push @extradirs, $ENV{'OSFONTDIR'} if $ENV{'OSFONTDIR'}; |
| 1500 |
if (@extradirs) { |
| 1501 |
# comment out -- HY (2016/09/27) |
| 1502 |
# my $newotf = join($sep, @extradirs) . $sep; |
| 1503 |
# my $newttf = $newotf; |
| 1504 |
# $newotf .= $ENV{'OPENTYPEFONTS'} if $ENV{'OPENTYPEFONTS'}; |
| 1505 |
# $newttf .= $ENV{'TTFONTS'} if $ENV{'TTFONTS'}; |
| 1506 |
# $ENV{'OPENTYPEFONTS'} = $newotf; |
| 1507 |
# $ENV{'TTFONTS'} = $newttf; |
| 1508 |
# new code for uppercase/lowercase workaround -- HY (2016/09/27) |
| 1509 |
my $extrafontdir = join($sep, @extradirs) . $sep; |
| 1510 |
$ENV{'OSFONTDIR'} = $extrafontdir; |
| 1511 |
} |
| 1512 |
} |
| 1513 |
# prepare for kpsewhich call, we need to do quoting |
| 1514 |
# we need as much candidate files as possible, so -all is needed |
| 1515 |
my $cmdl = 'kpsewhich -all '; |
| 1516 |
for my $f (@fn) { |
| 1517 |
$cmdl .= " \"$f\" "; |
| 1518 |
} |
| 1519 |
# shoot up kpsewhich |
| 1520 |
print_ddebug("checking for $cmdl\n"); |
| 1521 |
$cmdl = encode('locale', $cmdl); |
| 1522 |
@foundfiles = `$cmdl`; |
| 1523 |
# We assume that the output of kpsewhich is |
| 1524 |
# the same as perl's locale (or active code page). |
| 1525 |
@foundfiles = map { decode('locale', $_) } @foundfiles; |
| 1526 |
} |
| 1527 |
chomp(@foundfiles); |
| 1528 |
print_ddebug("Found files @foundfiles\n"); |
| 1529 |
# map basenames to filenames |
| 1530 |
my %bntofn; |
| 1531 |
for my $f (@foundfiles) { |
| 1532 |
$f =~ s/[\r\n]+\z//; # perl's chomp() on git-bash cannot strip CR of CRLF ?? |
| 1533 |
my $realf = decode('locale_fs', abs_path(encode('locale_fs', $f))); |
| 1534 |
if (!$realf) { |
| 1535 |
print_warning("dead link or strange file found: $f - ignored!\n"); |
| 1536 |
next; |
| 1537 |
} |
| 1538 |
if (win32()) { |
| 1539 |
# abs_path cannot read NTFS symlink/hardlink, and it serves as |
| 1540 |
# identity transformation. |
| 1541 |
# this might lead to dangling links for multiple runs of cjk-gs-integrate, |
| 1542 |
# when $opt_texmflink (in the previous run) is contained in the (current) |
| 1543 |
# kpsewhich search path. |
| 1544 |
# to avoid this, ignore targets which contain $otf_pathpart or $ttf_pathpart |
| 1545 |
my $temp_realfdir = "$realf"; |
| 1546 |
$temp_realfdir =~ s!^(.*)/(.*)$!$1!; |
| 1547 |
next if ($temp_realfdir =~ $otf_pathpart || $temp_realfdir =~ $ttf_pathpart); |
| 1548 |
} |
| 1549 |
my $bn = basename($f); |
| 1550 |
# kpsewhich -all might return multiple files with the same basename; |
| 1551 |
# collect all of them |
| 1552 |
$bntofn{$bn}{$realf} = 1; |
| 1553 |
} |
| 1554 |
|
| 1555 |
# show the %fontdb before file check |
| 1556 |
if ($opt_debug >= 2) { |
| 1557 |
print_ddebug("dumping font database before file check:\n"); |
| 1558 |
print_ddebug(Data::Dumper::Dumper(\%fontdb)); |
| 1559 |
} |
| 1560 |
if ($opt_debug >= 3) { |
| 1561 |
print_dddebug("dumping basename to filename list:\n"); |
| 1562 |
print_dddebug(Data::Dumper::Dumper(\%bntofn)); |
| 1563 |
} |
| 1564 |
|
| 1565 |
# update the %fontdb with the found files |
| 1566 |
for my $k (keys %fontdb) { |
| 1567 |
$fontdb{$k}{'available'} = 0; |
| 1568 |
for my $f (keys %{$fontdb{$k}{'files'}}) { |
| 1569 |
# check for subfont extension |
| 1570 |
my $realfile = $f; |
| 1571 |
$realfile =~ s/^(.*)\(\d*\)$/$1/; |
| 1572 |
my $index = 0; |
| 1573 |
if ($fontdb{$k}{'files'}{$f}{'type'} eq 'TTC' || $fontdb{$k}{'files'}{$f}{'type'} eq 'OTC') { |
| 1574 |
if ($f =~ m/^(.*)\((\d*)\)$/) { |
| 1575 |
$index = $2; |
| 1576 |
} |
| 1577 |
} |
| 1578 |
# double check for casefolding or incompatible OTC/TTC index |
| 1579 |
# [1] casefolding issue |
| 1580 |
# we might catch different names (batang/Batang) and identify them wrongly on |
| 1581 |
# * case-insensitive file systems (like HFS on MacOS) |
| 1582 |
# * kpathsea 6.3.0 or later, with casefolding fallback search (TL2018) |
| 1583 |
# check the actual psname using zrlistttc.lua, only when we "know" |
| 1584 |
# both uppercase/lowercase font files are possible and they are different |
| 1585 |
# [2] incompatible index |
| 1586 |
# the index in msgothic.ttc changed at some time between Win7 and Win10. |
| 1587 |
my $actualpsname; |
| 1588 |
my $bname; |
| 1589 |
for my $b (sort keys %{$bntofn{$realfile}}) { |
| 1590 |
if ($opt_strictpsname && !$fontdb{$k}{'doublecheck'}) { |
| 1591 |
$fontdb{$k}{'doublecheck'} = "debug"; # stub |
| 1592 |
} |
| 1593 |
if ($fontdb{$k}{'doublecheck'} && $fontdb{$k}{'doublecheck'} ne "false" && $zrlistttc_available) { |
| 1594 |
print_debug("We need to test whether\n"); |
| 1595 |
print_debug(" $b:$index\n"); |
| 1596 |
print_debug("is the correct one ($k). Invoking zrlistttc ...\n"); |
| 1597 |
my $cmdl = "texlua $zrlistttc -i $index \"$b\""; |
| 1598 |
$cmdl = encode('locale', $cmdl); |
| 1599 |
chomp($actualpsname = `$cmdl`); |
| 1600 |
if ($?) { |
| 1601 |
# something is wrong with the font file, or zrlistttc does not support it; |
| 1602 |
# still there is a chance that Ghostscript supports, so don't discard it |
| 1603 |
print_debug("... command exited with $?!\n"); |
| 1604 |
print_debug("OK, I'll take this, but it may not work properly.\n"); |
| 1605 |
print_warning("zrlistttc check failed for $b\n") if $opt_strictpsname; |
| 1606 |
$bname = $b; |
| 1607 |
last; |
| 1608 |
} |
| 1609 |
# We assume that the output of texlua is |
| 1610 |
# the same as perl's locale (or active code page). |
| 1611 |
$actualpsname = decode('locale', $actualpsname); |
| 1612 |
$actualpsname =~ s/[\r\n]+\z//; # perl's chomp() on git-bash cannot strip CR of CRLF ?? |
| 1613 |
if ($actualpsname ne $k) { |
| 1614 |
print_debug("... PSName returned by zrlistttc ($actualpsname) is\n"); |
| 1615 |
print_debug("different from our database ($k), discarding!\n"); |
| 1616 |
if ($opt_strictpsname && $fontdb{$k}{'doublecheck'} eq "debug") { |
| 1617 |
# in our database, we've set $fontdb{$k}{'doublecheck'} to "true" intentionally |
| 1618 |
# when we *know* doublecheck is actually required; |
| 1619 |
# if the stub "debug" detects a difference, our database should contain a bug! |
| 1620 |
print_warning("zrlistttc check failed for $b: please report to the author!\n"); |
| 1621 |
} |
| 1622 |
} else { |
| 1623 |
print_debug("... test passed.\n"); |
| 1624 |
$bname = $b; |
| 1625 |
last; |
| 1626 |
} |
| 1627 |
} else { |
| 1628 |
$bname = $b; |
| 1629 |
last; |
| 1630 |
} |
| 1631 |
} |
| 1632 |
if ($bname) { |
| 1633 |
# we found a representative, make it available |
| 1634 |
$fontdb{$k}{'files'}{$f}{'target'} = $bname; |
| 1635 |
$fontdb{$k}{'available'} = 1; |
| 1636 |
} else { |
| 1637 |
# delete the entry for convenience |
| 1638 |
delete $fontdb{$k}{'files'}{$f}; |
| 1639 |
} |
| 1640 |
} |
| 1641 |
} |
| 1642 |
# second round to determine the winner in case of more targets |
| 1643 |
for my $k (keys %fontdb) { |
| 1644 |
if ($fontdb{$k}{'available'}) { |
| 1645 |
my $mp = 1000000; my $mf; |
| 1646 |
for my $f (keys %{$fontdb{$k}{'files'}}) { |
| 1647 |
if ($fontdb{$k}{'files'}{$f}{'priority'} < $mp) { |
| 1648 |
$mp = $fontdb{$k}{'files'}{$f}{'priority'}; |
| 1649 |
$mf = $f; |
| 1650 |
} |
| 1651 |
} |
| 1652 |
# extract subfont if necessary |
| 1653 |
my $sf = 0; |
| 1654 |
if ($mf =~ m/^(.*)\((\d*)\)$/) { $sf = $2; } |
| 1655 |
$fontdb{$k}{'target'} = $fontdb{$k}{'files'}{$mf}{'target'}; |
| 1656 |
$fontdb{$k}{'type'} = $fontdb{$k}{'files'}{$mf}{'type'}; |
| 1657 |
$fontdb{$k}{'subfont'} = $sf if ($fontdb{$k}{'type'} eq 'TTC' || $fontdb{$k}{'type'} eq 'OTC'); |
| 1658 |
} |
| 1659 |
# not needed anymore |
| 1660 |
# delete $fontdb{$k}{'files'}; |
| 1661 |
} |
| 1662 |
if ($opt_debug >= 2) { |
| 1663 |
print_ddebug("dumping font database:\n"); |
| 1664 |
print_ddebug(Data::Dumper::Dumper(\%fontdb)); |
| 1665 |
} |
| 1666 |
} |
| 1667 |
|
| 1668 |
sub compute_aliases { |
| 1669 |
# go through fontdb to check for provides |
| 1670 |
# accumulate all provided fonts in @provides |
| 1671 |
for my $k (keys %fontdb) { |
| 1672 |
if ($fontdb{$k}{'available'}) { |
| 1673 |
for my $p (keys %{$fontdb{$k}{'provides'}}) { |
| 1674 |
# do not check alias if the real font is available in OTF/TTF/TTC format |
| 1675 |
if ($fontdb{$p}{'available'}) { |
| 1676 |
next if ($fontdb{$p}{'type'} ne 'OTC'); |
| 1677 |
} |
| 1678 |
# use the priority as key |
| 1679 |
# if priorities are double, this will pick one at chance |
| 1680 |
if ($aliases{$p}{$fontdb{$k}{'provides'}{$p}}) { |
| 1681 |
print_warning("duplicate provide levels:\n"); |
| 1682 |
print_warning(" current $p $fontdb{$k}{'provides'}{$p} $aliases{$p}{$fontdb{$k}{'provides'}{$p}}\n"); |
| 1683 |
print_warning(" ignored $p $fontdb{$k}{'provides'}{$p} $k\n"); |
| 1684 |
} else { |
| 1685 |
# if OTC font is caught, then skip it as Ghostscript doesn't support it (2016/12/12) |
| 1686 |
if ($fontdb{$k}{'type'} eq 'OTC') { |
| 1687 |
print_debug("Currently Ghostscript does not support OTC font,\n"); |
| 1688 |
print_debug("not adding $fontdb{$k}{'otcname'} to alias candidates\n"); |
| 1689 |
} else { |
| 1690 |
$aliases{$p}{$fontdb{$k}{'provides'}{$p}} = $k; |
| 1691 |
} |
| 1692 |
} |
| 1693 |
} |
| 1694 |
} |
| 1695 |
} |
| 1696 |
# check for user supplied aliases |
| 1697 |
for my $a (@opt_aliases) { |
| 1698 |
if ($a =~ m/^(.*)=(.*)$/) { |
| 1699 |
my $ll = $1; |
| 1700 |
my $rr = $2; |
| 1701 |
# check for consistency of user provided aliases: |
| 1702 |
# - ll must not be available |
| 1703 |
# - rr needs to be available as font or alias |
| 1704 |
# check whether $rr is available, either as real font or as alias |
| 1705 |
if ($fontdb{$ll}{'available'}) { |
| 1706 |
print_error("left side of alias spec is provided by a real font: $a\n"); |
| 1707 |
print_error("stopping here\n"); |
| 1708 |
exit(1); |
| 1709 |
} |
| 1710 |
if (!($fontdb{$rr}{'available'} || $aliases{$rr})) { |
| 1711 |
print_error("right side of alias spec is not available as real font or alias: $a\n"); |
| 1712 |
print_error("stopping here\n"); |
| 1713 |
exit(1); |
| 1714 |
} |
| 1715 |
$user_aliases{$ll} = $rr; |
| 1716 |
} |
| 1717 |
} |
| 1718 |
if ($opt_debug >= 2) { |
| 1719 |
print_ddebug("dumping aliases:\n"); |
| 1720 |
print_ddebug(Data::Dumper::Dumper(\%aliases)); |
| 1721 |
} |
| 1722 |
} |
| 1723 |
|
| 1724 |
# While the OTF link target is determined by the filename itself |
| 1725 |
# for TTF we can have ttc with several fonts. |
| 1726 |
# The following routine determines the link target by selecting |
| 1727 |
# the file name of the ttf candidates with the lowest priority |
| 1728 |
# as the link target name for TTF |
| 1729 |
sub determine_nonotf_link_name { |
| 1730 |
for my $k (keys %fontdb) { |
| 1731 |
my $ttfname = ""; |
| 1732 |
my $ttcname = ""; |
| 1733 |
my $otcname = ""; |
| 1734 |
my $mpttf = 10000000; |
| 1735 |
my $mpttc = 10000000; |
| 1736 |
my $mpotc = 10000000; |
| 1737 |
for my $f (keys %{$fontdb{$k}{'files'}}) { |
| 1738 |
if ($fontdb{$k}{'files'}{$f}{'type'} eq 'TTF') { |
| 1739 |
my $p = $fontdb{$k}{'files'}{$f}{'priority'}; |
| 1740 |
if ($p < $mpttf) { |
| 1741 |
$ttfname = $f; |
| 1742 |
$ttfname =~ s/^(.*)\(\d*\)$/$1/; |
| 1743 |
$mpttf = $p; |
| 1744 |
} |
| 1745 |
} elsif ($fontdb{$k}{'files'}{$f}{'type'} eq 'TTC') { |
| 1746 |
my $p = $fontdb{$k}{'files'}{$f}{'priority'}; |
| 1747 |
if ($p < $mpttc) { |
| 1748 |
$ttcname = $f; |
| 1749 |
$ttcname =~ s/^(.*)\(\d*\)$/$1/; |
| 1750 |
$mpttc = $p; |
| 1751 |
} |
| 1752 |
} elsif ($fontdb{$k}{'files'}{$f}{'type'} eq 'OTC') { |
| 1753 |
my $p = $fontdb{$k}{'files'}{$f}{'priority'}; |
| 1754 |
if ($p < $mpotc) { |
| 1755 |
$otcname = $f; |
| 1756 |
$otcname =~ s/^(.*)\(\d*\)$/$1/; |
| 1757 |
$mpotc = $p; |
| 1758 |
} |
| 1759 |
} |
| 1760 |
} |
| 1761 |
if ($ttfname) { |
| 1762 |
$fontdb{$k}{'ttfname'} = $ttfname; |
| 1763 |
} |
| 1764 |
if ($ttcname) { |
| 1765 |
$fontdb{$k}{'ttcname'} = $ttcname; |
| 1766 |
} |
| 1767 |
if ($otcname) { |
| 1768 |
$fontdb{$k}{'otcname'} = $otcname; |
| 1769 |
} |
| 1770 |
} |
| 1771 |
} |
| 1772 |
|
| 1773 |
sub read_font_database { |
| 1774 |
my @dbl; |
| 1775 |
# if --fontdef=foo is given, disregard built-in database and |
| 1776 |
# use "foo" as a substitute; otherwise, use built-in database |
| 1777 |
if ($opt_fontdef) { |
| 1778 |
my $foo = kpse_miscfont($opt_fontdef); |
| 1779 |
open(FDB, "<:encoding(UTF-8)", encode('locale_fs', $foo)) || |
| 1780 |
die("Cannot find $opt_fontdef: $!"); |
| 1781 |
@dbl = <FDB>; |
| 1782 |
close(FDB); |
| 1783 |
print_debug("New database file: $opt_fontdef...\n"); |
| 1784 |
} else { |
| 1785 |
@dbl = <DATA>; |
| 1786 |
} |
| 1787 |
read_each_font_database(@dbl); |
| 1788 |
# if --fontdef-add=bar is given, use "bar" as an addition |
| 1789 |
# to the current database; if the same Name entry appears, |
| 1790 |
# overwrite existing one (that is, the addition wins) |
| 1791 |
for (@opt_fontdef_add) { |
| 1792 |
my $foo = kpse_miscfont($_); |
| 1793 |
open(FDB, "<:encoding(UTF-8)", encode('locale_fs', $foo)) || |
| 1794 |
die("Cannot find $_: $!"); |
| 1795 |
@dbl = <FDB>; |
| 1796 |
close(FDB); |
| 1797 |
print_debug("Additional database file: $_...\n"); |
| 1798 |
read_each_font_database(@dbl); |
| 1799 |
} |
| 1800 |
} |
| 1801 |
|
| 1802 |
sub read_each_font_database { |
| 1803 |
my (@curdbl) = @_; |
| 1804 |
my $fontname = ""; |
| 1805 |
my $fontclass = ""; |
| 1806 |
my @fontcmaps = (); |
| 1807 |
my %fontprovides = (); |
| 1808 |
my $fontdoublecheck = ""; |
| 1809 |
my %fontfiles; |
| 1810 |
my $psname = ""; |
| 1811 |
my $lineno = 0; |
| 1812 |
chomp(@curdbl); |
| 1813 |
push @curdbl, ""; # add a "final empty line" to easy parsing |
| 1814 |
for my $l (@curdbl) { |
| 1815 |
$lineno++; |
| 1816 |
next if ($l =~ m/^\s*#/); # skip comment line |
| 1817 |
$l =~ s/\s*#.*$//; # skip comment after '#' |
| 1818 |
if ($l =~ m/^\s*$/) { # empty line is a separator between entries |
| 1819 |
if ($fontname || $fontclass || keys(%fontfiles)) { |
| 1820 |
if ($fontname && $fontclass && keys(%fontfiles)) { |
| 1821 |
my $realfontname = ($psname ? $psname : $fontname); |
| 1822 |
if ($fontdb{$realfontname}{'origname'}) { |
| 1823 |
# needed for --fontdef-add, which allows overwriting with external database given by user |
| 1824 |
print_debug("$fontdb{$realfontname}{'origname'} is already registered in database,\n"); |
| 1825 |
print_debug("overwriting with the new one ...\n"); |
| 1826 |
} |
| 1827 |
$fontdb{$realfontname}{'origname'} = $fontname; |
| 1828 |
$fontdb{$realfontname}{'class'} = $fontclass; |
| 1829 |
$fontdb{$realfontname}{'doublecheck'} = $fontdoublecheck; |
| 1830 |
$fontdb{$realfontname}{'files'} = { %fontfiles }; |
| 1831 |
$fontdb{$realfontname}{'provides'} = { %fontprovides }; |
| 1832 |
if ($fontclass eq "AI0") { |
| 1833 |
$encode_list{"AI0-$realfontname"} = [ @fontcmaps ]; |
| 1834 |
} elsif (@fontcmaps) { |
| 1835 |
print_warning("CMap entry for $realfontname (Class: $fontclass) ignored!\n"); |
| 1836 |
} |
| 1837 |
if ($opt_debug >= 3) { |
| 1838 |
print_dddebug("Dumping fontfiles for $realfontname: " . Data::Dumper::Dumper(\%fontfiles)); |
| 1839 |
} |
| 1840 |
# reset to start |
| 1841 |
$fontname = $fontclass = $psname = ""; |
| 1842 |
$fontdoublecheck = ""; |
| 1843 |
@fontcmaps = (); |
| 1844 |
%fontfiles = (); |
| 1845 |
%fontprovides = (); |
| 1846 |
} else { |
| 1847 |
print_warning("incomplete entry above line $lineno for $fontname/$fontclass, skipping!\n"); |
| 1848 |
# reset to start |
| 1849 |
$fontname = $fontclass = $psname = ""; |
| 1850 |
$fontdoublecheck = ""; |
| 1851 |
@fontcmaps = (); |
| 1852 |
%fontfiles = (); |
| 1853 |
%fontprovides = (); |
| 1854 |
} |
| 1855 |
} else { |
| 1856 |
# no term is set, so nothing to warn about |
| 1857 |
} |
| 1858 |
next; |
| 1859 |
} |
| 1860 |
if ($l =~ m/^!INCLUDE\s*(.*)$/) { # for remove-only database |
| 1861 |
next if (!$opt_cleanup); |
| 1862 |
my @dbl; |
| 1863 |
my $foo = kpse_miscfont($1); |
| 1864 |
if (!open(FDB, "<:encoding(UTF-8)", encode('locale_fs', $foo))) { |
| 1865 |
print_warning("Cannot find $1, skipping!\n"); |
| 1866 |
next; |
| 1867 |
} |
| 1868 |
@dbl = <FDB>; |
| 1869 |
close(FDB); |
| 1870 |
print_debug("Reading database file $1...\n"); |
| 1871 |
read_each_font_database(@dbl); |
| 1872 |
next; |
| 1873 |
} |
| 1874 |
if ($l =~ m/^INCLUDE\s*(.*)$/) { |
| 1875 |
my @dbl; |
| 1876 |
my $foo = kpse_miscfont($1); |
| 1877 |
if (!open(FDB, "<:encoding(UTF-8)", encode('locale_fs', $foo))) { |
| 1878 |
print_warning("Cannot find $1, skipping!\n"); |
| 1879 |
next; |
| 1880 |
} |
| 1881 |
@dbl = <FDB>; |
| 1882 |
close(FDB); |
| 1883 |
print_debug("Reading database file $1...\n"); |
| 1884 |
read_each_font_database(@dbl); |
| 1885 |
next; |
| 1886 |
} |
| 1887 |
if ($l =~ m/^Name:\s*(.*)$/) { $fontname = $1; next; } |
| 1888 |
if ($l =~ m/^PSName:\s*(.*)$/) { $psname = $1; next; } |
| 1889 |
if ($l =~ m/^Class:\s*(.*)$/) { $fontclass = $1 ; next ; } |
| 1890 |
if ($l =~ m/^CMap:\s*(.*)$/) { push(@fontcmaps, $1); next ; } |
| 1891 |
if ($l =~ m/^Provides\((\d+)\):\s*(.*)$/) { $fontprovides{$2} = $1; next; } |
| 1892 |
if ($l =~ m/^Doublecheck:\s*(.*)$/) { $fontdoublecheck = $1 ; next ; } |
| 1893 |
if ($l =~ m/^Casefold:\s*(.*)$/) { $fontdoublecheck = $1 ; next ; } # no longer used |
| 1894 |
# new code: distinguish 4 types (otf, otc, ttf, ttc) |
| 1895 |
if ($l =~ m/^OTFname(\((\d+)\))?:\s*(.*)$/) { |
| 1896 |
my $fn = $3; |
| 1897 |
$fontfiles{$fn}{'priority'} = ($2 ? $2 : 10); |
| 1898 |
print_dddebug("filename: ${fn}\n"); |
| 1899 |
print_dddebug("type: otf\n"); |
| 1900 |
$fontfiles{$fn}{'type'} = 'OTF'; |
| 1901 |
next; |
| 1902 |
} |
| 1903 |
if ($l =~ m/^OTCname(\((\d+)\))?:\s*(.*)$/) { |
| 1904 |
my $fn = $3; |
| 1905 |
$fontfiles{$fn}{'priority'} = ($2 ? $2 : 10); |
| 1906 |
print_dddebug("filename: ${fn}\n"); |
| 1907 |
print_dddebug("type: otc\n"); |
| 1908 |
$fontfiles{$fn}{'type'} = 'OTC'; |
| 1909 |
next; |
| 1910 |
} |
| 1911 |
if ($l =~ m/^TTFname(\((\d+)\))?:\s*(.*)$/) { |
| 1912 |
my $fn = $3; |
| 1913 |
$fontfiles{$fn}{'priority'} = ($2 ? $2 : 10); |
| 1914 |
print_dddebug("filename: ${fn}\n"); |
| 1915 |
print_dddebug("type: ttf\n"); |
| 1916 |
$fontfiles{$fn}{'type'} = 'TTF'; |
| 1917 |
next; |
| 1918 |
} |
| 1919 |
if ($l =~ m/^TTCname(\((\d+)\))?:\s*(.*)$/) { |
| 1920 |
my $fn = $3; |
| 1921 |
$fontfiles{$fn}{'priority'} = ($2 ? $2 : 10); |
| 1922 |
print_dddebug("filename: ${fn}\n"); |
| 1923 |
print_dddebug("type: ttc\n"); |
| 1924 |
$fontfiles{$fn}{'type'} = 'TTC'; |
| 1925 |
next; |
| 1926 |
} |
| 1927 |
# only for backward compatibility; guess type from the file extension |
| 1928 |
if ($l =~ m/^Filename(\((\d+)\))?:\s*(.*)$/) { |
| 1929 |
my $fn = $3; |
| 1930 |
$fontfiles{$fn}{'priority'} = ($2 ? $2 : 10); |
| 1931 |
print_dddebug("filename: ${fn}\n"); |
| 1932 |
if ($fn =~ m/\.otf$/i) { |
| 1933 |
print_dddebug("type: otf\n"); |
| 1934 |
$fontfiles{$fn}{'type'} = 'OTF'; |
| 1935 |
} elsif ($fn =~ m/\.otc(\(\d+\))?$/i) { |
| 1936 |
print_dddebug("type: otc\n"); |
| 1937 |
$fontfiles{$fn}{'type'} = 'OTC'; |
| 1938 |
} elsif ($fn =~ m/\.ttf$/i) { |
| 1939 |
print_dddebug("type: ttf\n"); |
| 1940 |
$fontfiles{$fn}{'type'} = 'TTF'; |
| 1941 |
} elsif ($fn =~ m/\.ttc(\(\d+\))?$/i) { |
| 1942 |
print_dddebug("type: ttc\n"); |
| 1943 |
$fontfiles{$fn}{'type'} = 'TTC'; |
| 1944 |
} else { |
| 1945 |
print_warning("cannot determine font type of $fn at line $lineno, skipping!\n"); |
| 1946 |
delete $fontfiles{$fn}; |
| 1947 |
} |
| 1948 |
next; |
| 1949 |
} |
| 1950 |
# only for removing |
| 1951 |
if ($l =~ m/^RMVname(\((\d+)\))?:\s*(.*)$/) { |
| 1952 |
my $fn = $3; |
| 1953 |
$fontfiles{$fn}{'priority'} = ($2 ? $2 : 10); |
| 1954 |
print_dddebug("filename: ${fn}\n"); |
| 1955 |
print_dddebug("type: remove\n"); |
| 1956 |
$fontfiles{$fn}{'type'} = 'RMV'; |
| 1957 |
next; |
| 1958 |
} |
| 1959 |
# we are still here?? |
| 1960 |
print_error("Cannot parse this file at line $lineno, exiting. |
| 1961 |
Strange line: >>>$l<<<\n"); |
| 1962 |
exit(1); |
| 1963 |
} |
| 1964 |
} |
| 1965 |
|
| 1966 |
sub dump_font_database { |
| 1967 |
open(FOO, ">:encoding(UTF-8)", encode('locale_fs', $dump_datafile)) || |
| 1968 |
die("cannot open $dump_datafile for writing: $!"); |
| 1969 |
for my $k (sort keys %fontdb) { |
| 1970 |
print FOO "Name: $fontdb{$k}{'origname'}\n"; |
| 1971 |
print FOO "PSName: $k\n" if ($fontdb{$k}{'origname'} ne $k); |
| 1972 |
my $class = $fontdb{$k}{'class'}; |
| 1973 |
print FOO "Class: $class\n"; |
| 1974 |
if ($class eq "AI0") { |
| 1975 |
for my $cmap (@{$encode_list{"AI0-$k"}}) { |
| 1976 |
print FOO "CMap: $cmap\n"; |
| 1977 |
} |
| 1978 |
} |
| 1979 |
for my $p (sort keys %{$fontdb{$k}{'provides'}}) { |
| 1980 |
print FOO "Provides($fontdb{$k}{'provides'}{$p}): $p\n"; |
| 1981 |
} |
| 1982 |
print FOO "Doublecheck: $fontdb{$k}{'doublecheck'}\n" if ($fontdb{$k}{'doublecheck'}); |
| 1983 |
for my $f (sort { $fontdb{$k}{'files'}{$a}{'priority'} |
| 1984 |
<=> |
| 1985 |
$fontdb{$k}{'files'}{$b}{'priority'} } |
| 1986 |
keys %{$fontdb{$k}{'files'}}) { |
| 1987 |
print FOO "$fontdb{$k}{'files'}{$f}{'type'}name($fontdb{$k}{'files'}{$f}{'priority'}): $f\n"; |
| 1988 |
} |
| 1989 |
print FOO "\n"; # empty line is a separator between entries |
| 1990 |
} |
| 1991 |
close(FOO); |
| 1992 |
} |
| 1993 |
|
| 1994 |
sub find_gs_resource { |
| 1995 |
my $foundres = ''; |
| 1996 |
if (win32()) { |
| 1997 |
# determine tlgs or native gs |
| 1998 |
my $foo = `kpsewhich -var-value=SELFAUTOPARENT`; |
| 1999 |
# We assume that the output of kpsewhich is |
| 2000 |
# the same as perl's locale (or active code page). |
| 2001 |
decode('locale', $foo); |
| 2002 |
chomp($foo); |
| 2003 |
if ( -d encode('locale_fs', "$foo/tlpkg/tlgs") ) { |
| 2004 |
# should be texlive with tlgs |
| 2005 |
print_debug("Assuming tlgs win32 ...\n"); |
| 2006 |
$foundres = "$foo/tlpkg/tlgs/Resource"; |
| 2007 |
# for TL2016, tlgs binary has built-in Resource, |
| 2008 |
# so we cannot set up CJK fonts correctly. |
| 2009 |
# the following test forces to exit in such case |
| 2010 |
if ( ! -d encode('locale_fs', $foundres) ) { |
| 2011 |
print_error("No Resource directory available for tlgs,\n"); |
| 2012 |
print_error("we cannot support such gs, sorry.\n"); |
| 2013 |
$foundres = ''; |
| 2014 |
} |
| 2015 |
# change output location |
| 2016 |
$cidfmap_pathpart = "../lib/cidfmap"; |
| 2017 |
$cidfmap_local_pathpart = "../lib/cidfmap.local"; |
| 2018 |
$cidfmap_aliases_pathpart = "../lib/cidfmap.aliases"; |
| 2019 |
} else { |
| 2020 |
# we assume gswin32c is in the path |
| 2021 |
# TODO: what should we do for gswin64c? |
| 2022 |
$foundres = `where gswin32c 2>$nul`; # assume 'where' is available |
| 2023 |
if ($?) { |
| 2024 |
print_error("Cannot run where gswin32c ...\n"); |
| 2025 |
} else { |
| 2026 |
# We assume that the output of 'where' is |
| 2027 |
# the same as perl's locale (or active code page). |
| 2028 |
chomp($foundres = decode('locale', $foundres)); |
| 2029 |
# trial 1: assume the relative path |
| 2030 |
# when C:\path\to\bin\gswin32c.exe is found, then there should be |
| 2031 |
# C:\path\to\Resource (note that 'where' returns backslash-ed path) |
| 2032 |
print_debug("Finding gs resource by assuming relative path ...\n"); |
| 2033 |
$foundres =~ s!\\!/!g; |
| 2034 |
$foundres =~ s!/bin/gswin32c\.exe$!/Resource!; |
| 2035 |
if ( ! -d encode('locale_fs', $foundres) ) { |
| 2036 |
$foundres = ''; |
| 2037 |
} |
| 2038 |
if (!$foundres) { |
| 2039 |
print_debug("Found gs but no resource, try another routine ...\n"); |
| 2040 |
} |
| 2041 |
} |
| 2042 |
if (!$foundres) { |
| 2043 |
chomp(my $gsver = `gswin32c --version 2>$nul`); |
| 2044 |
if ($?) { |
| 2045 |
print_error("Cannot run gswin32c --version ...\n"); |
| 2046 |
} else { |
| 2047 |
# trial 2: assume the fixed path, c:/gs/gs$gsver/Resource |
| 2048 |
print_debug("Finding gs resource by assuming fixed path ...\n"); |
| 2049 |
$foundres = "c:/gs/gs$gsver/Resource"; |
| 2050 |
if ( ! -d encode('locale_fs', $foundres) ) { |
| 2051 |
$foundres = ''; |
| 2052 |
} |
| 2053 |
if (!$foundres) { |
| 2054 |
print_error("Found gs but no resource???\n"); |
| 2055 |
} |
| 2056 |
} |
| 2057 |
} |
| 2058 |
} |
| 2059 |
} else { |
| 2060 |
# we assume that gs is in the path |
| 2061 |
chomp(my $gsver = `gs --version 2>$nul`); |
| 2062 |
if ($?) { |
| 2063 |
print_error("Cannot run gs --version ...\n"); |
| 2064 |
} else { |
| 2065 |
# trial 1: assume the relative path |
| 2066 |
# when /path/to/bin/gs is found, then there should be |
| 2067 |
# /path/to/share/ghostscript/$(gs --version)/Resource |
| 2068 |
print_debug("Finding gs resource by assuming relative path ...\n"); |
| 2069 |
$foundres = `which gs`; |
| 2070 |
# We assume that the output of 'which' is |
| 2071 |
# the same as perl's locale (or active code page). |
| 2072 |
$foundres = decode('locale', $foundres); |
| 2073 |
chomp($foundres); |
| 2074 |
$foundres =~ s!/bin/gs$!/share/ghostscript/$gsver/Resource!; |
| 2075 |
if ( ! -d encode('locale_fs', $foundres) ) { |
| 2076 |
$foundres = ''; |
| 2077 |
} |
| 2078 |
if (!$foundres) { |
| 2079 |
print_debug("Found gs but no resource, try another routine ...\n"); |
| 2080 |
} |
| 2081 |
} |
| 2082 |
if (!$foundres) { |
| 2083 |
my @ret = `gs --help 2>$nul`; |
| 2084 |
if ($?) { |
| 2085 |
print_error("Cannot run gs --help ...\n"); |
| 2086 |
} else { |
| 2087 |
# We assume that the output of gs is |
| 2088 |
# the same as perl's locale (or active code page). |
| 2089 |
@ret = map { decode('locale', $_) } @ret; |
| 2090 |
chomp(@ret); |
| 2091 |
# trial 2: parse gs help message |
| 2092 |
print_debug("Finding gs resource by parsing help message ...\n"); |
| 2093 |
$foundres = ''; |
| 2094 |
# try to find resource line |
| 2095 |
for (@ret) { |
| 2096 |
if (m!Resource/Font!) { |
| 2097 |
$foundres = $_; |
| 2098 |
# extract the first substring of non-space chars |
| 2099 |
# up to Resource/Font and drop the /Font part |
| 2100 |
$foundres =~ s!^.*\s(\S*Resource)/Font.*$!$1!; |
| 2101 |
last; |
| 2102 |
} |
| 2103 |
} |
| 2104 |
if (!$foundres) { |
| 2105 |
print_error("Found gs but no resource???\n"); |
| 2106 |
} |
| 2107 |
} |
| 2108 |
} |
| 2109 |
} |
| 2110 |
return $foundres; |
| 2111 |
} |
| 2112 |
|
| 2113 |
sub kpse_miscfont { |
| 2114 |
my ($file) = @_; |
| 2115 |
my $foo = ''; |
| 2116 |
# first, prioritize GitHub repository diretory structure |
| 2117 |
$foo = "database/$file" if (-f encode('locale_fs', "database/$file")); |
| 2118 |
if ($foo eq "") { |
| 2119 |
my $cmdl = "kpsewhich -format=miscfont $file"; |
| 2120 |
$cmdl = encode('locale', $cmdl); |
| 2121 |
$foo = `$cmdl`; |
| 2122 |
# We assume that the output of kpsewhich is |
| 2123 |
# the same as perl's locale (or active code page). |
| 2124 |
$foo = decode('locale', $foo); |
| 2125 |
chomp($foo); |
| 2126 |
} |
| 2127 |
return $foo; |
| 2128 |
} |
| 2129 |
|
| 2130 |
sub init_encode_locale { |
| 2131 |
eval { |
| 2132 |
require Encode::Locale; |
| 2133 |
Encode::Locale->import(); |
| 2134 |
|
| 2135 |
$debug_msg_before_init .= "Encode::Locale is loaded.\n"; |
| 2136 |
}; |
| 2137 |
if ($@) { |
| 2138 |
if (win32) { |
| 2139 |
die ("For Windows, Encode::Locale is required.\n"); |
| 2140 |
} |
| 2141 |
|
| 2142 |
$debug_msg_before_init .= |
| 2143 |
"Encode::Locale is not found. Assuming all encodings are UTF-8.\n"; |
| 2144 |
Encode::Alias::define_alias('locale' => 'UTF-8'); |
| 2145 |
Encode::Alias::define_alias('locale_fs' => 'UTF-8'); |
| 2146 |
Encode::Alias::define_alias('console_in' => 'UTF-8'); |
| 2147 |
Encode::Alias::define_alias('console_out' => 'UTF-8'); |
| 2148 |
} |
| 2149 |
} |
| 2150 |
|
| 2151 |
sub version { |
| 2152 |
my $ret = sprintf "%s version %s\n", $prg, $version; |
| 2153 |
return $ret; |
| 2154 |
} |
| 2155 |
|
| 2156 |
sub Usage { |
| 2157 |
my $headline = "Configuring Ghostscript for CJK CID/TTF fonts"; |
| 2158 |
my $usage = "[perl] $prg\[.pl\] [OPTIONS]"; |
| 2159 |
my $options = " |
| 2160 |
-o, --output DIR specifies the base output dir, if not provided, |
| 2161 |
the Resource directory of an installed Ghostscript |
| 2162 |
is searched and used. |
| 2163 |
-f, --fontdef FILE specify alternate set of font definitions, if not |
| 2164 |
given, the built-in set is used |
| 2165 |
--fontdef-add FILE specify additional set of font definitions, to |
| 2166 |
overwrite subset of built-in definitions; |
| 2167 |
can be given multiple times |
| 2168 |
-a, --alias LL=RR defines an alias, or overrides a given alias; |
| 2169 |
illegal if LL is provided by a real font, or |
| 2170 |
RR is neither available as real font or alias; |
| 2171 |
can be given multiple times |
| 2172 |
--filelist FILE read list of available font files from FILE |
| 2173 |
instead of searching with kpathsea |
| 2174 |
--link-texmf [DIR] link fonts into |
| 2175 |
DIR/$otf_pathpart |
| 2176 |
and |
| 2177 |
DIR/$ttf_pathpart |
| 2178 |
where DIR defaults to TEXMFLOCAL |
| 2179 |
--otfps [DIR] generate configuration file (psnames-for-otf) into |
| 2180 |
DIR/$akotfps_pathpart |
| 2181 |
which is used by ps2otfps (developed by Akira Kakuto), |
| 2182 |
instead of generating snippets |
| 2183 |
--force do not bail out if linked fonts already exist |
| 2184 |
--remove try to remove instead of create |
| 2185 |
--cleanup try to clean up all possible links/snippets and |
| 2186 |
cidfmap.local/cidfmap.aliases, which could have been |
| 2187 |
generated in the previous runs |
| 2188 |
-n, --dry-run do not actually output anything |
| 2189 |
-q, --quiet be less verbose |
| 2190 |
-d, --debug output debug information, can be given multiple times |
| 2191 |
-v, --version outputs only the version information |
| 2192 |
-h, --help this help |
| 2193 |
"; |
| 2194 |
|
| 2195 |
my $commandoptions = " |
| 2196 |
--dump-data [FILE] dump the set of font definitions which is currently |
| 2197 |
effective, where FILE (the dump output) defaults to |
| 2198 |
$dump_datafile; you can easily modify it, |
| 2199 |
and tell me with -f (or --fontdef) option |
| 2200 |
--only-aliases regenerate only cidfmap.aliases file, instead of all |
| 2201 |
--list-aliases lists the available aliases and their options, with the |
| 2202 |
selected option on top |
| 2203 |
--list-all-aliases list all possible aliases without searching for |
| 2204 |
actually present files |
| 2205 |
--list-fonts lists the fonts found on the system |
| 2206 |
--info combines the information of --list-aliases and |
| 2207 |
--list-fonts |
| 2208 |
--machine-readable output of --list-aliases is machine readable |
| 2209 |
"; |
| 2210 |
|
| 2211 |
my $shortdesc = " |
| 2212 |
This script searches a list of directories for CJK fonts, and makes |
| 2213 |
them available to an installed Ghostscript. In the simplest case with |
| 2214 |
sufficient privileges, a run without arguments should effect in a |
| 2215 |
complete setup of Ghostscript. |
| 2216 |
Search is done using the kpathsea library, in particular `kpsewhich` |
| 2217 |
program. To run this script, you will need some TeX distribution in |
| 2218 |
your system. |
| 2219 |
"; |
| 2220 |
|
| 2221 |
my $operation = " |
| 2222 |
For each found TrueType (TTF) font it creates a cidfmap entry in |
| 2223 |
|
| 2224 |
<Resource>/Init/cidfmap.local |
| 2225 |
-- if you are using tlgs win32, tlpkg/tlgs/lib/cidfmap.local instead |
| 2226 |
|
| 2227 |
and links the font to |
| 2228 |
|
| 2229 |
<Resource>/CIDFSubst/ |
| 2230 |
|
| 2231 |
For each CID font it creates a snippet in |
| 2232 |
|
| 2233 |
<Resource>/Font/ |
| 2234 |
|
| 2235 |
and links the font to |
| 2236 |
|
| 2237 |
<Resource>/CIDFont/ |
| 2238 |
|
| 2239 |
The `<Resource>` dir is either given by `-o`/`--output`, or otherwise searched |
| 2240 |
from an installed Ghostscript (binary name is assumed to be 'gs' on unix, |
| 2241 |
'gswin32c' on win32). |
| 2242 |
|
| 2243 |
Aliases are added to |
| 2244 |
|
| 2245 |
<Resource>/Init/cidfmap.aliases |
| 2246 |
-- if you are using tlgs win32, tlpkg/tlgs/lib/cidfmap.aliases instead |
| 2247 |
|
| 2248 |
Finally, it tries to add runlib calls to |
| 2249 |
|
| 2250 |
<Resource>/Init/cidfmap |
| 2251 |
-- if you are using tlgs win32, tlpkg/tlgs/lib/cidfmap |
| 2252 |
|
| 2253 |
to load the cidfmap.local and cidfmap.aliases. |
| 2254 |
"; |
| 2255 |
|
| 2256 |
my $dirsearch = ' |
| 2257 |
Search is done using the kpathsea library, in particular using kpsewhich |
| 2258 |
program. By default the following directories are searched: |
| 2259 |
- all TEXMF trees |
| 2260 |
- `/Library/Fonts`, `/Library/Fonts/Microsoft`, `/System/Library/Fonts`, |
| 2261 |
`/System/Library/Assets`, `/Network/Library/Fonts`, |
| 2262 |
`~/Library/Fonts` and `/usr/share/fonts` (all if available) |
| 2263 |
- `/Applications/Microsoft Word.app/Contents/Resources/{Fonts,DFonts}`, |
| 2264 |
`/Applications/Microsoft Excel.app/Contents/Resources/{Fonts,DFonts}`, |
| 2265 |
`/Applications/Microsoft PowerPoint.app/Contents/Resources/{Fonts,DFonts}` |
| 2266 |
(all if available, meant for Office for Mac 2016) |
| 2267 |
- `c:/windows/fonts` (on Windows) |
| 2268 |
- the directories in `OSFONTDIR` environment variable |
| 2269 |
|
| 2270 |
In case you want to add some directories to the search path, adapt the |
| 2271 |
`OSFONTDIR` environment variable accordingly: Example: |
| 2272 |
|
| 2273 |
````` |
| 2274 |
OSFONTDIR="/usr/local/share/fonts/truetype//:/usr/local/share/fonts/opentype//" $prg |
| 2275 |
````` |
| 2276 |
|
| 2277 |
will result in fonts found in the above two given directories to be |
| 2278 |
searched in addition. |
| 2279 |
'; |
| 2280 |
|
| 2281 |
my $outputfile = " |
| 2282 |
If no output option is given, the program searches for a Ghostscript |
| 2283 |
interpreter 'gs' and determines its Resource directory. This might |
| 2284 |
fail, in which case one need to pass the output directory manually. |
| 2285 |
|
| 2286 |
Since the program adds files and link to this directory, sufficient |
| 2287 |
permissions are necessary. |
| 2288 |
"; |
| 2289 |
|
| 2290 |
my $aliases = " |
| 2291 |
Aliases are managed via the Provides values in the font database. |
| 2292 |
At the moment entries for the basic font names for CJK fonts |
| 2293 |
are added: |
| 2294 |
|
| 2295 |
Japanese: |
| 2296 |
|
| 2297 |
Ryumin-Light GothicBBB-Medium FutoMinA101-Bold FutoGoB101-Bold |
| 2298 |
MidashiMin-MA31 MidashiGo-MB31 Jun101-Light |
| 2299 |
|
| 2300 |
Korean: |
| 2301 |
|
| 2302 |
HYSMyeongJo-Medium HYGoThic-Medium HYRGoThic-Medium |
| 2303 |
|
| 2304 |
Simplified Chinese: |
| 2305 |
|
| 2306 |
STSong-Light STSong-Regular STHeiti-Regular STHeiti-Light |
| 2307 |
STKaiti-Regular STFangsong-Light STFangsong-Regular |
| 2308 |
|
| 2309 |
Traditional Chinese: |
| 2310 |
|
| 2311 |
MSung-Light MSung-Medium MHei-Medium MKai-Medium |
| 2312 |
|
| 2313 |
In addition, we also include provide entries for the OTF Morisawa names: |
| 2314 |
|
| 2315 |
RyuminPro-Light GothicBBBPro-Medium |
| 2316 |
FutoMinA101Pro-Bold FutoGoB101Pro-Bold |
| 2317 |
MidashiMinPro-MA31 MidashiGoPro-MB31 Jun101Pro-Light |
| 2318 |
|
| 2319 |
The order is determined by the `Provides` setting in the font database. |
| 2320 |
That is, the first font found in this order will be used to provide the |
| 2321 |
alias if necessary. |
| 2322 |
|
| 2323 |
For the Japanese fonts: |
| 2324 |
Morisawa Pr6N, Morisawa, Hiragino ProN, Hiragino, |
| 2325 |
Kozuka Pr6N, Kozuka ProVI, Kozuka Pro, Kozuka Std, |
| 2326 |
HaranoAji, Yu OS X, Yu Win, MS, |
| 2327 |
Moga-Mobo-ex, Moga-Mobo, IPAex, IPA, Ume |
| 2328 |
|
| 2329 |
For the Korean fonts: |
| 2330 |
(Hanyang,) Adobe, Solaris, MS, Unfonts, Baekmuk |
| 2331 |
|
| 2332 |
For the Simplified Chinese: |
| 2333 |
Adobe, Fandol, HaranoAji, Hiragino, Founder, MS, |
| 2334 |
CJKUnifonts, Arphic, CJKUnifonts-ttf |
| 2335 |
|
| 2336 |
For the Traditional Chinese: |
| 2337 |
Adobe, HaranoAji, MS, |
| 2338 |
CJKUnifonts, Arphic, CJKUnifonts-ttf |
| 2339 |
|
| 2340 |
#### Overriding aliases #### |
| 2341 |
|
| 2342 |
Using the command line option `--alias LL=RR` one can add arbitrary aliases, |
| 2343 |
or override ones selected by the program. For this to work the following |
| 2344 |
requirements of `LL` and `RR` must be fulfilled: |
| 2345 |
* `LL` is not provided by a real font |
| 2346 |
* `RR` is available either as real font, or as alias (indirect alias) |
| 2347 |
"; |
| 2348 |
|
| 2349 |
my $authors = " |
| 2350 |
The script and its documentation was written by Norbert Preining, based |
| 2351 |
on research and work by Masamichi Hosoda, Yusuke Kuroki, Yusuke Terada, |
| 2352 |
Bruno Voisin, Hironobu Yamashita, Munehiro Yamamoto and the TeX Q&A wiki |
| 2353 |
page. |
| 2354 |
|
| 2355 |
Maintained by Japanese TeX Development Community. For development, see |
| 2356 |
https://github.com/texjporg/cjk-gs-support |
| 2357 |
|
| 2358 |
The script is licensed under GNU General Public License Version 3 or later. |
| 2359 |
The contained font data is not copyrightable. |
| 2360 |
"; |
| 2361 |
|
| 2362 |
|
| 2363 |
if ($opt_markdown) { |
| 2364 |
print "$headline\n"; |
| 2365 |
print ("=" x length($headline)); |
| 2366 |
print "\n$shortdesc\nUsage\n-----\n\n`````\n$usage\n`````\n\n"; |
| 2367 |
print "#### Options ####\n\n`````"; |
| 2368 |
print_for_out($options, " "); |
| 2369 |
print "`````\n\n#### Command like options ####\n\n`````"; |
| 2370 |
print_for_out($commandoptions, " "); |
| 2371 |
print "`````\n\nOperation\n---------\n$operation\n"; |
| 2372 |
print "How and which directories are searched\n"; |
| 2373 |
print "--------------------------------------\n$dirsearch\n"; |
| 2374 |
print "Output files\n"; |
| 2375 |
print "------------\n$outputfile\n"; |
| 2376 |
print "Aliases\n"; |
| 2377 |
print "-------\n$aliases\n"; |
| 2378 |
print "Authors, Contributors, and Copyright\n"; |
| 2379 |
print "------------------------------------\n$authors\n"; |
| 2380 |
} else { |
| 2381 |
print "\nUsage: $usage\n\n$headline\n$shortdesc"; |
| 2382 |
print "\nOptions:\n"; |
| 2383 |
print_for_out($options, " "); |
| 2384 |
print "\nCommand like options:\n"; |
| 2385 |
print_for_out($commandoptions, " "); |
| 2386 |
print "\nOperation:\n"; |
| 2387 |
print_for_out($operation, " "); |
| 2388 |
print "\nHow and which directories are searched:\n"; |
| 2389 |
print_for_out($dirsearch, " "); |
| 2390 |
print "\nOutput files:\n"; |
| 2391 |
print_for_out($outputfile, " "); |
| 2392 |
print "\nAliases:\n"; |
| 2393 |
print_for_out($aliases, " "); |
| 2394 |
print "\nAuthors, Contributors, and Copyright:\n"; |
| 2395 |
print_for_out($authors, " "); |
| 2396 |
print "\n"; |
| 2397 |
} |
| 2398 |
exit(0); |
| 2399 |
} |
| 2400 |
|
| 2401 |
sub print_for_out { |
| 2402 |
my ($what, $indent) = @_; |
| 2403 |
for (split /\n/, $what) { |
| 2404 |
next if m/`````/; |
| 2405 |
s/\s*####\s*//g; |
| 2406 |
if ($_ eq '') { |
| 2407 |
print "\n"; |
| 2408 |
} else { |
| 2409 |
print "$indent$_\n"; |
| 2410 |
} |
| 2411 |
} |
| 2412 |
} |
| 2413 |
|
| 2414 |
# info/warning can be suppressed |
| 2415 |
# verbose/error cannot be suppressed |
| 2416 |
sub print_info { |
| 2417 |
print STDOUT "$prg: ", @_ if (!$opt_quiet); |
| 2418 |
} |
| 2419 |
sub print_verbose { |
| 2420 |
print STDOUT "$prg: ", @_; |
| 2421 |
} |
| 2422 |
sub print_warning { |
| 2423 |
print STDERR "$prg [WARNING]: ", @_ if (!$opt_quiet) |
| 2424 |
} |
| 2425 |
sub print_error { |
| 2426 |
print STDERR "$prg [ERROR]: ", @_; |
| 2427 |
} |
| 2428 |
sub print_debug { |
| 2429 |
print STDERR "$prg [DEBUG]: ", @_ if ($opt_debug >= 1); |
| 2430 |
} |
| 2431 |
sub print_ddebug { |
| 2432 |
print STDERR "$prg [DEBUG]: ", @_ if ($opt_debug >= 2); |
| 2433 |
} |
| 2434 |
sub print_dddebug { |
| 2435 |
print STDERR "$prg [DEBUG]: ", @_ if ($opt_debug >= 3); |
| 2436 |
} |
| 2437 |
|
| 2438 |
|
| 2439 |
__DATA__ |
| 2440 |
# |
| 2441 |
# CJK FONT DEFINITIONS |
| 2442 |
# |
| 2443 |
|
| 2444 |
# Noto |
| 2445 |
INCLUDE cjkgs-notoserif.dat |
| 2446 |
INCLUDE cjkgs-notosans.dat |
| 2447 |
|
| 2448 |
# SourceHan |
| 2449 |
INCLUDE cjkgs-sourcehanserif.dat |
| 2450 |
INCLUDE cjkgs-sourcehansans.dat |
| 2451 |
|
| 2452 |
# |
| 2453 |
# JAPANESE FONTS |
| 2454 |
# |
| 2455 |
|
| 2456 |
# Morisawa -- Provides J10(Pr6N), J15(Pr6), J18(Pr5), J20(Pro) |
| 2457 |
INCLUDE cjkgs-morisawa.dat |
| 2458 |
#INCLUDE cjkgs-morisawa-extra.dat |
| 2459 |
|
| 2460 |
# Hiragino -- Provides J30(ProN), J40(Pro) |
| 2461 |
INCLUDE cjkgs-hiragino.dat |
| 2462 |
|
| 2463 |
# Kozuka -- Provides J50(Pr6N), J55(ProVI), J60(Pro), J65(Std) |
| 2464 |
INCLUDE cjkgs-kozuka.dat |
| 2465 |
INCLUDE cjkgs-ryokana.dat |
| 2466 |
|
| 2467 |
# Yu-fonts MacOS version -- Provides J80 |
| 2468 |
INCLUDE cjkgs-yu-osx.dat |
| 2469 |
|
| 2470 |
# Yu-fonts Windows/MSOffice version -- Provides J90 |
| 2471 |
INCLUDE cjkgs-yu-win.dat |
| 2472 |
|
| 2473 |
# MS -- Provides J95 |
| 2474 |
INCLUDE cjkgs-microsoft.dat |
| 2475 |
|
| 2476 |
# BIZ UD |
| 2477 |
INCLUDE cjkgs-bizud.dat |
| 2478 |
|
| 2479 |
# TypeBank |
| 2480 |
INCLUDE cjkgs-typebank.dat |
| 2481 |
|
| 2482 |
# Fontworks |
| 2483 |
INCLUDE cjkgs-fontworks.dat |
| 2484 |
|
| 2485 |
# Toppan |
| 2486 |
INCLUDE cjkgs-toppan.dat |
| 2487 |
|
| 2488 |
# Heisei |
| 2489 |
INCLUDE cjkgs-heisei.dat |
| 2490 |
|
| 2491 |
# Moga-Mobo from Y.Oz Vox (free) -- Provides J100(Ex), J110(none) |
| 2492 |
INCLUDE cjkgs-mogamobo.dat |
| 2493 |
|
| 2494 |
# IPA (free) -- Provides J120(Ex), J130(none) |
| 2495 |
INCLUDE cjkgs-ipa.dat |
| 2496 |
|
| 2497 |
# Ume-font (free) -- Provides J140 |
| 2498 |
INCLUDE cjkgs-ume.dat |
| 2499 |
|
| 2500 |
# Sazanami (free) |
| 2501 |
INCLUDE cjkgs-sazanami.dat |
| 2502 |
|
| 2503 |
# Harano Aji Fonts (free) -- Provides J70, J71 |
| 2504 |
INCLUDE cjkgs-haranoaji.dat |
| 2505 |
|
| 2506 |
# Osaka (Apple) |
| 2507 |
|
| 2508 |
Name: Osaka |
| 2509 |
Class: Japan |
| 2510 |
TTFname: Osaka.ttf |
| 2511 |
|
| 2512 |
Name: Osaka-Mono |
| 2513 |
Class: Japan |
| 2514 |
TTFname: OsakaMono.ttf |
| 2515 |
|
| 2516 |
# |
| 2517 |
# CHINESE FONTS |
| 2518 |
# |
| 2519 |
|
| 2520 |
# Adobe -- Provides S30, T30 |
| 2521 |
INCLUDE cjkgs-adobe.dat |
| 2522 |
|
| 2523 |
# HaranoAji -- Provides S45, T45 |
| 2524 |
# (already included in JAPANESE section) |
| 2525 |
|
| 2526 |
# Hiragino -- Provides S50 |
| 2527 |
# (already included in JAPANESE section) |
| 2528 |
|
| 2529 |
# Beijing Founder Electronics -- Provides S55 |
| 2530 |
INCLUDE cjkgs-founder.dat |
| 2531 |
|
| 2532 |
# Changzhou SinoType -- Provides S?? |
| 2533 |
INCLUDE cjkgs-sinotype.dat |
| 2534 |
|
| 2535 |
# DynaComware -- Provides T?? |
| 2536 |
INCLUDE cjkgs-dynacomware.dat |
| 2537 |
|
| 2538 |
# Monotype |
| 2539 |
INCLUDE cjkgs-monotype.dat |
| 2540 |
|
| 2541 |
# Shanghai Ikarus Ltd./URW Software & Type GmbH |
| 2542 |
|
| 2543 |
Name: SIL-Hei-Med-Jian |
| 2544 |
Class: GB |
| 2545 |
TTFname: Hei.ttf |
| 2546 |
|
| 2547 |
Name: SIL-Kai-Reg-Jian |
| 2548 |
Class: GB |
| 2549 |
TTFname: Kai.ttf |
| 2550 |
|
| 2551 |
# Fandol (free) -- Provides S40 |
| 2552 |
INCLUDE cjkgs-fandol.dat |
| 2553 |
|
| 2554 |
# Arphic (free) -- Provides S80, T80 |
| 2555 |
INCLUDE cjkgs-arphic.dat |
| 2556 |
|
| 2557 |
# CJK-Unifonts new ttc edition (free) -- Provides T70, S70 |
| 2558 |
# CJK-Unifonts old ttf edition (free) -- Provides T90, S90 |
| 2559 |
INCLUDE cjkgs-cjkuni.dat |
| 2560 |
|
| 2561 |
# WenQuanYi (free) |
| 2562 |
INCLUDE cjkgs-wenquanyi.dat |
| 2563 |
|
| 2564 |
# cwTeX (free) |
| 2565 |
|
| 2566 |
Name: cwTeXMing |
| 2567 |
Class: CNS |
| 2568 |
TTFname: cwming.ttf |
| 2569 |
|
| 2570 |
Name: cwTeXHeiBold |
| 2571 |
Class: CNS |
| 2572 |
TTFname: cwheib.ttf |
| 2573 |
|
| 2574 |
Name: cwTeXKai |
| 2575 |
Class: CNS |
| 2576 |
TTFname: cwkai.ttf |
| 2577 |
|
| 2578 |
Name: cwTeXYen |
| 2579 |
Class: CNS |
| 2580 |
TTFname: cwyen.ttf |
| 2581 |
|
| 2582 |
Name: cwTeXFangSong |
| 2583 |
Class: CNS |
| 2584 |
TTFname: cwfs.ttf |
| 2585 |
|
| 2586 |
# |
| 2587 |
# KOREAN FONTS |
| 2588 |
# |
| 2589 |
|
| 2590 |
# Adobe -- Provides K30/80 |
| 2591 |
# (already included in CHINESE section) |
| 2592 |
|
| 2593 |
# Solaris -- Provides K40 |
| 2594 |
INCLUDE cjkgs-solaris.dat |
| 2595 |
|
| 2596 |
# HaranoAji -- Provides K45 |
| 2597 |
# (already included in JAPANESE section) |
| 2598 |
|
| 2599 |
# Baekmuk (free) |
| 2600 |
# This is a special case, because "batang.ttf" in baekmuk and |
| 2601 |
# "Batang.ttf" in Microsoft Mac Office font share the same filename; |
| 2602 |
# symlink name should be "Baekmuk-Batang.ttf" |
| 2603 |
# similar for "Gulim.ttf" -- HY (2016/09/29) |
| 2604 |
|
| 2605 |
Name: Baekmuk-Batang |
| 2606 |
Class: Korea |
| 2607 |
Provides(70): HYSMyeongJo-Medium |
| 2608 |
Doublecheck: true |
| 2609 |
TTFname(20): batang.ttf |
| 2610 |
TTFname(10): Baekmuk-Batang.ttf |
| 2611 |
|
| 2612 |
Name: Baekmuk-Dotum |
| 2613 |
Class: Korea |
| 2614 |
Provides(70): HYGoThic-Medium |
| 2615 |
TTFname(20): dotum.ttf |
| 2616 |
TTFname(10): Baekmuk-Dotum.ttf |
| 2617 |
|
| 2618 |
Name: Baekmuk-Gulim |
| 2619 |
Class: Korea |
| 2620 |
Provides(70): HYRGoThic-Medium |
| 2621 |
Doublecheck: true |
| 2622 |
TTFname(20): gulim.ttf |
| 2623 |
TTFname(10): Baekmuk-Gulim.ttf |
| 2624 |
|
| 2625 |
Name: Baekmuk-Headline |
| 2626 |
Class: Korea |
| 2627 |
TTFname(20): hline.ttf |
| 2628 |
TTFname(10): Baekmuk-Headline.ttf |
| 2629 |
|
| 2630 |
# Unfonts (free) -- Provides K60 |
| 2631 |
INCLUDE cjkgs-unfonts.dat |
| 2632 |
|
| 2633 |
# Nanum (free) |
| 2634 |
INCLUDE cjkgs-nanum.dat |
| 2635 |
|
| 2636 |
# Apple |
| 2637 |
INCLUDE cjkgs-apple.dat |
| 2638 |
|
| 2639 |
# Design font by Ho-Seok Ee, aka. "ALee's font" (free) |
| 2640 |
|
| 2641 |
Name: Bandal |
| 2642 |
Class: Korea |
| 2643 |
TTFname: Bandal.ttf |
| 2644 |
|
| 2645 |
Name: Bangwool |
| 2646 |
Class: Korea |
| 2647 |
TTFname: Bangwool.ttf |
| 2648 |
|
| 2649 |
Name: Eunjin |
| 2650 |
Class: Korea |
| 2651 |
TTFname: Eunjin.ttf |
| 2652 |
|
| 2653 |
Name: EunjinNakseo |
| 2654 |
Class: Korea |
| 2655 |
TTFname: EunjinNakseo.ttf |
| 2656 |
|
| 2657 |
Name: Guseul |
| 2658 |
Class: Korea |
| 2659 |
TTFname: Guseul.ttf |
| 2660 |
|
| 2661 |
# Woowa Brothers (free) |
| 2662 |
|
| 2663 |
Name: BMHANNA |
| 2664 |
Class: Korea |
| 2665 |
TTFname: BM-HANNA.ttf |
| 2666 |
|
| 2667 |
# Hancom HCR (free) |
| 2668 |
INCLUDE cjkgs-hancom.dat |
| 2669 |
|
| 2670 |
|
| 2671 |
# |
| 2672 |
# Microsoft Windows, Windows/Mac Office fonts |
| 2673 |
# |
| 2674 |
|
| 2675 |
# korea |
| 2676 |
|
| 2677 |
Name: Batang |
| 2678 |
Class: Korea |
| 2679 |
Doublecheck: true |
| 2680 |
TTFname(50): Batang.ttf |
| 2681 |
TTCname(20): batang.ttc(0) |
| 2682 |
|
| 2683 |
Name: BatangChe |
| 2684 |
Class: Korea |
| 2685 |
Provides(50): HYSMyeongJo-Medium |
| 2686 |
TTCname(20): batang.ttc(1) |
| 2687 |
|
| 2688 |
Name: Dotum |
| 2689 |
Class: Korea |
| 2690 |
TTCname(20): gulim.ttc(2) |
| 2691 |
|
| 2692 |
Name: DotumChe |
| 2693 |
Class: Korea |
| 2694 |
Provides(50): HYGoThic-Medium |
| 2695 |
TTCname(20): gulim.ttc(3) |
| 2696 |
|
| 2697 |
Name: Gulim |
| 2698 |
Class: Korea |
| 2699 |
Doublecheck: true |
| 2700 |
TTFname(50): Gulim.ttf |
| 2701 |
TTCname(20): gulim.ttc(0) |
| 2702 |
|
| 2703 |
Name: GulimChe |
| 2704 |
Class: Korea |
| 2705 |
Provides(50): HYRGoThic-Medium |
| 2706 |
Provides(90): HYGoThic-Medium |
| 2707 |
TTCname(20): gulim.ttc(1) |
| 2708 |
|
| 2709 |
Name: Gungsuh |
| 2710 |
Class: Korea |
| 2711 |
TTCname(20): batang.ttc(2) |
| 2712 |
|
| 2713 |
Name: GungsuhChe |
| 2714 |
Class: Korea |
| 2715 |
TTCname(20): batang.ttc(3) |
| 2716 |
|
| 2717 |
# for Windows 10 |
| 2718 |
# and Office for Mac 2016 (at least Ver.16.11.0, 2018-03) |
| 2719 |
Name: MalgunGothic |
| 2720 |
Class: Korea |
| 2721 |
Doublecheck: true |
| 2722 |
TTFname: malgun.ttf |
| 2723 |
|
| 2724 |
# for Windows 7 |
| 2725 |
# and Office for Mac 2016 (Ver.15.32.0, 2017-03) |
| 2726 |
Name: MalgunGothicRegular |
| 2727 |
Class: Korea |
| 2728 |
Doublecheck: true |
| 2729 |
TTFname: malgun.ttf |
| 2730 |
|
| 2731 |
Name: MalgunGothicBold |
| 2732 |
Class: Korea |
| 2733 |
TTFname: malgunbd.ttf |
| 2734 |
|
| 2735 |
Name: MalgunGothic-Semilight |
| 2736 |
Class: Korea |
| 2737 |
TTFname: malgunsl.ttf |
| 2738 |
|
| 2739 |
# simplified chinese |
| 2740 |
|
| 2741 |
Name: SimHei |
| 2742 |
Class: GB |
| 2743 |
Provides(60): STHeiti-Regular |
| 2744 |
Provides(60): STHeiti-Light |
| 2745 |
TTFname(50): SimHei.ttf |
| 2746 |
TTFname(20): simhei.ttf |
| 2747 |
|
| 2748 |
Name: SimSun |
| 2749 |
Class: GB |
| 2750 |
Provides(60): STSong-Light |
| 2751 |
Provides(60): STSong-Regular |
| 2752 |
TTFname(50): SimSun.ttf |
| 2753 |
TTFname(21): simsun.ttf |
| 2754 |
TTCname(20): simsun.ttc(0) |
| 2755 |
|
| 2756 |
Name: NSimSun |
| 2757 |
Class: GB |
| 2758 |
TTCname(20): simsun.ttc(1) |
| 2759 |
|
| 2760 |
Name: KaiTi |
| 2761 |
Class: GB |
| 2762 |
Provides(60): STKaiti-Regular |
| 2763 |
TTFname(40): Kaiti.ttf |
| 2764 |
TTFname(20): simkai.ttf |
| 2765 |
|
| 2766 |
Name: FangSong |
| 2767 |
Class: GB |
| 2768 |
Provides(60): STFangsong-Light |
| 2769 |
Provides(60): STFangsong-Regular |
| 2770 |
TTFname(40): Fangsong.ttf |
| 2771 |
TTFname(20): simfang.ttf |
| 2772 |
|
| 2773 |
Name: LiSu |
| 2774 |
Class: GB |
| 2775 |
TTCname(20): SIMLI.TTF |
| 2776 |
TTCname(19): simli.ttf |
| 2777 |
|
| 2778 |
Name: YouYuan |
| 2779 |
Class: GB |
| 2780 |
TTCname(20): SIMYOU.TTF |
| 2781 |
TTCname(19): simyou.ttf |
| 2782 |
|
| 2783 |
Name: MicrosoftYaHei |
| 2784 |
Class: GB |
| 2785 |
TTFname(20): msyh.ttf |
| 2786 |
TTCname(30): msyh.ttc(0) |
| 2787 |
|
| 2788 |
Name: MicrosoftYaHei-Bold |
| 2789 |
Class: GB |
| 2790 |
TTFname(20): msyhbd.ttf |
| 2791 |
TTCname(30): msyhbd.ttc(0) |
| 2792 |
|
| 2793 |
Name: MicrosoftYaHeiLight |
| 2794 |
Class: GB |
| 2795 |
TTFname(20): msyhl.ttf |
| 2796 |
TTCname(30): msyhl.ttc(0) |
| 2797 |
|
| 2798 |
Name: DengXian-Regular |
| 2799 |
Class: GB |
| 2800 |
TTFname: Deng.ttf |
| 2801 |
|
| 2802 |
Name: DengXian-Bold |
| 2803 |
Class: GB |
| 2804 |
TTFname: Dengb.ttf |
| 2805 |
|
| 2806 |
Name: DengXian-Light |
| 2807 |
Class: GB |
| 2808 |
TTFname: Dengl.ttf |
| 2809 |
|
| 2810 |
# traditional chinese |
| 2811 |
|
| 2812 |
Name: MingLiU |
| 2813 |
Class: CNS |
| 2814 |
Provides(60): MSung-Medium |
| 2815 |
Provides(60): MSung-Light |
| 2816 |
TTFname(50): MingLiU.ttf |
| 2817 |
TTCname(20): mingliu.ttc(0) |
| 2818 |
|
| 2819 |
Name: PMingLiU |
| 2820 |
Class: CNS |
| 2821 |
TTFname(50): PMingLiU.ttf |
| 2822 |
TTCname(20): mingliu.ttc(1) |
| 2823 |
|
| 2824 |
Name: DFKaiShu-SB-Estd-BF |
| 2825 |
Class: CNS |
| 2826 |
Provides(60): MKai-Medium |
| 2827 |
TTFname(50): BiauKai.ttf |
| 2828 |
TTFname(20): kaiu.ttf |
| 2829 |
|
| 2830 |
Name: MicrosoftJhengHeiRegular |
| 2831 |
Class: CNS |
| 2832 |
Provides(60): MHei-Medium |
| 2833 |
TTFname(40): MSJH.ttf |
| 2834 |
TTFname(20): msjh.ttf |
| 2835 |
TTCname(30): msjh.ttc(0) |
| 2836 |
|
| 2837 |
Name: MicrosoftJhengHeiBold |
| 2838 |
Class: CNS |
| 2839 |
TTFname(40): MSJHBD.ttf |
| 2840 |
TTFname(20): msjhbd.ttf |
| 2841 |
TTCname(30): msjhbd.ttc(0) |
| 2842 |
|
| 2843 |
Name: MicrosoftJhengHeiLight |
| 2844 |
Class: CNS |
| 2845 |
TTCname(30): msjhl.ttc(0) |
| 2846 |
|
| 2847 |
Name: MicrosoftMHei |
| 2848 |
Class: CNS |
| 2849 |
Provides(65): MHei-Medium |
| 2850 |
TTFname(10): MSMHei.ttf |
| 2851 |
|
| 2852 |
Name: MicrosoftMHei-Bold |
| 2853 |
Class: CNS |
| 2854 |
TTFname(10): MSMHei-Bold.ttf |
| 2855 |
|
| 2856 |
# Remove-only database (should begin with !INCLUDE) |
| 2857 |
# that is, entries which contain at least one 'RMVname' line |
| 2858 |
# note that this line should come at the _end_ of all INCLUDE files |
| 2859 |
!INCLUDE cjkgs-removeonly.dat |
| 2860 |
!INCLUDE cjkgs-macos-removeonly.dat |
| 2861 |
|
| 2862 |
|
| 2863 |
### Local Variables: |
| 2864 |
### perl-indent-level: 2 |
| 2865 |
### tab-width: 2 |
| 2866 |
### indent-tabs-mode: nil |
| 2867 |
### End: |
| 2868 |
# vim: set tabstop=2 expandtab autoindent: |