2 * Copyright 2003-2010, Haiku, Inc.
3 * Distributed under the terms of the MIT License.
5 #ifndef __WIDTHBUFFER_H
6 #define __WIDTHBUFFER_H
12 #include "TextViewSupportBuffer.h"
24 struct _width_table_
{
25 BFont font
; // corresponding font
26 int32 hashCount
; // number of hashed items
27 int32 tableCount
; // size of table
28 void* widths
; // width table
32 class WidthBuffer
: public _BTextViewSupportBuffer_
<_width_table_
> {
35 virtual ~WidthBuffer();
37 float StringWidth(const char* inText
,
38 int32 fromOffset
, int32 length
,
39 const BFont
* inStyle
);
40 float StringWidth(TextGapBuffer
& gapBuffer
,
41 int32 fromOffset
, int32 length
,
42 const BFont
* inStyle
);
45 bool FindTable(const BFont
* font
, int32
* outIndex
);
46 int32
InsertTable(const BFont
* font
);
48 bool GetEscapement(uint32 value
, int32 index
,
50 float HashEscapements(const char* chars
,
51 int32 numChars
, int32 numBytes
,
52 int32 tableIndex
, const BFont
* font
);
54 static uint32
Hash(uint32
);
61 extern WidthBuffer
* gWidthBuffer
;
64 } // namespace BPrivate
67 using BPrivate::WidthBuffer
;
71 //! NetPositive binary compatibility support
73 class _BWidthBuffer_
: public _BTextViewSupportBuffer_
<BPrivate::_width_table_
> {
75 virtual ~_BWidthBuffer_();
79 _BWidthBuffer_
* gCompatibilityWidthBuffer
;
81 #endif // __GNUC__ < 3
84 #endif // __WIDTHBUFFER_H