1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _SV_IMPFONT_HXX 25 #define _SV_IMPFONT_HXX 26 27 #include <tools/gen.hxx> 28 #include <tools/string.hxx> 29 #include <i18npool/lang.h> 30 #include <tools/color.hxx> 31 #include <vcl/dllapi.h> 32 #include <vcl/vclenum.hxx> 33 #include <vcl/fntstyle.hxx> 34 #include <outfont.hxx> 35 36 // ------------ 37 // - Impl_Font - 38 // ------------ 39 40 class Impl_Font 41 { 42 public: 43 Impl_Font(); 44 Impl_Font( const Impl_Font& ); 45 46 bool operator==( const Impl_Font& ) const; 47 GetPitch()48 FontPitch GetPitch() { if(mePitch==PITCH_DONTKNOW) AskConfig(); return mePitch; } GetFamily()49 FontFamily GetFamily() { if(meFamily==FAMILY_DONTKNOW) AskConfig(); return meFamily; } GetItalic()50 FontItalic GetItalic() { if(meItalic==ITALIC_DONTKNOW) AskConfig(); return meItalic; } GetWeight()51 FontWeight GetWeight() { if(meWeight==WEIGHT_DONTKNOW) AskConfig(); return meWeight; } GetWidthType()52 FontWidth GetWidthType() { if(meWidthType==WIDTH_DONTKNOW)AskConfig(); return meWidthType; } 53 54 private: 55 friend class Font; 56 void AskConfig(); 57 58 int mnRefCount; 59 String maFamilyName; 60 String maStyleName; 61 Size maSize; 62 Color maColor; // compatibility, now on output device 63 Color maFillColor; // compatibility, now on output device 64 rtl_TextEncoding meCharSet; 65 LanguageType meLanguage; 66 LanguageType meCJKLanguage; 67 FontFamily meFamily; 68 FontPitch mePitch; 69 TextAlign meAlign; 70 FontWeight meWeight; 71 FontWidth meWidthType; 72 FontItalic meItalic; 73 FontUnderline meUnderline; 74 FontUnderline meOverline; 75 FontStrikeout meStrikeout; 76 FontRelief meRelief; 77 FontEmphasisMark meEmphasisMark; 78 FontType meType; // used by metrics only 79 short mnOrientation; 80 FontKerning mnKerning; 81 sal_Bool mbWordLine:1, 82 mbOutline:1, 83 mbConfigLookup:1, // there was a config lookup 84 mbShadow:1, 85 mbVertical:1, 86 mbTransparent:1; // compatibility, now on output device 87 88 friend SvStream& operator>>( SvStream& rIStm, Impl_Font& ); 89 friend SvStream& operator<<( SvStream& rOStm, const Impl_Font& ); 90 }; 91 92 // ------------------ 93 // - ImplFontMetric - 94 // ------------------ 95 96 class ImplFontMetric 97 { 98 friend class OutputDevice; 99 100 private: 101 long mnAscent; // Ascent 102 long mnDescent; // Descent 103 long mnIntLeading; // Internal Leading 104 long mnExtLeading; // External Leading 105 long mnLineHeight; // Ascent+Descent+EmphasisMark 106 long mnSlant; // Slant 107 sal_uInt16 mnMiscFlags; // Misc Flags 108 sal_uInt32 mnRefCount; // Reference Counter 109 110 enum { DEVICE_FLAG=1, SCALABLE_FLAG=2, LATIN_FLAG=4, CJK_FLAG=8, CTL_FLAG=16 }; 111 112 public: 113 ImplFontMetric(); 114 void AddReference(); 115 void DeReference(); 116 GetAscent() const117 long GetAscent() const { return mnAscent; } GetDescent() const118 long GetDescent() const { return mnDescent; } GetIntLeading() const119 long GetIntLeading() const { return mnIntLeading; } GetExtLeading() const120 long GetExtLeading() const { return mnExtLeading; } GetLineHeight() const121 long GetLineHeight() const { return mnLineHeight; } GetSlant() const122 long GetSlant() const { return mnSlant; } 123 IsDeviceFont() const124 bool IsDeviceFont() const { return ((mnMiscFlags & DEVICE_FLAG) != 0); } IsScalable() const125 bool IsScalable() const { return ((mnMiscFlags & SCALABLE_FLAG) != 0); } SupportsLatin() const126 bool SupportsLatin() const { return ((mnMiscFlags & LATIN_FLAG) != 0); } SupportsCJK() const127 bool SupportsCJK() const { return ((mnMiscFlags & CJK_FLAG) != 0); } SupportsCTL() const128 bool SupportsCTL() const { return ((mnMiscFlags & CTL_FLAG) != 0); } 129 130 bool operator==( const ImplFontMetric& ) const; 131 }; 132 133 // ------------------ 134 // - ImplFontHints - 135 // ------------------ 136 137 class ImplFontOptions 138 { 139 public: 140 FontEmbeddedBitmap meEmbeddedBitmap; // whether the embedded bitmaps should be used 141 FontAntiAlias meAntiAlias; // whether the font should be antialiased 142 FontAutoHint meAutoHint; // whether the font should be autohinted 143 FontHinting meHinting; // whether the font should be hinted 144 FontHintStyle meHintStyle; // type of font hinting to be used 145 public: ImplFontOptions()146 ImplFontOptions() : 147 meEmbeddedBitmap(EMBEDDEDBITMAP_DONTKNOW), 148 meAntiAlias(ANTIALIAS_DONTKNOW), 149 meAutoHint(AUTOHINT_DONTKNOW), 150 meHinting(HINTING_DONTKNOW), 151 meHintStyle(HINT_SLIGHT) 152 {} ImplFontOptions(FontEmbeddedBitmap eEmbeddedBitmap,FontAntiAlias eAntiAlias,FontAutoHint eAutoHint,FontHinting eHinting,FontHintStyle eHintStyle)153 ImplFontOptions( FontEmbeddedBitmap eEmbeddedBitmap, FontAntiAlias eAntiAlias, 154 FontAutoHint eAutoHint, FontHinting eHinting, FontHintStyle eHintStyle) : 155 meEmbeddedBitmap(eEmbeddedBitmap), 156 meAntiAlias(eAntiAlias), 157 meAutoHint(eAutoHint), 158 meHinting(eHinting), 159 meHintStyle(eHintStyle) 160 {} GetUseAutoHint() const161 FontAutoHint GetUseAutoHint() const { return meAutoHint; } GetHintStyle() const162 FontHintStyle GetHintStyle() const { return meHintStyle; } DontUseEmbeddedBitmaps() const163 bool DontUseEmbeddedBitmaps() const { return meEmbeddedBitmap == EMBEDDEDBITMAP_FALSE; } DontUseAntiAlias() const164 bool DontUseAntiAlias() const { return meAntiAlias == ANTIALIAS_FALSE; } DontUseHinting() const165 bool DontUseHinting() const { return (meHinting == HINTING_FALSE) || (GetHintStyle() == HINT_NONE); } 166 }; 167 168 // ------------------- 169 // - ImplFontCharMap - 170 // ------------------- 171 172 class CmapResult; 173 174 class VCL_PLUGIN_PUBLIC ImplFontCharMap 175 { 176 public: 177 explicit ImplFontCharMap( const CmapResult& ); 178 virtual ~ImplFontCharMap(); 179 180 static ImplFontCharMap* GetDefaultMap( bool bSymbols=false); 181 182 bool IsDefaultMap() const; 183 bool HasChar( sal_uInt32 ) const; 184 int CountCharsInRange( sal_uInt32 cMin, sal_uInt32 cMax ) const; 185 int GetCharCount() const; 186 187 sal_uInt32 GetFirstChar() const; 188 sal_uInt32 GetLastChar() const; 189 190 sal_uInt32 GetNextChar( sal_uInt32 ) const; 191 sal_uInt32 GetPrevChar( sal_uInt32 ) const; 192 193 int GetIndexFromChar( sal_uInt32 ) const; 194 sal_uInt32 GetCharFromIndex( int ) const; 195 196 void AddReference() const; 197 void DeReference() const; 198 199 int GetGlyphIndex( sal_uInt32 ) const; 200 201 private: 202 int ImplFindRangeIndex( sal_uInt32 ) const; 203 204 // prevent assignment and copy construction 205 explicit ImplFontCharMap( const ImplFontCharMap& ); 206 void operator=( const ImplFontCharMap& ); 207 208 private: 209 const sal_uInt32* mpRangeCodes; // pairs of StartCode/(EndCode+1) 210 const int* mpStartGlyphs; // range-specific mapper to glyphs 211 const sal_uInt16* mpGlyphIds; // individual glyphid mappings 212 int mnRangeCount; 213 int mnCharCount; // covered codepoints 214 mutable int mnRefCount; 215 }; 216 217 // CmapResult is a normalized version of the many CMAP formats 218 class VCL_PLUGIN_PUBLIC CmapResult 219 { 220 public: 221 explicit CmapResult( bool bSymbolic = false, 222 const sal_uInt32* pRangeCodes = NULL, int nRangeCount = 0, 223 const int* pStartGlyphs = 0, const sal_uInt16* pGlyphIds = NULL ); 224 225 const sal_uInt32* mpRangeCodes; 226 const int* mpStartGlyphs; 227 const sal_uInt16* mpGlyphIds; 228 int mnRangeCount; 229 bool mbSymbolic; 230 bool mbRecoded; 231 }; 232 233 bool ParseCMAP( const unsigned char* pRawData, int nRawLength, CmapResult& ); 234 235 void UpdateAttributesFromPSName( const String& rPSName, ImplDevFontAttributes& ); 236 237 #endif // _SV_IMPFONT_HXX 238 239