Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. #include "fitz.h"
  2. #include "mupdf.h"
  3.  
  4. #include "data_encodings.h"
  5. #include "data_glyphlist.h"
  6.  
  7. void
  8. pdf_load_encoding(char **estrings, char *encoding)
  9. {
  10.         char **bstrings = NULL;
  11.         int i;
  12.  
  13.         if (!strcmp(encoding, "StandardEncoding"))
  14.                 bstrings = (char**) pdf_standard;
  15.         if (!strcmp(encoding, "MacRomanEncoding"))
  16.                 bstrings = (char**) pdf_mac_roman;
  17.         if (!strcmp(encoding, "MacExpertEncoding"))
  18.                 bstrings = (char**) pdf_mac_expert;
  19.         if (!strcmp(encoding, "WinAnsiEncoding"))
  20.                 bstrings = (char**) pdf_win_ansi;
  21.  
  22.         if (bstrings)
  23.                 for (i = 0; i < 256; i++)
  24.                         estrings[i] = bstrings[i];
  25. }
  26.  
  27. int
  28. pdf_lookup_agl(char *name)
  29. {
  30.         char buf[64];
  31.         char *p;
  32.         int l = 0;
  33.         int r = nelem(agl_name_list) - 1;
  34.  
  35.         fz_strlcpy(buf, name, sizeof buf);
  36.  
  37.         /* kill anything after first period and underscore */
  38.         p = strchr(buf, '.');
  39.         if (p) p[0] = 0;
  40.         p = strchr(buf, '_');
  41.         if (p) p[0] = 0;
  42.  
  43.         while (l <= r)
  44.         {
  45.                 int m = (l + r) >> 1;
  46.                 int c = strcmp(buf, agl_name_list[m]);
  47.                 if (c < 0)
  48.                         r = m - 1;
  49.                 else if (c > 0)
  50.                         l = m + 1;
  51.                 else
  52.                         return agl_code_list[m];
  53.         }
  54.  
  55.         if (strstr(buf, "uni") == buf)
  56.                 return strtol(buf + 3, NULL, 16);
  57.         else if (strstr(buf, "u") == buf)
  58.                 return strtol(buf + 1, NULL, 16);
  59.         else if (strstr(buf, "a") == buf && strlen(buf) >= 3)
  60.                 return strtol(buf + 1, NULL, 10);
  61.  
  62.         return 0;
  63. }
  64.  
  65. static const char *empty_dup_list[] = { 0 };
  66.  
  67. const char **
  68. pdf_lookup_agl_duplicates(int ucs)
  69. {
  70.         int l = 0;
  71.         int r = nelem(agl_dup_offsets) / 2 - 1;
  72.         while (l <= r)
  73.         {
  74.                 int m = (l + r) >> 1;
  75.                 if (ucs < agl_dup_offsets[m << 1])
  76.                         r = m - 1;
  77.                 else if (ucs > agl_dup_offsets[m << 1])
  78.                         l = m + 1;
  79.                 else
  80.                         return agl_dup_names + agl_dup_offsets[(m << 1) + 1];
  81.         }
  82.         return empty_dup_list;
  83. }
  84.