generated from bing/readnotes
85 lines
2.4 KiB
C++
85 lines
2.4 KiB
C++
#ifndef __GLYF_H__
|
|
#define __GLYF_H__
|
|
#include "../../../reader/reader.h"
|
|
#define ON_CURVE_POINT 0x01
|
|
#define X_SHORT_VECTOR 0x02
|
|
#define Y_SHORT_VECTOR 0x04
|
|
#define REPEAT_FLAG 0x08
|
|
#define X_IS_SAME_OR_POSITIVE_X_SHORT_VECTOR 0x10
|
|
#define Y_IS_SAME_OR_POSITIVE_X_SHORT_VECTOR 0x20
|
|
#define OVERLAP_SIMPLE 0x40
|
|
#define FLAG_Reserved 0x80
|
|
#define list_uint8 std::vector<uint8_t>
|
|
#define list_uint16 std::vector<uint16_t>
|
|
/*
|
|
header 其实是字形的边界框
|
|
*/
|
|
class GlyfTableHeader
|
|
{
|
|
private:
|
|
int16_t _numberOfContours; //非负数表示简单字形,负数表示复合字形
|
|
int16_t _xMin;
|
|
int16_t _yMin;
|
|
int16_t _xMax;
|
|
int16_t _yMax;
|
|
|
|
public:
|
|
GlyfTableHeader():_numberOfContours(0),_xMax(0),_yMax(0),_xMin(0),_yMin(0){};
|
|
~GlyfTableHeader(){};
|
|
GlyfTableHeader(reader* rd){read(rd);};
|
|
void read(reader*rd){
|
|
_numberOfContours = rd->readInt16();
|
|
_xMin = rd->readInt16();
|
|
_yMin = rd->readInt16();
|
|
_xMax = rd->readInt16();
|
|
_yMax = rd->readInt16();
|
|
}
|
|
int16_t numberOfContours(){return _numberOfContours;};
|
|
int16_t xMin(){return _xMin;};
|
|
int16_t yMin()const{return _yMin;};
|
|
int16_t xMax()const{return _xMax;};
|
|
int16_t yMax()const{return _yMax;};
|
|
};
|
|
//
|
|
class SimpleGlyfTable
|
|
{
|
|
private:
|
|
uint16_t _numOfContours;
|
|
list_uint16 _endPtsOfContours;
|
|
uint16_t _instructionLength;
|
|
list_uint8 _instructions;
|
|
list_uint8 _flags;
|
|
list_uint16 _xCoordinates;
|
|
list_uint16 _yCoordinates;
|
|
|
|
public:
|
|
SimpleGlyfTable() : _instructionLength(0), _numOfContours(0) {};
|
|
~SimpleGlyfTable() {};
|
|
SimpleGlyfTable(uint16_t numOfContours, reader *rd)
|
|
{
|
|
_numOfContours = numOfContours;
|
|
read(rd);
|
|
};
|
|
void read(reader *rd)
|
|
{
|
|
for (auto i = 0; i < _numOfContours; i++)
|
|
{
|
|
uint16_t n = rd->readUint16();
|
|
_endPtsOfContours.push_back(n);
|
|
}
|
|
_instructionLength = rd->readUint16();
|
|
for (auto i = 0; i < _instructionLength; i++)
|
|
{
|
|
uint8_t n = rd->readUint8();
|
|
_instructions.push_back(n);
|
|
}
|
|
};
|
|
list_uint16 endPtsOfContours() { return _endPtsOfContours; };
|
|
uint16_t instructionLength() { return _instructionLength; };
|
|
list_uint8 instructions() { return _instructions; };
|
|
list_uint8 flags() { return _flags; };
|
|
list_uint16 xCoordinates() { return _xCoordinates; };
|
|
list_uint16 yCoordinates() { return _yCoordinates; };
|
|
};
|
|
|
|
#endif |