~ubuntu-branches/ubuntu/dapper/poppler/dapper-security

« back to all changes in this revision

Viewing changes to poppler/SplashOutputDev.cc

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2006-03-06 18:42:44 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20060306184244-oomqyiqr7cgncp2c
Tags: 0.5.1-0ubuntu1
* New upstream version:
  - Support for embedded files.
  - Handle 0-width lines correctly.
  - Avoid external file use when opening fonts.
  - Only use vector fonts returned from fontconfig (#5758).
  - Fix scaled 1x1 pixmaps use for drawing lines (#3387).
  - drawSoftMaskedImage support in cairo backend.
  - Misc bug fixes: #5922, #5946, #5749, #5952, #4030, #5420.
* debian/control.in, debian/libpoppler0c2.dirs, 
  debian/libpoppler0c2-glib.dirs, debian/libpoppler0c2-glib.install,
  debian/libpoppler0c2.install, debian/libpoppler0c2-qt.dirs,
  debian/libpoppler0c2-qt.install, debian/rules:
  - updated for the soname change
* debian/patches/000_splash_build_fix.patch:
  - fix build when using splash
* debian/patches/001_fixes_for_fonts_selection.patch:
  - fix with the new version

Show diffs side-by-side

added added

removed removed

Lines of Context:
941
941
  GfxFontType fontType;
942
942
  SplashOutFontFileID *id;
943
943
  SplashFontFile *fontFile;
 
944
  SplashFontSrc *fontsrc;
944
945
  FoFiTrueType *ff;
945
946
  Ref embRef;
946
947
  Object refObj, strObj;
947
 
  GooString *tmpFileName, *fileName, *substName;
948
 
  FILE *tmpFile;
 
948
  GooString *fileName, *substName;
 
949
  char *tmpBuf;
 
950
  int tmpBufLen;
949
951
  Gushort *codeToGID;
950
952
  DisplayFontParam *dfp;
951
953
  CharCodeToUnicode *ctu;
954
956
  char *name;
955
957
  Unicode uBuf[8];
956
958
  int c, substIdx, n, code, cmap;
 
959
  int faceIndex = 0;
957
960
 
958
961
  needFontUpdate = gFalse;
959
962
  font = NULL;
960
 
  tmpFileName = NULL;
 
963
  fileName = NULL;
 
964
  tmpBuf = NULL;
961
965
  substIdx = -1;
962
966
  dfp = NULL;
963
967
 
978
982
 
979
983
    // if there is an embedded font, write it to disk
980
984
    if (gfxFont->getEmbeddedFontID(&embRef)) {
981
 
      if (!openTempFile(&tmpFileName, &tmpFile, "wb", NULL)) {
982
 
        error(-1, "Couldn't create temporary font file");
 
985
      tmpBuf = gfxFont->readEmbFontFile(xref, &tmpBufLen);
 
986
      if (! tmpBuf)
983
987
        goto err2;
984
 
      }
985
 
      refObj.initRef(embRef.num, embRef.gen);
986
 
      refObj.fetch(xref, &strObj);
987
 
      refObj.free();
988
 
      strObj.streamReset();
989
 
      while ((c = strObj.streamGetChar()) != EOF) {
990
 
        fputc(c, tmpFile);
991
 
      }
992
 
      strObj.streamClose();
993
 
      strObj.free();
994
 
      fclose(tmpFile);
995
 
      fileName = tmpFileName;
996
 
 
997
988
    // if there is an external font file, use it
998
989
    } else if (!(fileName = gfxFont->getExtFontFile())) {
999
990
 
1016
1007
      case displayFontTT:
1017
1008
        fileName = dfp->tt.fileName;
1018
1009
        fontType = gfxFont->isCIDFont() ? fontCIDType2 : fontTrueType;
 
1010
        faceIndex = dfp->tt.faceIndex;
1019
1011
        break;
1020
1012
      }
1021
1013
    }
1022
1014
 
 
1015
    fontsrc = new SplashFontSrc;
 
1016
    if (fileName)
 
1017
      fontsrc->setFile(fileName, gFalse);
 
1018
    else
 
1019
      fontsrc->setBuf(tmpBuf, tmpBufLen, gFalse);
 
1020
 
1023
1021
    // load the font file
1024
1022
    switch (fontType) {
1025
1023
    case fontType1:
1026
 
      if (!(fontFile = fontEngine->loadType1Font(
1027
 
                           id,
1028
 
                           fileName->getCString(),
1029
 
                           fileName == tmpFileName,
1030
 
                           ((Gfx8BitFont *)gfxFont)->getEncoding()))) {
 
1024
      fontFile = fontEngine->loadType1Font(id, fontsrc, 
 
1025
                                           ((Gfx8BitFont *)gfxFont)->getEncoding());
 
1026
      if (! fontFile) {
1031
1027
        error(-1, "Couldn't create a font for '%s'",
1032
1028
              gfxFont->getName() ? gfxFont->getName()->getCString()
1033
1029
                                 : "(unnamed)");
1035
1031
      }
1036
1032
      break;
1037
1033
    case fontType1C:
1038
 
      if (!(fontFile = fontEngine->loadType1CFont(
1039
 
                           id,
1040
 
                           fileName->getCString(),
1041
 
                           fileName == tmpFileName,
1042
 
                           ((Gfx8BitFont *)gfxFont)->getEncoding()))) {
 
1034
      fontFile = fontEngine->loadType1CFont(id, fontsrc,
 
1035
                                            ((Gfx8BitFont *)gfxFont)->getEncoding());
 
1036
      if (! fontFile) {
1043
1037
        error(-1, "Couldn't create a font for '%s'",
1044
1038
              gfxFont->getName() ? gfxFont->getName()->getCString()
1045
1039
                                 : "(unnamed)");
1047
1041
      }
1048
1042
      break;
1049
1043
    case fontTrueType:
1050
 
      if ((ff = FoFiTrueType::load(fileName->getCString()))) {
 
1044
        if (fileName)
 
1045
         ff = FoFiTrueType::load(fileName->getCString());
 
1046
        else
 
1047
         ff = new FoFiTrueType(tmpBuf, tmpBufLen, gFalse);
 
1048
        if (ff) {
1051
1049
      codeToGID = ((Gfx8BitFont *)gfxFont)->getCodeToGIDMap(ff);
1052
1050
        n = 256;
1053
1051
      delete ff;
1057
1055
      }
1058
1056
      if (!(fontFile = fontEngine->loadTrueTypeFont(
1059
1057
                           id,
1060
 
                           fileName->getCString(),
1061
 
                           fileName == tmpFileName,
 
1058
                           fontsrc,
1062
1059
                           codeToGID, n))) {
1063
1060
        error(-1, "Couldn't create a font for '%s'",
1064
1061
              gfxFont->getName() ? gfxFont->getName()->getCString()
1068
1065
      break;
1069
1066
    case fontCIDType0:
1070
1067
    case fontCIDType0C:
1071
 
      if (!(fontFile = fontEngine->loadCIDFont(
1072
 
                           id,
1073
 
                           fileName->getCString(),
1074
 
                           fileName == tmpFileName))) {
 
1068
      fontFile = fontEngine->loadCIDFont(id, fontsrc);
 
1069
      if (! fontFile) {
1075
1070
        error(-1, "Couldn't create a font for '%s'",
1076
1071
              gfxFont->getName() ? gfxFont->getName()->getCString()
1077
1072
                                 : "(unnamed)");
1084
1079
      if (dfp) {
1085
1080
        // create a CID-to-GID mapping, via Unicode
1086
1081
        if ((ctu = ((GfxCIDFont *)gfxFont)->getToUnicode())) {
1087
 
          if ((ff = FoFiTrueType::load(fileName->getCString()))) {
 
1082
                if (fileName)
 
1083
                 ff = FoFiTrueType::load(fileName->getCString());
 
1084
                else
 
1085
                 ff = new FoFiTrueType(tmpBuf, tmpBufLen, gFalse);
 
1086
                if (ff) {
1088
1087
            // look for a Unicode cmap
1089
1088
            for (cmap = 0; cmap < ff->getNumCmaps(); ++cmap) {
1090
1089
              if ((ff->getCmapPlatform(cmap) == 3 &&
1116
1115
      } else {
1117
1116
        if (((GfxCIDFont *)gfxFont)->getCIDToGID()) {
1118
1117
      n = ((GfxCIDFont *)gfxFont)->getCIDToGIDLen();
1119
 
          codeToGID = (Gushort *)gmallocn(n, sizeof(Gushort));
1120
 
      memcpy(codeToGID, ((GfxCIDFont *)gfxFont)->getCIDToGID(),
1121
 
             n * sizeof(Gushort));
 
1118
        if (n) {
 
1119
                codeToGID = (Gushort *)gmallocn(n, sizeof(Gushort));
 
1120
                memcpy(codeToGID, ((GfxCIDFont *)gfxFont)->getCIDToGID(),
 
1121
                        n * sizeof(Gushort));
 
1122
        } else {
 
1123
                if (fileName)
 
1124
                 ff = FoFiTrueType::load(fileName->getCString());
 
1125
                else
 
1126
                 ff = new FoFiTrueType(tmpBuf, tmpBufLen, gFalse);
 
1127
                if (! ff)
 
1128
                 goto err2;
 
1129
                codeToGID = ((GfxCIDFont *)gfxFont)->getCodeToGIDMap(ff, &n);
 
1130
                delete ff;
 
1131
        }
1122
1132
        }
1123
1133
      }
1124
1134
      if (!(fontFile = fontEngine->loadTrueTypeFont(
1125
1135
                           id,
1126
 
                           fileName->getCString(),
1127
 
                           fileName == tmpFileName,
1128
 
                           codeToGID, n))) {
 
1136
                           fontsrc,
 
1137
                           codeToGID,
 
1138
                           n,
 
1139
                           faceIndex))) {
1129
1140
        error(-1, "Couldn't create a font for '%s'",
1130
1141
              gfxFont->getName() ? gfxFont->getName()->getCString()
1131
1142
                                 : "(unnamed)");
1153
1164
  }
1154
1165
  font = fontEngine->getFont(fontFile, mat);
1155
1166
 
1156
 
  if (tmpFileName) {
1157
 
    delete tmpFileName;
1158
 
  }
1159
1167
  return;
1160
1168
 
1161
1169
 err2:
1162
1170
  delete id;
1163
1171
 err1:
1164
 
  if (tmpFileName) {
1165
 
    delete tmpFileName;
1166
 
  }
1167
1172
  return;
1168
1173
}
1169
1174