Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 42161
Collapse All | Expand All

(-)xpdf.orig/CharCodeToUnicode.h (+4 lines)
Lines 67-72 Link Here
67
  // Map a CharCode to Unicode.
67
  // Map a CharCode to Unicode.
68
  int mapToUnicode(CharCode c, Unicode *u, int size);
68
  int mapToUnicode(CharCode c, Unicode *u, int size);
69
69
70
  // Return the mapping's length, i.e., one more than the max char
71
  // code supported by the mapping.
72
  CharCode getLength() { return mapLen; }
73
70
private:
74
private:
71
75
72
  void parseCMap1(int (*getCharFunc)(void *), void *data, int nBits);
76
  void parseCMap1(int (*getCharFunc)(void *), void *data, int nBits);
(-)xpdf.orig/SplashOutputDev.cc (-6 / +46 lines)
Lines 497-511 Link Here
497
  FILE *tmpFile;
497
  FILE *tmpFile;
498
  Gushort *codeToGID;
498
  Gushort *codeToGID;
499
  DisplayFontParam *dfp;
499
  DisplayFontParam *dfp;
500
  CharCodeToUnicode *ctu;
500
  double m11, m12, m21, m22, w1, w2;
501
  double m11, m12, m21, m22, w1, w2;
501
  SplashCoord mat[4];
502
  SplashCoord mat[4];
502
  char *name;
503
  char *name;
503
  int c, substIdx, n, code;
504
  Unicode uBuf[8];
505
  int c, substIdx, n, code, cmap;
504
506
505
  needFontUpdate = gFalse;
507
  needFontUpdate = gFalse;
506
  font = NULL;
508
  font = NULL;
507
  tmpFileName = NULL;
509
  tmpFileName = NULL;
508
  substIdx = -1;
510
  substIdx = -1;
511
  dfp = NULL;
509
512
510
  if (!(gfxFont = state->getFont())) {
513
  if (!(gfxFont = state->getFont())) {
511
    goto err1;
514
    goto err1;
Lines 544-550 Link Here
544
    } else if (!(fileName = gfxFont->getExtFontFile())) {
547
    } else if (!(fileName = gfxFont->getExtFontFile())) {
545
548
546
      // look for a display font mapping or a substitute font
549
      // look for a display font mapping or a substitute font
547
      dfp = NULL;
548
      if (gfxFont->isCIDFont()) {
550
      if (gfxFont->isCIDFont()) {
549
	if (((GfxCIDFont *)gfxFont)->getCollection()) {
551
	if (((GfxCIDFont *)gfxFont)->getCollection()) {
550
	  dfp = globalParams->
552
	  dfp = globalParams->
Lines 650-659 Link Here
650
      }
652
      }
651
      break;
653
      break;
652
    case fontCIDType2:
654
    case fontCIDType2:
653
      n = ((GfxCIDFont *)gfxFont)->getCIDToGIDLen();
655
      codeToGID = NULL;
654
      codeToGID = (Gushort *)gmalloc(n * sizeof(Gushort));
656
      n = 0;
655
      memcpy(codeToGID, ((GfxCIDFont *)gfxFont)->getCIDToGID(),
657
      if (dfp) {
656
	     n * sizeof(Gushort));
658
	// create a CID-to-GID mapping, via Unicode
659
	if ((ctu = ((GfxCIDFont *)gfxFont)->getToUnicode())) {
660
	  if ((ff = FoFiTrueType::load(fileName->getCString()))) {
661
	    // look for a Unicode cmap
662
	    for (cmap = 0; cmap < ff->getNumCmaps(); ++cmap) {
663
	      if ((ff->getCmapPlatform(cmap) == 3 &&
664
		   ff->getCmapEncoding(cmap) == 1) ||
665
		  ff->getCmapPlatform(cmap) == 0) {
666
		break;
667
	      }
668
	    }
669
	    if (cmap < ff->getNumCmaps()) {
670
	      // map CID -> Unicode -> GID
671
	      n = ctu->getLength();
672
	      codeToGID = (Gushort *)gmalloc(n * sizeof(Gushort));
673
	      for (code = 0; code < n; ++code) {
674
		if (ctu->mapToUnicode(code, uBuf, 8) > 0) {
675
		  codeToGID[code] = ff->mapCodeToGID(cmap, uBuf[0]);
676
		} else {
677
		  codeToGID[code] = 0;
678
		}
679
	      }
680
	    }
681
	    delete ff;
682
	  }
683
	  ctu->decRefCnt();
684
	} else {
685
	  error(-1, "Couldn't find a mapping to Unicode for font '%s'",
686
		gfxFont->getName() ? gfxFont->getName()->getCString()
687
		                   : "(unnamed)");
688
	}
689
      } else {
690
	if (((GfxCIDFont *)gfxFont)->getCIDToGID()) {
691
	  n = ((GfxCIDFont *)gfxFont)->getCIDToGIDLen();
692
	  codeToGID = (Gushort *)gmalloc(n * sizeof(Gushort));
693
	  memcpy(codeToGID, ((GfxCIDFont *)gfxFont)->getCIDToGID(),
694
		 n * sizeof(Gushort));
695
	}
696
      }
657
      if (!(fontFile = fontEngine->loadTrueTypeFont(
697
      if (!(fontFile = fontEngine->loadTrueTypeFont(
658
			   id,
698
			   id,
659
			   fileName->getCString(),
699
			   fileName->getCString(),
(-)xpdf.orig/XPDFApp.cc (+1 lines)
Lines 116-121 Link Here
116
#endif
116
#endif
117
117
118
XPDFApp::XPDFApp(int *argc, char *argv[]) {
118
XPDFApp::XPDFApp(int *argc, char *argv[]) {
119
  XtSetLanguageProc (NULL, NULL, NULL);
119
  appShell = XtAppInitialize(&appContext, xpdfAppName, xOpts, nXOpts,
120
  appShell = XtAppInitialize(&appContext, xpdfAppName, xOpts, nXOpts,
120
			     argc, argv, fallbackResources, NULL, 0);
121
			     argc, argv, fallbackResources, NULL, 0);
121
  display = XtDisplay(appShell);
122
  display = XtDisplay(appShell);
(-)xpdf.orig/XPDFCore.cc (-3 / +17 lines)
Lines 96-101 Link Here
96
GString *XPDFCore::currentSelection = NULL;
96
GString *XPDFCore::currentSelection = NULL;
97
XPDFCore *XPDFCore::currentSelectionOwner = NULL;
97
XPDFCore *XPDFCore::currentSelectionOwner = NULL;
98
Atom XPDFCore::targetsAtom;
98
Atom XPDFCore::targetsAtom;
99
Atom XPDFCore::CompoundTextAtom;
99
100
100
//------------------------------------------------------------------------
101
//------------------------------------------------------------------------
101
// XPDFCore
102
// XPDFCore
Lines 113-118 Link Here
113
  display = XtDisplay(parentWidget);
114
  display = XtDisplay(parentWidget);
114
  screenNum = XScreenNumberOfScreen(XtScreen(parentWidget));
115
  screenNum = XScreenNumberOfScreen(XtScreen(parentWidget));
115
  targetsAtom = XInternAtom(display, "TARGETS", False);
116
  targetsAtom = XInternAtom(display, "TARGETS", False);
117
  CompoundTextAtom = XInternAtom (display, "COMPOUND_TEXT", False);
116
118
117
  paperColor = paperColorA;
119
  paperColor = paperColorA;
118
  fullScreen = fullScreenA;
120
  fullScreen = fullScreenA;
Lines 962-971 Link Here
962
  // send back a list of supported conversion targets
964
  // send back a list of supported conversion targets
963
  if (*target == targetsAtom) {
965
  if (*target == targetsAtom) {
964
    if (!(array = (Atom *)XtMalloc(sizeof(Atom)))) {
966
    if (!(array = (Atom *)XtMalloc(sizeof(Atom)*2))) {
965
      return False;
967
      return False;
966
    }
968
    }
967
    array[0] = XA_STRING;
969
    array[0] = CompoundTextAtom;
970
       array[1] = XA_STRING;
968
    *value = (XtPointer)array;
971
    *value = (XtPointer)array;
969
    *type = XA_ATOM;
972
    *type = XA_ATOM;
970
    *format = 32;
973
    *format = 32;
Lines 973-980 Link Here
973
    return True;
976
    return True;
974
  // send the selected text
977
  // send the selected text
975
  } else if (*target == XA_STRING) {
978
  } else if (*target == CompoundTextAtom) {
976
    //~ for multithreading: need a mutex here
979
    //~ for multithreading: need a mutex here
980
       //from multi-byte to compound_text
981
    XTextProperty tpr;
982
    *value = currentSelection->getCString();
983
    XmbTextListToTextProperty (XtDisplay(widget), (char**)value, 1,
984
            XCompoundTextStyle, &tpr);
985
    *value = tpr.value;
986
       *length = tpr.nitems;
987
    *type = CompoundTextAtom;
988
    *format = 8; // 8-bit elements
989
    return True;
990
  } else if (*target == XA_STRING) {
977
    *value = XtNewString(currentSelection->getCString());
991
    *value = XtNewString(currentSelection->getCString());
978
    *length = currentSelection->getLength();
992
    *length = currentSelection->getLength();
979
    *type = XA_STRING;
993
    *type = XA_STRING;
(-)xpdf.orig/XPDFCore.h (+1 lines)
Lines 259-264 Link Here
259
  static GString *currentSelection;  // selected text
259
  static GString *currentSelection;  // selected text
260
  static XPDFCore *currentSelectionOwner;
260
  static XPDFCore *currentSelectionOwner;
261
  static Atom targetsAtom;
261
  static Atom targetsAtom;
262
  static Atom CompoundTextAtom;
262
263
263
  GBool panning;
264
  GBool panning;
264
  int panMX, panMY;
265
  int panMX, panMY;
(-)xpdf.orig/XPDFViewer.cc (-1 / +3 lines)
Lines 1612-1618 Link Here
1612
    items = core->getDoc()->getOutline()->getItems();
1612
    items = core->getDoc()->getOutline()->getItems();
1613
    if (items && items->getLength() > 0) {
1613
    if (items && items->getLength() > 0) {
1614
      enc = new GString("Latin1");
1614
      enc = new GString("Latin1");
1615
      uMap = globalParams->getUnicodeMap(enc);
1615
	if (!(uMap = globalParams->getTextEncoding())) {
1616
      uMap = globalParams->getUnicodeMap(enc);	  
1617
	}
1616
      delete enc;
1618
      delete enc;
1617
      setupOutlineItems(items, NULL, uMap);
1619
      setupOutlineItems(items, NULL, uMap);
1618
      uMap->decRefCnt();
1620
      uMap->decRefCnt();
(-)xpdf.orig/TextOutputDev.cc (-19 / +49 lines)
Lines 2618-2630 Link Here
2618
  TextBlock *blk;
2618
  TextBlock *blk;
2619
  TextLine *line;
2619
  TextLine *line;
2620
  Unicode *p;
2620
  Unicode *p;
2621
  Unicode u1, u2;
2621
  int m, i, j, k, n, l1, l2;
2622
  int m, i, j, k;
2623
  double xStart, yStart, xStop, yStop;
2622
  double xStart, yStart, xStop, yStop;
2624
  double xMin0, yMin0, xMax0, yMax0;
2623
  double xMin0, yMin0, xMax0, yMax0;
2625
  double xMin1, yMin1, xMax1, yMax1;
2624
  double xMin1, yMin1, xMax1, yMax1;
2626
  GBool found;
2625
  GBool found;
2627
2626
  UnicodeMap *uMap;
2627
  GString *enc, *str;
2628
  char buf[8], ptr[8];
2629
  char u1, u2;
2630
  int index[160], linelen=0;
2631
	
2632
  for (i=0; i < 160; i++) index[i] = 0;
2628
  //~ needs to handle right-to-left text
2633
  //~ needs to handle right-to-left text
2629
2634
2630
  if (rawOrder) {
2635
  if (rawOrder) {
Lines 2676-2693 Link Here
2676
	continue;
2681
	continue;
2677
      }
2682
      }
2678
2683
2679
      // search each position in this line
2684
    enc = new GString("Latin1");	
2680
      m = line->len;
2685
	if (!(uMap = globalParams->getTextEncoding())) {
2681
      for (j = 0, p = line->text; j <= m - len; ++j, ++p) {
2686
      uMap = globalParams->getUnicodeMap(enc);	  
2682
2687
	}
2688
	delete enc;
2689
	str = new GString("");
2690
	m = line->len;
2691
	linelen = m;
2692
	index[0] = 0;
2693
	for (j = 0, p = line->text; j < m; ++j) {
2694
	  n = uMap->mapUnicode(p[j], buf, sizeof(buf));
2695
	  index[j+1] = index[j] + n;
2696
	  str->append(buf,n);
2697
	}
2698
	m = str->getLength();
2699
	for (j = 0; j <= m - len; ++j) {
2683
	// compare the strings
2700
	// compare the strings
2684
	for (k = 0; k < len; ++k) {
2701
	for (k = 0; k < len; ++k) {
2685
#if 1 //~ this lowercases Latin A-Z only -- this will eventually be
2702
#if 1 //~ this lowercases Latin A-Z only -- this will eventually be
2686
      //~ extended to handle other character sets
2703
      //~ extended to handle other character sets
2687
	  if (p[k] >= 0x41 && p[k] <= 0x5a) {
2704
	ptr[0] = 0;
2688
	    u1 = p[k] + 0x20;
2705
	ptr[0] = str->getChar(j+k) & 0xff;
2706
	  if (ptr[0] >= 0x41 && ptr[0] <= 0x5a) {
2707
	    u1 = ptr[0] + 0x20;
2689
	  } else {
2708
	  } else {
2690
	    u1 = p[k];
2709
	    u1 = ptr[0];
2691
	  }
2710
	  }
2692
	  if (s[k] >= 0x41 && s[k] <= 0x5a) {
2711
	  if (s[k] >= 0x41 && s[k] <= 0x5a) {
2693
	    u2 = s[k] + 0x20;
2712
	    u2 = s[k] + 0x20;
Lines 2699-2731 Link Here
2699
	    break;
2718
	    break;
2700
	  }
2719
	  }
2701
	}
2720
	}
2702
2703
	// found it
2721
	// found it
2704
	if (k == len) {
2722
	if (k == len) {
2723
	l1 = l2 = 0;
2724
	for ( n = 1; n <= linelen; n++) {
2725
		if ( (index[n] >= j-1) && (index[n-1] <= j-1)) { 
2726
		l1 = n;
2727
		}
2728
		if ( (index[n] >= j+len-1) && (index[n-1] <= j+len-1)) { 
2729
		l2 = n;
2730
		}
2731
		
2732
	}
2733
	len = l2 - l1;
2705
	  switch (line->rot) {
2734
	  switch (line->rot) {
2706
	  case 0:
2735
	  case 0:
2707
	    xMin1 = line->edge[j];
2736
	    xMin1 = line->edge[l1];
2708
	    xMax1 = line->edge[j + len];
2737
	    xMax1 = line->edge[l1 + len];
2709
	    yMin1 = line->yMin;
2738
	    yMin1 = line->yMin;
2710
	    yMax1 = line->yMax;
2739
	    yMax1 = line->yMax;
2711
	    break;
2740
	    break;
2712
	  case 1:
2741
	  case 1:
2713
	    xMin1 = line->xMin;
2742
	    xMin1 = line->xMin;
2714
	    xMax1 = line->xMax;
2743
	    xMax1 = line->xMax;
2715
	    yMin1 = line->edge[j];
2744
	    yMin1 = line->edge[l1];
2716
	    yMax1 = line->edge[j + len];
2745
	    yMax1 = line->edge[l1 + len];
2717
	    break;
2746
	    break;
2718
	  case 2:
2747
	  case 2:
2719
	    xMin1 = line->edge[j + len];
2748
	    xMin1 = line->edge[l1 + len];
2720
	    xMax1 = line->edge[j];
2749
	    xMax1 = line->edge[l1];
2721
	    yMin1 = line->yMin;
2750
	    yMin1 = line->yMin;
2722
	    yMax1 = line->yMax;
2751
	    yMax1 = line->yMax;
2723
	    break;
2752
	    break;
2724
	  case 3:
2753
	  case 3:
2725
	    xMin1 = line->xMin;
2754
	    xMin1 = line->xMin;
2726
	    xMax1 = line->xMax;
2755
	    xMax1 = line->xMax;
2727
	    yMin1 = line->edge[j + len];
2756
	    yMin1 = line->edge[l1 + len];
2728
	    yMax1 = line->edge[j];
2757
	    yMax1 = line->edge[l1];
2729
	    break;
2758
	    break;
2730
	  }
2759
	  }
2731
	  if ((startAtTop ||
2760
	  if ((startAtTop ||
Lines 2742-2747 Link Here
2742
	  }
2771
	  }
2743
	}
2772
	}
2744
      }
2773
      }
2774
	delete str;
2745
    }
2775
    }
2746
  }
2776
  }

Return to bug 42161