1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <sal/config.h>
21 #include <sal/log.hxx>
24 #include <osx/saldata.hxx>
25 #include <osx/salinst.h>
27 #include <font/LogicalFontInstance.hxx>
28 #include <quartz/CoreTextFont.hxx>
29 #include <quartz/CoreTextFontFace.hxx>
30 #include <quartz/salgdi.h>
31 #include <quartz/utils.h>
33 CoreTextFontFace::CoreTextFontFace(const FontAttributes
& rDFA
, CTFontDescriptorRef xFontDescriptor
)
34 : vcl::font::PhysicalFontFace(rDFA
)
35 , mxFontDescriptor(xFontDescriptor
)
37 CFRetain(mxFontDescriptor
);
40 CoreTextFontFace::~CoreTextFontFace() { CFRelease(mxFontDescriptor
); }
42 sal_IntPtr
CoreTextFontFace::GetFontId() const
44 return reinterpret_cast<sal_IntPtr
>(mxFontDescriptor
);
47 const std::vector
<hb_variation_t
>& CoreTextFontFace::GetVariations(const LogicalFontInstance
&) const
49 CTFontRef pFont
= CTFontCreateWithFontDescriptor(mxFontDescriptor
, 0.0, nullptr);
53 mxVariations
.emplace();
54 CFArrayRef pAxes
= CTFontCopyVariationAxes(pFont
);
57 CFDictionaryRef pVariations
= CTFontCopyVariation(pFont
);
60 CFIndex nAxes
= CFArrayGetCount(pAxes
);
61 for (CFIndex i
= 0; i
< nAxes
; ++i
)
63 auto pAxis
= static_cast<CFDictionaryRef
>(CFArrayGetValueAtIndex(pAxes
, i
));
67 auto pTag
= static_cast<CFNumberRef
>(
68 CFDictionaryGetValue(pAxis
, kCTFontVariationAxisIdentifierKey
));
71 CFNumberGetValue(pTag
, kCFNumberIntType
, &nTag
);
75 = static_cast<CFNumberRef
>(CFDictionaryGetValue(pVariations
, pTag
));
78 CFNumberGetValue(pValue
, kCFNumberFloatType
, &fValue
);
80 mxVariations
->push_back({ nTag
, fValue
});
83 CFRelease(pVariations
);
92 rtl::Reference
<LogicalFontInstance
>
93 CoreTextFontFace::CreateFontInstance(const vcl::font::FontSelectPattern
& rFSD
) const
95 return new CoreTextFont(*this, rFSD
);
98 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */