1 #ifndef __WIDTHBUFFER_H 2 #define __WIDTHBUFFER_H 3 4 #include "TextGapBuffer.h" 5 #include "TextViewSupportBuffer.h" 6 7 8 struct _width_table_ { 9 #if B_BEOS_VERSION_DANO 10 BFont font; // corresponding font 11 #else 12 int32 fontCode; // font code 13 float fontSize; // font size 14 #endif 15 int32 hashCount; // number of hashed items 16 int32 tableCount; // size of table 17 void *widths; // width table 18 }; 19 20 21 class _BWidthBuffer_ : public _BTextViewSupportBuffer_<_width_table_> { 22 public: 23 _BWidthBuffer_(); 24 virtual ~_BWidthBuffer_(); 25 26 float StringWidth(const char *inText, int32 fromOffset, int32 length, 27 const BFont *inStyle); 28 float StringWidth(_BTextGapBuffer_ &, int32 fromOffset, int32 length, 29 const BFont *inStyle); 30 31 private: 32 bool FindTable(const BFont *font, int32 *outIndex); 33 int32 InsertTable(const BFont *font); 34 35 bool GetEscapement(uint32, int32, float *); 36 float HashEscapements(const char *, int32, int32, int32, const BFont *); 37 38 static uint32 Hash(uint32); 39 }; 40 41 #endif // __WIDTHBUFFER_H 42