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()); } }
void VFont::Read () { if (! characterTable.empty() || dviInfo.notLoadable) { return; } dviInfo.notLoadable = true; InputStream stream (dviInfo.fileName.c_str()); trace_vfont->WriteFormattedLine ("libdvi", T_("reading vf file %s"), Q_(dviInfo.fileName)); if (stream.ReadByte() != pre) { FATAL_DVI_ERROR ("VFont::Read", T_("Not a VF file."), dviInfo.fileName.c_str()); } ReadPreamble (stream); ReadFontDefsAndCharPackets (stream); ReadPostamble (stream); dviInfo.notLoadable = false; }
void VFont::ReadFontDefsAndCharPackets (/*[in]*/ InputStream & inputStream) { short tempByte; do { tempByte = inputStream.ReadByte(); if (tempByte != post) { if (tempByte > long_char) { ReadFontDef (inputStream, tempByte); } else { ReadCharPacket (inputStream, tempByte); } } } while (tempByte != post); }
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; }
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); } }