📄 ttf.txt
字号:
~TtfContour();
void Setup(int *x, int *y, uchar *Flags, int MinX, int MinY);
bool Create(int Pts, double XScale, double YScale);
bool RasterX(int Size, DataList *List);
bool RasterY(int Size, DataList *List);
void DebugDraw(GSurface *pDC, int Sx, int Sy);
};
class LgiClass TtfGlyph : public TtfObj {
int Points;
uchar *Temp;
public:
TtfGlyph();
~TtfGlyph();
short Contours; // If the number of contours is greater than or equal to zero,
// this is a single glyph, if negative, this is a composite glyph.
TTF_FWORD xMin; // Minimum x for coordinate data.
TTF_FWORD yMin; // Minimum y for coordinate data.
TTF_FWORD xMax; // Maximum x for coordinate data.
TTF_FWORD yMax; // Maximum y for coordinate data.
// simple glyph
ushort *EndPtsOfContours; // Array of last points of each contour; n is the number of contours.
ushort InstructionLength; // Total number of bytes for instructions.
uchar *Instructions; // Array of instructions for each glyph; n is the number of instructions.
uchar *Flags; // Array of flags for each coordinate in outline; n is the number of flags.
int *X; // First coordinates relative to (0,0)
int *Y; // others are relative to previous point.
// complex glyph
// yeah right... later i think... maybe
int GetX() { return xMax - xMin; }
int GetY() { return yMax - yMin; }
bool Read(GFile &F);
bool Write(GFile &F);
void Dump();
void Draw(GSurface *pDC, int x, int y, int Scale);
int DrawEm(GSurface *pDC, int X, int Y, int EmUnits, double PixelsPerEm);
bool Rasterize( GSurface *pDC,
GRect *pDest,
double xppem,
double yppem,
int BaseLine);
};
class LgiClass TtfMap {
public:
TtfMap() {}
virtual ~TtfMap() {}
virtual int operator[](int i) { return 0; }
virtual bool Read(GFile &F) { return FALSE; }
virtual bool Write(GFile &F) { return FALSE; }
virtual void Dump() {}
};
class LgiClass TtfCMapTable {
public:
TtfCMapTable();
~TtfCMapTable();
ushort PlatformID;
ushort EncodingID;
ulong Offset;
ushort Format;
TtfMap *Map;
bool Read(GFile &F);
bool Write(GFile &F);
void Dump();
};
class LgiClass TtfCMapByteEnc : public TtfMap {
ushort Format; // set to 0
ushort Length; // length in bytes of the subtable
ushort Version;
uchar Map[256];
public:
int operator[](int i);
bool Read(GFile &F);
bool Write(GFile &F);
void Dump();
};
class LgiClass TtfCMapHighByte : public TtfMap {
class SubHeader {
public:
ushort FirstCode; // First valid low byte for this subHeader
ushort EntryCount; // Number of valid low bytes for this subHeader
short IdDelta;
ushort IdRangeOffset;
};
ushort Format; // set to 2
ushort Length;
ushort Version;
ushort subHeaderKeys[256]; // Array that maps high bytes to subHeaders:
// value is subHeader index * 8.
SubHeader *Header;
ushort *GlyphIndexArray;
public:
int operator[](int i) { return 0; }
bool Read(GFile &F) { return FALSE; }
bool Write(GFile &F) { return FALSE; }
void Dump() {}
};
class LgiClass TtfCMapSegDelta : public TtfMap {
int SegCount;
int IdCount;
ushort Format; // set to 4
ushort Length;
ushort Version;
ushort SegCountX2; // 2 x segCount.
ushort SearchRange; // 2 x (2**floor(log2(segCount)))
ushort EntrySelector; // log2(searchRange/2)
ushort RangeShift; // 2 x segCount - searchRange
ushort *EndCount; // End characterCode for each segment,last =0xFFFF.
ushort *StartCount; // Start character code for each segment.
short *IdDelta; // Delta for all character codes in segment.
ushort *IdRangeOffset; // Offsets into glyphIdArray or 0
// the GlyphIdArray is appended to the
// end of the IdRangeOffset array
public:
TtfCMapSegDelta();
~TtfCMapSegDelta();
int operator[](int i);
bool Read(GFile &F);
bool Write(GFile &F);
void Dump();
};
class LgiClass TtfCMap : public TtfObj {
TtfMap *Fravorite;
public:
ushort Version;
ushort Tables;
TtfCMapTable *Table;
TtfCMap();
~TtfCMap();
int operator[](int i) { return (Fravorite) ? (*Fravorite)[i] : 0; }
bool Read(GFile &F);
bool Write(GFile &F);
void Dump();
};
class LgiClass TtfRaster : public TtfObj {
friend class GSurface;
int XPixelsPerEm;
int YPixelsPerEm;
int Glyphs;
public:
int *BaseLine; // pixels down to baseline in bitmap
GRect *pSource; // where glyph is stored in the bitmap
GSurface *pDC; // the bitmap
TtfRaster();
~TtfRaster();
double GetXPixelsPerEm() { return XPixelsPerEm; }
double GetYPixelsPerEm() { return YPixelsPerEm; }
bool Rasterize(double xPPEm, double yPPEm, int OverSample);
int DrawChar(GSurface *pDC, int x, int y, int Char);
};
class LgiClass GdcTtf : public GTypeFace {
friend class TtfObj;
protected:
int Tables;
TtfTable *TableList;
TtfTable *FindTag(char *t);
TtfTable *SeekTag(char *t, GFile *F);
TtfHeader Header;
TtfMaxProfile Profile;
TtfLocation Location;
TtfGlyph **Glyph;
TtfCMap Map;
int Rasters;
TtfRaster **Raster;
TtfRaster *FindRaster(int Point, int XDpi = 96, int YDpi = -1);
public:
GdcTtf();
virtual ~GdcTtf();
virtual bool Load(GFile &F);
virtual bool Save(GFile &F);
virtual bool Rasterize( int Point,
int StyleFlags,
int OverSample = 2,
int XDpi = 96,
int YDpi = -1);
void Test(GSurface *pDC);
virtual void Size(int *x, int *y, char *Str, int Len = -1, int Flags = 0);
int X(char *Str, int Len = -1, int Flags = 0);
int Y(char *Str, int Len = -1, int Flags = 0);
// Text drawing functions
virtual bool SelectPoint(int Pt) { return FALSE; }
virtual void Text(GSurface *pDC, int x, int y, char *Str, int Len = -1);
};
#define LFONT_LIGHT FW_LIGHT
#define LFONT_NORMAL FW_NORMAL
#define LFONT_BOLD FW_BOLD
class LgiClass GFont : public GdcTtf {
HFONT hFont;
float *Widths;
void SetWidths();
public:
GFont();
~GFont();
HFONT Handle() { return hFont; }
bool Load(GFile &F) { return TRUE; }
bool Save(GFile &F) { return FALSE; }
bool Create(char *Face,
int Height,
int Width = 0,
int Weight = LFONT_NORMAL,
uint32 Italic = false,
uint32 Underline = false,
uint32 StrikeOut = false,
uint32 CharSet = ANSI_CHARSET,
int Escapement = 0,
int Orientation = 0,
uint32 OutputPrecision = OUT_DEFAULT_PRECIS,
uint32 ClipPrecision = CLIP_DEFAULT_PRECIS,
uint32 Quality = ANTIALIASED_QUALITY,
uint32 PitchAndFamily = DEFAULT_PITCH);
bool CreateFont(LOGFONT *LogFont);
void Text( GSurface *pDC,
int x, int y,
char *Str,
int Len = -1,
GRect *r = NULL); // ASCII version
void Size(int *x, int *y, char *Str, int Len = -1, int Flags = 0);
int CharAt(int x, char *Str, int Len = -1);
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -