示例#1
0
static unsigned long Stream_ReadFunc(FT_Stream stream, unsigned long offset, unsigned char*  buffer, unsigned long count)
{
	InputStream *pSource;

	pSource = (InputStream *)stream->descriptor.pointer;
	pSource->Seek(offset, SEEK_SET);
	return pSource->Read(buffer, count);
}
示例#2
0
void
VFont::ReadPreamble (/*[in]*/ InputStream & inputStream)
{
  if (inputStream.ReadByte() != id_byte)
    {
      FATAL_DVI_ERROR ("VFont::ReadPreamble",
		       T_("Bad VF file."),
		       dviInfo.fileName.c_str());
    }

  unsigned long commentSize = inputStream.ReadByte();

  char tmp[256];
  inputStream.Read (tmp, commentSize);
  tmp[commentSize] = 0;
  dviInfo.comment = tmp;

  int my_checkSum = inputStream.ReadSignedQuad();
  int my_designSize = inputStream.ReadSignedQuad();

  trace_vfont->WriteFormattedLine
    ("libdvi",
     "comment: %s",
     dviInfo.comment.c_str());
  trace_vfont->WriteFormattedLine
    ("libdvi",
     "checkSum: 0%o",
     my_checkSum);
  trace_vfont->WriteFormattedLine
    ("libdvi",
     "designSize: %d",
     my_designSize);

  if (my_designSize * tfmConv != designSize)
    {
      trace_error->WriteFormattedLine
	("libdvi",
	 T_("%s: designSize mismatch"),
	 dviInfo.name.c_str());
    }

  if (my_checkSum != checkSum)
    {
      trace_error->WriteFormattedLine
	("libdvi",
	 T_("%s: checkSum mismatch"),
	 dviInfo.name.c_str());
    }
}
示例#3
0
cairo_surface_t *CairoRenderer::CreateImageSurface(const Stream *pStream, int nWidth, int nHeight)
{
	cairo_surface_t *pSurface;
	unsigned char *ptr, pixel[3];
	InputStream *pSource;
	int i;

	pSurface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, nWidth, nHeight);
	ptr = cairo_image_surface_get_data(pSurface);
	pSource = m_pPDF->CreateInputStream(pStream);
	for (i = nWidth * nHeight; i > 0; --i)
	{
		pSource->Read(pixel, 3);
		ptr[0] = pixel[2];
		ptr[1] = pixel[1];
		ptr[2] = pixel[0];
		ptr[3] = 0xFF;
		ptr += 4;
	}
	delete pSource;
	cairo_surface_mark_dirty(pSurface);

	return pSurface;
}
示例#4
0
void
VFont::ReadFontDef (/*[in]*/ InputStream &	inputStream,
		    /*[in]*/ short		fntDefX)
{
  int fontNum;

  switch (fntDefX)
    {
    case fnt_def1:
      fontNum = inputStream.ReadByte();
      break;
    case fnt_def2:
      fontNum = inputStream.ReadPair();
      break;
    case fnt_def3:
      fontNum = inputStream.ReadTrio();
      break;
    case fnt_def4:
      fontNum = inputStream.ReadSignedQuad();
      break;
    default:
      FATAL_DVI_ERROR ("VFont::ReadFontDef",
		       T_("Bad VF file."),
		       dviInfo.fileName.c_str());
      break;
    }

  trace_vfont->WriteFormattedLine
    ("libdvi",
     T_("defining font %d"),
     fontNum);

  int cs = inputStream.ReadSignedQuad();
  int ss = inputStream.ReadSignedQuad();
  int ds = inputStream.ReadSignedQuad();

  int areaNameSize = inputStream.ReadByte();
  int fontNameSize = inputStream.ReadByte();

  char szArea[256];
  inputStream.Read (szArea, areaNameSize);
  szArea[areaNameSize] = 0;

  char szName[256];
  inputStream.Read (szName, fontNameSize);
  szName[fontNameSize] = 0;

  trace_vfont->WriteFormattedLine
    ("libdvi",
     "areaname: %s",
     szArea);
  trace_vfont->WriteFormattedLine
    ("libdvi",
     "fontname: %s",
     szName);
  trace_vfont->WriteFormattedLine
    ("libdvi",
     "checkSum: 0%o",
     cs);
  trace_vfont->WriteFormattedLine
    ("libdvi",
     "scaledSize: %d",
     ss);
  trace_vfont->WriteFormattedLine
    ("libdvi",
     "designSize: %d",
     ds);
  
  DviFont * pFont;
  PathName fileName;
  if (SessionWrapper(true)->FindFile(szName, FileType::VF, fileName))
    {
      trace_vfont->WriteFormattedLine
	("libdvi",
	 T_("found vf file %s"),
	 Q_(fileName));
      pFont =
	new VFont (pDviImpl,
		   cs,
		   ScaleFix(ss, scaledAt),
		   static_cast<int>(ds * tfmConv),
		   szArea,
		   szName,
		   fileName.Get(),
		   tfmConv,
		   conv,
		   mag,
		   metafontMode.c_str(),
		   baseDpi);
    }
  else if (pDviImpl->GetPageMode() != DviPageMode::Dvips)
    {
      pFont =
	new PkFont (pDviImpl,
		    cs,
		    ScaleFix(ss, scaledAt),
		    static_cast<int>(ds * tfmConv),
		    szArea,
		    szName,
		    "",
		    tfmConv,
		    conv,
		    mag,
		    metafontMode.c_str(),
		    baseDpi);
    }
  else
    {
      pFont =
	new Tfm (pDviImpl,
		 cs,
		 ScaleFix(ss, scaledAt),
		 static_cast<int>(ds * tfmConv),
		 szArea,
		 szName,
		 "",
		 tfmConv,
		 conv);
    }

  fontMap[fontNum] = pFont;
}
示例#5
0
void
PkChar::Read (/*[in]*/ InputStream &	inputstream,
	      /*[in]*/ int		flag)
{
  this->flag = flag;

  if (IsShort())
    {
      // read character preamble (short form)
      packetSize = (((static_cast<int>(GetLower3()) % 4) << 8
		     | inputstream.ReadByte())
		    - 8);
      charCode = inputstream.ReadByte();
      tfm = inputstream.ReadTrio();
      cx = inputstream.ReadByte();
      rasterWidth = inputstream.ReadByte();
      rasterHeight = inputstream.ReadByte();
      cxOffset = inputstream.ReadSignedByte();
      cyOffset = inputstream.ReadSignedByte();
    }
  else if (IsExtendedShort())
    {
      // read character preamble (extended short form)
      packetSize = (((static_cast<int>(GetLower3()) % 4) << 16
		     | inputstream.ReadPair())
		    - 13);
      charCode = inputstream.ReadByte();
      tfm = inputstream.ReadTrio();
      cx = inputstream.ReadPair();
      rasterWidth = inputstream.ReadPair(); 
      rasterHeight = inputstream.ReadPair(); 
      cxOffset = inputstream.ReadSignedPair();
      cyOffset = inputstream.ReadSignedPair();
    }
  else
    {
      // read character preamble (long form)
      packetSize = inputstream.ReadSignedQuad() - 28;
      charCode = inputstream.ReadSignedQuad();
      tfm = inputstream.ReadSignedQuad();
      cx = inputstream.ReadSignedQuad();
      cx = (cx + 0x10000) >> 16;
      cy = inputstream.ReadSignedQuad();
      cy = (cy + 0x10000) >> 16;
      rasterWidth = inputstream.ReadSignedQuad();
      rasterHeight = inputstream.ReadSignedQuad();
      cxOffset = inputstream.ReadSignedQuad();
      cyOffset = inputstream.ReadSignedQuad();
    }

  tfm = ScaleFix(tfm, pDviFont->GetScaledAt());

  if (packetSize == 0)
    {
#if 0
      trace_error->WriteFormattedLine
	("libdvi",
	 T_("%d: no glyph!"),
	 charCode);
#endif
    }
  else
    {
      trace_pkchar->WriteFormattedLine
	("libdvi",
	 T_("going to read character %d"),
	 charCode);
      pPackedRaster = new BYTE[packetSize];
      inputstream.Read (pPackedRaster, packetSize);
    }
}
示例#6
0
	void PngReadFunction(png_structp structp, png_bytep bytep, png_size_t size)
	{
		InputStream *stream = (InputStream*)png_get_io_ptr(structp);
        stream->Read(bytep, size);
	}