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