X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Ffont_id_allocator.cc;h=5263e7f9087525c02e8485f26f5a8330d98a7784;hb=db22f81ccce9e1a5f205e6d8b3c0631fc039a173;hp=c566c3676c956f9685f92d455e5261cfabfc2ce9;hpb=7a301e22de2a3c47a81ebc4c9f19b68131b482aa;p=dcpomatic.git diff --git a/src/lib/font_id_allocator.cc b/src/lib/font_id_allocator.cc index c566c3676..5263e7f90 100644 --- a/src/lib/font_id_allocator.cc +++ b/src/lib/font_id_allocator.cc @@ -64,17 +64,19 @@ void FontIDAllocator::add_fonts_from_asset(int reel_index, shared_ptr asset) { for (auto const& font: asset->font_data()) { - _map[Font(reel_index, asset->id(), font.first)] = 0; + add_font(reel_index, asset->id(), font.first); } - - _map[Font(reel_index, asset->id(), "")] = 0; } void FontIDAllocator::add_font(int reel_index, string asset_id, string font_id) { - _map[Font(reel_index, asset_id, font_id)] = 0; + auto font = Font(reel_index, asset_id, font_id); + if (!_default_font) { + _default_font = font; + } + _map[font] = 0; } @@ -119,3 +121,13 @@ FontIDAllocator::font_id(int reel_index, string asset_id, string font_id) const return String::compose("%1_%2", iter->second, font_id); } + +string +FontIDAllocator::default_font_id() const +{ + if (_default_font) { + return font_id(_default_font->reel_index, _default_font->asset_id, _default_font->font_id); + } + + return "default"; +}