Exemple #1
0
        public override bool AddChar(int code, int FallbackLevel)
        {
            bool Result = FTrueTypeData.HasGlyph(code);

            if (!Result)
            {
                TPdfFont Fallbk = FallbackFont(FallbackLevel);
                if (Fallbk != null)
                {
                    if (Fallbk.AddChar(code, FallbackLevel + 1))
                    {
                        return(true);
                    }
                }
            }

            if (Result || FallbackLevel == 0)
            {
                int ccode   = FTrueTypeData.Glyph(code, true);
                int newcode = EmbeddedData.GetNewGlyphFromOldGlyph(ccode);
                UsedChars.Add((char)newcode, FTrueTypeData.GlyphWidth(ccode));
                ToUnicodeData.Add(newcode, (int)code);
            }

            return(Result);
        }
Exemple #2
0
 public override TKernedString[] KernString(string s)
 {
     int[] b = new int[s.Length];
     for (int i = 0; i < b.Length; i++)
     {
         b[i] = FTrueTypeData.Glyph(s[i], false);
     }
     return(FTrueTypeData.KernString(s, b));
 }
Exemple #3
0
        internal override byte[] EncodeString(string s)
        {
            byte[] Result = new byte[2 * s.Length];
            for (int i = 0; i < s.Length; i++)
            {
                int gl = FTrueTypeData.Glyph((int)s[i], true);
                MotorolaSetWord(Result, i * 2, EmbeddedData.GetNewGlyphFromOldGlyph(gl));
            }

            return(Result);
        }
Exemple #4
0
        public override TKernedString[] KernString(string s)
        {
            //Here we don't have chars > 255, so there are no unicode surrogates.
            int[] bi = new int[s.Length];
            for (int i = 0; i < s.Length; i++)
            {
                bi[i] = FTrueTypeData.Glyph(s[i], false);
            }

            return(FTrueTypeData.KernString(s, bi));
        }
Exemple #5
0
        public override real MeasureString(string s)
        {
            real Result = 0;

            int[]  b      = new int[s.Length];
            bool[] ignore = new bool[s.Length];
            for (int i = 0; i < b.Length; i++)
            {
                TPdfFont f = Fallback(s[i], 0);
                if (f != this && f != null)
                {
                    Result   += f.MeasureString(new String(s[i], 1));
                    ignore[i] = true;
                    b[i]      = 0;
                }
                else
                {
                    b[i] = FTrueTypeData.Glyph(s[i], true);
                }
            }
            return(Result + FTrueTypeData.MeasureString(b, ignore));
        }
Exemple #6
0
        public override real MeasureString(string s)
        {
            real Result = 0;

            //Here we don't have chars > 255, so there are no unicode surrogates.
            int[]  bi     = new int[s.Length];
            bool[] ignore = new bool[s.Length];
            for (int i = 0; i < s.Length; i++)
            {
                TPdfFont f = Fallback(s[i], 0);
                if (f != this && f != null)
                {
                    Result   += f.MeasureString(new String(s[i], 1));
                    ignore[i] = true;
                    bi[i]     = 0;
                }
                else
                {
                    bi[i] = FTrueTypeData.Glyph(s[i], true);                  //This returns the Glyph for an unicode character, so s[i] is ok. (s is unicode)
                }
            }

            return(Result + FTrueTypeData.MeasureString(bi, ignore));
        }
Exemple #7
0
        private void SaveWidths(TPdfStream DataStream)
        {
            //Docs say it is prefered to save as indirect object, but acrobat writes it directly.
            //Widths object.
            TPdfBaseRecord.WriteLine(DataStream, TPdfTokens.GetString(TPdfToken.WidthsName) + " " + TPdfTokens.GetString(TPdfToken.OpenArray));
            int fc = FirstChar; if (fc < 0)

            {
                fc = 0;
            }

            for (int i = fc; i <= LastChar; i++)         //characters on winansi are NOT the same as in low byte unicode.  For example char 0x92 (146) is a typographic ' in winansi, not defined in unicode.
            {
                int z = (int)CharUtils.GetUniFromWin1252_PDF((byte)i);
                TPdfBaseRecord.WriteLine(DataStream, PdfConv.CoordsToString(Math.Round(FTrueTypeData.GlyphWidth(FTrueTypeData.Glyph(z, false)))));                 //don't log the erorr here, character doesn't need to exist.
            }

            TPdfBaseRecord.WriteLine(DataStream, TPdfTokens.GetString(TPdfToken.CloseArray));
        }