26#include <com/sun/star/rendering/PanoseWeight.hpp>
27#include <com/sun/star/rendering/XSpriteCanvas.hpp>
41 INT calcFontStyle(
const rendering::FontRequest& rFontRequest )
43 INT nFontStyle( Gdiplus::FontStyleRegular );
45 if( rFontRequest.FontDescription.FontDescription.Weight > rendering::PanoseWeight::BOOK )
46 nFontStyle = Gdiplus::FontStyleBold;
53 const uno::Sequence< beans::PropertyValue >& extraFontProperties,
54 const geometry::Matrix2D& fontMatrix ) :
59 maFontRequest( rFontRequest ),
61 maFontMatrix( fontMatrix )
63 mpFontFamily = std::make_shared<Gdiplus::FontFamily>(o3tl::toW(rFontRequest.FontDescription.FamilyName.getStr()),
nullptr);
64 if( !mpFontFamily->IsAvailable() )
65 mpFontFamily = std::make_shared<Gdiplus::FontFamily>(L
"Arial",
nullptr);
67 mpFont = std::make_shared<Gdiplus::Font>( mpFontFamily.get(),
68 static_cast<Gdiplus::REAL
>(rFontRequest.CellSize),
69 calcFontStyle( rFontRequest ),
75 void SAL_CALL CanvasFont::disposing()
77 ::osl::MutexGuard aGuard(
m_aMutex );
81 mpGdiPlusUser.reset();
84 uno::Reference< rendering::XTextLayout > SAL_CALL CanvasFont::createTextLayout(
const rendering::StringContext& aText,
86 sal_Int64 nRandomSeed )
88 ::osl::MutexGuard aGuard( m_aMutex );
90 return new TextLayout( aText, nDirection, nRandomSeed, ImplRef(
this ) );
93 uno::Sequence< double > SAL_CALL CanvasFont::getAvailableSizes( )
96 return uno::Sequence< double >();
99 uno::Sequence< beans::PropertyValue > SAL_CALL CanvasFont::getExtraFontProperties( )
102 return uno::Sequence< beans::PropertyValue >();
105 rendering::FontRequest SAL_CALL CanvasFont::getFontRequest( )
107 ::osl::MutexGuard aGuard(
m_aMutex );
109 return maFontRequest;
112 rendering::FontMetrics SAL_CALL CanvasFont::getFontMetrics( )
115 return rendering::FontMetrics();
118 OUString SAL_CALL CanvasFont::getImplementationName()
120 return "DXCanvas::CanvasFont";
123 sal_Bool SAL_CALL CanvasFont::supportsService(
const OUString& ServiceName )
128 uno::Sequence< OUString > SAL_CALL CanvasFont::getSupportedServiceNames()
130 return {
"com.sun.star.rendering.CanvasFont" };
133 double CanvasFont::getCellAscent()
const
135 ::osl::MutexGuard aGuard(
m_aMutex );
137 return mpFontFamily->GetCellAscent(0);
140 double CanvasFont::getEmHeight()
const
142 ::osl::MutexGuard aGuard(
m_aMutex );
144 return mpFontFamily->GetEmHeight(0);
149 ::osl::MutexGuard aGuard(
m_aMutex );
154 const css::geometry::Matrix2D& CanvasFont::getFontMatrix()
const
156 ::osl::MutexGuard aGuard(
m_aMutex );
HRESULT createInstance(REFIID iid, Ifc **ppIfc)
CanvasFont(const CanvasFont &)=delete
make noncopyable
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
::cppu::WeakComponentImplHelper< css::rendering::XCanvasFont, css::lang::XServiceInfo > CanvasFont_Base
std::shared_ptr< Gdiplus::Font > FontSharedPtr
std::optional< vcl::Font > mpFont