/// <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);
        }
        /// <summary>
        /// get existing or create new one from current font setting
        /// </summary>
        /// <param name="glyphIndex"></param>
        /// <returns></returns>
        GlyphMeshData InternalGetGlyphMesh(ushort glyphIndex)
        {
            GlyphMeshData glyphMeshData;

            if (!_hintGlyphCollection.TryGetCacheGlyph(glyphIndex, out glyphMeshData))
            {
                //if not found then create new glyph vxs and cache it
                _currentGlyphBuilder.SetHintTechnique(_currentHintTech);
                _currentGlyphBuilder.BuildFromGlyphIndex(glyphIndex, _currentFontSizeInPoints);
                GlyphDynamicOutline dynamicOutline = _currentGlyphBuilder.LatestGlyphFitOutline;
                //-----------------------------------
                glyphMeshData = new GlyphMeshData();

                if (dynamicOutline != null)
                {
                    //has dynamic outline data
                    glyphMeshData.avgXOffsetToFit = dynamicOutline.AvgXFitOffset;
                    glyphMeshData.orgBounds       = dynamicOutline.OriginalGlyphControlBounds;
                    glyphMeshData.dynamicOutline  = dynamicOutline;
                }
                _hintGlyphCollection.RegisterCachedGlyph(glyphIndex, glyphMeshData);
                //-----------------------------------
            }
            return(glyphMeshData);
        }
Esempio n. 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);
        }
        void SimulateQbliqueGlyph(GlyphMeshData orgGlyphMashData)
        {
            _temp1.Clear();
            PixelFarm.CpuBlit.VertexProcessing.VertexStoreTransformExtensions.TransformToVxs(_slantHorizontal, orgGlyphMashData.vxsStore, _temp1);
            //italic mesh data

            GlyphMeshData obliqueVersion = new GlyphMeshData();

            obliqueVersion.vxsStore = _temp1.CreateTrim();

            orgGlyphMashData._synthOblique = obliqueVersion;
        }
Esempio n. 5
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);
                DynamicOutline dynamicOutline = glyphMeshData.dynamicOutline;
                if (dynamicOutline != null)
                {
                    //TODO: review here aain
                    dynamicOutline.GenerateOutput(new ContourToGlyphTranslator(_tovxs), pxscale);
                    //version 3
                    using (Tools.BorrowVxs(out var v1))
                    {
                        _tovxs.WriteOutput(v1);
                        glyphMeshData.vxsStore = FlipGlyphUpward ? v1.CreateTrim(s_flipY) : v1.CreateTrim();
                    }
                }
                else
                {
                    using (Tools.BorrowVxs(out var v1))
                    {
                        _currentGlyphBuilder.ReadShapes(_tovxs);
                        _tovxs.WriteOutput(v1); //write to temp buffer first

                        //then
                        glyphMeshData.vxsStore = FlipGlyphUpward ? v1.CreateTrim(s_flipY) : v1.CreateTrim();
                    }
                }
            }


            if (SimulateOblique)
            {
                if (glyphMeshData._synthOblique == null)
                {
                    //create italic version
                    SimulateQbliqueGlyph(glyphMeshData);
                }
                return(glyphMeshData._synthOblique.vxsStore);
            }
            else
            {
                return(glyphMeshData.vxsStore);
            }
        }
Esempio n. 6
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);
            }
        }