More font work:
* Simplified server communication a bit: instead of separate queries for font
direction, "is fixed", ... there is now a private extra flags field that is
filled on demand.
* The server command names now describe what the command does, and are not simply
named after the BFont method (AS_SET_FAMILY_AND_STYLE vs. AS_GET_FAMILY_AND_STYLE_IDS).
* Replaced B_SET_SYSFONT_{PLAIN|BOLD|FIXED} with a single B_GET_SYSTEM_FONTS.
* Rewrote Font.h and added our license.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14741 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+205
-228
@@ -1,103 +1,104 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2005, Haiku, Inc. All Rights Reserved.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
#ifndef _FONT_H_
|
#ifndef _FONT_H_
|
||||||
#define _FONT_H_
|
#define _FONT_H_
|
||||||
|
|
||||||
#include <BeBuild.h>
|
|
||||||
#include <SupportDefs.h>
|
#include <SupportDefs.h>
|
||||||
#include <InterfaceDefs.h>
|
#include <InterfaceDefs.h>
|
||||||
|
|
||||||
/*----------------------------------------------------------------*/
|
|
||||||
/*----- BFont defines and structures -----------------------------*/
|
|
||||||
|
|
||||||
#define B_FONT_FAMILY_LENGTH 63
|
#define B_FONT_FAMILY_LENGTH 63
|
||||||
typedef char font_family[B_FONT_FAMILY_LENGTH + 1];
|
|
||||||
#define B_FONT_STYLE_LENGTH 63
|
#define B_FONT_STYLE_LENGTH 63
|
||||||
|
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
|
||||||
enum {
|
enum {
|
||||||
B_CHAR_SPACING = 0,
|
B_CHAR_SPACING = 0,
|
||||||
B_STRING_SPACING = 1,
|
B_STRING_SPACING = 1,
|
||||||
B_BITMAP_SPACING = 2,
|
B_BITMAP_SPACING = 2,
|
||||||
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
|
||||||
enum {
|
enum {
|
||||||
B_DISABLE_ANTIALIASING = 0x00000001,
|
B_DISABLE_ANTIALIASING = 0x00000001,
|
||||||
B_FORCE_ANTIALIASING = 0x00000002
|
B_FORCE_ANTIALIASING = 0x00000002
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// truncation modes
|
||||||
enum {
|
enum {
|
||||||
B_TRUNCATE_END = 0,
|
B_TRUNCATE_END = 0,
|
||||||
B_TRUNCATE_BEGINNING = 1,
|
B_TRUNCATE_BEGINNING = 1,
|
||||||
B_TRUNCATE_MIDDLE = 2,
|
B_TRUNCATE_MIDDLE = 2,
|
||||||
B_TRUNCATE_SMART = 3
|
B_TRUNCATE_SMART = 3
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// font encodings
|
||||||
enum {
|
enum {
|
||||||
B_UNICODE_UTF8 = 0,
|
B_UNICODE_UTF8 = 0,
|
||||||
B_ISO_8859_1 = 1,
|
B_ISO_8859_1 = 1,
|
||||||
B_ISO_8859_2 = 2,
|
B_ISO_8859_2 = 2,
|
||||||
B_ISO_8859_3 = 3,
|
B_ISO_8859_3 = 3,
|
||||||
B_ISO_8859_4 = 4,
|
B_ISO_8859_4 = 4,
|
||||||
B_ISO_8859_5 = 5,
|
B_ISO_8859_5 = 5,
|
||||||
B_ISO_8859_6 = 6,
|
B_ISO_8859_6 = 6,
|
||||||
B_ISO_8859_7 = 7,
|
B_ISO_8859_7 = 7,
|
||||||
B_ISO_8859_8 = 8,
|
B_ISO_8859_8 = 8,
|
||||||
B_ISO_8859_9 = 9,
|
B_ISO_8859_9 = 9,
|
||||||
B_ISO_8859_10 = 10,
|
B_ISO_8859_10 = 10,
|
||||||
B_MACINTOSH_ROMAN = 11
|
B_MACINTOSH_ROMAN = 11
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// flags for get_font_family() and get_font_style()
|
||||||
enum {
|
enum {
|
||||||
B_SCREEN_FONT_CACHE = 0x0001,
|
B_HAS_TUNED_FONT = 0x0001,
|
||||||
B_PRINTING_FONT_CACHE = 0x0002,
|
B_IS_FIXED = 0x0002
|
||||||
B_DEFAULT_CACHE_SETTING = 0x0004,
|
|
||||||
B_APP_CACHE_SETTING = 0x0008
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// font face flags
|
||||||
enum {
|
enum {
|
||||||
B_HAS_TUNED_FONT = 0x0001,
|
B_ITALIC_FACE = 0x0001,
|
||||||
B_IS_FIXED = 0x0002
|
B_UNDERSCORE_FACE = 0x0002,
|
||||||
};
|
B_NEGATIVE_FACE = 0x0004,
|
||||||
|
B_OUTLINED_FACE = 0x0008,
|
||||||
enum {
|
B_STRIKEOUT_FACE = 0x0010,
|
||||||
B_ITALIC_FACE = 0x0001,
|
B_BOLD_FACE = 0x0020,
|
||||||
B_UNDERSCORE_FACE = 0x0002,
|
B_REGULAR_FACE = 0x0040
|
||||||
B_NEGATIVE_FACE = 0x0004,
|
|
||||||
B_OUTLINED_FACE = 0x0008,
|
|
||||||
B_STRIKEOUT_FACE = 0x0010,
|
|
||||||
B_BOLD_FACE = 0x0020,
|
|
||||||
B_REGULAR_FACE = 0x0040
|
|
||||||
};
|
};
|
||||||
|
|
||||||
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 {
|
||||||
@@ -137,222 +138,198 @@ class BShape;
|
|||||||
class BString;
|
class BString;
|
||||||
class BFontPrivate;
|
class BFontPrivate;
|
||||||
|
|
||||||
|
|
||||||
class BFont {
|
class BFont {
|
||||||
public:
|
public:
|
||||||
BFont(void);
|
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 SetShear(float shear);
|
|
||||||
void SetRotation(float rotation);
|
|
||||||
void SetSpacing(uint8 spacing);
|
|
||||||
void SetEncoding(uint8 encoding);
|
|
||||||
void SetFace(uint16 face);
|
|
||||||
void SetFlags(uint32 flags);
|
|
||||||
|
|
||||||
void GetFamilyAndStyle(font_family *family,
|
void SetSize(float size);
|
||||||
font_style *style) const;
|
void SetShear(float shear);
|
||||||
uint32 FamilyAndStyle(void) const;
|
void SetRotation(float rotation);
|
||||||
float Size(void) const;
|
void SetSpacing(uint8 spacing);
|
||||||
float Shear(void) const;
|
void SetEncoding(uint8 encoding);
|
||||||
float Rotation(void) const;
|
void SetFace(uint16 face);
|
||||||
uint8 Spacing(void) const;
|
void SetFlags(uint32 flags);
|
||||||
uint8 Encoding(void) const;
|
|
||||||
uint16 Face(void) const;
|
|
||||||
uint32 Flags(void) const;
|
|
||||||
|
|
||||||
font_direction Direction(void) const;
|
|
||||||
bool IsFixed(void) const;
|
|
||||||
bool IsFullAndHalfFixed(void) const;
|
|
||||||
BRect BoundingBox(void) const;
|
|
||||||
unicode_block Blocks(void) const;
|
|
||||||
font_file_format FileFormat(void) const;
|
|
||||||
|
|
||||||
int32 CountTuned(void) const;
|
void GetFamilyAndStyle(font_family *family,
|
||||||
void GetTunedInfo(int32 index, tuned_font_info *info) const;
|
font_style *style) const;
|
||||||
|
uint32 FamilyAndStyle() const;
|
||||||
|
float Size() const;
|
||||||
|
float Shear() const;
|
||||||
|
float Rotation() const;
|
||||||
|
uint8 Spacing() const;
|
||||||
|
uint8 Encoding() const;
|
||||||
|
uint16 Face() const;
|
||||||
|
uint32 Flags() const;
|
||||||
|
|
||||||
void TruncateString(BString* in_out,
|
font_direction Direction() const;
|
||||||
uint32 mode,
|
bool IsFixed() const;
|
||||||
float width) const;
|
bool IsFullAndHalfFixed() const;
|
||||||
void GetTruncatedStrings(const char *stringArray[],
|
BRect BoundingBox() const;
|
||||||
int32 numStrings,
|
unicode_block Blocks() const;
|
||||||
uint32 mode,
|
font_file_format FileFormat() const;
|
||||||
float width,
|
|
||||||
BString resultArray[]) const;
|
|
||||||
void GetTruncatedStrings(const char *stringArray[],
|
|
||||||
int32 numStrings,
|
|
||||||
uint32 mode,
|
|
||||||
float width,
|
|
||||||
char *resultArray[]) const;
|
|
||||||
|
|
||||||
float StringWidth(const char *string) const;
|
int32 CountTuned() const;
|
||||||
float StringWidth(const char *string, int32 length) const;
|
void GetTunedInfo(int32 index, tuned_font_info *info) const;
|
||||||
void GetStringWidths(const char *stringArray[],
|
|
||||||
const int32 lengthArray[],
|
|
||||||
int32 numStrings,
|
|
||||||
float widthArray[]) const;
|
|
||||||
|
|
||||||
void GetEscapements(const char charArray[],
|
void TruncateString(BString* inOut, uint32 mode,
|
||||||
int32 numChars,
|
float width) const;
|
||||||
float escapementArray[]) const;
|
void GetTruncatedStrings(const char *stringArray[],
|
||||||
void GetEscapements(const char charArray[],
|
int32 numStrings, uint32 mode, float width,
|
||||||
int32 numChars,
|
BString resultArray[]) const;
|
||||||
escapement_delta *delta,
|
void GetTruncatedStrings(const char *stringArray[],
|
||||||
float escapementArray[]) const;
|
int32 numStrings, uint32 mode, float width,
|
||||||
void GetEscapements(const char charArray[],
|
char *resultArray[]) const;
|
||||||
int32 numChars,
|
|
||||||
escapement_delta *delta,
|
|
||||||
BPoint escapementArray[]) const;
|
|
||||||
void GetEscapements(const char charArray[],
|
|
||||||
int32 numChars,
|
|
||||||
escapement_delta *delta,
|
|
||||||
BPoint escapementArray[],
|
|
||||||
BPoint offsetArray[]) const;
|
|
||||||
|
|
||||||
void GetEdges(const char charArray[],
|
|
||||||
int32 numBytes,
|
|
||||||
edge_info edgeArray[]) const;
|
|
||||||
void GetHeight(font_height *height) const;
|
|
||||||
|
|
||||||
void GetBoundingBoxesAsGlyphs(const char charArray[],
|
|
||||||
int32 numChars,
|
|
||||||
font_metric_mode mode,
|
|
||||||
BRect boundingBoxArray[]) const;
|
|
||||||
void GetBoundingBoxesAsString(const char charArray[],
|
|
||||||
int32 numChars,
|
|
||||||
font_metric_mode mode,
|
|
||||||
escapement_delta *delta,
|
|
||||||
BRect boundingBoxArray[]) const;
|
|
||||||
void GetBoundingBoxesForStrings(const char *stringArray[],
|
|
||||||
int32 numStrings,
|
|
||||||
font_metric_mode mode,
|
|
||||||
escapement_delta deltas[],
|
|
||||||
BRect boundingBoxArray[]) const;
|
|
||||||
|
|
||||||
void GetGlyphShapes(const char charArray[],
|
|
||||||
int32 numChars,
|
|
||||||
BShape *glyphShapeArray[]) const;
|
|
||||||
|
|
||||||
void GetHasGlyphs(const char charArray[],
|
float StringWidth(const char *string) const;
|
||||||
int32 numChars,
|
float StringWidth(const char *string, int32 length) const;
|
||||||
bool hasArray[]) const;
|
void GetStringWidths(const char *stringArray[],
|
||||||
|
const int32 lengthArray[], int32 numStrings,
|
||||||
BFont& operator=(const BFont &font);
|
float widthArray[]) const;
|
||||||
bool operator==(const BFont &font) const;
|
|
||||||
bool operator!=(const BFont &font) const;
|
|
||||||
|
|
||||||
void PrintToStream(void) const;
|
void GetEscapements(const char charArray[], int32 numChars,
|
||||||
|
float escapementArray[]) const;
|
||||||
private:
|
void GetEscapements(const char charArray[], int32 numChars,
|
||||||
|
escapement_delta *delta, float escapementArray[]) const;
|
||||||
|
void GetEscapements(const char charArray[], int32 numChars,
|
||||||
|
escapement_delta *delta, BPoint escapementArray[]) const;
|
||||||
|
void GetEscapements(const char charArray[], int32 numChars,
|
||||||
|
escapement_delta *delta, BPoint escapementArray[],
|
||||||
|
BPoint offsetArray[]) const;
|
||||||
|
|
||||||
friend void _font_control_(BFont*, int32, void*);
|
void GetEdges(const char charArray[], int32 numBytes,
|
||||||
|
edge_info edgeArray[]) const;
|
||||||
|
void GetHeight(font_height *height) const;
|
||||||
|
|
||||||
uint16 fFamilyID;
|
void GetBoundingBoxesAsGlyphs(const char charArray[],
|
||||||
uint16 fStyleID;
|
int32 numChars, font_metric_mode mode,
|
||||||
float fSize;
|
BRect boundingBoxArray[]) const;
|
||||||
float fShear;
|
void GetBoundingBoxesAsString(const char charArray[],
|
||||||
float fRotation;
|
int32 numChars, font_metric_mode mode,
|
||||||
uint8 fSpacing;
|
escapement_delta *delta, BRect boundingBoxArray[]) const;
|
||||||
uint8 fEncoding;
|
void GetBoundingBoxesForStrings(const char *stringArray[],
|
||||||
uint16 fFace;
|
int32 numStrings, font_metric_mode mode,
|
||||||
uint32 fFlags;
|
escapement_delta deltas[],
|
||||||
|
BRect boundingBoxArray[]) const;
|
||||||
|
|
||||||
|
void GetGlyphShapes(const char charArray[], int32 numChars,
|
||||||
|
BShape *glyphShapeArray[]) const;
|
||||||
|
|
||||||
|
void GetHasGlyphs(const char charArray[], int32 numChars,
|
||||||
|
bool hasArray[]) const;
|
||||||
|
|
||||||
|
BFont& operator=(const BFont &font);
|
||||||
|
bool operator==(const BFont &font) const;
|
||||||
|
bool operator!=(const BFont &font) const;
|
||||||
|
|
||||||
|
void PrintToStream() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
friend void _init_global_fonts_();
|
||||||
|
|
||||||
|
uint16 fFamilyID;
|
||||||
|
uint16 fStyleID;
|
||||||
|
float fSize;
|
||||||
|
float fShear;
|
||||||
|
float fRotation;
|
||||||
|
uint8 fSpacing;
|
||||||
|
uint8 fEncoding;
|
||||||
|
uint16 fFace;
|
||||||
|
uint32 fFlags;
|
||||||
mutable font_height fHeight;
|
mutable font_height fHeight;
|
||||||
uint32 _reserved[3];
|
mutable uint32 fExtraFlags;
|
||||||
|
uint32 _reserved[2];
|
||||||
|
|
||||||
void SetPacket(void *packet) const;
|
status_t _GetExtraFlags() const;
|
||||||
void GetTruncatedStrings64(const char *stringArray[],
|
void _GetBoundingBoxes(const char charArray[],
|
||||||
int32 numStrings,
|
int32 numChars, font_metric_mode mode,
|
||||||
uint32 mode,
|
bool string_escapement, escapement_delta *delta,
|
||||||
float width,
|
BRect boundingBoxArray[]) const;
|
||||||
char *resultArray[]) const;
|
|
||||||
void GetTruncatedStrings64(const char *stringArray[],
|
|
||||||
int32 numStrings,
|
|
||||||
uint32 mode,
|
|
||||||
float width,
|
|
||||||
BString resultArray[]) const;
|
|
||||||
void _GetEscapements_(const char charArray[],
|
|
||||||
int32 numChars,
|
|
||||||
escapement_delta *delta,
|
|
||||||
uint8 mode,
|
|
||||||
float *escapements,
|
|
||||||
float *offsets = NULL) const;
|
|
||||||
void _GetBoundingBoxes_(const char charArray[],
|
|
||||||
int32 numChars,
|
|
||||||
font_metric_mode mode,
|
|
||||||
bool string_escapement,
|
|
||||||
escapement_delta *delta,
|
|
||||||
BRect boundingBoxArray[]) const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*----------------------------------------------------------------*/
|
|
||||||
/*----- BFont related declarations -------------------------------*/
|
// 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 check_only);
|
bool update_font_families(bool checkOnly);
|
||||||
|
|
||||||
status_t get_font_cache_info(uint32 id, void *set);
|
|
||||||
status_t set_font_cache_info(uint32 id, void *set);
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------*/
|
// unicode_block inlines
|
||||||
/*----- unicode_block inlines ------------------------------------*/
|
|
||||||
|
|
||||||
unicode_block::unicode_block() { fData[0] = fData[1] = 0LL; }
|
unicode_block::unicode_block()
|
||||||
|
{
|
||||||
|
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 unicode_block::Includes(const unicode_block &block) const {
|
bool
|
||||||
return (((fData[0] & block.fData[0]) == block.fData[0]) &&
|
unicode_block::Includes(const unicode_block &block) const
|
||||||
((fData[1] & block.fData[1]) == block.fData[1]));
|
{
|
||||||
|
return (fData[0] & block.fData[0]) == block.fData[0]
|
||||||
|
&& (fData[1] & block.fData[1]) == block.fData[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
unicode_block unicode_block::operator&(const unicode_block &block) const {
|
unicode_block
|
||||||
unicode_block res;
|
unicode_block::operator&(const unicode_block &block) const
|
||||||
|
{
|
||||||
res.fData[0] = fData[0] & block.fData[0];
|
unicode_block result;
|
||||||
res.fData[1] = fData[1] & block.fData[1];
|
result.fData[0] = fData[0] & block.fData[0];
|
||||||
return res;
|
result.fData[1] = fData[1] & block.fData[1];
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
unicode_block unicode_block::operator|(const unicode_block &block) const {
|
unicode_block
|
||||||
unicode_block res;
|
unicode_block::operator|(const unicode_block &block) const
|
||||||
|
{
|
||||||
res.fData[0] = fData[0] | block.fData[0];
|
unicode_block result;
|
||||||
res.fData[1] = fData[1] | block.fData[1];
|
result.fData[0] = fData[0] | block.fData[0];
|
||||||
return res;
|
result.fData[1] = fData[1] | block.fData[1];
|
||||||
|
|
||||||
|
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 unicode_block::operator==(const unicode_block &block) const {
|
bool
|
||||||
return ((fData[0] == block.fData[0]) && (fData[1] == block.fData[1]));
|
unicode_block::operator==(const unicode_block &block) const
|
||||||
|
{
|
||||||
|
return fData[0] == block.fData[0] && fData[1] == block.fData[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
bool unicode_block::operator!=(const unicode_block &block) const {
|
bool
|
||||||
return ((fData[0] != block.fData[0]) || (fData[1] != block.fData[1]));
|
unicode_block::operator!=(const unicode_block &block) const
|
||||||
|
{
|
||||||
|
return fData[0] != block.fData[0] || fData[1] != block.fData[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* _FONT_H_ */
|
#endif /* _FONT_H_ */
|
||||||
|
|||||||
@@ -113,23 +113,23 @@ enum {
|
|||||||
|
|
||||||
// Font-related server communications
|
// Font-related server communications
|
||||||
AS_SET_SYSTEM_FONT,
|
AS_SET_SYSTEM_FONT,
|
||||||
|
AS_GET_SYSTEM_FONTS,
|
||||||
|
|
||||||
AS_QUERY_FONTS_CHANGED,
|
AS_QUERY_FONTS_CHANGED,
|
||||||
AS_UPDATED_CLIENT_FONTLIST,
|
AS_UPDATED_CLIENT_FONTLIST,
|
||||||
AS_GET_FAMILY_NAME,
|
AS_GET_FAMILY_NAME,
|
||||||
AS_GET_STYLE_NAME,
|
AS_GET_STYLE_NAME,
|
||||||
|
AS_COUNT_FONT_FAMILIES,
|
||||||
|
AS_COUNT_FONT_STYLES,
|
||||||
|
|
||||||
AS_GET_FAMILY_AND_STYLE,
|
AS_GET_FAMILY_AND_STYLE,
|
||||||
AS_GET_FONT_DIRECTION,
|
AS_GET_FAMILY_AND_STYLE_IDS,
|
||||||
AS_GET_FONT_BOUNDING_BOX,
|
AS_GET_FONT_BOUNDING_BOX,
|
||||||
AS_GET_TUNED_COUNT,
|
AS_GET_TUNED_COUNT,
|
||||||
AS_GET_TUNED_INFO,
|
AS_GET_TUNED_INFO,
|
||||||
AS_GET_FONT_HEIGHT,
|
AS_GET_FONT_HEIGHT,
|
||||||
AS_GET_FONT_FILE_FORMAT,
|
AS_GET_FONT_FILE_FORMAT,
|
||||||
|
AS_GET_EXTRA_FONT_FLAGS,
|
||||||
AS_QUERY_FONT_FIXED,
|
|
||||||
AS_SET_FAMILY_AND_STYLE,
|
|
||||||
|
|
||||||
AS_COUNT_FONT_FAMILIES,
|
|
||||||
AS_COUNT_FONT_STYLES,
|
|
||||||
|
|
||||||
AS_GET_STRING_WIDTHS,
|
AS_GET_STRING_WIDTHS,
|
||||||
AS_GET_EDGES,
|
AS_GET_EDGES,
|
||||||
@@ -141,10 +141,6 @@ enum {
|
|||||||
AS_GET_GLYPH_SHAPES,
|
AS_GET_GLYPH_SHAPES,
|
||||||
AS_GET_TRUNCATED_STRINGS,
|
AS_GET_TRUNCATED_STRINGS,
|
||||||
|
|
||||||
AS_SET_SYSFONT_PLAIN,
|
|
||||||
AS_SET_SYSFONT_BOLD,
|
|
||||||
AS_SET_SYSFONT_FIXED,
|
|
||||||
|
|
||||||
// Screen methods
|
// Screen methods
|
||||||
AS_SCREEN_GET_MODE,
|
AS_SCREEN_GET_MODE,
|
||||||
AS_SCREEN_SET_MODE,
|
AS_SCREEN_SET_MODE,
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2005, Haiku, Inc. All Rights Reserved.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
#ifndef FONT_PRIVATE_H
|
||||||
|
#define FONT_PRIVATE_H
|
||||||
|
|
||||||
|
|
||||||
|
// extra flags (shares B_IS_FIXED and B_HAS_TUNED_FONT)
|
||||||
|
enum {
|
||||||
|
B_PRIVATE_FONT_IS_FULL_AND_HALF_FIXED = 0x04,
|
||||||
|
B_PRIVATE_FONT_HAS_KERNING = 0x08,
|
||||||
|
B_PRIVATE_FONT_DIRECTION_MASK = 0x30,
|
||||||
|
};
|
||||||
|
|
||||||
|
#define B_PRIVATE_FONT_DIRECTION_SHIFT 8
|
||||||
|
|
||||||
|
#endif /* FONT_PRIVATE_H */
|
||||||
+98
-127
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2001-2005, Haiku.
|
* Copyright 2001-2005, Haiku, Inc.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -13,6 +13,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <AppServerLink.h>
|
#include <AppServerLink.h>
|
||||||
|
#include <Font.h>
|
||||||
#include <Message.h>
|
#include <Message.h>
|
||||||
#include <PortLink.h>
|
#include <PortLink.h>
|
||||||
#include <Rect.h>
|
#include <Rect.h>
|
||||||
@@ -22,11 +23,11 @@
|
|||||||
|
|
||||||
#include <moreUTF8.h>
|
#include <moreUTF8.h>
|
||||||
#include <truncate_string.h>
|
#include <truncate_string.h>
|
||||||
|
#include <FontPrivate.h>
|
||||||
#include <Font.h>
|
|
||||||
|
|
||||||
|
|
||||||
const float kUninitializedAscent = INFINITY;
|
const float kUninitializedAscent = INFINITY;
|
||||||
|
const uint32 kUninitializedExtraFlags = 0xffffffff;
|
||||||
|
|
||||||
// The actual objects which the globals point to
|
// The actual objects which the globals point to
|
||||||
static BFont sPlainFont;
|
static BFont sPlainFont;
|
||||||
@@ -38,59 +39,53 @@ const BFont *be_bold_font = &sBoldFont;
|
|||||||
const BFont *be_fixed_font = &sFixedFont;
|
const BFont *be_fixed_font = &sFixedFont;
|
||||||
|
|
||||||
|
|
||||||
extern "C" void
|
|
||||||
_init_global_fonts()
|
|
||||||
{
|
|
||||||
_font_control_(&sPlainFont, AS_SET_SYSFONT_PLAIN, NULL);
|
|
||||||
_font_control_(&sBoldFont, AS_SET_SYSFONT_BOLD, NULL);
|
|
||||||
_font_control_(&sFixedFont, AS_SET_SYSFONT_FIXED, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Private function originally used by Be. Now used for initialization
|
|
||||||
\param font The font to initialize
|
|
||||||
\param cmd message code to send to the app_server
|
|
||||||
\param data unused
|
|
||||||
|
|
||||||
While it is not known what Be used it for, Haiku uses it to initialize the
|
|
||||||
three system fonts when the interface kit is initialized when an app starts.
|
|
||||||
*/
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_font_control_(BFont *font, int32 cmd, void *data)
|
_init_global_fonts_()
|
||||||
{
|
{
|
||||||
if (!font
|
|
||||||
|| (cmd != AS_SET_SYSFONT_PLAIN && cmd != AS_SET_SYSFONT_BOLD
|
|
||||||
&& cmd != AS_SET_SYSFONT_FIXED)) {
|
|
||||||
// this shouldn't ever happen, but just in case....
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
BPrivate::AppServerLink link;
|
BPrivate::AppServerLink link;
|
||||||
link.StartMessage(cmd);
|
link.StartMessage(AS_GET_SYSTEM_FONTS);
|
||||||
|
|
||||||
int32 code;
|
int32 code;
|
||||||
if (link.FlushWithReply(code) != B_OK
|
if (link.FlushWithReply(code) != B_OK
|
||||||
|| code != B_OK) {
|
|| code != B_OK) {
|
||||||
printf("DEBUG: Couldn't initialize font in _font_control()\n");
|
printf("DEBUG: Couldn't initialize global fonts!\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// there really isn't that much data that we need to set for such cases -- most
|
char type[B_OS_NAME_LENGTH];
|
||||||
// of them need to be set to the defaults. The stuff that can change are family,
|
|
||||||
// style/face, size, and height.
|
|
||||||
// NOTE: this code assumes it's only called
|
|
||||||
link.Read<uint16>(&font->fFamilyID);
|
|
||||||
link.Read<uint16>(&font->fStyleID);
|
|
||||||
link.Read<float>(&font->fSize);
|
|
||||||
link.Read<uint16>(&font->fFace);
|
|
||||||
link.Read<uint32>(&font->fFlags);
|
|
||||||
|
|
||||||
font->fHeight.ascent = kUninitializedAscent;
|
while (link.ReadString(type, sizeof(type)) >= B_OK && type[0]) {
|
||||||
|
BFont dummy;
|
||||||
|
BFont *font = &dummy;
|
||||||
|
|
||||||
|
if (!strcmp(type, "plain"))
|
||||||
|
font = &sPlainFont;
|
||||||
|
else if (!strcmp(type, "bold"))
|
||||||
|
font = &sBoldFont;
|
||||||
|
else if (!strcmp(type, "fixed"))
|
||||||
|
font = &sFixedFont;
|
||||||
|
|
||||||
|
link.Read<uint16>(&font->fFamilyID);
|
||||||
|
link.Read<uint16>(&font->fStyleID);
|
||||||
|
link.Read<float>(&font->fSize);
|
||||||
|
link.Read<uint16>(&font->fFace);
|
||||||
|
link.Read<uint32>(&font->fFlags);
|
||||||
|
|
||||||
|
font->fHeight.ascent = kUninitializedAscent;
|
||||||
|
font->fExtraFlags = kUninitializedExtraFlags;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: the following functions are private Be API functions - if no problems
|
||||||
|
// arise by not exporting these symbols, we can just remove them
|
||||||
|
#if 0
|
||||||
|
void _font_control_(BFont *font, int32 cmd, void *data) {}
|
||||||
|
status_t get_font_cache_info(uint32 id, void *set) { return B_ERROR; }
|
||||||
|
status_t set_font_cache_info(uint32 id, void *set) { return B_ERROR; }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Private function used to replace the R5 hack which sets a system font
|
\brief Private function used to replace the R5 hack which sets a system font
|
||||||
\param which string denoting which font to set
|
\param which string denoting which font to set
|
||||||
@@ -105,21 +100,18 @@ void
|
|||||||
_set_system_font_(const char *which, font_family family, font_style style,
|
_set_system_font_(const char *which, font_family family, font_style style,
|
||||||
float size)
|
float size)
|
||||||
{
|
{
|
||||||
if (!which)
|
if (which == NULL || strcmp(which, "plain")
|
||||||
|
|| strcmp(which, "bold") || strcmp(which, "fixed"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!strcmp(which, "plain")
|
|
||||||
|| !strcmp(which, "bold")
|
|
||||||
|| !strcmp(which, "fixed")) {
|
|
||||||
BPrivate::AppServerLink link;
|
|
||||||
|
|
||||||
link.StartMessage(AS_SET_SYSTEM_FONT);
|
BPrivate::AppServerLink link;
|
||||||
link.AttachString(which);
|
|
||||||
link.AttachString(family);
|
link.StartMessage(AS_SET_SYSTEM_FONT);
|
||||||
link.AttachString(style);
|
link.AttachString(which);
|
||||||
link.Attach<float>(size);
|
link.AttachString(family);
|
||||||
link.Flush();
|
link.AttachString(style);
|
||||||
}
|
link.Attach<float>(size);
|
||||||
|
link.Flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -293,30 +285,6 @@ update_font_families(bool checkOnly)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
|
||||||
get_font_cache_info(uint32 id, void *set)
|
|
||||||
{
|
|
||||||
// TODO: Implement
|
|
||||||
|
|
||||||
// Note that the only reliable data from this function will probably be the cache size
|
|
||||||
// Depending on how the font cache is implemented, this function and the corresponding
|
|
||||||
// set function will either see major revision or completely disappear in R2.
|
|
||||||
return B_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
status_t
|
|
||||||
set_font_cache_info(uint32 id, void *set)
|
|
||||||
{
|
|
||||||
// TODO: Implement
|
|
||||||
|
|
||||||
// Note that this function will likely only set the cache size in our implementation
|
|
||||||
// because of (a) the lack of knowledge on R5's font system and (b) the fact that it
|
|
||||||
// is a completely different font engine.
|
|
||||||
return B_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
@@ -331,7 +299,8 @@ BFont::BFont()
|
|||||||
fSpacing(0),
|
fSpacing(0),
|
||||||
fEncoding(0),
|
fEncoding(0),
|
||||||
fFace(0),
|
fFace(0),
|
||||||
fFlags(0)
|
fFlags(0),
|
||||||
|
fExtraFlags(kUninitializedExtraFlags)
|
||||||
{
|
{
|
||||||
if (be_plain_font != NULL && this != &sPlainFont)
|
if (be_plain_font != NULL && this != &sPlainFont)
|
||||||
*this = *be_plain_font;
|
*this = *be_plain_font;
|
||||||
@@ -373,7 +342,7 @@ BFont::SetFamilyAndStyle(const font_family family, const font_style style)
|
|||||||
|
|
||||||
BPrivate::AppServerLink link;
|
BPrivate::AppServerLink link;
|
||||||
|
|
||||||
link.StartMessage(AS_SET_FAMILY_AND_STYLE);
|
link.StartMessage(AS_GET_FAMILY_AND_STYLE_IDS);
|
||||||
link.AttachString(family);
|
link.AttachString(family);
|
||||||
link.AttachString(style);
|
link.AttachString(style);
|
||||||
link.Attach<uint16>(fFamilyID);
|
link.Attach<uint16>(fFamilyID);
|
||||||
@@ -412,7 +381,7 @@ BFont::SetFamilyAndStyle(uint32 fontcode)
|
|||||||
family = (fontcode & 0xFFFF0000) >> 16;
|
family = (fontcode & 0xFFFF0000) >> 16;
|
||||||
|
|
||||||
BPrivate::AppServerLink link;
|
BPrivate::AppServerLink link;
|
||||||
link.StartMessage(AS_SET_FAMILY_AND_STYLE);
|
link.StartMessage(AS_GET_FAMILY_AND_STYLE_IDS);
|
||||||
link.AttachString(NULL); // no family and style name
|
link.AttachString(NULL); // no family and style name
|
||||||
link.AttachString(NULL);
|
link.AttachString(NULL);
|
||||||
link.Attach<uint16>(family);
|
link.Attach<uint16>(family);
|
||||||
@@ -446,7 +415,7 @@ status_t
|
|||||||
BFont::SetFamilyAndFace(const font_family family, uint16 face)
|
BFont::SetFamilyAndFace(const font_family family, uint16 face)
|
||||||
{
|
{
|
||||||
BPrivate::AppServerLink link;
|
BPrivate::AppServerLink link;
|
||||||
link.StartMessage(AS_SET_FAMILY_AND_STYLE);
|
link.StartMessage(AS_GET_FAMILY_AND_STYLE_IDS);
|
||||||
link.AttachString(family);
|
link.AttachString(family);
|
||||||
link.AttachString(NULL); // no style given
|
link.AttachString(NULL); // no style given
|
||||||
link.Attach<uint16>(fFamilyID);
|
link.Attach<uint16>(fFamilyID);
|
||||||
@@ -558,96 +527,76 @@ BFont::GetFamilyAndStyle(font_family *family, font_style *style) const
|
|||||||
|
|
||||||
|
|
||||||
uint32
|
uint32
|
||||||
BFont::FamilyAndStyle(void) const
|
BFont::FamilyAndStyle() const
|
||||||
{
|
{
|
||||||
return (fFamilyID << 16UL) | fStyleID;
|
return (fFamilyID << 16UL) | fStyleID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float
|
float
|
||||||
BFont::Size(void) const
|
BFont::Size() const
|
||||||
{
|
{
|
||||||
return fSize;
|
return fSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float
|
float
|
||||||
BFont::Shear(void) const
|
BFont::Shear() const
|
||||||
{
|
{
|
||||||
return fShear;
|
return fShear;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float
|
float
|
||||||
BFont::Rotation(void) const
|
BFont::Rotation() const
|
||||||
{
|
{
|
||||||
return fRotation;
|
return fRotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint8
|
uint8
|
||||||
BFont::Spacing(void) const
|
BFont::Spacing() const
|
||||||
{
|
{
|
||||||
return fSpacing;
|
return fSpacing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint8
|
uint8
|
||||||
BFont::Encoding(void) const
|
BFont::Encoding() const
|
||||||
{
|
{
|
||||||
return fEncoding;
|
return fEncoding;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint16
|
uint16
|
||||||
BFont::Face(void) const
|
BFont::Face() const
|
||||||
{
|
{
|
||||||
return fFace;
|
return fFace;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint32
|
uint32
|
||||||
BFont::Flags(void) const
|
BFont::Flags() const
|
||||||
{
|
{
|
||||||
return fFlags;
|
return fFlags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
font_direction
|
font_direction
|
||||||
BFont::Direction(void) const
|
BFont::Direction() const
|
||||||
{
|
{
|
||||||
BPrivate::AppServerLink link;
|
if (_GetExtraFlags() != B_OK)
|
||||||
link.StartMessage(AS_GET_FONT_DIRECTION);
|
|
||||||
link.Attach<uint16>(fFamilyID);
|
|
||||||
link.Attach<uint16>(fStyleID);
|
|
||||||
|
|
||||||
int32 code;
|
|
||||||
if (link.FlushWithReply(code) != B_OK
|
|
||||||
|| code != B_OK)
|
|
||||||
return B_FONT_LEFT_TO_RIGHT;
|
return B_FONT_LEFT_TO_RIGHT;
|
||||||
|
|
||||||
font_direction fdir;
|
return (font_direction)(fExtraFlags >> B_PRIVATE_FONT_DIRECTION_SHIFT);
|
||||||
link.Read<font_direction>(&fdir);
|
|
||||||
return fdir;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BFont::IsFixed(void) const
|
BFont::IsFixed() const
|
||||||
{
|
{
|
||||||
BPrivate::AppServerLink link;
|
_GetExtraFlags();
|
||||||
link.StartMessage(AS_QUERY_FONT_FIXED);
|
return (fExtraFlags & B_IS_FIXED) != 0;
|
||||||
link.Attach<uint16>(fFamilyID);
|
|
||||||
link.Attach<uint16>(fStyleID);
|
|
||||||
|
|
||||||
int32 code;
|
|
||||||
if (link.FlushWithReply(code) != B_OK
|
|
||||||
|| code != B_OK)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
bool fixed;
|
|
||||||
link.Read<bool>(&fixed);
|
|
||||||
return fixed;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -659,14 +608,15 @@ BFont::IsFixed(void) const
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BFont::IsFullAndHalfFixed(void) const
|
BFont::IsFullAndHalfFixed() const
|
||||||
{
|
{
|
||||||
return false;
|
_GetExtraFlags();
|
||||||
|
return (fExtraFlags & B_PRIVATE_FONT_IS_FULL_AND_HALF_FIXED) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BRect
|
BRect
|
||||||
BFont::BoundingBox(void) const
|
BFont::BoundingBox() const
|
||||||
{
|
{
|
||||||
BPrivate::AppServerLink link;
|
BPrivate::AppServerLink link;
|
||||||
link.StartMessage(AS_GET_FONT_BOUNDING_BOX);
|
link.StartMessage(AS_GET_FONT_BOUNDING_BOX);
|
||||||
@@ -685,7 +635,7 @@ BFont::BoundingBox(void) const
|
|||||||
|
|
||||||
|
|
||||||
unicode_block
|
unicode_block
|
||||||
BFont::Blocks(void) const
|
BFont::Blocks() const
|
||||||
{
|
{
|
||||||
// TODO: Add Block support
|
// TODO: Add Block support
|
||||||
return unicode_block();
|
return unicode_block();
|
||||||
@@ -693,7 +643,7 @@ BFont::Blocks(void) const
|
|||||||
|
|
||||||
|
|
||||||
font_file_format
|
font_file_format
|
||||||
BFont::FileFormat(void) const
|
BFont::FileFormat() const
|
||||||
{
|
{
|
||||||
BPrivate::AppServerLink link;
|
BPrivate::AppServerLink link;
|
||||||
link.StartMessage(AS_GET_FONT_FILE_FORMAT);
|
link.StartMessage(AS_GET_FONT_FILE_FORMAT);
|
||||||
@@ -715,7 +665,7 @@ BFont::FileFormat(void) const
|
|||||||
|
|
||||||
|
|
||||||
int32
|
int32
|
||||||
BFont::CountTuned(void) const
|
BFont::CountTuned() const
|
||||||
{
|
{
|
||||||
BPrivate::AppServerLink link;
|
BPrivate::AppServerLink link;
|
||||||
link.StartMessage(AS_GET_TUNED_COUNT);
|
link.StartMessage(AS_GET_TUNED_COUNT);
|
||||||
@@ -1014,7 +964,7 @@ void
|
|||||||
BFont::GetBoundingBoxesAsGlyphs(const char charArray[], int32 numChars, font_metric_mode mode,
|
BFont::GetBoundingBoxesAsGlyphs(const char charArray[], int32 numChars, font_metric_mode mode,
|
||||||
BRect boundingBoxArray[]) const
|
BRect boundingBoxArray[]) const
|
||||||
{
|
{
|
||||||
_GetBoundingBoxes_(charArray, numChars, mode, false, NULL, boundingBoxArray);
|
_GetBoundingBoxes(charArray, numChars, mode, false, NULL, boundingBoxArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1022,12 +972,12 @@ void
|
|||||||
BFont::GetBoundingBoxesAsString(const char charArray[], int32 numChars, font_metric_mode mode,
|
BFont::GetBoundingBoxesAsString(const char charArray[], int32 numChars, font_metric_mode mode,
|
||||||
escapement_delta *delta, BRect boundingBoxArray[]) const
|
escapement_delta *delta, BRect boundingBoxArray[]) const
|
||||||
{
|
{
|
||||||
_GetBoundingBoxes_(charArray, numChars, mode, true, delta, boundingBoxArray);
|
_GetBoundingBoxes(charArray, numChars, mode, true, delta, boundingBoxArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BFont::_GetBoundingBoxes_(const char charArray[], int32 numChars, font_metric_mode mode,
|
BFont::_GetBoundingBoxes(const char charArray[], int32 numChars, font_metric_mode mode,
|
||||||
bool string_escapement, escapement_delta *delta, BRect boundingBoxArray[]) const
|
bool string_escapement, escapement_delta *delta, BRect boundingBoxArray[]) const
|
||||||
{
|
{
|
||||||
if (!charArray || numChars < 1 || !boundingBoxArray)
|
if (!charArray || numChars < 1 || !boundingBoxArray)
|
||||||
@@ -1213,9 +1163,30 @@ BFont::operator!=(const BFont &font) const
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BFont::PrintToStream(void) const
|
BFont::PrintToStream() const
|
||||||
{
|
{
|
||||||
printf("FAMILY STYLE %f %f %f %f %f %f\n", fSize, fShear, fRotation, fHeight.ascent,
|
printf("FAMILY STYLE %f %f %f %f %f %f\n", fSize, fShear, fRotation, fHeight.ascent,
|
||||||
fHeight.descent, fHeight.leading);
|
fHeight.descent, fHeight.leading);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
BFont::_GetExtraFlags() const
|
||||||
|
{
|
||||||
|
// TODO: this has to be const in order to allow other font getters to stay const as well
|
||||||
|
if (fExtraFlags != kUninitializedExtraFlags)
|
||||||
|
return B_OK;
|
||||||
|
|
||||||
|
BPrivate::AppServerLink link;
|
||||||
|
link.StartMessage(AS_GET_EXTRA_FONT_FLAGS);
|
||||||
|
link.Attach<uint16>(fFamilyID);
|
||||||
|
link.Attach<uint16>(fStyleID);
|
||||||
|
|
||||||
|
status_t status = B_ERROR;
|
||||||
|
if (link.FlushWithReply(status) != B_OK
|
||||||
|
|| status != B_OK)
|
||||||
|
return status;
|
||||||
|
|
||||||
|
link.Read<uint32>(&fExtraFlags);
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,31 +1,15 @@
|
|||||||
//------------------------------------------------------------------------------
|
/*
|
||||||
// Copyright (c) 2001-2005, Haiku
|
* Copyright 2001-2005, Haiku, Inc.
|
||||||
//
|
* Distributed under the terms of the MIT License.
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
*
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
* Authors:
|
||||||
// to deal in the Software without restriction, including without limitation
|
* DarkWyrm <[email protected]>
|
||||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
* Caz <[email protected]>
|
||||||
// and/or sell copies of the Software, and to permit persons to whom the
|
* Axel Dörfler, [email protected]e
|
||||||
// Software is furnished to do so, subject to the following conditions:
|
*/
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in
|
/** Global functions and variables for the Interface Kit */
|
||||||
// all copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
// DEALINGS IN THE SOFTWARE.
|
|
||||||
//
|
|
||||||
// File Name: InterfaceDefs.cpp
|
|
||||||
// Author: DarkWyrm <[email protected]>
|
|
||||||
// Caz <[email protected]>
|
|
||||||
// Axel Dörfler <[email protected]>
|
|
||||||
// Description: Global functions and variables for the Interface Kit
|
|
||||||
//
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
#include <InterfaceDefs.h>
|
#include <InterfaceDefs.h>
|
||||||
#include <Menu.h>
|
#include <Menu.h>
|
||||||
@@ -53,7 +37,7 @@
|
|||||||
#include "truncate_string.h"
|
#include "truncate_string.h"
|
||||||
|
|
||||||
// Private definitions not placed in public headers
|
// Private definitions not placed in public headers
|
||||||
extern "C" void _init_global_fonts();
|
void _init_global_fonts_();
|
||||||
extern "C" status_t _fini_interface_kit_();
|
extern "C" status_t _fini_interface_kit_();
|
||||||
|
|
||||||
using namespace BPrivate;
|
using namespace BPrivate;
|
||||||
@@ -810,7 +794,7 @@ _init_interface_kit_()
|
|||||||
BTextView::sWidthAtom = 0;
|
BTextView::sWidthAtom = 0;
|
||||||
BTextView::sWidths = new _BWidthBuffer_;
|
BTextView::sWidths = new _BWidthBuffer_;
|
||||||
|
|
||||||
_init_global_fonts();
|
_init_global_fonts_();
|
||||||
|
|
||||||
_menu_info_ptr_ = &BMenu::sMenuInfo;
|
_menu_info_ptr_ = &BMenu::sMenuInfo;
|
||||||
status_t status = load_menu_settings(BMenu::sMenuInfo);
|
status_t status = load_menu_settings(BMenu::sMenuInfo);
|
||||||
|
|||||||
@@ -18,16 +18,19 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <syslog.h>
|
||||||
|
|
||||||
#include <AppDefs.h>
|
#include <AppDefs.h>
|
||||||
#include <Autolock.h>
|
#include <Autolock.h>
|
||||||
#include <ColorSet.h>
|
|
||||||
#include <List.h>
|
#include <List.h>
|
||||||
#include <ScrollBar.h>
|
#include <ScrollBar.h>
|
||||||
#include <ServerProtocol.h>
|
|
||||||
#include <Shape.h>
|
#include <Shape.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
|
||||||
|
#include <ColorSet.h>
|
||||||
|
#include <ServerProtocol.h>
|
||||||
|
#include <FontPrivate.h>
|
||||||
|
|
||||||
#include "AppServer.h"
|
#include "AppServer.h"
|
||||||
#include "BGet++.h"
|
#include "BGet++.h"
|
||||||
#include "BitmapManager.h"
|
#include "BitmapManager.h"
|
||||||
@@ -38,10 +41,10 @@
|
|||||||
#include "DrawingEngine.h"
|
#include "DrawingEngine.h"
|
||||||
#include "FontManager.h"
|
#include "FontManager.h"
|
||||||
#include "HWInterface.h"
|
#include "HWInterface.h"
|
||||||
//#include "DrawState.h"
|
|
||||||
#include "OffscreenServerWindow.h"
|
#include "OffscreenServerWindow.h"
|
||||||
#include "RAMLinkMsgReader.h"
|
#include "RAMLinkMsgReader.h"
|
||||||
#include "RootLayer.h"
|
#include "RootLayer.h"
|
||||||
|
#include "ServerApp.h"
|
||||||
#include "ServerBitmap.h"
|
#include "ServerBitmap.h"
|
||||||
#include "ServerConfig.h"
|
#include "ServerConfig.h"
|
||||||
#include "ServerCursor.h"
|
#include "ServerCursor.h"
|
||||||
@@ -52,9 +55,6 @@
|
|||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
#include "WinBorder.h"
|
#include "WinBorder.h"
|
||||||
|
|
||||||
#include "ServerApp.h"
|
|
||||||
#include <syslog.h>
|
|
||||||
|
|
||||||
//#define DEBUG_SERVERAPP
|
//#define DEBUG_SERVERAPP
|
||||||
|
|
||||||
#ifdef DEBUG_SERVERAPP
|
#ifdef DEBUG_SERVERAPP
|
||||||
@@ -1227,35 +1227,6 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
|
|||||||
gFontManager->Unlock();
|
gFontManager->Unlock();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AS_GET_FONT_DIRECTION:
|
|
||||||
{
|
|
||||||
FTRACE(("ServerApp %s: AS_GET_FONT_DIRECTION\n", Signature()));
|
|
||||||
// Attached Data:
|
|
||||||
// 1) uint16 - family ID
|
|
||||||
// 2) uint16 - style ID
|
|
||||||
|
|
||||||
// Returns:
|
|
||||||
// 1) font_direction direction of font
|
|
||||||
|
|
||||||
int32 familyID, styleID;
|
|
||||||
link.Read<int32>(&familyID);
|
|
||||||
link.Read<int32>(&styleID);
|
|
||||||
|
|
||||||
gFontManager->Lock();
|
|
||||||
|
|
||||||
FontStyle *fontStyle = gFontManager->GetStyle(familyID, styleID);
|
|
||||||
if (fontStyle) {
|
|
||||||
font_direction direction = fontStyle->Direction();
|
|
||||||
|
|
||||||
fLink.StartMessage(B_OK);
|
|
||||||
fLink.Attach<font_direction>(direction);
|
|
||||||
} else
|
|
||||||
fLink.StartMessage(B_BAD_VALUE);
|
|
||||||
|
|
||||||
gFontManager->Unlock();
|
|
||||||
fLink.Flush();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case AS_GET_FONT_FILE_FORMAT:
|
case AS_GET_FONT_FILE_FORMAT:
|
||||||
{
|
{
|
||||||
FTRACE(("ServerApp %s: AS_GET_FONT_FILE_FORMAT\n", Signature()));
|
FTRACE(("ServerApp %s: AS_GET_FONT_FILE_FORMAT\n", Signature()));
|
||||||
@@ -1411,16 +1382,16 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
|
|||||||
fLink.Flush();
|
fLink.Flush();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AS_QUERY_FONT_FIXED:
|
case AS_GET_EXTRA_FONT_FLAGS:
|
||||||
{
|
{
|
||||||
FTRACE(("ServerApp %s: AS_QUERY_FONT_FIXED unimplmemented\n",
|
FTRACE(("ServerApp %s: AS_GET_EXTRA_FONT_FLAGS\n",
|
||||||
Signature()));
|
Signature()));
|
||||||
// Attached Data:
|
// Attached Data:
|
||||||
// 1) uint16 - family ID
|
// 1) uint16 - family ID
|
||||||
// 2) uint16 - style ID
|
// 2) uint16 - style ID
|
||||||
|
|
||||||
// Returns:
|
// Returns:
|
||||||
// 1) bool - font is/is not fixed
|
// 1) uint32 - extra font flags
|
||||||
uint16 familyID, styleID;
|
uint16 familyID, styleID;
|
||||||
link.Read<uint16>(&familyID);
|
link.Read<uint16>(&familyID);
|
||||||
link.Read<uint16>(&styleID);
|
link.Read<uint16>(&styleID);
|
||||||
@@ -1430,7 +1401,18 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
|
|||||||
FontStyle *fontStyle = gFontManager->GetStyle(familyID, styleID);
|
FontStyle *fontStyle = gFontManager->GetStyle(familyID, styleID);
|
||||||
if (fontStyle != NULL) {
|
if (fontStyle != NULL) {
|
||||||
fLink.StartMessage(B_OK);
|
fLink.StartMessage(B_OK);
|
||||||
fLink.Attach<bool>(fontStyle->IsFixedWidth());
|
|
||||||
|
uint32 flags = 0;
|
||||||
|
if (fontStyle->IsFixedWidth())
|
||||||
|
flags |= B_IS_FIXED;
|
||||||
|
if (fontStyle->HasTuned())
|
||||||
|
flags |= B_HAS_TUNED_FONT;
|
||||||
|
if (fontStyle->HasKerning())
|
||||||
|
flags |= B_PRIVATE_FONT_HAS_KERNING;
|
||||||
|
|
||||||
|
flags |= uint32(fontStyle->Direction()) << B_PRIVATE_FONT_DIRECTION_SHIFT;
|
||||||
|
|
||||||
|
fLink.Attach<uint32>(flags);
|
||||||
} else
|
} else
|
||||||
fLink.StartMessage(B_BAD_VALUE);
|
fLink.StartMessage(B_BAD_VALUE);
|
||||||
|
|
||||||
@@ -1438,10 +1420,9 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
|
|||||||
fLink.Flush();
|
fLink.Flush();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AS_SET_FAMILY_AND_STYLE:
|
case AS_GET_FAMILY_AND_STYLE_IDS:
|
||||||
{
|
{
|
||||||
FTRACE(("ServerApp %s: AS_SET_FAMILY_AND_STYLE\n",
|
FTRACE(("ServerApp %s: AS_GET_FAMILY_AND_STYLE_IDS\n", Signature()));
|
||||||
Signature()));
|
|
||||||
// Attached Data:
|
// Attached Data:
|
||||||
// 1) font_family - name of font family to use
|
// 1) font_family - name of font family to use
|
||||||
// 2) font_style - name of style in family
|
// 2) font_style - name of style in family
|
||||||
@@ -1527,11 +1508,9 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
|
|||||||
fLink.Flush();
|
fLink.Flush();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AS_SET_SYSFONT_PLAIN:
|
case AS_GET_SYSTEM_FONTS:
|
||||||
case AS_SET_SYSFONT_BOLD:
|
|
||||||
case AS_SET_SYSFONT_FIXED:
|
|
||||||
{
|
{
|
||||||
FTRACE(("ServerApp %s: AS_SET_SYSFONT_PLAIN\n", Signature()));
|
FTRACE(("ServerApp %s: AS_GET_SYSTEM_FONTS\n", Signature()));
|
||||||
// Returns:
|
// Returns:
|
||||||
// 1) uint16 - family ID
|
// 1) uint16 - family ID
|
||||||
// 2) uint16 - style ID
|
// 2) uint16 - style ID
|
||||||
@@ -1540,26 +1519,31 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
|
|||||||
// 5) uint32 - font flags
|
// 5) uint32 - font flags
|
||||||
|
|
||||||
DesktopSettings settings(fDesktop);
|
DesktopSettings settings(fDesktop);
|
||||||
|
|
||||||
ServerFont font;
|
|
||||||
switch (code) {
|
|
||||||
case AS_SET_SYSFONT_PLAIN:
|
|
||||||
settings.GetDefaultPlainFont(font);
|
|
||||||
break;
|
|
||||||
case AS_SET_SYSFONT_BOLD:
|
|
||||||
settings.GetDefaultBoldFont(font);
|
|
||||||
break;
|
|
||||||
case AS_SET_SYSFONT_FIXED:
|
|
||||||
settings.GetDefaultFixedFont(font);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
fLink.StartMessage(B_OK);
|
fLink.StartMessage(B_OK);
|
||||||
fLink.Attach<uint16>(font.FamilyID());
|
|
||||||
fLink.Attach<uint16>(font.StyleID());
|
for (int32 i = 0; i < 3; i++) {
|
||||||
fLink.Attach<float>(font.Size());
|
ServerFont font;
|
||||||
fLink.Attach<uint16>(font.Face());
|
switch (i) {
|
||||||
fLink.Attach<uint32>(font.Flags());
|
case 0:
|
||||||
|
settings.GetDefaultPlainFont(font);
|
||||||
|
fLink.AttachString("plain");
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
settings.GetDefaultBoldFont(font);
|
||||||
|
fLink.AttachString("bold");
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
settings.GetDefaultFixedFont(font);
|
||||||
|
fLink.AttachString("fixed");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
fLink.Attach<uint16>(font.FamilyID());
|
||||||
|
fLink.Attach<uint16>(font.StyleID());
|
||||||
|
fLink.Attach<float>(font.Size());
|
||||||
|
fLink.Attach<uint16>(font.Face());
|
||||||
|
fLink.Attach<uint32>(font.Flags());
|
||||||
|
}
|
||||||
|
|
||||||
fLink.Flush();
|
fLink.Flush();
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user