예제 #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);
        }
예제 #2
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));
        }