/* -*- 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 .
*/
// Sets and unsets the needed DirectWrite transform to support the font's rotation. class WinFontTransformGuard
{ public:
WinFontTransformGuard(ID2D1RenderTarget* pRenderTarget, float hscale, const GenericSalLayout& rLayout, const D2D1_POINT_2F& rBaseline, bool bIsVertical);
~WinFontTransformGuard();
if (hr == D2DERR_RECREATE_TARGET)
{
CreateRenderTarget();
bRetry = true; returnfalse;
} if (FAILED(hr))
{ // If for any reason we can't bind fallback to legacy APIs. return ExTextOutRenderer()(rLayout, rGraphics, hDC);
}
auto [succeeded, bounds] = [&rLayout]()
{
basegfx::B2DRectangle r; bool result = rLayout.GetBoundRect(r); if (result)
r.grow(1); // plus 1 pixel to the tight range return std::make_pair(result, SalLayout::BoundRect2Rectangle(r));
}();
if (succeeded)
{
hr = BindDC(hDC, bounds); // Update the bounding rect.
succeeded = SUCCEEDED(hr);
}
if (hscale != 1.0f) // basegfx::fTools::equal is useless with float
aTransform = aTransform * D2D1::Matrix3x2F::Scale(hscale, 1.0f, { 0, 0 });
// DWrite angle is in clockwise degrees, our orientation is in counter-clockwise 10th // degrees. if (angle)
aTransform = aTransform * D2D1::Matrix3x2F::Rotation(-toDegrees(angle), rBaseline);
mpRenderTarget->SetTransform(aTransform);
}
}
WinFontTransformGuard::~WinFontTransformGuard()
{ if (moTransform)
mpRenderTarget->SetTransform(*moTransform);
}
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.