示例#1
0
        protected override void FitCurrentGlyph(Glyph glyph)
        {
            //not use interperter so we need to scale it with our mechanism
            //this demonstrate our auto hint engine ***
            //you can change this to your own hint engine***   
            _latestDynamicOutline = null;//reset
            if (this.UseTrueTypeInstructions)
            {
                base.FitCurrentGlyph(glyph);
            }
            else
            {
                //
                if (TemporaryDisableCustomFit)
                {
                    return;
                }
                //
                if (this.UseVerticalHinting)
                {
                    if (!_fitoutlineCollection.TryGetValue(glyph.GlyphIndex, out _latestDynamicOutline))
                    {

                        //---------------------------------------------
                        //test code 
                        //GlyphContourBuilder contBuilder = new GlyphContourBuilder();
                        //contBuilder.Reset();
                        //int x = 100, y = 120, w = 700, h = 200; 
                        //contBuilder.MoveTo(x, y);
                        //contBuilder.LineTo(x + w, y);
                        //contBuilder.LineTo(x + w, y + h);
                        //contBuilder.LineTo(x, y + h);
                        //contBuilder.CloseFigure(); 
                        //--------------------------------------------- 
                        _latestDynamicOutline = _fitShapeAnalyzer.CreateDynamicOutline(
                            _outputGlyphPoints,
                            _outputContours);
                        //add more information for later scaling process
                        _latestDynamicOutline.OriginalAdvanceWidth = glyph.OriginalAdvanceWidth;
                        _latestDynamicOutline.OriginalGlyphControlBounds = glyph.Bounds;
                        //store to our dynamic outline collection
                        //so we can reuse it
                        _fitoutlineCollection.Add(glyph.GlyphIndex, _latestDynamicOutline);
                        //-------------------
                        //
                        _latestDynamicOutline.GenerateOutput(null, Typeface.CalculateScaleToPixel(RecentFontSizeInPixels));
                        //-------------------

                    }
                    else
                    {
                        if (IsSizeChanged)
                        {
                            _latestDynamicOutline.GenerateOutput(null, Typeface.CalculateScaleToPixel(RecentFontSizeInPixels));
                            IsSizeChanged = false;
                        }
                    }
                }
            }
        }
        /// <summary>
        /// get glyph mesh from current font setting
        /// </summary>
        /// <param name="glyphIndex"></param>
        /// <returns></returns>
        public VertexStore GetGlyphMesh(ushort glyphIndex)
        {
            GlyphMeshData glyphMeshData = InternalGetGlyphMesh(glyphIndex);

            if (glyphMeshData.vxsStore == null)
            {
                //build vxs
                _tovxs.Reset();
                float pxscale = _currentTypeface.CalculateScaleToPixelFromPointSize(_currentFontSizeInPoints);
                GlyphDynamicOutline dynamicOutline = glyphMeshData.dynamicOutline;
                if (dynamicOutline != null)
                {
                    dynamicOutline.GenerateOutput(_tovxs, pxscale);

                    //version 3
                    if (_flipGlyphUpward)
                    {
                        _vxs1.Clear(); //write to temp buffer first
                        _tovxs.WriteOutput(_vxs1);

                        VertexStore vxs = new VertexStore();
                        PixelFarm.Agg.VertexStoreTransformExtensions.TransformToVxs(_invertY, _vxs1, vxs);
                        //then
                        glyphMeshData.vxsStore = vxs;
                    }
                    else
                    {
                        glyphMeshData.vxsStore = new VertexStore();
                        _tovxs.WriteOutput(glyphMeshData.vxsStore);
                    }
                }
                else
                {
                    if (_flipGlyphUpward)
                    {
                        _vxs1.Clear(); //write to temp buffer first

                        _currentGlyphBuilder.ReadShapes(_tovxs);
                        _tovxs.WriteOutput(_vxs1);

                        VertexStore vxs = new VertexStore();
                        PixelFarm.Agg.VertexStoreTransformExtensions.TransformToVxs(_invertY, _vxs1, vxs);
                        //then
                        glyphMeshData.vxsStore = vxs;
                    }
                    else
                    {
                        //no dynamic outline

                        _currentGlyphBuilder.ReadShapes(_tovxs);
                        //TODO: review here,
                        //float pxScale = _glyphPathBuilder.GetPixelScale();

                        glyphMeshData.vxsStore = new VertexStore();
                        _tovxs.WriteOutput(glyphMeshData.vxsStore);
                    }
                }
            }
            return(glyphMeshData.vxsStore);
        }
示例#3
0
        /// <summary>
        /// get glyph mesh from current font setting
        /// </summary>
        /// <param name="glyphIndex"></param>
        /// <returns></returns>
        public VertexStore GetGlyphMesh(ushort glyphIndex)
        {
            GlyphMeshData glyphMeshData = InternalGetGlyphMesh(glyphIndex);

            if (glyphMeshData.vxsStore == null)
            {
                //build vxs
                _tovxs.Reset();
                float pxscale = _currentTypeface.CalculateScaleToPixelFromPointSize(_currentFontSizeInPoints);
                GlyphDynamicOutline dynamicOutline = glyphMeshData.dynamicOutline;
                if (dynamicOutline != null)
                {
                    dynamicOutline.GenerateOutput(_tovxs, pxscale);
                    glyphMeshData.vxsStore = new VertexStore();
                    _tovxs.WriteOutput(glyphMeshData.vxsStore, _vxsPool);
                }
                else
                {
                    //no dynamic outline
                    glyphMeshData.vxsStore = new VertexStore();
                    _currentGlyphBuilder.ReadShapes(_tovxs);
                    //TODO: review here,
                    //float pxScale = _glyphPathBuilder.GetPixelScale();
                    _tovxs.WriteOutput(glyphMeshData.vxsStore, _vxsPool);
                }
            }
            return(glyphMeshData.vxsStore);
        }
示例#4
0
        /// <summary>
        /// get glyph mesh from current font setting
        /// </summary>
        /// <param name="glyphIndex"></param>
        /// <returns></returns>
        public VertexStore GetGlyphMesh(ushort glyphIndex)
        {
            GlyphMeshData glyphMeshData = InternalGetGlyphMesh(glyphIndex);

            if (glyphMeshData.vxsStore == null)
            {
                //build vxs
                _tovxs.Reset();
                float pxscale = _currentTypeface.CalculateScaleToPixelFromPointSize(_currentFontSizeInPoints);
                GlyphDynamicOutline dynamicOutline = glyphMeshData.dynamicOutline;
                if (dynamicOutline != null)
                {
                    dynamicOutline.GenerateOutput(_tovxs, pxscale);

                    //version 3

                    if (FlipGlyphUpward)
                    {
                        using (VxsTemp.Borrow(out var v1))
                        {
                            _tovxs.WriteOutput(v1);
                            //write to temp buffer first
                            //then
                            glyphMeshData.vxsStore = v1.CreateTrim(_invertY);// _temp2.CreateTrim();
                        }
                    }
                    else
                    {
                        using (VxsTemp.Borrow(out var v1))
                        {
                            _tovxs.WriteOutput(v1);
                            glyphMeshData.vxsStore = v1.CreateTrim();
                        }
                    }
                }
                else
                {
                    if (FlipGlyphUpward)
                    {
                        using (VxsTemp.Borrow(out var v1))
                        {
                            _currentGlyphBuilder.ReadShapes(_tovxs);
                            _tovxs.WriteOutput(v1); //write to temp buffer first

                            //then
                            glyphMeshData.vxsStore = v1.CreateTrim(_invertY);
                        }
                    }
                    else
                    {
                        //no dynamic outline
                        using (VxsTemp.Borrow(out var v1))
                        {
                            _currentGlyphBuilder.ReadShapes(_tovxs);
                            //TODO: review here,
                            //float pxScale = _glyphPathBuilder.GetPixelScale();

                            _tovxs.WriteOutput(v1);
                            glyphMeshData.vxsStore = v1.CreateTrim();
                        }
                    }
                }
            }


            if (SimulateOblique)
            {
                if (glyphMeshData._synthOblique == null)
                {
                    //create italic version
                    SimulateQbliqueGlyph(glyphMeshData);
                }
                return(glyphMeshData._synthOblique.vxsStore);
            }
            else
            {
                return(glyphMeshData.vxsStore);
            }
        }