- Pango::FontDescription font (f);
- font.set_absolute_size (i->size_in_pixels (target.height) * PANGO_SCALE);
- if (i->italic ()) {
- font.set_style (Pango::STYLE_ITALIC);
- }
- layout->set_font_description (font);
- layout->set_text (i->text ());
-
- /* Compute fade factor */
- /* XXX */
- float fade_factor = 1;
-#if 0
- libdcp::Time now (time * 1000 / (4 * TIME_HZ));
- libdcp::Time end_fade_up = i->in() + i->fade_up_time ();
- libdcp::Time start_fade_down = i->out() - i->fade_down_time ();
- if (now < end_fade_up) {
- fade_factor = (now - i->in()) / i->fade_up_time();
- } else if (now > start_fade_down) {
- fade_factor = 1.0 - ((now - start_fade_down) / i->fade_down_time ());
- }
-#endif
-
- layout->update_from_cairo_context (context);
-
- /* Work out position */
-
- int const x = 0;
- int const y = calculate_position (i->v_align (), i->v_position (), target.height, (layout->get_baseline() / PANGO_SCALE) + top.get ());
-
- if (i->effect() == libdcp::SHADOW) {
- /* Drop-shadow effect */
- libdcp::Color const ec = i->effect_color ();
- context->set_source_rgba (float(ec.r) / 255, float(ec.g) / 255, float(ec.b) / 255, fade_factor);
- context->move_to (x + 4, y + 4);
- layout->add_to_cairo_context (context);
- context->fill ();
+ }
+
+ list<pair<boost::filesystem::path, string> >::const_iterator existing = fc_config_fonts.begin ();
+ while (existing != fc_config_fonts.end() && existing->first != font_file) {
+ ++existing;
+ }
+
+ string font_name;
+ if (existing != fc_config_fonts.end ()) {
+ font_name = existing->second;
+ } else {
+ /* Make this font available to DCP-o-matic */
+ FcConfigAppFontAddFile (fc_config, reinterpret_cast<FcChar8 const *> (font_file.string().c_str ()));
+
+ FcPattern* pattern = FcPatternBuild (0, FC_FILE, FcTypeString, font_file.string().c_str(), static_cast<char *> (0));
+ FcObjectSet* object_set = FcObjectSetBuild (FC_FAMILY, FC_STYLE, FC_LANG, FC_FILE, static_cast<char *> (0));
+ FcFontSet* font_set = FcFontList (fc_config, pattern, object_set);
+ if (font_set) {
+ for (int i = 0; i < font_set->nfont; ++i) {
+ FcPattern* font = font_set->fonts[i];
+ FcChar8* file;
+ FcChar8* family;
+ FcChar8* style;
+ if (
+ FcPatternGetString (font, FC_FILE, 0, &file) == FcResultMatch &&
+ FcPatternGetString (font, FC_FAMILY, 0, &family) == FcResultMatch &&
+ FcPatternGetString (font, FC_STYLE, 0, &style) == FcResultMatch
+ ) {
+ font_name = reinterpret_cast<char const *> (family);
+ }
+ }
+
+ FcFontSetDestroy (font_set);