Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-11 10:26:10

0001 //========================================================================
0002 //
0003 // SplashFont.h
0004 //
0005 //========================================================================
0006 
0007 //========================================================================
0008 //
0009 // Modified under the Poppler project - http://poppler.freedesktop.org
0010 //
0011 // All changes made under the Poppler project to this file are licensed
0012 // under GPL version 2 or later
0013 //
0014 // Copyright (C) 2007-2008, 2018, 2019 Albert Astals Cid <aacid@kde.org>
0015 // Copyright (C) 2018 Oliver Sander <oliver.sander@tu-dresden.de>
0016 //
0017 // To see a description of the changes please see the Changelog file that
0018 // came with your tarball or type make ChangeLog if you are building from git
0019 //
0020 //========================================================================
0021 
0022 #ifndef SPLASHFONT_H
0023 #define SPLASHFONT_H
0024 
0025 #include "SplashTypes.h"
0026 #include "SplashClip.h"
0027 
0028 struct SplashGlyphBitmap;
0029 struct SplashFontCacheTag;
0030 class SplashFontFile;
0031 class SplashPath;
0032 
0033 //------------------------------------------------------------------------
0034 
0035 // Fractional positioning uses this many bits to the right of the
0036 // decimal points.
0037 #define splashFontFractionBits 2
0038 #define splashFontFraction (1 << splashFontFractionBits)
0039 #define splashFontFractionMul ((SplashCoord)1 / (SplashCoord)splashFontFraction)
0040 
0041 //------------------------------------------------------------------------
0042 // SplashFont
0043 //------------------------------------------------------------------------
0044 
0045 class SplashFont
0046 {
0047 public:
0048     SplashFont(SplashFontFile *fontFileA, const SplashCoord *matA, const SplashCoord *textMatA, bool aaA);
0049 
0050     // This must be called after the constructor, so that the subclass
0051     // constructor has a chance to compute the bbox.
0052     void initCache();
0053 
0054     virtual ~SplashFont();
0055 
0056     SplashFont(const SplashFont &) = delete;
0057     SplashFont &operator=(const SplashFont &) = delete;
0058 
0059     SplashFontFile *getFontFile() { return fontFile; }
0060 
0061     // Return true if <this> matches the specified font file and matrix.
0062     bool matches(SplashFontFile *fontFileA, const SplashCoord *matA, const SplashCoord *textMatA) const
0063     {
0064         return fontFileA == fontFile && matA[0] == mat[0] && matA[1] == mat[1] && matA[2] == mat[2] && matA[3] == mat[3] && textMatA[0] == textMat[0] && textMatA[1] == textMat[1] && textMatA[2] == textMat[2] && textMatA[3] == textMat[3];
0065     }
0066 
0067     // Get a glyph - this does a cache lookup first, and if not found,
0068     // creates a new bitmap and adds it to the cache.  The <xFrac> and
0069     // <yFrac> values are splashFontFractionBits bits each, representing
0070     // the numerators of fractions in [0, 1), where the denominator is
0071     // splashFontFraction = 1 << splashFontFractionBits.  Subclasses
0072     // should override this to zero out xFrac and/or yFrac if they don't
0073     // support fractional coordinates.
0074     virtual bool getGlyph(int c, int xFrac, int yFrac, SplashGlyphBitmap *bitmap, int x0, int y0, SplashClip *clip, SplashClipResult *clipRes);
0075 
0076     // Rasterize a glyph.  The <xFrac> and <yFrac> values are the same
0077     // as described for getGlyph.
0078     virtual bool makeGlyph(int c, int xFrac, int yFrac, SplashGlyphBitmap *bitmap, int x0, int y0, SplashClip *clip, SplashClipResult *clipRes) = 0;
0079 
0080     // Return the path for a glyph.
0081     virtual SplashPath *getGlyphPath(int c) = 0;
0082 
0083     // Return the advance of a glyph. (in 0..1 range)
0084     // < 0 means not known
0085     virtual double getGlyphAdvance(int c) { return -1; }
0086 
0087     // Return the font transform matrix.
0088     SplashCoord *getMatrix() { return mat; }
0089 
0090     // Return the glyph bounding box.
0091     void getBBox(int *xMinA, int *yMinA, int *xMaxA, int *yMaxA)
0092     {
0093         *xMinA = xMin;
0094         *yMinA = yMin;
0095         *xMaxA = xMax;
0096         *yMaxA = yMax;
0097     }
0098 
0099 protected:
0100     SplashFontFile *fontFile;
0101     SplashCoord mat[4]; // font transform matrix
0102                         //   (text space -> device space)
0103     SplashCoord textMat[4]; // text transform matrix
0104                             //   (text space -> user space)
0105     bool aa; // anti-aliasing
0106     int xMin, yMin, xMax, yMax; // glyph bounding box
0107     unsigned char *cache; // glyph bitmap cache
0108     SplashFontCacheTag * // cache tags
0109             cacheTags;
0110     int glyphW, glyphH; // size of glyph bitmaps
0111     int glyphSize; // size of glyph bitmaps, in bytes
0112     int cacheSets; // number of sets in cache
0113     int cacheAssoc; // cache associativity (glyphs per set)
0114 };
0115 
0116 #endif