Indentation cleanup.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32691 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+116
-71
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2005-2007, Haiku, Inc. All Rights Reserved.
|
* Copyright 2005-2009, Haiku, Inc. All Rights Reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT license.
|
||||||
*/
|
*/
|
||||||
#ifndef _FONT_H_
|
#ifndef _FONT_H_
|
||||||
#define _FONT_H_
|
#define _FONT_H_
|
||||||
@@ -17,6 +17,7 @@ class BPoint;
|
|||||||
typedef char font_family[B_FONT_FAMILY_LENGTH + 1];
|
typedef char font_family[B_FONT_FAMILY_LENGTH + 1];
|
||||||
typedef char font_style[B_FONT_STYLE_LENGTH + 1];
|
typedef char font_style[B_FONT_STYLE_LENGTH + 1];
|
||||||
|
|
||||||
|
|
||||||
// font spacing
|
// font spacing
|
||||||
enum {
|
enum {
|
||||||
B_CHAR_SPACING = 0,
|
B_CHAR_SPACING = 0,
|
||||||
@@ -25,17 +26,20 @@ enum {
|
|||||||
B_FIXED_SPACING = 3
|
B_FIXED_SPACING = 3
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
enum font_direction {
|
enum font_direction {
|
||||||
B_FONT_LEFT_TO_RIGHT = 0,
|
B_FONT_LEFT_TO_RIGHT = 0,
|
||||||
B_FONT_RIGHT_TO_LEFT = 1
|
B_FONT_RIGHT_TO_LEFT = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// font flags
|
// font flags
|
||||||
enum {
|
enum {
|
||||||
B_DISABLE_ANTIALIASING = 0x00000001,
|
B_DISABLE_ANTIALIASING = 0x00000001,
|
||||||
B_FORCE_ANTIALIASING = 0x00000002
|
B_FORCE_ANTIALIASING = 0x00000002
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// truncation modes
|
// truncation modes
|
||||||
enum {
|
enum {
|
||||||
B_TRUNCATE_END = 0,
|
B_TRUNCATE_END = 0,
|
||||||
@@ -44,6 +48,7 @@ enum {
|
|||||||
B_TRUNCATE_SMART = 3
|
B_TRUNCATE_SMART = 3
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// font encodings
|
// font encodings
|
||||||
enum {
|
enum {
|
||||||
B_UNICODE_UTF8 = 0,
|
B_UNICODE_UTF8 = 0,
|
||||||
@@ -60,12 +65,14 @@ enum {
|
|||||||
B_MACINTOSH_ROMAN = 11
|
B_MACINTOSH_ROMAN = 11
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// flags for get_font_family() and get_font_style()
|
// flags for get_font_family() and get_font_style()
|
||||||
enum {
|
enum {
|
||||||
B_HAS_TUNED_FONT = 0x0001,
|
B_HAS_TUNED_FONT = 0x0001,
|
||||||
B_IS_FIXED = 0x0002
|
B_IS_FIXED = 0x0002
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// font face flags
|
// font face flags
|
||||||
enum {
|
enum {
|
||||||
B_ITALIC_FACE = 0x0001,
|
B_ITALIC_FACE = 0x0001,
|
||||||
@@ -81,48 +88,55 @@ enum {
|
|||||||
B_HEAVY_FACE = 0x0200,
|
B_HEAVY_FACE = 0x0200,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
enum font_metric_mode {
|
enum font_metric_mode {
|
||||||
B_SCREEN_METRIC = 0,
|
B_SCREEN_METRIC = 0,
|
||||||
B_PRINTING_METRIC = 1
|
B_PRINTING_METRIC = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
enum font_file_format {
|
enum font_file_format {
|
||||||
B_TRUETYPE_WINDOWS = 0,
|
B_TRUETYPE_WINDOWS = 0,
|
||||||
B_POSTSCRIPT_TYPE1_WINDOWS = 1
|
B_POSTSCRIPT_TYPE1_WINDOWS = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class unicode_block {
|
class unicode_block {
|
||||||
public:
|
public:
|
||||||
inline unicode_block();
|
inline unicode_block();
|
||||||
inline unicode_block(uint64 block2, uint64 block1);
|
inline unicode_block(uint64 block2, uint64 block1);
|
||||||
|
|
||||||
inline bool Includes(const unicode_block &block) const;
|
inline bool Includes(const unicode_block& block) const;
|
||||||
inline unicode_block operator&(const unicode_block &block) const;
|
inline unicode_block operator&(const unicode_block& block) const;
|
||||||
inline unicode_block operator|(const unicode_block &block) const;
|
inline unicode_block operator|(const unicode_block& block) const;
|
||||||
inline unicode_block &operator=(const unicode_block &block);
|
inline unicode_block& operator=(const unicode_block& block);
|
||||||
inline bool operator==(const unicode_block &block) const;
|
inline bool operator==(const unicode_block& block) const;
|
||||||
inline bool operator!=(const unicode_block &block) const;
|
inline bool operator!=(const unicode_block& block) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint64 fData[2];
|
uint64 fData[2];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct edge_info {
|
struct edge_info {
|
||||||
float left;
|
float left;
|
||||||
float right;
|
float right;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct font_height {
|
struct font_height {
|
||||||
float ascent;
|
float ascent;
|
||||||
float descent;
|
float descent;
|
||||||
float leading;
|
float leading;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct escapement_delta {
|
struct escapement_delta {
|
||||||
float nonspace;
|
float nonspace;
|
||||||
float space;
|
float space;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct font_cache_info {
|
struct font_cache_info {
|
||||||
int32 sheared_font_penalty;
|
int32 sheared_font_penalty;
|
||||||
int32 rotated_font_penalty;
|
int32 rotated_font_penalty;
|
||||||
@@ -132,6 +146,7 @@ struct font_cache_info {
|
|||||||
float spacing_size_threshold;
|
float spacing_size_threshold;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct tuned_font_info {
|
struct tuned_font_info {
|
||||||
float size;
|
float size;
|
||||||
float shear;
|
float shear;
|
||||||
@@ -140,21 +155,23 @@ struct tuned_font_info {
|
|||||||
uint16 face;
|
uint16 face;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class BShape;
|
class BShape;
|
||||||
class BString;
|
class BString;
|
||||||
class BFontPrivate;
|
class BFontPrivate;
|
||||||
|
|
||||||
|
|
||||||
class BFont {
|
class BFont {
|
||||||
public:
|
public:
|
||||||
BFont();
|
BFont();
|
||||||
BFont(const BFont &font);
|
BFont(const BFont& font);
|
||||||
BFont(const BFont *font);
|
BFont(const BFont* font);
|
||||||
|
|
||||||
status_t SetFamilyAndStyle(const font_family family,
|
status_t SetFamilyAndStyle(const font_family family,
|
||||||
const font_style style);
|
const font_style style);
|
||||||
void SetFamilyAndStyle(uint32 code);
|
void SetFamilyAndStyle(uint32 code);
|
||||||
status_t SetFamilyAndFace(const font_family family, uint16 face);
|
status_t SetFamilyAndFace(const font_family family,
|
||||||
|
uint16 face);
|
||||||
|
|
||||||
void SetSize(float size);
|
void SetSize(float size);
|
||||||
void SetShear(float shear);
|
void SetShear(float shear);
|
||||||
@@ -165,8 +182,8 @@ class BFont {
|
|||||||
void SetFace(uint16 face);
|
void SetFace(uint16 face);
|
||||||
void SetFlags(uint32 flags);
|
void SetFlags(uint32 flags);
|
||||||
|
|
||||||
void GetFamilyAndStyle(font_family *family,
|
void GetFamilyAndStyle(font_family* family,
|
||||||
font_style *style) const;
|
font_style* style) const;
|
||||||
uint32 FamilyAndStyle() const;
|
uint32 FamilyAndStyle() const;
|
||||||
float Size() const;
|
float Size() const;
|
||||||
float Shear() const;
|
float Shear() const;
|
||||||
@@ -185,63 +202,86 @@ class BFont {
|
|||||||
font_file_format FileFormat() const;
|
font_file_format FileFormat() const;
|
||||||
|
|
||||||
int32 CountTuned() const;
|
int32 CountTuned() const;
|
||||||
void GetTunedInfo(int32 index, tuned_font_info *info) const;
|
void GetTunedInfo(int32 index,
|
||||||
|
tuned_font_info* info) const;
|
||||||
|
|
||||||
void TruncateString(BString* inOut, uint32 mode,
|
void TruncateString(BString* inOut, uint32 mode,
|
||||||
float width) const;
|
float width) const;
|
||||||
void GetTruncatedStrings(const char *stringArray[],
|
void GetTruncatedStrings(const char* stringArray[],
|
||||||
int32 numStrings, uint32 mode, float width,
|
int32 numStrings, uint32 mode, float width,
|
||||||
BString resultArray[]) const;
|
BString resultArray[]) const;
|
||||||
void GetTruncatedStrings(const char *stringArray[],
|
void GetTruncatedStrings(const char* stringArray[],
|
||||||
int32 numStrings, uint32 mode, float width,
|
int32 numStrings, uint32 mode,
|
||||||
char *resultArray[]) const;
|
float width, char* resultArray[]) const;
|
||||||
|
|
||||||
float StringWidth(const char *string) const;
|
float StringWidth(const char* string) const;
|
||||||
float StringWidth(const char *string, int32 length) const;
|
float StringWidth(const char* string,
|
||||||
void GetStringWidths(const char *stringArray[],
|
int32 length) const;
|
||||||
const int32 lengthArray[], int32 numStrings,
|
void GetStringWidths(const char* stringArray[],
|
||||||
|
const int32 lengthArray[],
|
||||||
|
int32 numStrings,
|
||||||
float widthArray[]) const;
|
float widthArray[]) const;
|
||||||
|
|
||||||
void GetEscapements(const char charArray[], int32 numChars,
|
void GetEscapements(const char charArray[],
|
||||||
|
int32 numChars,
|
||||||
float escapementArray[]) const;
|
float escapementArray[]) const;
|
||||||
void GetEscapements(const char charArray[], int32 numChars,
|
void GetEscapements(const char charArray[],
|
||||||
escapement_delta *delta, float escapementArray[]) const;
|
int32 numChars, escapement_delta* delta,
|
||||||
void GetEscapements(const char charArray[], int32 numChars,
|
float escapementArray[]) const;
|
||||||
escapement_delta *delta, BPoint escapementArray[]) const;
|
void GetEscapements(const char charArray[],
|
||||||
void GetEscapements(const char charArray[], int32 numChars,
|
int32 numChars, escapement_delta* delta,
|
||||||
escapement_delta *delta, BPoint escapementArray[],
|
BPoint escapementArray[]) const;
|
||||||
|
void GetEscapements(const char charArray[],
|
||||||
|
int32 numChars, escapement_delta* delta,
|
||||||
|
BPoint escapementArray[],
|
||||||
BPoint offsetArray[]) const;
|
BPoint offsetArray[]) const;
|
||||||
|
|
||||||
void GetEdges(const char charArray[], int32 numBytes,
|
void GetEdges(const char charArray[],
|
||||||
|
int32 numBytes,
|
||||||
edge_info edgeArray[]) const;
|
edge_info edgeArray[]) const;
|
||||||
void GetHeight(font_height *height) const;
|
void GetHeight(font_height* height) const;
|
||||||
|
|
||||||
void GetBoundingBoxesAsGlyphs(const char charArray[],
|
void GetBoundingBoxesAsGlyphs(
|
||||||
int32 numChars, font_metric_mode mode,
|
const char charArray[], int32 numChars,
|
||||||
|
font_metric_mode mode,
|
||||||
BRect boundingBoxArray[]) const;
|
BRect boundingBoxArray[]) const;
|
||||||
void GetBoundingBoxesAsString(const char charArray[],
|
void GetBoundingBoxesAsString(
|
||||||
int32 numChars, font_metric_mode mode,
|
const char charArray[], int32 numChars,
|
||||||
escapement_delta *delta, BRect boundingBoxArray[]) const;
|
font_metric_mode mode,
|
||||||
void GetBoundingBoxesForStrings(const char *stringArray[],
|
escapement_delta* delta,
|
||||||
|
BRect boundingBoxArray[]) const;
|
||||||
|
void GetBoundingBoxesForStrings(
|
||||||
|
const char* stringArray[],
|
||||||
int32 numStrings, font_metric_mode mode,
|
int32 numStrings, font_metric_mode mode,
|
||||||
escapement_delta deltas[],
|
escapement_delta deltas[],
|
||||||
BRect boundingBoxArray[]) const;
|
BRect boundingBoxArray[]) const;
|
||||||
|
|
||||||
void GetGlyphShapes(const char charArray[], int32 numChars,
|
void GetGlyphShapes(const char charArray[],
|
||||||
BShape *glyphShapeArray[]) const;
|
int32 numChars,
|
||||||
|
BShape* glyphShapeArray[]) const;
|
||||||
|
|
||||||
void GetHasGlyphs(const char charArray[], int32 numChars,
|
void GetHasGlyphs(const char charArray[],
|
||||||
|
int32 numChars,
|
||||||
bool hasArray[]) const;
|
bool hasArray[]) const;
|
||||||
|
|
||||||
BFont& operator=(const BFont &font);
|
BFont& operator=(const BFont& font);
|
||||||
bool operator==(const BFont &font) const;
|
bool operator==(const BFont& font) const;
|
||||||
bool operator!=(const BFont &font) const;
|
bool operator!=(const BFont& font) const;
|
||||||
|
|
||||||
void PrintToStream() const;
|
void PrintToStream() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend void _init_global_fonts_();
|
friend void _init_global_fonts_();
|
||||||
|
|
||||||
|
void _GetExtraFlags() const;
|
||||||
|
void _GetBoundingBoxes(const char charArray[],
|
||||||
|
int32 numChars, font_metric_mode mode,
|
||||||
|
bool string_escapement,
|
||||||
|
escapement_delta* delta,
|
||||||
|
BRect boundingBoxArray[],
|
||||||
|
bool asString) const;
|
||||||
|
|
||||||
|
private:
|
||||||
uint16 fFamilyID;
|
uint16 fFamilyID;
|
||||||
uint16 fStyleID;
|
uint16 fStyleID;
|
||||||
float fSize;
|
float fSize;
|
||||||
@@ -254,55 +294,56 @@ class BFont {
|
|||||||
uint32 fFlags;
|
uint32 fFlags;
|
||||||
mutable font_height fHeight;
|
mutable font_height fHeight;
|
||||||
mutable uint32 fExtraFlags;
|
mutable uint32 fExtraFlags;
|
||||||
uint32 _reserved[1];
|
|
||||||
|
|
||||||
void _GetExtraFlags() const;
|
uint32 _reserved[1];
|
||||||
void _GetBoundingBoxes(const char charArray[],
|
|
||||||
int32 numChars, font_metric_mode mode,
|
|
||||||
bool string_escapement, escapement_delta *delta,
|
|
||||||
BRect boundingBoxArray[], bool asString) const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// BFont related declarations
|
// #pragma mark - BFont related declarations
|
||||||
|
|
||||||
extern const BFont *be_plain_font;
|
extern const BFont* be_plain_font;
|
||||||
extern const BFont *be_bold_font;
|
extern const BFont* be_bold_font;
|
||||||
extern const BFont *be_fixed_font;
|
extern const BFont* be_fixed_font;
|
||||||
|
|
||||||
int32 count_font_families(void);
|
int32 count_font_families(void);
|
||||||
status_t get_font_family(int32 index, font_family *name, uint32 *flags = NULL);
|
status_t get_font_family(int32 index, font_family* name,
|
||||||
|
uint32* flags = NULL);
|
||||||
|
|
||||||
int32 count_font_styles(font_family name);
|
int32 count_font_styles(font_family name);
|
||||||
status_t get_font_style(font_family family, int32 index, font_style *name,
|
status_t get_font_style(font_family family, int32 index, font_style* name,
|
||||||
uint32 *flags = NULL);
|
uint32* flags = NULL);
|
||||||
status_t get_font_style(font_family family, int32 index, font_style *name,
|
status_t get_font_style(font_family family, int32 index, font_style* name,
|
||||||
uint16 *face, uint32 *flags = NULL);
|
uint16* face, uint32* flags = NULL);
|
||||||
bool update_font_families(bool checkOnly);
|
bool update_font_families(bool checkOnly);
|
||||||
|
|
||||||
|
|
||||||
// unicode_block inlines
|
|
||||||
|
// #pragma mark - unicode_block inlines
|
||||||
|
|
||||||
|
|
||||||
unicode_block::unicode_block()
|
unicode_block::unicode_block()
|
||||||
{
|
{
|
||||||
fData[0] = fData[1] = 0LL;
|
fData[0] = fData[1] = 0LL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
unicode_block::unicode_block(uint64 block2, uint64 block1)
|
unicode_block::unicode_block(uint64 block2, uint64 block1)
|
||||||
{
|
{
|
||||||
fData[0] = block1;
|
fData[0] = block1;
|
||||||
fData[1] = block2;
|
fData[1] = block2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
unicode_block::Includes(const unicode_block &block) const
|
unicode_block::Includes(const unicode_block& block) const
|
||||||
{
|
{
|
||||||
return (fData[0] & block.fData[0]) == block.fData[0]
|
return (fData[0] & block.fData[0]) == block.fData[0]
|
||||||
&& (fData[1] & block.fData[1]) == block.fData[1];
|
&& (fData[1] & block.fData[1]) == block.fData[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
unicode_block
|
unicode_block
|
||||||
unicode_block::operator&(const unicode_block &block) const
|
unicode_block::operator&(const unicode_block& block) const
|
||||||
{
|
{
|
||||||
unicode_block result;
|
unicode_block result;
|
||||||
result.fData[0] = fData[0] & block.fData[0];
|
result.fData[0] = fData[0] & block.fData[0];
|
||||||
@@ -311,8 +352,9 @@ unicode_block::operator&(const unicode_block &block) const
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
unicode_block
|
unicode_block
|
||||||
unicode_block::operator|(const unicode_block &block) const
|
unicode_block::operator|(const unicode_block& block) const
|
||||||
{
|
{
|
||||||
unicode_block result;
|
unicode_block result;
|
||||||
result.fData[0] = fData[0] | block.fData[0];
|
result.fData[0] = fData[0] | block.fData[0];
|
||||||
@@ -321,24 +363,27 @@ unicode_block::operator|(const unicode_block &block) const
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
unicode_block &
|
|
||||||
unicode_block::operator=(const unicode_block &block)
|
unicode_block&
|
||||||
|
unicode_block::operator=(const unicode_block& block)
|
||||||
{
|
{
|
||||||
fData[0] = block.fData[0];
|
fData[0] = block.fData[0];
|
||||||
fData[1] = block.fData[1];
|
fData[1] = block.fData[1];
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
unicode_block::operator==(const unicode_block &block) const
|
unicode_block::operator==(const unicode_block& block) const
|
||||||
{
|
{
|
||||||
return fData[0] == block.fData[0] && fData[1] == block.fData[1];
|
return fData[0] == block.fData[0] && fData[1] == block.fData[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
unicode_block::operator!=(const unicode_block &block) const
|
unicode_block::operator!=(const unicode_block& block) const
|
||||||
{
|
{
|
||||||
return fData[0] != block.fData[0] || fData[1] != block.fData[1];
|
return fData[0] != block.fData[0] || fData[1] != block.fData[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* _FONT_H_ */
|
#endif // _FONT_H_
|
||||||
|
|||||||
Reference in New Issue
Block a user