Ejemplo n.º 1
0
            static public glyph_simple GetSimpleGlyphLogicalData(header h)
            {
                glyph_simple gs = null;
                SimpleGlyph  sg = h.GetSimpleGlyph();

                if (sg != null)
                {
                    // glyph is a simple glyph

                    gs = new glyph_simple(h.numberOfContours, h.xMin, h.yMin, h.xMax, h.yMax);

                    SimpleGlyph.Coordinate[]  coords = sg.GetDecodedRelativeCoordinates();
                    glyph_simple.Coordinate16 prevPoint;
                    prevPoint.x = prevPoint.y = 0;
                    glyph_simple.Coordinate16 newPoint;
                    for (uint iContour = 0; iContour < h.numberOfContours; iContour++)
                    {
                        // convert the coordinates in this contour from relative to absolute
                        uint startCoord = 0;
                        if (iContour > 0)
                        {
                            startCoord = (uint)sg.GetEndPtOfContour(iContour - 1) + 1;
                        }
                        uint endCoord = sg.GetEndPtOfContour(iContour);

                        int nPoints = (int)(endCoord - startCoord + 1);
                        glyph_simple.contour Contour = new glyph_simple.contour(nPoints);

                        for (uint iCoord = startCoord; iCoord <= endCoord; iCoord++)
                        {
                            newPoint.x        = (short)(prevPoint.x + coords[iCoord].x);
                            newPoint.y        = (short)(prevPoint.y + coords[iCoord].y);
                            newPoint.bOnCurve = coords[iCoord].bOnCurve;
                            Contour.m_arrPoints.Add(newPoint);
                            prevPoint = newPoint;
                        }

                        gs.m_arrContours.Add(Contour);

                        // copy the hinting instructions
                        gs.m_arrInstructions = new byte[sg.instructionLength];
                        for (uint i = 0; i < sg.instructionLength; i++)
                        {
                            gs.m_arrInstructions[i] = sg.GetInstruction(i);
                        }
                    }
                }
                return(gs);
            }
Ejemplo n.º 2
0
            static public glyph_simple GetSimpleGlyphLogicalData(header h)
            {
                glyph_simple gs = null;
                SimpleGlyph sg = h.GetSimpleGlyph();
                if (sg != null)
                {
                    // glyph is a simple glyph

                    gs = new glyph_simple(h.numberOfContours, h.xMin, h.yMin, h.xMax, h.yMax);

                    SimpleGlyph.Coordinate[] coords = sg.GetDecodedRelativeCoordinates();
                    glyph_simple.Coordinate16 prevPoint;
                    prevPoint.x = prevPoint.y = 0;
                    glyph_simple.Coordinate16 newPoint;
                    for (uint iContour=0; iContour<h.numberOfContours; iContour++)
                    {
                        // convert the coordinates in this contour from relative to absolute
                        uint startCoord = 0;
                        if (iContour > 0)
                        {
                            startCoord = (uint)sg.GetEndPtOfContour(iContour-1)+1;
                        }
                        uint endCoord = sg.GetEndPtOfContour(iContour);

                        int nPoints = (int)(endCoord - startCoord + 1);
                        glyph_simple.contour Contour = new glyph_simple.contour(nPoints);

                        for (uint iCoord = startCoord; iCoord <= endCoord; iCoord++)
                        {
                            newPoint.x = (short)(prevPoint.x + coords[iCoord].x);
                            newPoint.y = (short)(prevPoint.y + coords[iCoord].y);
                            newPoint.bOnCurve = coords[iCoord].bOnCurve;
                            Contour.m_arrPoints.Add(newPoint);
                            prevPoint = newPoint;
                        }

                        gs.m_arrContours.Add(Contour);

                        // copy the hinting instructions
                        gs.m_arrInstructions = new byte[sg.instructionLength];
                        for (uint i=0; i<sg.instructionLength; i++)
                        {
                            gs.m_arrInstructions[i] = sg.GetInstruction(i);
                        }
                    }
                }
                return gs;
            }