LibreOffice Module vcl (master) 1
DirectFontSubstitution.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <unotools/fontdefs.hxx>
21
23
24#include <svdata.hxx>
25
26#include <string>
27#include <vector>
28
29namespace vcl::font
30{
31void DirectFontSubstitution::AddFontSubstitute(const OUString& rFontName,
32 const OUString& rSubstFontName,
34{
35 maFontSubstList.emplace_back(rFontName, rSubstFontName, nFlags);
36}
37
39
41 std::u16string_view rSearchName) const
42{
43 // TODO: get rid of O(N) searches
44 std::vector<FontSubstEntry>::const_iterator it = std::find_if(
45 maFontSubstList.begin(), maFontSubstList.end(), [&](const FontSubstEntry& s) {
46 return (s.mnFlags & AddFontSubstituteFlags::ALWAYS) && (s.maSearchName == rSearchName);
47 });
48 if (it != maFontSubstList.end())
49 {
50 rSubstName = it->maSearchReplaceName;
51 return true;
52 }
53 return false;
54}
55
56void ImplFontSubstitute(OUString& rFontName)
57{
58 // must be canonicalised
59 assert(GetEnglishSearchFontName(rFontName) == rFontName);
60 OUString aSubstFontName;
61 // apply user-configurable font replacement (eg, from the list in Tools->Options)
63 if (pSubst && pSubst->FindFontSubstitute(aSubstFontName, rFontName))
64 {
65 rFontName = aSubstFontName;
66 return;
67 }
68}
69}
70
71/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
AddFontSubstituteFlags
DirectFontSubstitution is for Tools->Options->FontReplacement and PsPrinter substitutions The class i...
void AddFontSubstitute(const OUString &rFontName, const OUString &rSubstName, AddFontSubstituteFlags nFlags)
std::vector< FontSubstEntry > maFontSubstList
bool FindFontSubstitute(OUString &rSubstName, std::u16string_view rFontName) const
UNOTOOLS_DLLPUBLIC OUString GetEnglishSearchFontName(std::u16string_view rName)
A PhysicalFontFaceCollection is created by a PhysicalFontCollection and becomes invalid when original...
void ImplFontSubstitute(OUString &rFontName)
ImplSVGDIData maGDIData
Definition: svdata.hxx:401
vcl::font::DirectFontSubstitution * mpDirectFontSubst
Definition: svdata.hxx:232
ImplSVData * ImplGetSVData()
Definition: svdata.cxx:76