@@ -158,68 +158,72 @@ void MacFontManager::loadFonts() {
158
158
for (Common::ArchiveMemberList::iterator it = list.begin (); it != list.end (); ++it) {
159
159
Common::SeekableReadStream *stream = dat->createReadStreamForMember ((*it)->getName ());
160
160
161
- Common::MacResManager *fontFile = new Common::MacResManager ();
161
+ loadFontsFromStream (stream);
162
+ }
162
163
163
- if (!fontFile->loadFromMacBinary (*stream))
164
- continue ;
164
+ _builtInFonts = false ;
165
165
166
- Common::MacResIDArray fonds = fontFile->getResIDArray (MKTAG (' F' ,' O' ,' N' ,' D' ));
167
- if (fonds.size () > 0 ) {
168
- for (Common::Array<uint16>::iterator iterator = fonds.begin (); iterator != fonds.end (); ++iterator) {
169
- Common::SeekableReadStream *fond = fontFile->getResource (MKTAG (' F' , ' O' , ' N' , ' D' ), *iterator);
166
+ delete dat;
167
+ }
170
168
171
- Common::String familyName = fontFile->getResName (MKTAG (' F' , ' O' , ' N' , ' D' ), *iterator);
169
+ void MacFontManager::loadFontsFromStream (Common::SeekableReadStream *stream) {
170
+ Common::MacResManager *fontFile = new Common::MacResManager ();
172
171
173
- Graphics::MacFontFamily *fontFamily = new MacFontFamily ();
174
- fontFamily-> load (*fond) ;
172
+ if (!fontFile-> loadFromMacBinary (*stream))
173
+ return ;
175
174
176
- Common::Array<Graphics::MacFontFamily::AsscEntry> *assoc = fontFamily->getAssocTable ();
175
+ Common::MacResIDArray fonds = fontFile->getResIDArray (MKTAG (' F' ,' O' ,' N' ,' D' ));
176
+ if (fonds.size () > 0 ) {
177
+ for (Common::Array<uint16>::iterator iterator = fonds.begin (); iterator != fonds.end (); ++iterator) {
178
+ Common::SeekableReadStream *fond = fontFile->getResource (MKTAG (' F' , ' O' , ' N' , ' D' ), *iterator);
177
179
178
- for (uint i = 0 ; i < assoc->size (); i++) {
179
- debug (" size: %d style: %d id: %d" , (*assoc)[i]._fontSize , (*assoc)[i]._fontStyle ,
180
- (*assoc)[i]._fontID );
180
+ Common::String familyName = fontFile->getResName (MKTAG (' F' , ' O' , ' N' , ' D' ), *iterator);
181
181
182
- Common::SeekableReadStream *fontstream;
183
- MacFont *macfont;
184
- Graphics::MacFONTFont *font;
182
+ Graphics::MacFontFamily *fontFamily = new MacFontFamily ();
183
+ fontFamily->load (*fond);
185
184
186
- fontstream = fontFile-> getResource ( MKTAG ( ' N ' , ' F ' , ' N ' , ' T ' ), (*assoc)[i]. _fontID );
185
+ Common::Array<Graphics::MacFontFamily::AsscEntry> *assoc = fontFamily-> getAssocTable ( );
187
186
188
- if (!fontstream)
189
- fontstream = fontFile->getResource (MKTAG (' F' , ' O' , ' N' , ' T' ), (*assoc)[i]._fontID );
187
+ for (uint i = 0 ; i < assoc->size (); i++) {
188
+ debug (" size: %d style: %d id: %d" , (*assoc)[i]._fontSize , (*assoc)[i]._fontStyle ,
189
+ (*assoc)[i]._fontID );
190
190
191
- if (!fontstream) {
192
- warning (" Unknown FontId: %d" , (*assoc)[i]._fontID );
191
+ Common::SeekableReadStream *fontstream;
192
+ MacFont *macfont;
193
+ Graphics::MacFONTFont *font;
193
194
194
- continue ;
195
- }
195
+ fontstream = fontFile->getResource (MKTAG (' N' , ' F' , ' N' , ' T' ), (*assoc)[i]._fontID );
196
196
197
- font = new Graphics::MacFONTFont;
198
- font-> loadFont (*fontstream, fontFamily, (*assoc)[i]. _fontSize , (*assoc)[i]._fontStyle );
197
+ if (!fontstream)
198
+ fontstream = fontFile-> getResource ( MKTAG ( ' F ' , ' O ' , ' N ' , ' T ' ) , (*assoc)[i]._fontID );
199
199
200
- delete fontstream;
200
+ if (!fontstream) {
201
+ warning (" Unknown FontId: %d" , (*assoc)[i]._fontID );
201
202
202
- Common::String fontName = Common::String::format (" %s-%d-%d" , familyName.c_str (), (*assoc)[i]._fontStyle , (*assoc)[i]._fontSize );
203
+ continue ;
204
+ }
203
205
204
- macfont = new MacFont (_fontNames.getVal (familyName, kMacFontNonStandard ), (*assoc)[i]._fontSize , (*assoc)[i]._fontStyle );
206
+ font = new Graphics::MacFONTFont;
207
+ font->loadFont (*fontstream, fontFamily, (*assoc)[i]._fontSize , (*assoc)[i]._fontStyle );
205
208
206
- FontMan.assignFontToName (fontName, font);
207
- macfont->setFont (font);
208
- _fontRegistry.setVal (fontName, macfont);
209
+ delete fontstream;
209
210
210
- debug (2 , " %s" , fontName.c_str ());
211
- }
211
+ Common::String fontName = Common::String::format (" %s-%d-%d" , familyName.c_str (), (*assoc)[i]._fontStyle , (*assoc)[i]._fontSize );
212
212
213
- delete fond;
213
+ macfont = new MacFont (_fontNames.getVal (familyName, kMacFontNonStandard ), (*assoc)[i]._fontSize , (*assoc)[i]._fontStyle );
214
+
215
+ FontMan.assignFontToName (fontName, font);
216
+ macfont->setFont (font);
217
+ _fontRegistry.setVal (fontName, macfont);
218
+
219
+ debug (2 , " %s" , fontName.c_str ());
214
220
}
215
- }
216
221
217
- delete fontFile;
222
+ delete fond;
223
+ }
218
224
}
219
225
220
- _builtInFonts = false ;
221
-
222
- delete dat;
226
+ delete fontFile;
223
227
}
224
228
225
229
const Font *MacFontManager::getFont (MacFont macFont) {
0 commit comments