Skip to content

Commit

Permalink
ass: use libass supported path. No fonts dir if font file is set
Browse files Browse the repository at this point in the history
if ass_set_fonts_dir is called, libass will scan fonts and it's slow
  • Loading branch information
wang-bin committed Apr 29, 2016
1 parent 1fa799d commit 517776b
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/subtitle/SubtitleProcessorLibASS.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/******************************************************************************
QtAV: Media play library based on Qt and LibASS
Copyright (C) 2014-2016 Wang Bin <[email protected]>
QtAV: Multimedia framework based on Qt and LibASS
Copyright (C) 2012-2016 Wang Bin <[email protected]>
* This file is part of QtAV
* This file is part of QtAV (from 2014)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -570,16 +570,17 @@ void SubtitleProcessorLibASS::updateFontCache()
family = QByteArrayLiteral("Arial");
}
// prefer user settings
const QString kFont = font_file.isEmpty() ? sFont : font_file;
const QString kFontsDir = fonts_dir.isEmpty() ? sFontsDir : fonts_dir;
const QString kFont = font_file.isEmpty() ? sFont : Internal::Path::toLocal(font_file);
const QString kFontsDir = fonts_dir.isEmpty() ? sFontsDir : Internal::Path::toLocal(fonts_dir);
qDebug() << "font file: " << kFont << "; fonts dir: " << kFontsDir;
// setup libass
#ifdef Q_OS_WINRT
if (!kFontsDir.isEmpty())
qDebug("BUG: winrt libass set a valid fonts dir results in crash. skip fonts dir setup.");
#else
// will call strdup, so safe to use temp array .toUtf8().constData()
ass_set_fonts_dir(m_ass, kFontsDir.isEmpty() ? 0 : kFontsDir.toUtf8().constData()); // look up fonts in fonts dir can be slow. force font file to skip lookup
if (!force_font_file || (!font_file.isEmpty() && !QFile::exists(kFont)))
ass_set_fonts_dir(m_ass, kFontsDir.isEmpty() ? 0 : kFontsDir.toUtf8().constData()); // look up fonts in fonts dir can be slow. force font file to skip lookup
#endif
/* ass_set_fonts:
* fc/dfp=false(auto font provider): Prefer font provider to find a font(FC needs fonts.conf) in font_dir, or provider's configuration. If failed, try the given font
Expand Down

0 comments on commit 517776b

Please sign in to comment.