Пример #1
0
 public bool RastTest(int resX, int resY, int[] arrPointSizes,
                      float stretchX, float stretchY,
                      float rotation, float skew,
                      float[,] matrix,
                      bool unknown1, bool unknown2, bool unknown3, uint unknown4,
                      RastTestErrorDelegate pRastTestErrorDelegate,
                      UpdateProgressDelegate pUpdateProgressDelegate,
                      int numGlyphs)
 {
     throw new NotImplementedException("UnImplemented OTFontFile.Rasterizer:RastTest");
 }
Пример #2
0
 public bool RastTest (int resX, int resY, int[] arrPointSizes,
                      float stretchX, float stretchY,
                      float rotation, float skew,
                      float[,] matrix,
                      bool unknown1, bool unknown2, bool unknown3, uint unknown4,
                      RastTestErrorDelegate pRastTestErrorDelegate,
                      UpdateProgressDelegate pUpdateProgressDelegate,
                      int numGlyphs)
 {
     throw new NotImplementedException("UnImplemented OTFontFile.Rasterizer:RastTest");
 }
Пример #3
0
        public bool RastTest(int resX, int resY, int[] arrPointSizes,
                             float stretchX, float stretchY,
                             float rotation, float skew,
                             float[,] matrix,
                             bool setBW, bool setGrayscale, bool setCleartype, uint CTFlags,
                             RastTestErrorDelegate pRastTestErrorDelegate,
                             UpdateProgressDelegate pUpdateProgressDelegate,
                             int numGlyphs)
        {
            int count_sets = 0;
            LoadFlags lf = LoadFlags.Default;
            LoadTarget lt = LoadTarget.Normal;
            if ( setBW )
            {
                lf = LoadFlags.Default|LoadFlags.NoAutohint|LoadFlags.Monochrome|LoadFlags.ComputeMetrics;
                lt = LoadTarget.Mono;
                _lib.PropertySet("truetype", "interpreter-version", 35);

                count_sets++;
            }
            if ( setGrayscale )
            {
                lf = LoadFlags.Default|LoadFlags.NoAutohint|LoadFlags.ComputeMetrics;
                lt = LoadTarget.Normal;
                _lib.PropertySet("truetype", "interpreter-version", 35);

                count_sets++;
            }
            if ( setCleartype )
            {
                lf = LoadFlags.Default|LoadFlags.NoAutohint|LoadFlags.ComputeMetrics;
                lt = LoadTarget.Lcd;
                _lib.PropertySet("truetype", "interpreter-version", 40);

                count_sets++;
            }
            if ( count_sets != 1 )
                throw new ArgumentOutOfRangeException("Only one of BW/Grayscale/Cleartype should be set");

            try
            {
                TT_Diagnostics_Unset();
            }
            catch (Exception e)
            {
                throw new NotImplementedException("UnImplemented in this version of Freetype: " + FTVersion);
            };

            FTMatrix fmatrix = new FTMatrix(new Fixed16Dot16( matrix[0,0] * stretchX ), new Fixed16Dot16( matrix[0,1] * stretchX ),
                                            new Fixed16Dot16( matrix[1,0] * stretchY ), new Fixed16Dot16( matrix[1,1] * stretchY ));
            FTVector fdelta = new FTVector(new Fixed16Dot16( matrix[0,2] * stretchX ), new Fixed16Dot16( matrix[1,2] * stretchY ));
            /* matrix[2,0] = matrix[2,1] = 0, matrix[2,2] =1, not used */

            FTMatrix mskew = new FTMatrix(new Fixed16Dot16( 1 ), new Fixed16Dot16( 0 ),
                                          (new Fixed16Dot16(skew)).Tan(), new Fixed16Dot16( 1 ));
            FTMatrix.Multiply(ref mskew, ref fmatrix);
            fdelta.Transform(mskew);

            FTVector rot_row1 = new FTVector(new Fixed16Dot16( 1 ), new Fixed16Dot16( 0 ));
            FTVector rot_row2 = new FTVector(new Fixed16Dot16( 1 ), new Fixed16Dot16( 0 ));
            rot_row1.Rotate(new Fixed16Dot16(rotation));
            rot_row2.Rotate(new Fixed16Dot16(rotation + 90));
            FTMatrix mrot = new FTMatrix(rot_row1, rot_row2);
            FTMatrix.Multiply(ref mrot, ref fmatrix);
            fdelta.Rotate(new Fixed16Dot16(-rotation));

            for (int i = 0; i < arrPointSizes.Length ; i++)
            {
                if ( m_UserCancelledTest ) return true;
                pUpdateProgressDelegate("Processing Size " + arrPointSizes[i]);
                _face.SetCharSize(new Fixed26Dot6(arrPointSizes[i]),
                                  new Fixed26Dot6(arrPointSizes[i]),
                                  (uint) resX, (uint) resY);
                _face.SetTransform(fmatrix, fdelta);
                for (uint ig = 0; ig < numGlyphs; ig++) {
                    diagnostics_Function diagnostics =
                        (message, opcode, range_base, is_composite, IP, callTop, opc, start) =>
                        {
                            string sDetails = "Size " + arrPointSizes[i] + ", " + opcode;
                            switch ( range_base )
                            {
                                case 3:
                                    if (is_composite != 0)
                                        sDetails += ", Composite Glyph ID " + ig;
                                    else
                                        sDetails += ", Glyph ID " + ig;
                                    break;
                                case 1: /* font */
                                case 2: /* cvt */ // ?
                                    sDetails += ", Pre-Program";
                                    break;
                                default: /* none */
                                    sDetails += ", Unknown?"; // ?
                                    break;
                            }

                            sDetails += ", At ByteOffset " + IP;

                            if (callTop > 0)
                                sDetails += ", In function " + opc + " offsetted by " + (IP - start);

                            pRastTestErrorDelegate(message, sDetails);
                            m_RastErrorCount += 1;
                            return 0; // Not used currently.
                        };
                    TT_Diagnostics_Set(diagnostics);
                    _face.LoadGlyph(ig, lf, lt);
                    TT_Diagnostics_Unset();
                }
            }
            return true;
        }
Пример #4
0
        public bool RastTest(int resX, int resY, int[] arrPointSizes,
                             float stretchX, float stretchY,
                             float rotation, float skew,
                             float[,] matrix,
                             bool setBW, bool setGrayscale, bool setCleartype, uint CTFlags,
                             RastTestErrorDelegate pRastTestErrorDelegate,
                             UpdateProgressDelegate pUpdateProgressDelegate,
                             int numGlyphs)
        {
            int        count_sets = 0;
            LoadFlags  lf         = LoadFlags.Default;
            LoadTarget lt         = LoadTarget.Normal;

            if (setBW)
            {
                lf = LoadFlags.Default | LoadFlags.NoAutohint | LoadFlags.Monochrome | LoadFlags.ComputeMetrics;
                lt = LoadTarget.Mono;
                _lib.PropertySet("truetype", "interpreter-version", 35);

                count_sets++;
            }
            if (setGrayscale)
            {
                lf = LoadFlags.Default | LoadFlags.NoAutohint | LoadFlags.ComputeMetrics;
                lt = LoadTarget.Normal;
                _lib.PropertySet("truetype", "interpreter-version", 35);

                count_sets++;
            }
            if (setCleartype)
            {
                lf = LoadFlags.Default | LoadFlags.NoAutohint | LoadFlags.ComputeMetrics;
                lt = LoadTarget.Lcd;
                _lib.PropertySet("truetype", "interpreter-version", 40);

                count_sets++;
            }
            if (count_sets != 1)
            {
                throw new ArgumentOutOfRangeException("Only one of BW/Grayscale/Cleartype should be set");
            }

            try
            {
                TT_Diagnostics_Unset();
            }
            catch (Exception e)
            {
                throw new NotImplementedException("UnImplemented in this version of Freetype: " + FTVersion);
            };

            FTMatrix fmatrix = new FTMatrix(new Fixed16Dot16(matrix[0, 0] * stretchX), new Fixed16Dot16(matrix[0, 1] * stretchX),
                                            new Fixed16Dot16(matrix[1, 0] * stretchY), new Fixed16Dot16(matrix[1, 1] * stretchY));
            FTVector fdelta = new FTVector(new Fixed16Dot16(matrix[0, 2] * stretchX), new Fixed16Dot16(matrix[1, 2] * stretchY));
            /* matrix[2,0] = matrix[2,1] = 0, matrix[2,2] =1, not used */

            FTMatrix mskew = new FTMatrix(new Fixed16Dot16(1), new Fixed16Dot16(0),
                                          (new Fixed16Dot16(skew)).Tan(), new Fixed16Dot16(1));

            FTMatrix.Multiply(ref mskew, ref fmatrix);
            fdelta.Transform(mskew);

            FTVector rot_row1 = new FTVector(new Fixed16Dot16(1), new Fixed16Dot16(0));
            FTVector rot_row2 = new FTVector(new Fixed16Dot16(1), new Fixed16Dot16(0));

            rot_row1.Rotate(new Fixed16Dot16(rotation));
            rot_row2.Rotate(new Fixed16Dot16(rotation + 90));
            FTMatrix mrot = new FTMatrix(rot_row1, rot_row2);

            FTMatrix.Multiply(ref mrot, ref fmatrix);
            fdelta.Rotate(new Fixed16Dot16(-rotation));

            for (int i = 0; i < arrPointSizes.Length; i++)
            {
                if (m_UserCancelledTest)
                {
                    return(true);
                }
                pUpdateProgressDelegate("Processing Size " + arrPointSizes[i]);
                try{
                    _face.SetCharSize(new Fixed26Dot6(arrPointSizes[i]),
                                      new Fixed26Dot6(arrPointSizes[i]),
                                      (uint)resX, (uint)resY);
                } catch (FreeTypeException e) {
                    if (e.Error == Error.InvalidPixelSize)
                    {
                        pRastTestErrorDelegate("_rast_W_FT_InvalidPixelSize", "Setting unsupported size "
                                               + arrPointSizes[i] + " for fixed-size font.");
                        m_RastErrorCount += 1;
                        continue;
                    }
                    else
                    {
                        throw;
                    }
                }
                _face.SetTransform(fmatrix, fdelta);
                for (uint ig = 0; ig < numGlyphs; ig++)
                {
                    diagnostics_Function diagnostics =
                        (message, opcode, range_base, is_composite, IP, callTop, opc, start) =>
                    {
                        string sDetails = "Size " + arrPointSizes[i] + ", " + opcode;
                        switch (range_base)
                        {
                        case 3:
                            if (is_composite != 0)
                            {
                                sDetails += ", Composite Glyph ID " + ig;
                            }
                            else
                            {
                                sDetails += ", Glyph ID " + ig;
                            }
                            break;

                        case 1:           /* font */
                        case 2: /* cvt */ // ?
                            sDetails += ", Pre-Program";
                            break;

                        default:                      /* none */
                            sDetails += ", Unknown?"; // ?
                            break;
                        }

                        sDetails += ", At ByteOffset " + IP;

                        if (callTop > 0)
                        {
                            sDetails += ", In function " + opc + " offsetted by " + (IP - start);
                        }

                        pRastTestErrorDelegate(message, sDetails);
                        m_RastErrorCount += 1;
                        return(0);    // Not used currently.
                    };
                    TT_Diagnostics_Set(diagnostics);
                    try{
                        _face.LoadGlyph(ig, lf, lt);
                    } catch (Exception ee) {
                        if (ee is FreeTypeException)
                        {
                            FreeTypeException e = (FreeTypeException)ee;
                            if (e.Error == Error.InvalidOutline)
                            {
                                pRastTestErrorDelegate("_rast_W_FT_InvalidOutline", "Invalid Outline in Glyph " + ig);
                                m_RastErrorCount += 1;
                                continue;
                            }
                            if (e.Error == Error.InvalidArgument)
                            {
                                pRastTestErrorDelegate("_rast_W_FT_InvalidArgument", "Invalid Argument in Glyph " + ig);
                                m_RastErrorCount += 1;
                                continue;
                            }
                            if (e.Error == Error.InvalidSizeHandle)
                            {
                                pRastTestErrorDelegate("_rast_W_FT_InvalidSizeHandle", "Invalid Metrics for Glyph " + ig + " at size "
                                                       + arrPointSizes[i]);
                                m_RastErrorCount += 1;
                                continue;
                            }
                        }

                        pRastTestErrorDelegate("_rast_I_FT_Error_Supplymentary_Info", "Glyph " + ig +
                                               " at size " + arrPointSizes[i]);
                        throw;
                    }
                    TT_Diagnostics_Unset();
                }
            }
            return(true);
        }
Пример #5
0
 public bool RastTest(int resX, int resY, int[] arrPointSizes,
                      float stretchX, float stretchY,
                      float rotation, float skew,
                      float[,] matrix,
                      bool setBW, bool setGrayscale, bool setCleartype, uint CTFlags,
                      RastTestErrorDelegate pRastTestErrorDelegate,
                      UpdateProgressDelegate pUpdateProgressDelegate,
                      int numGlyphs)
 {
     throw new NotImplementedException("UnImplemented OTFontFile.Rasterizer:RastTest");
 }