[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/libraries/tcpdf/fonts/ttf2ufm/ttf2ufm-src/scripts/ -> forceiso (source)

   1  #!/usr/bin/perl
   2  # 
   3  #  Copyright (c) 1998
   4  #   Sergey A. Babkin.  All rights reserved.
   5  # 
   6  #  Redistribution and use in source and binary forms, with or without
   7  #  modification, are permitted provided that the following conditions
   8  #  are met:
   9  #  1. Redistributions of source code must retain the above copyright
  10  #     notice, this list of conditions and the following disclaimer.
  11  #  2. Redistributions in binary form must reproduce the above copyright
  12  #     notice, this list of conditions and the following disclaimer in the
  13  #     documentation and/or other materials provided with the distribution.
  14  # 
  15  #  THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
  16  #  WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  17  #  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  18  # 
  19  #  Sergey A. Babkin ([email protected], [email protected])
  20  # 
  21  
  22  #
  23  # Force the font to use the encoding as close to ISO Latin-1 as possible
  24  #
  25  # Use:
  26  #   forceiso [format] <file1.t1a >file2.t1a
  27  # where format is a printf-type format used to select names for the
  28  # glyphs without standard Latin-1 names. It must expect one argument,
  29  # the character code. The default format is "_%d".
  30  
  31  %latin1=(
  32     0, "",
  33     1, "",
  34     2, "",
  35     3, "",
  36     4, "",
  37     5, "",
  38     6, "",
  39     7, "",
  40     8, "",
  41     9, "",
  42    10, "",
  43    11, "",
  44    12, "",
  45    13, "",
  46    14, "",
  47    15, "",
  48    16, "",
  49    17, "",
  50    18, "",
  51    19, "",
  52    20, "",
  53    21, "",
  54    22, "",
  55    23, "",
  56    24, "",
  57    25, "",
  58    26, "",
  59    27, "",
  60    28, "",
  61    29, "",
  62    30, "",
  63    31, "",
  64    32, "space",
  65    33, "exclam",
  66    34, "quotedbl",
  67    35, "numbersign",
  68    36, "dollar",
  69    37, "percent",
  70    38, "ampersand",
  71    39, "quoteright",
  72    40, "parenleft",
  73    41, "parenright",
  74    42, "asterisk",
  75    43, "plus",
  76    44, "comma",
  77    45, "hyphen",
  78    46, "period",
  79    47, "slash",
  80    48, "zero",
  81    49, "one",
  82    50, "two",
  83    51, "three",
  84    52, "four",
  85    53, "five",
  86    54, "six",
  87    55, "seven",
  88    56, "eight",
  89    57, "nine",
  90    58, "colon",
  91    59, "semicolon",
  92    60, "less",
  93    61, "equal",
  94    62, "greater",
  95    63, "question",
  96    64, "at",
  97    65, "A",
  98    66, "B",
  99    67, "C",
 100    68, "D",
 101    69, "E",
 102    70, "F",
 103    71, "G",
 104    72, "H",
 105    73, "I",
 106    74, "J",
 107    75, "K",
 108    76, "L",
 109    77, "M",
 110    78, "N",
 111    79, "O",
 112    80, "P",
 113    81, "Q",
 114    82, "R",
 115    83, "S",
 116    84, "T",
 117    85, "U",
 118    86, "V",
 119    87, "W",
 120    88, "X",
 121    89, "Y",
 122    90, "Z",
 123    91, "bracketleft",
 124    92, "backslash",
 125    93, "bracketright",
 126    94, "asciicircum",
 127    95, "underscore",
 128    96, "grave",
 129    97, "a",
 130    98, "b",
 131    99, "c",
 132   100, "d",
 133   101, "e",
 134   102, "f",
 135   103, "g",
 136   104, "h",
 137   105, "i",
 138   106, "j",
 139   107, "k",
 140   108, "l",
 141   109, "m",
 142   110, "n",
 143   111, "o",
 144   112, "p",
 145   113, "q",
 146   114, "r",
 147   115, "s",
 148   116, "t",
 149   117, "u",
 150   118, "v",
 151   119, "w",
 152   120, "x",
 153   121, "y",
 154   122, "z",
 155   123, "braceleft",
 156   124, "bar",
 157   125, "braceright",
 158   126, "asciitilde",
 159   127, "",
 160   128, "",
 161   129, "",
 162   130, "",
 163   131, "",
 164   132, "",
 165   133, "",
 166   134, "",
 167   135, "",
 168   136, "",
 169   137, "",
 170   138, "",
 171   139, "",
 172   140, "",
 173   141, "",
 174   142, "",
 175   143, "",
 176   144, "",
 177   145, "",
 178   146, "",
 179   147, "",
 180   148, "",
 181   149, "",
 182   150, "",
 183   151, "",
 184   152, "",
 185   153, "",
 186   154, "",
 187   155, "",
 188   156, "",
 189   157, "",
 190   158, "",
 191   159, "",
 192   160, "",
 193   161, "exclamdown",
 194   162, "cent",
 195   163, "sterling",
 196   164, "currency",
 197   165, "yen",
 198   166, "brokenbar",
 199   167, "section",
 200   168, "dieresis",
 201   169, "copyright",
 202   170, "ordfeminine",
 203   171, "guillemotleft",
 204   172, "logicalnot",
 205   173, "minus",
 206   174, "registered",
 207   175, "macron",
 208   176, "degree",
 209   177, "plusminus",
 210   178, "twosuperior",
 211   179, "threesuperior",
 212   180, "acute",
 213   181, "mu",
 214   182, "paragraph",
 215   183, "periodcentered",
 216   184, "cedilla",
 217   185, "onesuperior",
 218   186, "ordmasculine",
 219   187, "guillemotright",
 220   188, "onequarter",
 221   189, "onehalf",
 222   190, "threequarters",
 223   191, "questiondown",
 224   192, "Agrave",
 225   193, "Aacute",
 226   194, "Acircumflex",
 227   195, "Atilde",
 228   196, "Adieresis",
 229   197, "Aring",
 230   198, "AE",
 231   199, "Ccedilla",
 232   200, "Egrave",
 233   201, "Eacute",
 234   202, "Ecircumflex",
 235   203, "Edieresis",
 236   204, "Igrave",
 237   205, "Iacute",
 238   206, "Icircumflex",
 239   207, "Idieresis",
 240   208, "Eth",
 241   209, "Ntilde",
 242   210, "Ograve",
 243   211, "Oacute",
 244   212, "Ocircumflex",
 245   213, "Otilde",
 246   214, "Odieresis",
 247   215, "multiply",
 248   216, "Oslash",
 249   217, "Ugrave",
 250   218, "Uacute",
 251   219, "Ucircumflex",
 252   220, "Udieresis",
 253   221, "Yacute",
 254   222, "Thorn",
 255   223, "germandbls",
 256   224, "agrave",
 257   225, "aacute",
 258   226, "acircumflex",
 259   227, "atilde",
 260   228, "adieresis",
 261   229, "aring",
 262   230, "ae",
 263   231, "ccedilla",
 264   232, "egrave",
 265   233, "eacute",
 266   234, "ecircumflex",
 267   235, "edieresis",
 268   236, "igrave",
 269   237, "iacute",
 270   238, "icircumflex",
 271   239, "idieresis",
 272   240, "eth",
 273   241, "ntilde",
 274   242, "ograve",
 275   243, "oacute",
 276   244, "ocircumflex",
 277   245, "otilde",
 278   246, "odieresis",
 279   247, "divide",
 280   248, "oslash",
 281   249, "ugrave",
 282   250, "uacute",
 283   251, "ucircumflex",
 284   252, "udieresis",
 285   253, "yacute",
 286   254, "thorn",
 287   255, "ydieresis"
 288  );
 289  
 290  # how to treat the unknown characters
 291  $unk = "_%d";
 292  
 293  if($#ARGV >= 0) {
 294      $unk = $ARGV[0];
 295  }
 296  
 297  # fill in the unnamed characters
 298  if( sprintf($unk, 0) eq sprintf($unk, 1) ) {
 299      die "The format for unnamed characters must not be a constant"
 300  }
 301  for($i=0; $i < 256; $i++) {
 302      if($latin1{$i} eq "") {
 303          $latin1{$i} = sprintf($unk, $i);
 304      }
 305  }
 306  
 307  while(<STDIN>) {
 308      print $_;
 309      if(/^\/Encoding\s+.*\s+array/) {
 310          $fontfile=1;
 311          last;
 312      }
 313      if(/^StartCharMetrics\s+/) {
 314          $fontfile=0;
 315          last;
 316      }
 317  }
 318  
 319  $ndups=0;
 320  
 321  if($fontfile) { # .t1a file 
 322      while(<STDIN>) {
 323          if($_ !~ /^dup\s+(\d+)\s+\/(\S+)\s+put/) {
 324              print $_;
 325              last;
 326          }
 327          $code=$1+0;
 328          $name=$2;
 329          if($name eq ".notdef") {
 330              print $_;
 331          } else {
 332              printf("dup %d /%s put\n",$code,$latin1{$code});
 333              if($trans{$name}) { # two or more references to the same glyph
 334                  $ndups++;
 335                  #printf(STDERR "forceiso: %d dups\n", $ndups);
 336                  if($copies{$name} eq "") {
 337                      $copies{$name} = $latin1{$code};
 338                  } else {
 339                      $copies{$name} .= "|" . $latin1{$code};
 340                  }
 341              } else {
 342                  $trans{$name}=$latin1{$code};
 343              }
 344          }
 345  
 346      }
 347  
 348      while(<STDIN>) {
 349          if( /\/CharStrings\s+(\d+)\s/) {
 350              $nchars=$1+$ndups;
 351              #printf(STDERR "forceiso: %d dups %d chars\n", $ndups, $nchars);
 352              $_ =~ s|/CharStrings\s+\d+\s|/CharStrings $nchars |;
 353              print $_;
 354              last;
 355          }
 356          print $_;
 357      }
 358  
 359      while(<STDIN>) {
 360          if(/^\/(\S+)/) {
 361              $name=$1;
 362              $to=$trans{$name};
 363  
 364              $header=$_;
 365              $body="";
 366  
 367              if($to ne "") {
 368                  $_ =~ s/^\/\S+/\/$to/;
 369              }
 370              print $_;
 371          } elsif(/endchar/) {
 372              print $_;
 373              if($copies{$name}) {
 374                  for $to (split(/\|/,$copies{$name})) {
 375                      $header =~ s/^\/\S+/\/$to/;
 376                      print($header, $body, $_);
 377                  }
 378              }
 379          } else {
 380              print $_;
 381              $body .= $_;
 382          }
 383      }
 384  } else { # .afm file 
 385      while(<STDIN>) {
 386          if($_ !~ /^C\s+(\d+)(\s*;.*N\s+)(\S+)(\s*;.*)\n/) {
 387              print $_;
 388              last;
 389          }
 390          $code=$1+0;
 391          $name=$3;
 392          $part2=$2;
 393          $part4=$4;
 394          if($name eq ".notdef") {
 395              print $_;
 396          } else {
 397              printf("C %d%s%s%s\n",$code,$part2,$latin1{$code},$part4);
 398              if($copies{$name} eq "") {
 399                  $copies{$name} = $latin1{$code};
 400              } else {
 401                  $copies{$name} .= "|" . $latin1{$code};
 402                  $ndups++;
 403                  #printf(STDERR "forceiso: %d dups\n", $ndups);
 404              }
 405          }
 406  
 407      }
 408  
 409      while(<STDIN>) {
 410          if(/^StartKernPairs\s+(\d+)/) {
 411              last;
 412          }
 413          print $_;
 414      }
 415  
 416      $npairs=0;
 417      $kps="";
 418      while(<STDIN>) {
 419          if(/^KPX\s+(\S+)\s+(\S+)\s+(.*)\n/) {
 420              $name1=$1;
 421              $name2=$2;
 422              $metric=$3;
 423  
 424              $cp1=$copies{$name1};
 425              if($cp1 eq "") {
 426                  $cp1=$name1;
 427              }
 428  
 429              $cp2=$copies{$name2};
 430              if($cp2 eq "") {
 431                  $cp2=$name2;
 432              }
 433  
 434              for $to1 (split(/\|/,$cp1)) {
 435                  for $to2 (split(/\|/,$cp2)) {
 436                      $kps .= sprintf("KPX %s %s %s\n", $to1, $to2, $metric);
 437                      $npairs++;
 438                  }
 439              }
 440          } else {
 441              if($npairs!=0) {
 442                  printf("StartKernPairs %d\n", $npairs);
 443                  printf("%s", $kps);
 444                  $npairs=0;
 445                  $kps="";
 446              }
 447              print $_;
 448          }
 449      }
 450  }


Generated: Fri Nov 28 20:08:37 2014 Cross-referenced by PHPXref 0.7.1