/* -*- 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 .
*/
namespace cairocanvas
{ namespace
{ void setupLayoutMode( OutputDevice& rOutDev,
sal_Int8 nTextDirection )
{ // TODO(P3): avoid if already correctly set
vcl::text::ComplexTextLayoutFlags nLayoutMode = vcl::text::ComplexTextLayoutFlags::Default; switch( nTextDirection )
{ case rendering::TextDirection::WEAK_LEFT_TO_RIGHT: break; case rendering::TextDirection::STRONG_LEFT_TO_RIGHT:
nLayoutMode = vcl::text::ComplexTextLayoutFlags::BiDiStrong; break; case rendering::TextDirection::WEAK_RIGHT_TO_LEFT:
nLayoutMode = vcl::text::ComplexTextLayoutFlags::BiDiRtl; break; case rendering::TextDirection::STRONG_RIGHT_TO_LEFT:
nLayoutMode = vcl::text::ComplexTextLayoutFlags::BiDiRtl | vcl::text::ComplexTextLayoutFlags::BiDiStrong; break; default: break;
}
// set calculated layout mode. Origin is always the left edge, // as required at the API spec
rOutDev.SetLayoutMode( nLayoutMode | vcl::text::ComplexTextLayoutFlags::TextOriginLeft );
}
}
/** * TextLayout::draw * * Cairo-based text rendering. Draw text directly on the cairo surface with cairo fonts. * Avoid using VCL VirtualDevices for that, bypassing VCL DrawText functions, when possible * * Note: some text effects are not rendered due to lacking generic canvas or cairo canvas * implementation. See issues 92657, 92658, 92659, 92660, 97529
**/ void TextLayout::draw( OutputDevice& rOutDev, const Point& rOutpos, const rendering::ViewState& viewState, const rendering::RenderState& renderState ) const
{
std::unique_lock aGuard( m_aMutex );
setupLayoutMode( rOutDev, mnTextDirection );
namespace
{ class OffsetTransformer
{ public: explicit OffsetTransformer( ::basegfx::B2DHomMatrix aMat ) :
maMatrix(std::move( aMat ))
{
}
sal_Int32 operator()( constdouble& rOffset )
{ // This is an optimization of the normal rMat*[x,0] // transformation of the advancement vector (in x // direction), followed by a length calculation of the // resulting vector: advancement' = // ||rMat*[x,0]||. Since advancements are vectors, we // can ignore translational components, thus if [x,0], // it follows that rMat*[x,0]=[x',0] holds. Thus, we // just have to calc the transformation of the x // component.
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.