예제 #1
0
        public GlyphPlanSequence Layout(GlyphLayout glyphLayout, TextBuffer buffer, int startAt, int len)
        {
            //this func get the raw char from buffer
            //and create glyph list
            //check if we have the string cache in specific value
            //---------
            if (len > _glyphPlanSeqSet.MaxCacheLen)
            {
                //layout string is too long to be cache
                //it need to split into small buffer
            }

            GlyphPlanSequence planSeq = GlyphPlanSequence.Empty;

            GlyphPlanSeqCollection seqCol = _glyphPlanSeqSet.GetSeqCollectionOrCreateIfNotExist(len);
            int hashValue = CalculateHash(buffer, startAt, len);

            if (!seqCol.TryGetCacheGlyphPlanSeq(hashValue, out planSeq))
            {
                ////not found then create glyph plan seq
                //bool useOutputScale = glyphLayout.UsePxScaleOnReadOutput;

                ////save
                //some font may have 'special' glyph x,y at some font size(eg. for subpixel-rendering position)
                //but in general we store the new glyph plan seq with unscale glyph pos
                //glyphLayout.UsePxScaleOnReadOutput = false;
                planSeq = CreateGlyphPlanSeq(glyphLayout, buffer, startAt, len);
                //glyphLayout.UsePxScaleOnReadOutput = useOutputScale;//restore
                seqCol.Register(hashValue, planSeq);
            }
            //---
            //on unscale font=> we use original
            return(planSeq);
        }
예제 #2
0
        public GlyphPlanSequence GetUnscaledGlyphPlanSequence(
            GlyphLayout glyphLayout,
            TextBuffer buffer, int start, int seqLen)
        {
            //UNSCALED VERSION
            //use current typeface + scriptlang
            int seqHashValue = CalculateHash(buffer, start, seqLen);

            //this func get the raw char from buffer
            //and create glyph list
            //check if we have the string cache in specific value
            //---------
            if (seqLen > _glyphPlanSeqSet.MaxCacheLen)
            {
                //layout string is too long to be cache
                //it need to split into small buffer
            }

            GlyphPlanSequence      planSeq = GlyphPlanSequence.Empty;
            GlyphPlanSeqCollection seqCol  = _glyphPlanSeqSet.GetSeqCollectionOrCreateIfNotExist(seqLen);

            if (!seqCol.TryGetCacheGlyphPlanSeq(seqHashValue, out planSeq))
            {
                //create a new one if we don't has a cache
                //1. layout
                glyphLayout.Layout(
                    buffer.UnsafeGetInternalBuffer(),
                    start,
                    seqLen);

                int pre_count = _reusableGlyphPlanList.Count;
                //create glyph-plan ( UnScaled version) and add it to planList

                glyphLayout.GenerateUnscaledGlyphPlans(_reusableGlyphPlanList);

                int post_count = _reusableGlyphPlanList.Count;
                planSeq = new GlyphPlanSequence(_reusableGlyphPlanList, pre_count, post_count - pre_count);
                //
                seqCol.Register(seqHashValue, planSeq);
            }
            return(planSeq);
        }