コード例 #1
0
ファイル: GlyphIndices.cs プロジェクト: adkhan2002/PdfSharp
        /// <summary>
        /// Evaluates how complex the GlyphMapping is.
        /// </summary>
        GlyphIndicesComplexity CalcGlyphIndicesComplexity()
        {
            GlyphIndicesComplexity result = GlyphIndicesComplexity.None;
            int count = this.glyphMapping != null ? this.glyphMapping.Length : 0;

            for (int idx = 0; idx < count; idx++)
            {
                GlyphMapping gm = this.glyphMapping[idx];

                if (gm.ClusterCodeUnitCount > 1 || gm.ClusterGlyphCount > 1)
                {
                    // Max. complexity -> break
                    result = GlyphIndicesComplexity.ClusterMapping;
                    break;
                }

                if (gm.GlyphIndex != -1 && (int)result < (int)GlyphIndicesComplexity.GlyphIndicesAndDistanceOnly)
                {
                    result = GlyphIndicesComplexity.GlyphIndicesAndDistanceOnly;
                    continue;
                }
                if ((int)result < (int)GlyphIndicesComplexity.GlyphIndicesAndDistanceOnly)
                {
                    if (!DoubleUtil.IsNaN(gm.AdvanceWidth) || !DoubleUtil.IsNaN(gm.UOffset) || !DoubleUtil.IsNaN(gm.VOffset))
                    {
                        result = GlyphIndicesComplexity.DistanceOnly;
                        continue;
                    }
                }
            }
            return(result);
        }
コード例 #2
0
        // ...on the way to handle Indices...
        private void WriteGlyphsInternal(Glyphs glyphs, string text)
        {
            GlyphIndicesComplexity complexity = GlyphIndicesComplexity.None;

            if (glyphs.Indices != null)
            {
                complexity = glyphs.Indices.Complexity;
            }
            complexity = GlyphIndicesComplexity.ClusterMapping;
            switch (complexity)
            {
            case GlyphIndicesComplexity.None:
                break;

            case GlyphIndicesComplexity.DistanceOnly:
                WriteGlyphs_DistanceOnly(glyphs);
                break;

            case GlyphIndicesComplexity.GlyphIndicesAndDistanceOnly:
                break;

            case GlyphIndicesComplexity.ClusterMapping:
                WriteGlyphs_ClusterMapping(glyphs);
                break;
            }
        }