-
Notifications
You must be signed in to change notification settings - Fork 0
/
DefineFont.cpp
72 lines (55 loc) · 1.52 KB
/
DefineFont.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include "DefineFont.h"
DefineFont::DefineFont(void)
{
nGlyphs=0;
}
DefineFont::~DefineFont(void)
{
OffsetTable.clear();
GlyphShapeTable.clear();
}
void DefineFont::ReadData(SWFReader *swf, int l){
printf(" DefineFont\n");
this->FontID = swf->ReadUI16();
printf(" FontID = %d\n", FontID);
UInt16 nFirstOffset = swf->ReadUI16();
this->nGlyphs = nFirstOffset/2;
printf(" Number of glyphs = %d\n", nGlyphs);
this->OffsetTable.push_back(nFirstOffset);
for(int i=1; i<nGlyphs; i++){
this->OffsetTable.push_back( swf->ReadUI16() );
}
for(int i=0; i<nGlyphs; i++){
DefineShape *shape = new DefineShape();
shape->ReadData(swf,0);// 0 means unknown
this->GlyphShapeTable.push_back(*shape);
}
}
void DefineFont::WriteData(SWFWriter *swf, int l){
printf(" DefineFont\n");
swf->WriteUI16(this->FontID);
printf(" FontID = %d\n", FontID);
list<UInt16>::iterator i;;
list<DefineShape>::iterator j;
for(i=OffsetTable.begin(); i!=OffsetTable.end(); ++i){
swf->WriteUI16( (*i) );
}
for(j=GlyphShapeTable.begin(); j!=GlyphShapeTable.end(); ++j){
(*j).WriteData(swf, (*j).GetLength());
}
}
ulong DefineFont::GetLength(void){
return this->length;
}
void DefineFont::SetLength(ulong len){
this->length = len;
}
UInt16 DefineFont::GetCharacterID(){
return FontID;
}
void DefineFont::SetCharacterID(UInt16 IdNew){
FontID = IdNew;
}
void DefineFont::IncreaseCharacterID(UInt16 nAmount) {
SetCharacterID( GetCharacterID()+nAmount );
}