Esempio n. 1
0
        //--------------------------------------------------------------------//
        //                                              C o n s t r u c t o r //
        // P C L S y m b o l S e t                                            //
        //                                                                    //
        //--------------------------------------------------------------------//

        public PCLSymbolSet(PCLSymbolSets.eSymSetGroup group,
                            PCLSymSetTypes.eIndex indxType,
                            PCLTextParsingMethods.eIndex parsingMethod,
                            UInt16 kind1,
                            String alias,
                            String name,
                            Boolean mapped,
                            PCLSymSetMaps.eSymSetMapId mapId)
        {
            _group         = group;
            _indxType      = indxType;
            _parsingMethod = parsingMethod;
            _kind1         = kind1;
            _alias         = alias;
            _name          = name;

            if ((kind1 < 1)         // 1        = 0A    //
                ||
                (kind1 > 65530))    // 65530    = 2047Z //
            {
                _idNum   = 0;
                _idAlpha = 0x3f;    // ? //
            }
            else
            {
                _idNum   = (UInt16)(kind1 / 32);
                _idAlpha = (Byte)((kind1 - (_idNum * 32)) + 64);
            }

            _id = _idNum.ToString() + Convert.ToChar(_idAlpha);

            _mapped = mapped;
            _mapId  = mapId;
        }
Esempio n. 2
0
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // g e n e r a t e S y m S e t                                        //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Generate symbol set definition.                                    //
        //                                                                    //
        //--------------------------------------------------------------------//

        public Boolean generateSymSet(ref String symSetFilename,
                                      Boolean flagIgnoreC0,
                                      Boolean flagIgnoreC1,
                                      UInt16 symSetNo,
                                      UInt16 codeMin,
                                      UInt16 codeMax,
                                      UInt64 charCollReq,
                                      UInt16 [] symSetMap,
                                      PCLSymSetTypes.eIndex symSetType)
        {
            Boolean flagOK = true;

            //----------------------------------------------------------------//
            //                                                                //
            // Open print file and stream.                                    //
            //                                                                //
            //----------------------------------------------------------------//

            try
            {
                streamOpen(ref symSetFilename,
                           ref _binWriter,
                           ref _opStream);
            }

            catch (Exception exc)
            {
                flagOK = false;

                MessageBox.Show(exc.ToString(),
                                "Failure to open symbol set file",
                                MessageBoxButton.OK,
                                MessageBoxImage.Error);
            }

            if (flagOK)
            {
                //------------------------------------------------------------//
                //                                                            //
                // Generate symbol set file contents.                         //
                //                                                            //
                //------------------------------------------------------------//

                try
                {
                    //--------------------------------------------------------//
                    //                                                        //
                    // Write symbol set identifier sequence.                  //
                    //                                                        //
                    //--------------------------------------------------------//

                    PCLWriter.symSetDownloadCode(_binWriter,
                                                 (UInt16)symSetNo);

                    //--------------------------------------------------------//
                    //                                                        //
                    // Write symbol set descriptor header.                    //
                    //                                                        //
                    //--------------------------------------------------------//

                    writeHddr(symSetNo, codeMin, codeMax, charCollReq,
                              PCLSymSetTypes.getIdPCL((Int32)symSetType));

                    //--------------------------------------------------------//
                    //                                                        //
                    // Write symbol set map data.                             //
                    //                                                        //
                    //--------------------------------------------------------//

                    writeMapData(flagIgnoreC1, codeMin, codeMax, symSetMap);

                    //--------------------------------------------------------//
                    //                                                        //
                    // Write symbol set save sequence.                        //
                    //                                                        //
                    //--------------------------------------------------------//

                    PCLWriter.symSetDownloadSave(_binWriter, true);

                    //--------------------------------------------------------//
                    //                                                        //
                    // Close streams and files.                               //
                    //                                                        //
                    //--------------------------------------------------------//

                    _binWriter.Close();
                    _opStream.Close();
                }

                catch (Exception exc)
                {
                    flagOK = false;

                    MessageBox.Show(exc.ToString(),
                                    "Failure to write symbol set file",
                                    MessageBoxButton.OK,
                                    MessageBoxImage.Error);
                }
            }

            return(flagOK);
        }
Esempio n. 3
0
        //--------------------------------------------------------------------//
        //                                                        F i e l d s //
        // Class variables.                                                   //
        //                                                                    //
        //--------------------------------------------------------------------//

        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // g e n e r a t e                                                    //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Generate the report.                                               //
        //                                                                    //
        //--------------------------------------------------------------------//

        public static void generate(ReportCore.eRptFileFmt rptFileFmt,
                                    String symSetFilename,
                                    UInt16 symSetNo,
                                    UInt16 [] symSetMap,
                                    UInt16 codeMin,
                                    UInt16 codeMax,
                                    UInt16 codeCt,
                                    UInt64 charCollReq,
                                    Boolean flagIgnoreC0,
                                    Boolean flagIgnoreC1,
                                    Boolean flagMapHex,
                                    PCLSymSetTypes.eIndex symSetType)
        {
            Object stream = null;
            Object writer = null;

            Boolean OK = false;

            String fileExt;
            String saveFilename = null;

            if (rptFileFmt == ReportCore.eRptFileFmt.html)
            {
                fileExt = "html";
            }
            else if (rptFileFmt == ReportCore.eRptFileFmt.xml)
            {
                fileExt = "xml";
            }
            else
            {
                fileExt = "txt";
            }

            saveFilename = symSetFilename + "_report." + fileExt;

            OK = ReportCore.docOpen(rptFileFmt,
                                    ref saveFilename,
                                    ref stream,
                                    ref writer);

            if (OK)
            {
                ReportCore.docInitialise(rptFileFmt, writer, true, false,
                                         0, null,
                                         null, null);

                reportHddr(rptFileFmt, writer, symSetFilename);

                reportBodyMain(rptFileFmt, writer, symSetNo,
                               codeMin, codeMax, codeCt, charCollReq,
                               flagIgnoreC0, flagIgnoreC1, flagMapHex,
                               symSetType);

                reportBodyMap(rptFileFmt, writer, symSetMap,
                              codeMin, codeMax,
                              flagIgnoreC0, flagIgnoreC1, flagMapHex);

                ReportCore.docFinalise(rptFileFmt, writer);

                ReportCore.docClose(rptFileFmt, stream, writer);
            }
        }
Esempio n. 4
0
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // r e p o r t B o d y M a i n                                        //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Write report header.                                               //
        //                                                                    //
        //--------------------------------------------------------------------//

        private static void reportBodyMain(
            ReportCore.eRptFileFmt rptFileFmt,
            Object writer,
            //  String symSetFilename,
            UInt16 symSetNo,
            UInt16 codeMin,
            UInt16 codeMax,
            UInt16 codeCt,
            UInt64 charCollReq,
            Boolean flagIgnoreC0,
            Boolean flagIgnoreC1,
            Boolean flagMapHex,
            PCLSymSetTypes.eIndex symSetType)
        {
            const Int32 maxLineLen = 80;        // ***************** constant elsewhere ???????????????

            //----------------------------------------------------------------//
            //                                                                //
            // Write out the title.                                           //
            //                                                                //
            //----------------------------------------------------------------//

            ReportCore.hddrTitle(writer, rptFileFmt, true,
                                 "Symbol set details:");

            //----------------------------------------------------------------//
            //                                                                //
            // Write out the symbol set basic details.                        //
            //                                                                //
            //----------------------------------------------------------------//

            ReportCore.tableHddrPair(writer, rptFileFmt);

            ReportCore.tableRowPair(writer, rptFileFmt,
                                    "SymSetNo", symSetNo.ToString(),
                                    _colSpanNone, _colSpanNone,
                                    _maxSizeNameTag, maxLineLen,
                                    _flagNone, _flagNone, _flagNone);

            ReportCore.tableRowPair(writer, rptFileFmt,
                                    "SymSetId",
                                    PCLSymbolSets.translateKind1ToId(symSetNo).ToString(),
                                    _colSpanNone, _colSpanNone,
                                    _maxSizeNameTag, maxLineLen,
                                    _flagNone, _flagNone, _flagNone);

            ReportCore.tableRowPair(writer, rptFileFmt,
                                    "IgnoreC0Codes",
                                    (flagIgnoreC0 ? "true" : "false"),
                                    _colSpanNone, _colSpanNone,
                                    _maxSizeNameTag, maxLineLen,
                                    _flagNone, _flagNone, _flagNone);

            ReportCore.tableRowPair(writer, rptFileFmt,
                                    "IgnoreC1Codes",
                                    (flagIgnoreC1 ? "true" : "false"),
                                    _colSpanNone, _colSpanNone,
                                    _maxSizeNameTag, maxLineLen,
                                    _flagNone, _flagNone, _flagNone);

            ReportCore.tableRowPair(writer, rptFileFmt,
                                    "FirstCode",
                                    (flagMapHex ? "0x" + codeMin.ToString("x4")
                                             : codeMin.ToString()),
                                    _colSpanNone, _colSpanNone,
                                    _maxSizeNameTag, maxLineLen,
                                    _flagNone, _flagNone, _flagNone);

            ReportCore.tableRowPair(writer, rptFileFmt,
                                    "Lastcode",
                                    (flagMapHex ? "0x" + codeMax.ToString("x4")
                                             : codeMax.ToString()),
                                    _colSpanNone, _colSpanNone,
                                    _maxSizeNameTag, maxLineLen,
                                    _flagNone, _flagNone, _flagNone);

            ReportCore.tableRowPair(writer, rptFileFmt,
                                    "CharCount",
                                    (flagMapHex ? "0x" + codeCt.ToString("x4")
                                             : codeCt.ToString()),
                                    _colSpanNone, _colSpanNone,
                                    _maxSizeNameTag, maxLineLen,
                                    _flagNone, _flagNone, _flagNone);

            ReportCore.tableRowPair(writer, rptFileFmt,
                                    "CharReqBits",
                                    "0x" + charCollReq.ToString("x16"),
                                    _colSpanNone, _colSpanNone,
                                    _maxSizeNameTag, maxLineLen,
                                    _flagNone, _flagNone, _flagNone);

            ReportCore.tableClose(writer, rptFileFmt);
        }
Esempio n. 5
0
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // c h e c k S y m S e t F i l e                                      //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Check symbol set file to see if it starts with a 'symbol set       //
        // identifier' sequence; if so, return the identifier and first and   //
        // last code-point values.                                            //
        // The symbol set map id stored in the special 'user-defined' symbol  //
        // set instance.                                                      //
        //                                                                    //
        // TODO perhaps we ought to check that symbol set control (make       //
        // permanent) is also present?                                        //
        //                                                                    //
        //--------------------------------------------------------------------//

        public static Boolean checkSymSetFile(
            String filename,
            ref UInt16 symSetNo,
            ref UInt16 firstCode,
            ref UInt16 lastCode,
            ref PCLSymSetTypes.eIndex symSetType)
        {
            Boolean flagOK = true;

            Boolean fileOpen = false;

            Int64 fileSize = 0,
                  offset   = 0;

            //----------------------------------------------------------------//
            //                                                                //
            // Read file to obtain characteristics.                           //
            //                                                                //
            //----------------------------------------------------------------//

            fileOpen = symSetFileOpen(filename, ref fileSize);

            if (!fileOpen)
            {
                flagOK = false;

                MessageBox.Show("Unable to open symbol set definition" +
                                " file '" + filename + "'",
                                "Symbol Set file invalid",
                                MessageBoxButton.OK,
                                MessageBoxImage.Error);
            }
            else
            {
                firstCode = 0;
                lastCode  = 0;

                flagOK = readSymSetId(fileSize,
                                      ref offset,
                                      ref symSetNo);
                if (!flagOK)
                {
                    MessageBox.Show("Symbol set definition" +
                                    " file '" + filename + "':\r\n\r\n" +
                                    "File does not start with" +
                                    " 'symbol set Id' escape sequence",
                                    "Symbol Set file invalid",
                                    MessageBoxButton.OK,
                                    MessageBoxImage.Error);
                }
                else
                {
                    Byte symSetFormat = 0;
                    Byte symSetTypeId = 0;

                    flagOK = readSymSetHddr(filename,
                                            fileSize,
                                            symSetNo,
                                            ref symSetFormat,
                                            ref symSetTypeId,
                                            ref offset,
                                            ref firstCode,
                                            ref lastCode);

                    if (!flagOK)
                    {
                        MessageBox.Show("Symbol set definition" +
                                        " file '" + filename + "':\r\n\r\n" +
                                        "Header is invalid",
                                        "Symbol Set file invalid",
                                        MessageBoxButton.OK,
                                        MessageBoxImage.Error);
                    }
                    else
                    {
                        flagOK = readAndStoreSymSetMap(offset,
                                                       symSetNo,
                                                       firstCode,
                                                       lastCode);

                        if (!flagOK)
                        {
                            MessageBox.Show("Symbol set definition" +
                                            " file '" + filename + "':\r\n\r\n" +
                                            "Mapping data is invalid",
                                            "Symbol Set file invalid",
                                            MessageBoxButton.OK,
                                            MessageBoxImage.Error);
                        }
                        else
                        {
                            symSetType = PCLSymSetTypes.getIndexForIdPCL(symSetTypeId);
                        }
                    }
                }

                symSetFileClose();
            }

            return(flagOK);
        }
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // g e t F o n t S e l e c t i o n D a t a                            //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Read font selection characteristics from PCL soft font descriptor. //
        //                                                                    //
        //--------------------------------------------------------------------//

        private static Boolean getFontSelectionData(
            Int32 hddrOffset,
            Int32 hddrLen,
            ref Boolean proportional,
            ref Boolean scalable,
            ref Boolean bound,
            ref Double pitch,
            ref Double height,
            ref UInt16 style,
            ref Int16 weight,
            ref UInt16 typeface,
            ref UInt16 symSetNo,
            ref PCLSymSetTypes.eIndex symSetType)
        {
            Boolean OK = true;

            UInt16 hddrDescLen;

            Byte[] hddr;

            Boolean bitmapFont = false;

            UInt16 dotResX,
                   dotResY;

            Byte[] buf = new Byte[2];

            _ipStream.Seek(hddrOffset, SeekOrigin.Begin);

            _binReader.Read(buf, 0, 2);

            hddrDescLen = (UInt16)((buf[0] << 8) + buf[1]);

            hddr = new Byte[hddrDescLen];       // if universal bitmap, want whole header read, inclduing segments

            _ipStream.Seek(hddrOffset, SeekOrigin.Begin);

            _binReader.Read(hddr, 0, hddrDescLen);

            //----------------------------------------------------------------//

            ePCLFontFormat hddrFormat;

            hddrFormat = (ePCLFontFormat)hddr[2];

            switch (hddrFormat)
            {
            case ePCLFontFormat.Bitmap:
                bitmapFont = true;
                break;

            case ePCLFontFormat.BitmapResSpec:
                bitmapFont = true;
                break;

            case ePCLFontFormat.IntellifontBound:
                //  intelliFont = true;
                break;

            case ePCLFontFormat.IntellifontUnbound:
                //  intelliFont = true;
                break;

            case ePCLFontFormat.TrueType:
                //  truetypeFont = true;
                break;

            case ePCLFontFormat.Universal:
                //  universalFont = true;
                if (hddr[70] == 254)        // scaling technology
                {
                    bitmapFont = true;
                }
                break;
            }

            //----------------------------------------------------------------//

            if (bitmapFont)
            {
                scalable = false;
            }
            else
            {
                scalable = true;
            }

            //----------------------------------------------------------------//

            dotResX = _defaultPCLDotRes;
            dotResY = _defaultPCLDotRes;

            if (hddrFormat == ePCLFontFormat.Universal)
            {
                if (bitmapFont)     // scaling technology = 254
                {
                    // need to read BR segment to get resolutions

                    Boolean endSegs = false;


                    Byte[] segData;

                    Int32 segDataLen;
                    Int32 segSize;
                    Int32 segType;
                    Int32 offset;

                    segDataLen = hddrLen - hddrDescLen;

                    segData = new Byte[segDataLen];

                    //      _ipStream.Seek (hddrOffset, SeekOrigin.Begin); // already at correct position ?

                    _binReader.Read(segData, 0, segDataLen);

                    offset = 0;

                    while (!endSegs)
                    {
                        //----------------------------------------------------//
                        //                                                    //
                        // Segment Type and Length data is in buffer.         //
                        //                                                    //
                        //----------------------------------------------------//

                        segType = (segData[offset] << 8) +
                                  segData[offset + 1];

                        segSize = (segData[offset + 2] << 24) +
                                  (segData[offset + 3] << 16) +
                                  (segData[offset + 4] << 8) +
                                  segData[offset + 5];

                        if ((segType == 0x4252) &&
                            ((offset + 6 + segSize) < hddrLen))
                        {
                            // BR
                            dotResX = (UInt16)((segData[offset + 6] << 8) +
                                               segData[offset + 7]);
                            dotResY = (UInt16)((segData[offset + 8] << 8) +
                                               segData[offset + 9]);
                        }
                        else if (segType == 0xffff)
                        {
                            // null

                            endSegs = true;
                        }

                        offset += (6 + segSize);

                        if ((offset + 6) > hddrLen)
                        {
                            endSegs = true;
                        }
                    }
                }
            }
            else if (hddrFormat == ePCLFontFormat.BitmapResSpec)
            {
                dotResX = (UInt16)((hddr[64] << 8) + hddr[65]);
                dotResY = (UInt16)((hddr[66] << 8) + hddr[67]);
            }
            else //if (hddrFormat == PCLSoftFonts.eIdHddrFormat.BitmapResSpec)
            {
                dotResX = _defaultPCLDotRes;
                dotResY = _defaultPCLDotRes;
            }

            //----------------------------------------------------------------//

            symSetType = PCLSymSetTypes.getIndexForIdPCL(hddr[3]);

            bound = PCLSymSetTypes.isBound((Int32)symSetType);

            //----------------------------------------------------------------//

            if (hddr[13] == 0)
            {
                proportional = false;
            }
            else
            {
                proportional = true;
            }

            //----------------------------------------------------------------//

            symSetNo = (UInt16)((hddr[14] << 8) + hddr[15]);

            //----------------------------------------------------------------//

            if (bitmapFont)
            {
                UInt16 dotsQtr = 0;
                UInt16 dotsExt = 0;
                Double dotsK   = 0.0;

                dotsQtr = (UInt16)((hddr[16] << 8) + hddr[17]);
                dotsExt = (UInt16)(hddr[40]);
                dotsK   = (dotsQtr << 8) + dotsExt;

                if ((dotsQtr == 0) && (dotsExt == 0))
                {
                    pitch = 0.0;
                }
                else
                {
                    dotsK = (dotsQtr << 8) + dotsExt;
                    pitch = (dotResX << 10) / dotsK;
                }

                dotsQtr = (UInt16)((hddr[18] << 8) + hddr[19]);
                dotsExt = (UInt16)(hddr[41]);

                if ((dotsQtr == 0) && (dotsExt == 0))
                {
                    height = 0.0;
                }
                else
                {
                    dotsK  = (dotsQtr << 8) + dotsExt;
                    height = (dotsK * 72) / (dotResY << 10);
                }
            }
            else
            {
                pitch  = 0.0;
                height = 0.0;
            }

            //----------------------------------------------------------------//

            style    = (UInt16)((hddr[4] << 8) + hddr[23]);
            weight   = (Int16)hddr[24];
            typeface = (UInt16)((hddr[26] << 8) + hddr[25]);

            //----------------------------------------------------------------//

            return(OK);
        }
        /*
         * //--------------------------------------------------------------------//
         * //                                                        M e t h o d //
         * // g e t F o n t C h a r a c t e r i s t i c s                        //
         * //--------------------------------------------------------------------//
         * //                                                                    //
         * // Validate font header and return font characteristics.              //
         * //                                                                    //
         * //--------------------------------------------------------------------//
         *
         * public static Boolean getFontCharacteristics (
         *  String      fontFilename,
         *  ref Boolean proportional,
         *  ref Boolean scalable,
         *  ref Boolean bound,
         *  ref Double  pitch,
         *  ref Double  height,
         *  ref UInt16  style,
         *  ref Int16   weight,
         *  ref UInt16  typeface,
         *  ref UInt16  symSetNo,
         *  ref PCLSymSetTypes.eIndex symSetType)
         * {
         *  Boolean OK = true;
         *
         *  Boolean fileOpen = false;
         *
         *  UInt16 hddrLen     = 0;
         *  UInt16 hddrOffset  = 0;
         *  UInt16 hddrDescLen = 0;
         *  Int64  fileSize    = 0;
         *
         *  //----------------------------------------------------------------//
         *  //                                                                //
         *  // Read file to obtain characteristics.                           //
         *  //                                                                //
         *  //----------------------------------------------------------------//
         *
         *  fileOpen = fontFileOpen (fontFilename, ref fileSize);
         *
         *  if (!fileOpen)
         *  {
         *      OK = false;
         *  }
         *  else
         *  {
         *      OK = readHddrIntro (fontFilename,
         *                          fileSize,
         *                          ref hddrLen,
         *                          ref hddrOffset,
         *                          ref hddrDescLen);
         *
         *      if (OK)
         *      {
         *          OK = readHddrDescriptor (hddrOffset,
         *                                   hddrDescLen,
         *                                   ref proportional,
         *                                   ref scalable,
         *                                   ref bound,
         *                                   ref pitch,
         *                                   ref height,
         *                                   ref style,
         *                                   ref weight,
         *                                   ref typeface,
         *                                   ref symSetNo,
         *                                   ref symSetType);
         *      }
         *
         *      fontFileClose ();
         *  }
         *
         *  return OK;
         * }
         */

        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // g e t F o n t C h a r a c t e r i s t i c s                        //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Read font header and return font characteristics.                  //
        //                                                                    //
        //--------------------------------------------------------------------//

        public static Boolean getFontCharacteristics(
            String fontFilename,
            ref Boolean proportional,
            ref Boolean scalable,
            ref Boolean bound,
            ref Double pitch,
            ref Double height,
            ref UInt16 style,
            ref Int16 weight,
            ref UInt16 typeface,
            ref UInt16 symSetNo,
            ref PCLSymSetTypes.eIndex symSetType)
        {
            Boolean OK = true;

            Boolean fileOpen = false;

            UInt16 hddrLen = 0;

            Int32 fileOffset = 0;

            Int64 fontFileSize = 0;

            //----------------------------------------------------------------//
            //                                                                //
            // Read file to obtain characteristics.                           //
            //                                                                //
            //----------------------------------------------------------------//

            //      _fontFileName = fontFilename;

            fileOpen = fontFileOpen(fontFilename, ref fontFileSize);

            if (!fileOpen)
            {
                OK = false;
            }
            else
            {
                OK = readHddrIntro(fontFilename,
                                   fontFileSize,
                                   ref fileOffset,
                                   ref hddrLen);

                if (OK)
                {
                    OK = getFontSelectionData(fileOffset,
                                              hddrLen,
                                              ref proportional,
                                              ref scalable,
                                              ref bound,
                                              ref pitch,
                                              ref height,
                                              ref style,
                                              ref weight,
                                              ref typeface,
                                              ref symSetNo,
                                              ref symSetType);
                }

                fontFileClose();
            }

            return(OK);
        }