10 cm( inst, this,
"StreamFont_Subprovider" )
18 cm( inst, this,
"StreamFont" ),
25 [&]( std::istream & in )
32 void StreamFont::ReadAdvance(
Lex & lex )
53 Font::Variant StreamFont::ReadVariant(
Lex & lex )
55 lex.AcceptOperator(
"{" );
57 Font::Variant variant;
58 while( !lex.Failed() && !lex.IsNextOperator(
"}" ) )
60 if( lex.IsNextKeyword(
"texture" ) )
62 lex.AcceptKeyword(
"texture" );
63 std::string filename = lex.AcceptString();
71 lex.AcceptKeyword(
"glyph" );
72 glyph.code = lex.AcceptInteger();
73 glyph.pos_x = lex.AcceptInteger();
74 glyph.pos_y = lex.AcceptInteger();
75 glyph.width = lex.AcceptInteger();
76 glyph.height = lex.AcceptInteger();
77 glyph.bearing_x = lex.AcceptDouble();
78 glyph.bearing_y = lex.AcceptDouble();
80 variant.glyphs[ glyph.code ] = glyph;
84 lex.RecoverOperator(
"}" );
85 lex.AcceptOperator(
"}" );
90 void StreamFont::Load( std::istream & in )
93 lex.DefineKeyword(
"line_height" );
94 lex.DefineKeyword(
"ascender" );
95 lex.DefineKeyword(
"descender" );
96 lex.DefineKeyword(
"max_advance" );
97 lex.DefineKeyword(
"advance" );
98 lex.DefineKeyword(
"glyph" );
99 lex.DefineKeyword(
"variant" );
100 lex.DefineKeyword(
"msdf" );
101 lex.DefineKeyword(
"fixed" );
102 lex.DefineKeyword(
"texture" );
103 lex.DefineOperator(
"{" );
104 lex.DefineOperator(
"}" );
106 Lex_LogTrace _trace( lex );
110 while( !lex.Failed() && !lex.IsNext(
Lex::Eof ) )
112 if( lex.IsNextKeyword(
"line_height" ) )
114 lex.AcceptKeyword(
"line_height" );
117 else if( lex.IsNextKeyword(
"ascender" ) )
119 lex.AcceptKeyword(
"ascender" );
122 else if( lex.IsNextKeyword(
"descender" ) )
124 lex.AcceptKeyword(
"descender" );
127 else if( lex.IsNextKeyword(
"max_advance" ) )
129 lex.AcceptKeyword(
"max_advance" );
132 else if( lex.IsNextKeyword(
"advance" ) )
134 lex.AcceptKeyword(
"advance" );
135 this->ReadAdvance( lex );
139 lex.AcceptKeyword(
"variant" );
140 if( lex.IsNextKeyword(
"msdf" ) )
142 lex.AcceptKeyword(
"msdf" );
143 int size = lex.AcceptInteger();
144 Variant variant = this->ReadVariant( lex );
154 lex.AcceptKeyword(
"fixed" );
155 int size = lex.AcceptInteger();
156 Variant variant = this->ReadVariant( lex );