1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xfont.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef EXTENDED_FONTSTRUCT_HXX
31 #define EXTENDED_FONTSTRUCT_HXX
34 #include <tools/prex.h>
36 #include <tools/postx.h>
38 #include <tools/ref.hxx>
39 #include <rtl/tencinfo.h>
40 #include <vcl/vclenum.hxx>
41 #include <vcl/sallayout.hxx>
43 typedef unsigned short sal_MultiByte
;
45 class ImplFontMetricData
;
48 struct VerticalTextItem
51 XFontStruct
* mpXFontStruct
;
52 const sal_Unicode
* mpString
;
59 VerticalTextItem( XFontStruct
* pXFontStruct
,
60 const sal_Unicode
* pString
,
66 mpXFontStruct( pXFontStruct
),
71 mnFixedAdvance( nFixedAdvance
)
74 VerticalTextItem( XFontStruct
* pXFontStruct
,
75 const sal_Unicode
* pString
,
81 mpXFontStruct( pXFontStruct
),
86 mpAdvanceAry( pAdvanceAry
)
93 delete( mpAdvanceAry
);
98 class ExtendedFontStruct
: public SvRefBase
105 sal_Size mnDefaultWidth
;
107 rtl_TextEncoding mnCachedEncoding
;
108 rtl_TextEncoding mnAsciiEncoding
;
110 ExtendedXlfd
* mpXlfd
;
111 XFontStruct
** mpXFontStruct
;
113 // unicode range cache
114 mutable sal_uInt32
* mpRangeCodes
;
115 mutable int mnRangeCount
;
117 int LoadEncoding( rtl_TextEncoding nEncoding
);
118 FontPitch
GetSpacing( rtl_TextEncoding nEncoding
);
119 bool GetFontBoundingBox( XCharStruct
*pCharStruct
,
120 int *pAscent
, int *pDescent
) ;
122 sal_Size
GetDefaultWidth();
123 sal_Size
GetCharWidth8( sal_Unicode nFrom
, sal_Unicode nTo
,
124 sal_Int32
*pWidthArray
,
125 rtl_TextEncoding nEncoding
);
126 sal_Size
GetCharWidthUTF16( sal_Unicode nFrom
, sal_Unicode nTo
,
127 sal_Int32
*pWidthArray
);
128 sal_Size
GetCharWidth16( sal_Unicode nFrom
, sal_Unicode nTo
,
129 sal_Int32
*pWidthArray
, ExtendedFontStruct
*pFallback
);
131 ExtendedFontStruct( Display
* pDisplay
,
132 const Size
& rPixelSize
, sal_Bool bVertical
,
133 ExtendedXlfd
* pXlfd
);
134 ~ExtendedFontStruct();
135 bool Match( const ExtendedXlfd
*pXlfd
,
136 const Size
& rPixelSize
, sal_Bool bVertical
) const;
137 XFontStruct
* GetFontStruct( rtl_TextEncoding nEncoding
);
138 XFontStruct
* GetFontStruct( sal_Unicode nChar
,
139 rtl_TextEncoding
*pEncoding
);
140 bool ToImplFontMetricData( ImplFontMetricData
*pMetric
);
141 rtl_TextEncoding
GetAsciiEncoding( int *pAsciiRange
= NULL
) const;
142 sal_Size
GetCharWidth( sal_Unicode
,
143 sal_Int32
* pPhysWidth
, sal_Int32
* pLogWidth
);
144 int GetFontCodeRanges( sal_uInt32
* pCodePairs
) const;
145 bool HasUnicodeChar( sal_Unicode
) const;
148 // Declaration and Implementation for ExtendedFontStructRef: Add RefCounting
149 // to ExtendedFontStruct (it's not possible to separate decl and impl into
150 // a separate source file: all ref member functions are inline
151 SV_DECL_IMPL_REF( ExtendedFontStruct
);
153 class X11FontLayout
: public GenericSalLayout
156 X11FontLayout( ExtendedFontStruct
& );
157 virtual bool LayoutText( ImplLayoutArgs
& );
158 virtual void AdjustLayout( ImplLayoutArgs
& );
159 virtual void DrawText( SalGraphics
& ) const;
162 ExtendedFontStruct
& mrFont
;
165 #endif /* EXTENDED_FONTSTRUCT_HXX */