/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
static ImplFontAttrs lcl_IsCJKFont( std::u16string_view rFontName )
{ // Test, if Fontname includes CJK characters --> In this case we // mention that it is a CJK font for (const sal_Unicode& ch : rFontName)
{ // japanese if ( ((ch >= 0x3040) && (ch <= 0x30FF)) ||
((ch >= 0x3190) && (ch <= 0x319F)) ) return ImplFontAttrs::CJK|ImplFontAttrs::CJK_JP;
// add the new physical font face, replacing existing font face if necessary // TODO: get rid of linear search? auto it(maFontFaces.begin()); for (; it != maFontFaces.end(); ++it)
{
PhysicalFontFace* pFoundFontFace = it->get();
sal_Int32 eComp = pNewFontFace->CompareIgnoreSize( *pFoundFontFace ); if( eComp > 0 ) continue; if( eComp < 0 ) break;
// ignore duplicate if its quality is worse if( pNewFontFace->GetQuality() < pFoundFontFace->GetQuality() ) return;
// keep the device font if its quality is good enough if( pNewFontFace->GetQuality() == pFoundFontFace->GetQuality() ) return;
// replace existing font face with a better one
*it = pNewFontFace; // insert at sort position return;
}
maFontFaces.emplace(it, pNewFontFace); // insert at sort position
}
// get font attributes using the normalized font family name void PhysicalFontFamily::InitMatchData( const utl::FontSubstConfiguration& rFontSubst, const OUString& rSearchName )
{
OUString aShortName;
OUString aMatchFamilyName(maMatchFamilyName); // get font attributes from the decorated font name
utl::FontSubstConfiguration::getMapName( rSearchName, aShortName, aMatchFamilyName,
meMatchWeight, meMatchWidth, mnMatchType );
maMatchFamilyName = aMatchFamilyName; const utl::FontNameAttr* pFontAttr = rFontSubst.getSubstInfo( rSearchName ); // eventually use the stripped name if( !pFontAttr ) if( aShortName != rSearchName )
pFontAttr = rFontSubst.getSubstInfo( aShortName );
CalcType( mnMatchType, meMatchWeight, meMatchWidth, meFamily, pFontAttr );
mnMatchType |= lcl_IsCJKFont( maFamilyName );
}
// update device font list with unique font faces, with uniqueness // meaning different font attributes, but not different fonts sizes void PhysicalFontFamily::UpdateDevFontList( vcl::font::PhysicalFontFaceCollection& rDevFontList ) const
{
PhysicalFontFace* pPrevFace = nullptr; for (autoconst& font : maFontFaces)
{
PhysicalFontFace* pFoundFontFace = font.get(); if( !pPrevFace || pFoundFontFace->CompareIgnoreSize( *pPrevFace ) )
rDevFontList.Add( pFoundFontFace );
pPrevFace = pFoundFontFace;
}
}
for (autoconst& font : maFontFaces)
{
PhysicalFontFace *pFoundFontFace = font.get();
if (!pFamily)
{ // tdf#98989 lazy create as family without faces won't work
pFamily = rFontCollection.FindOrCreateFontFamily(aFamilyName);
}
assert(pFamily);
pFamily->AddFontFace( pFoundFontFace );
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.