Exemple #1
0
        public ObjVectList ConvMojiToVectList(string sStr, String sFontName)
        {
            int sjis;

            byte[]      bytesSJIS;
            String      sTblFontFileName;
            String      sDataFontFileName;
            int         seekpoint;
            FileStream  fsTbl;
            FileStream  fsData;
            int         nDataLen;
            long        nSeekp;
            byte        atr;
            int         pp, pointmax;
            int         sp, ep;
            ObjVectList objVectList;
            ObjVect     objVect;

            bytesSJIS = System.Text.Encoding.Default.GetBytes(sStr);
            sjis      = ((int)(bytesSJIS[0])) << 8 | bytesSJIS[1];
            byte[] byteIdx = new Byte[Constants.FIDXSIZE];
            sTblFontFileName  = getTblFontFileName(sjis, sFontName);
            sDataFontFileName = getDataFontFileName(sjis, sFontName);
            seekpoint         = getSeekPoint(sjis);
            if (seekpoint == 0)
            {
                return(null);
            }
            fsTbl = new FileStream(sTblFontFileName, FileMode.Open);
            fsTbl.Seek(seekpoint, SeekOrigin.Begin);
            fsTbl.Read(byteIdx, 0, Constants.FIDXSIZE);
            nDataLen = BitConverter.ToInt16(byteIdx, 0);
            nSeekp   = BitConverter.ToInt32(byteIdx, 2);
            if (nDataLen == 0)
            {
                fsTbl.Close();
                return(null);
            }
            byte[] byteData = new Byte[nDataLen];
            fsData = new FileStream(sDataFontFileName, FileMode.Open);
            fsData.Seek(nSeekp, SeekOrigin.Begin);
            fsData.Read(byteData, 0, nDataLen);
            if (m_nTateGaki == 1)
            {
                byteData = tategakiTrns(sjis, byteData, nDataLen);
            }
            pointmax    = nDataLen / Constants.ESF0SIZADD;
            objVectList = new ObjVectList();
            sp          = 0;
            for (pp = 1; pp < pointmax; pp++)
            {
                atr = AtrGet(byteData, pp);
                if ((atr & Constants.F0EORMASK) != 0)
                {
                    ep      = pp;
                    objVect = cnvRejionVect(byteData, sp, ep);
                    if (objVect != null)
                    {
                        objVectList.AddVect(objVect);
                    }
                    sp = ep + 1;
                }
            }
            fsTbl.Close();
            fsData.Close();
            return(objVectList);
        }
Exemple #2
0
        public ObjVectList ConvMojiToVectList(string str, string sFontName)
        {
            string              sTTFontName;
            double              dFontSize;
            ObjVectList         objVectList;
            ObjVect             objVect;
            ObjFigu             objFigu;
            ClsFontPathGeometry clsFGP;
            PathGeometry        pg;
            int               psmax, psidx;
            PathSegment       ps;
            int               pfmax, pfidx;
            PathFigure        pf;
            BezierSegment     bz;
            PolyBezierSegment pbz;
            LineSegment       ln;
            PolyLineSegment   pln;
            int               ptmax, ptidx;
            string            stype;
            double            x1, y1;

            dFontSize   = 1024;
            sTTFontName = GetTTFontName(sFontName);
            clsFGP      = m_libCmn.GetFontPathGeometry(str, dFontSize, sFontName);
            pfmax       = clsFGP.pg.Figures.Count;
            objVectList = new ObjVectList();
            for (pfidx = 0; pfidx < pfmax; pfidx++)
            {
                objVect = new ObjVect();
                pf      = clsFGP.pg.Figures[pfidx];
                x1      = pf.StartPoint.X;
                y1      = pf.StartPoint.Y + clsFGP.dMoveY;
                psmax   = pf.Segments.Count;
                for (psidx = 0; psidx < psmax; psidx++)
                {
                    ps    = pf.Segments[psidx];
                    stype = ps.GetType().Name;
                    if (stype.Equals("PolyBezierSegment"))
                    {
                        pbz   = (PolyBezierSegment)ps;
                        ptmax = pbz.Points.Count;
                        for (ptidx = 0; ptidx < ptmax; ptidx = ptidx + 3)
                        {
                            objFigu      = new ObjFigu();
                            objFigu.x1   = x1;
                            objFigu.y1   = y1;
                            objFigu.x2   = pbz.Points[ptidx].X;
                            objFigu.y2   = pbz.Points[ptidx].Y + clsFGP.dMoveY;
                            objFigu.x3   = pbz.Points[ptidx + 1].X;
                            objFigu.y3   = pbz.Points[ptidx + 1].Y + clsFGP.dMoveY;
                            objFigu.x4   = pbz.Points[ptidx + 2].X;
                            objFigu.y4   = pbz.Points[ptidx + 2].Y + clsFGP.dMoveY;
                            objFigu.kind = Constants.BEZEKIND;
                            objVect.m_lstObjFigu.Add(objFigu);
                            x1 = objFigu.x4;
                            y1 = objFigu.y4;
                        }
                    }
                    else if (stype.Equals("PolyLineSegment"))
                    {
                        pln   = (PolyLineSegment)ps;
                        ptmax = pln.Points.Count;
                        for (ptidx = 0; ptidx < ptmax; ptidx++)
                        {
                            objFigu      = new ObjFigu();
                            objFigu.x1   = x1;
                            objFigu.y1   = y1;
                            objFigu.x4   = pln.Points[ptidx].X;
                            objFigu.y4   = pln.Points[ptidx].Y + clsFGP.dMoveY;
                            objFigu.kind = Constants.LINEKIND;
                            objVect.m_lstObjFigu.Add(objFigu);
                            x1 = objFigu.x4;
                            y1 = objFigu.y4;
                        }
                    }
                    else if (stype.Equals("BezierSegment"))
                    {
                        objFigu      = new ObjFigu();
                        bz           = (BezierSegment)ps;
                        objFigu.x1   = x1;
                        objFigu.y1   = y1;
                        objFigu.x2   = bz.Point1.X;
                        objFigu.y2   = bz.Point1.Y + clsFGP.dMoveY;
                        objFigu.x3   = bz.Point2.X;
                        objFigu.y3   = bz.Point2.Y + clsFGP.dMoveY;
                        objFigu.x4   = bz.Point3.X;
                        objFigu.y4   = bz.Point3.Y + clsFGP.dMoveY;
                        objFigu.kind = Constants.BEZEKIND;
                        objVect.m_lstObjFigu.Add(objFigu);
                        x1 = objFigu.x4;
                        y1 = objFigu.y4;
                    }
                    else if (stype.Equals("LineSegment"))
                    {
                        objFigu      = new ObjFigu();
                        ln           = (LineSegment)ps;
                        objFigu.x1   = x1;
                        objFigu.y1   = y1;
                        objFigu.x4   = ln.Point.X;
                        objFigu.y4   = ln.Point.Y + clsFGP.dMoveY;
                        objFigu.kind = Constants.LINEKIND;
                        objVect.m_lstObjFigu.Add(objFigu);
                        x1 = objFigu.x4;
                        y1 = objFigu.y4;
                    }
                }
                objVectList.AddVect(objVect);
            }
            return(objVectList);
        }