- // Read style-file
- string const real_file = libFileSearch("layouts", name_, "layout");
- loaded_ = const_cast<LyXTextClass*>(this)->read(real_file) == 0;
+ // Read style-file, provided path is searched before the system ones
+ FileName layout_file;
+ if (!path.empty())
+ layout_file = FileName(addName(path, name_ + ".layout"));
+ if (layout_file.empty() || !fs::exists(layout_file.toFilesystemEncoding()))
+ layout_file = libFileSearch("layouts", name_, "layout");
+ loaded_ = const_cast<LyXTextClass*>(this)->read(layout_file) == 0;