Пример #1
0
 protected TPdfBaseTrueTypeFont(Font aFont, int aId, bool aCompress, bool aUseKerning, TPdfEmbeddedFont aEmbeddedData, FontStyle aAdditionalStyle, TPdfResources aResources) :
     base(aFont, aId, aUseKerning, aResources)
 {
     FCompress       = aCompress;
     EmbeddedData    = aEmbeddedData;
     FTrueTypeData   = aEmbeddedData.TrueTypeData;
     AdditionalStyle = aAdditionalStyle;
 }
Пример #2
0
        private void LoadFont(string path, byte[] b)
        {
            TTrueTypeInfo[] ttfs = TPdfTrueType.GetColection(b);

            foreach (TTrueTypeInfo ttf in ttfs)
            {
                //FFontList[MakeHash(ttf.FamilyName, GetStyle(ttf.SubFamilyName))]=path;
                FFontList[MakeHash(ttf.FamilyName, GetStyle(ttf.FontFlags))] = path;
            }
        }
Пример #3
0
 internal TPdfEmbeddedFont(bool Subset, TPdfTrueType aTrueTypeData)
 {
     ObjectId = -1;
     if (Subset)
     {
         SubsetCMap = new TGlyphMap();
         SubsetCMap.Add(0, 0);                //Standard missing glyph.
     }
     TrueTypeData = aTrueTypeData;
     AlreadySaved = false;
 }
Пример #4
0
        public TPdfEmbeddedFont Add(Font aFont, TFontEvents FontEvents, bool Subset, bool UseKerning, out FontStyle AdditionalStyle)
        {
            TPdfEmbeddedFont Result;

            //We can't search first for the font name, because 2 fonts with the same name might have different font files. (one might be a font file for italic or bold)
            //if (TryGetValue(aFont.Name, out Result)) return Result;

            byte[] FontData = LoadFont(aFont, FontEvents);

            TPdfTrueType TrueTypeData = new TPdfTrueType(FontData, aFont.Name, UseKerning);

            AdditionalStyle = FontStyle.Regular;
            FontStyle fs = TPsFontList.GetStyle(TrueTypeData.FontFlags);

            if (aFont.Italic && ((fs & FontStyle.Italic) == 0))
            {
                AdditionalStyle |= FontStyle.Italic;
            }
            if (aFont.Bold && ((fs & FontStyle.Bold) == 0))
            {
                AdditionalStyle |= FontStyle.Bold;
            }
            string FontFileName = TrueTypeData.UniqueFontName;

            if (Subset)
            {
                FontFileName = "1" + FontFileName;
            }
            else
            {
                FontFileName = "0" + FontFileName;                                                             //Fallback fonts are always subsetted. So we might have a non subsetted font and a subsetted font in the same file.
            }
            if (TryGetValue(FontFileName, out Result))
            {
                return(Result);
            }

            Result = new TPdfEmbeddedFont(Subset, TrueTypeData);

            this[FontFileName] = Result;
            return(Result);
        }