Branch libreoffice-5-0-4
[LibreOffice.git] / vcl / inc / impfont.hxx
blobafa1a3b479ffb1b0cc594f938a27a52f1bb88e93
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #ifndef INCLUDED_VCL_INC_IMPFONT_HXX
21 #define INCLUDED_VCL_INC_IMPFONT_HXX
23 #include <rtl/ustring.hxx>
24 #include <tools/gen.hxx>
25 #include <i18nlangtag/languagetag.hxx>
26 #include <tools/color.hxx>
27 #include <vcl/dllapi.h>
28 #include <vcl/vclenum.hxx>
29 #include <vcl/fntstyle.hxx>
30 #include <outfont.hxx>
32 #include <boost/intrusive_ptr.hpp>
34 class ImplFontCharMap;
35 typedef boost::intrusive_ptr< ImplFontCharMap > ImplFontCharMapPtr;
37 // - Impl_Font -
39 class Impl_Font
41 public:
42 Impl_Font();
43 Impl_Font( const Impl_Font& );
45 bool operator==( const Impl_Font& ) const;
47 FontPitch GetPitch() { if(mePitch==PITCH_DONTKNOW) AskConfig(); return mePitch; }
48 FontFamily GetFamily() { if(meFamily==FAMILY_DONTKNOW) AskConfig(); return meFamily; }
49 FontItalic GetItalic() { if(meItalic==ITALIC_DONTKNOW) AskConfig(); return meItalic; }
50 FontWeight GetWeight() { if(meWeight==WEIGHT_DONTKNOW) AskConfig(); return meWeight; }
51 FontWidth GetWidthType() { if(meWidthType==WIDTH_DONTKNOW)AskConfig(); return meWidthType; }
53 private:
54 friend class vcl::Font;
55 void AskConfig();
57 sal_uInt32 mnRefCount;
58 OUString maFamilyName;
59 OUString maStyleName;
60 Size maSize;
61 Color maColor; // compatibility, now on output device
62 Color maFillColor; // compatibility, now on output device
63 rtl_TextEncoding meCharSet;
64 LanguageTag maLanguageTag;
65 LanguageTag maCJKLanguageTag;
66 FontFamily meFamily;
67 FontPitch mePitch;
68 TextAlign meAlign;
69 FontWeight meWeight;
70 FontWidth meWidthType;
71 FontItalic meItalic;
72 FontUnderline meUnderline;
73 FontUnderline meOverline;
74 FontStrikeout meStrikeout;
75 FontRelief meRelief;
76 FontEmphasisMark meEmphasisMark;
77 short mnOrientation;
78 FontKerning mnKerning;
79 bool mbWordLine:1,
80 mbOutline:1,
81 mbConfigLookup:1, // there was a config lookup
82 mbShadow:1,
83 mbVertical:1,
84 mbTransparent:1; // compatibility, now on output device
86 friend SvStream& ReadImpl_Font( SvStream& rIStm, Impl_Font& );
87 friend SvStream& WriteImpl_Font( SvStream& rOStm, const Impl_Font& );
90 // - ImplFontMetric -
92 class ImplFontMetric
94 friend class ::OutputDevice;
96 private:
97 long mnAscent; // Ascent
98 long mnDescent; // Descent
99 long mnIntLeading; // Internal Leading
100 long mnExtLeading; // External Leading
101 long mnLineHeight; // Ascent+Descent+EmphasisMark
102 long mnSlant; // Slant
103 sal_uInt16 mnMiscFlags; // Misc Flags
104 sal_uInt32 mnRefCount; // Reference Counter
106 enum { DEVICE_FLAG=1, SCALABLE_FLAG=2, LATIN_FLAG=4, CJK_FLAG=8, CTL_FLAG=16, FULLSTOP_CENTERED_FLAG=32 };
108 public:
109 ImplFontMetric();
110 void AddReference();
111 void DeReference();
113 long GetAscent() const { return mnAscent; }
114 long GetDescent() const { return mnDescent; }
115 long GetIntLeading() const { return mnIntLeading; }
116 long GetExtLeading() const { return mnExtLeading; }
117 long GetLineHeight() const { return mnLineHeight; }
118 long GetSlant() const { return mnSlant; }
119 bool IsFullstopCentered() const { return ((mnMiscFlags & FULLSTOP_CENTERED_FLAG ) != 0); }
121 bool IsDeviceFont() const { return ((mnMiscFlags & DEVICE_FLAG) != 0); }
122 bool IsScalable() const { return ((mnMiscFlags & SCALABLE_FLAG) != 0); }
123 bool SupportsLatin() const { return ((mnMiscFlags & LATIN_FLAG) != 0); }
124 bool SupportsCJK() const { return ((mnMiscFlags & CJK_FLAG) != 0); }
125 bool SupportsCTL() const { return ((mnMiscFlags & CTL_FLAG) != 0); }
127 bool operator==( const ImplFontMetric& ) const;
130 // - ImplFontOptions -
132 class ImplFontOptions
134 public:
135 FontEmbeddedBitmap meEmbeddedBitmap; // whether the embedded bitmaps should be used
136 FontAntiAlias meAntiAlias; // whether the font should be antialiased
137 FontAutoHint meAutoHint; // whether the font should be autohinted
138 FontHinting meHinting; // whether the font should be hinted
139 FontHintStyle meHintStyle; // type of font hinting to be used
140 public:
141 ImplFontOptions() :
142 meEmbeddedBitmap(EMBEDDEDBITMAP_DONTKNOW),
143 meAntiAlias(ANTIALIAS_DONTKNOW),
144 meAutoHint(AUTOHINT_DONTKNOW),
145 meHinting(HINTING_DONTKNOW),
146 meHintStyle(HINT_SLIGHT) {}
147 virtual ~ImplFontOptions() {}
149 FontAutoHint GetUseAutoHint() const { return meAutoHint; }
150 FontHintStyle GetHintStyle() const { return meHintStyle; }
151 bool DontUseEmbeddedBitmaps() const { return meEmbeddedBitmap == EMBEDDEDBITMAP_FALSE; }
152 bool DontUseAntiAlias() const { return meAntiAlias == ANTIALIAS_FALSE; }
153 bool DontUseHinting() const { return (meHinting == HINTING_FALSE) || (GetHintStyle() == HINT_NONE); }
154 virtual void* GetPattern(void * /*pFace*/, bool /*bEmbolden*/, bool /*bVerticalMetrics*/) const { return NULL; }
157 // - ImplFontCharMap -
159 class CmapResult;
161 class VCL_PLUGIN_PUBLIC ImplFontCharMap
163 public:
164 explicit ImplFontCharMap( const CmapResult& );
165 virtual ~ImplFontCharMap();
167 private:
168 friend class FontCharMap;
169 friend void intrusive_ptr_add_ref(ImplFontCharMap* pImplFontCharMap);
170 friend void intrusive_ptr_release(ImplFontCharMap* pImplFontCharMap);
172 ImplFontCharMap( const ImplFontCharMap& ) SAL_DELETED_FUNCTION;
173 void operator=( const ImplFontCharMap& ) SAL_DELETED_FUNCTION;
175 static ImplFontCharMapPtr getDefaultMap( bool bSymbols=false);
176 bool isDefaultMap() const;
178 private:
179 const sal_uInt32* mpRangeCodes; // pairs of StartCode/(EndCode+1)
180 const int* mpStartGlyphs; // range-specific mapper to glyphs
181 const sal_uInt16* mpGlyphIds; // individual glyphid mappings
182 int mnRangeCount;
183 int mnCharCount; // covered codepoints
184 mutable sal_uInt32 mnRefCount;
187 inline void intrusive_ptr_add_ref(ImplFontCharMap* pImplFontCharMap)
189 ++pImplFontCharMap->mnRefCount;
192 inline void intrusive_ptr_release(ImplFontCharMap* pImplFontCharMap)
194 if (--pImplFontCharMap->mnRefCount == 0)
195 delete pImplFontCharMap;
198 // CmapResult is a normalized version of the many CMAP formats
199 class VCL_PLUGIN_PUBLIC CmapResult
201 public:
202 explicit CmapResult( bool bSymbolic = false,
203 const sal_uInt32* pRangeCodes = NULL, int nRangeCount = 0,
204 const int* pStartGlyphs = 0, const sal_uInt16* pGlyphIds = NULL );
206 const sal_uInt32* mpRangeCodes;
207 const int* mpStartGlyphs;
208 const sal_uInt16* mpGlyphIds;
209 int mnRangeCount;
210 bool mbSymbolic;
211 bool mbRecoded;
214 bool ParseCMAP( const unsigned char* pRawData, int nRawLength, CmapResult& );
216 void UpdateAttributesFromPSName( const OUString& rPSName, ImplDevFontAttributes& );
218 #endif // INCLUDED_VCL_INC_IMPFONT_HXX
220 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */