2018-11-30 22:52:05 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
2012-05-21 15:12:37 +04:00
|
|
|
* 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/. */
|
2009-03-30 04:31:51 +04:00
|
|
|
|
2010-03-10 15:46:41 +03:00
|
|
|
#ifndef GFX_CORETEXTSHAPER_H
|
|
|
|
#define GFX_CORETEXTSHAPER_H
|
2009-03-30 04:31:51 +04:00
|
|
|
|
|
|
|
#include "gfxFont.h"
|
|
|
|
|
2013-10-08 03:15:59 +04:00
|
|
|
#include <ApplicationServices/ApplicationServices.h>
|
2009-03-30 04:31:51 +04:00
|
|
|
|
2010-03-10 15:46:41 +03:00
|
|
|
class gfxMacFont;
|
2009-03-30 04:31:51 +04:00
|
|
|
|
2010-03-10 15:46:41 +03:00
|
|
|
class gfxCoreTextShaper : public gfxFontShaper {
|
2009-03-30 04:31:51 +04:00
|
|
|
public:
|
2014-08-08 05:17:30 +04:00
|
|
|
explicit gfxCoreTextShaper(gfxMacFont* aFont);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2010-03-10 15:46:41 +03:00
|
|
|
virtual ~gfxCoreTextShaper();
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2017-04-03 19:49:17 +03:00
|
|
|
bool ShapeText(DrawTarget* aDrawTarget, const char16_t* aText, uint32_t aOffset, uint32_t aLength,
|
2020-11-13 16:15:39 +03:00
|
|
|
Script aScript, nsAtom* aLanguage, bool aVertical, RoundingFlags aRounding,
|
2017-04-03 19:49:17 +03:00
|
|
|
gfxShapedText* aShapedText) override;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2009-03-30 04:31:51 +04:00
|
|
|
// clean up static objects that may have been cached
|
|
|
|
static void Shutdown();
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-03-29 23:53:55 +03:00
|
|
|
// Flags used to track what AAT features should be enabled on the Core Text
|
|
|
|
// font instance. (Internal; only public so that we can use the
|
|
|
|
// MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS macro below.)
|
|
|
|
enum FeatureFlags : uint8_t {
|
|
|
|
kDefaultFeatures = 0x00,
|
|
|
|
// bit flags for non-default feature settings we might need
|
|
|
|
// to use, which will require separate font instances
|
|
|
|
kDisableLigatures = 0x01,
|
|
|
|
kAddSmallCaps = 0x02,
|
|
|
|
kIndicFeatures = 0x04,
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-03-29 23:53:55 +03:00
|
|
|
// number of font instances, indexed by OR-ing the flags above
|
|
|
|
kMaxFontInstances = 8
|
|
|
|
};
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2009-03-30 04:31:51 +04:00
|
|
|
protected:
|
2018-03-29 23:53:55 +03:00
|
|
|
CTFontRef mCTFont[kMaxFontInstances];
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2015-12-30 23:29:48 +03:00
|
|
|
// attributes for shaping text with LTR or RTL directionality
|
|
|
|
CFDictionaryRef mAttributesDictLTR;
|
|
|
|
CFDictionaryRef mAttributesDictRTL;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2013-01-04 22:35:37 +04:00
|
|
|
nsresult SetGlyphsFromRun(gfxShapedText* aShapedText, uint32_t aOffset, uint32_t aLength,
|
2017-09-15 00:45:26 +03:00
|
|
|
CTRunRef aCTRun);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2015-03-25 11:25:49 +03:00
|
|
|
CTFontRef CreateCTFontWithFeatures(CGFloat aSize, CTFontDescriptorRef aDescriptor);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2015-12-30 23:29:48 +03:00
|
|
|
CFDictionaryRef CreateAttrDict(bool aRightToLeft);
|
|
|
|
CFDictionaryRef CreateAttrDictWithoutDirection();
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2015-03-25 11:25:49 +03:00
|
|
|
static CTFontDescriptorRef CreateFontFeaturesDescriptor(
|
2018-03-29 23:53:55 +03:00
|
|
|
const std::pair<SInt16, SInt16>* aFeatures, size_t aCount);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-03-29 23:53:55 +03:00
|
|
|
static CTFontDescriptorRef GetFeaturesDescriptor(FeatureFlags aFeatureFlags);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-03-29 23:53:55 +03:00
|
|
|
// cached font descriptors, created the first time they're needed
|
|
|
|
static CTFontDescriptorRef sFeaturesDescriptor[kMaxFontInstances];
|
2009-03-30 04:31:51 +04:00
|
|
|
};
|
|
|
|
|
2018-03-29 23:53:55 +03:00
|
|
|
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(gfxCoreTextShaper::FeatureFlags)
|
|
|
|
|
2010-03-10 15:46:41 +03:00
|
|
|
#endif /* GFX_CORETEXTSHAPER_H */
|