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_
|
||||
#define _FONT_H_
|
||||
|
||||
#include <BeBuild.h>
|
||||
|
||||
#include <SupportDefs.h>
|
||||
#include <InterfaceDefs.h>
|
||||
|
||||
/*----------------------------------------------------------------*/
|
||||
/*----- BFont defines and structures -----------------------------*/
|
||||
|
||||
#define B_FONT_FAMILY_LENGTH 63
|
||||
typedef char font_family[B_FONT_FAMILY_LENGTH + 1];
|
||||
#define B_FONT_STYLE_LENGTH 63
|
||||
typedef char font_family[B_FONT_FAMILY_LENGTH + 1];
|
||||
typedef char font_style[B_FONT_STYLE_LENGTH + 1];
|
||||
|
||||
// font spacing
|
||||
enum {
|
||||
B_CHAR_SPACING = 0,
|
||||
B_STRING_SPACING = 1,
|
||||
B_BITMAP_SPACING = 2,
|
||||
B_FIXED_SPACING = 3
|
||||
B_CHAR_SPACING = 0,
|
||||
B_STRING_SPACING = 1,
|
||||
B_BITMAP_SPACING = 2,
|
||||
B_FIXED_SPACING = 3
|
||||
};
|
||||
|
||||
enum font_direction {
|
||||
B_FONT_LEFT_TO_RIGHT = 0,
|
||||
B_FONT_RIGHT_TO_LEFT = 1
|
||||
B_FONT_LEFT_TO_RIGHT = 0,
|
||||
B_FONT_RIGHT_TO_LEFT = 1
|
||||
};
|
||||
|
||||
// font flags
|
||||
enum {
|
||||
B_DISABLE_ANTIALIASING = 0x00000001,
|
||||
B_FORCE_ANTIALIASING = 0x00000002
|
||||
};
|
||||
|
||||
// truncation modes
|
||||
enum {
|
||||
B_TRUNCATE_END = 0,
|
||||
B_TRUNCATE_BEGINNING = 1,
|
||||
B_TRUNCATE_MIDDLE = 2,
|
||||
B_TRUNCATE_SMART = 3
|
||||
B_TRUNCATE_END = 0,
|
||||
B_TRUNCATE_BEGINNING = 1,
|
||||
B_TRUNCATE_MIDDLE = 2,
|
||||
B_TRUNCATE_SMART = 3
|
||||
};
|
||||
|
||||
// font encodings
|
||||
enum {
|
||||
B_UNICODE_UTF8 = 0,
|
||||
B_ISO_8859_1 = 1,
|
||||
B_ISO_8859_2 = 2,
|
||||
B_ISO_8859_3 = 3,
|
||||
B_ISO_8859_4 = 4,
|
||||
B_ISO_8859_5 = 5,
|
||||
B_ISO_8859_6 = 6,
|
||||
B_ISO_8859_7 = 7,
|
||||
B_ISO_8859_8 = 8,
|
||||
B_ISO_8859_9 = 9,
|
||||
B_ISO_8859_10 = 10,
|
||||
B_MACINTOSH_ROMAN = 11
|
||||
B_UNICODE_UTF8 = 0,
|
||||
B_ISO_8859_1 = 1,
|
||||
B_ISO_8859_2 = 2,
|
||||
B_ISO_8859_3 = 3,
|
||||
B_ISO_8859_4 = 4,
|
||||
B_ISO_8859_5 = 5,
|
||||
B_ISO_8859_6 = 6,
|
||||
B_ISO_8859_7 = 7,
|
||||
B_ISO_8859_8 = 8,
|
||||
B_ISO_8859_9 = 9,
|
||||
B_ISO_8859_10 = 10,
|
||||
B_MACINTOSH_ROMAN = 11
|
||||
};
|
||||
|
||||
// flags for get_font_family() and get_font_style()
|
||||
enum {
|
||||
B_SCREEN_FONT_CACHE = 0x0001,
|
||||
B_PRINTING_FONT_CACHE = 0x0002,
|
||||
B_DEFAULT_CACHE_SETTING = 0x0004,
|
||||
B_APP_CACHE_SETTING = 0x0008
|
||||
B_HAS_TUNED_FONT = 0x0001,
|
||||
B_IS_FIXED = 0x0002
|
||||
};
|
||||
|
||||
// font face flags
|
||||
enum {
|
||||
B_HAS_TUNED_FONT = 0x0001,
|
||||
B_IS_FIXED = 0x0002
|
||||
};
|
||||
|
||||
enum {
|
||||
B_ITALIC_FACE = 0x0001,
|
||||
B_UNDERSCORE_FACE = 0x0002,
|
||||
B_NEGATIVE_FACE = 0x0004,
|
||||
B_OUTLINED_FACE = 0x0008,
|
||||
B_STRIKEOUT_FACE = 0x0010,
|
||||
B_BOLD_FACE = 0x0020,
|
||||
B_REGULAR_FACE = 0x0040
|
||||
B_ITALIC_FACE = 0x0001,
|
||||
B_UNDERSCORE_FACE = 0x0002,
|
||||
B_NEGATIVE_FACE = 0x0004,
|
||||
B_OUTLINED_FACE = 0x0008,
|
||||
B_STRIKEOUT_FACE = 0x0010,
|
||||
B_BOLD_FACE = 0x0020,
|
||||
B_REGULAR_FACE = 0x0040
|
||||
};
|
||||
|
||||
enum font_metric_mode {
|
||||
B_SCREEN_METRIC = 0,
|
||||
B_PRINTING_METRIC = 1
|
||||
B_SCREEN_METRIC = 0,
|
||||
B_PRINTING_METRIC = 1
|
||||
};
|
||||
|
||||
enum font_file_format {
|
||||
B_TRUETYPE_WINDOWS = 0,
|
||||
B_POSTSCRIPT_TYPE1_WINDOWS = 1
|
||||
B_TRUETYPE_WINDOWS = 0,
|
||||
B_POSTSCRIPT_TYPE1_WINDOWS = 1
|
||||
};
|
||||
|
||||
class unicode_block {
|
||||
public:
|
||||
inline unicode_block();
|
||||
inline unicode_block(uint64 block2, uint64 block1);
|
||||
public:
|
||||
inline unicode_block();
|
||||
inline unicode_block(uint64 block2, uint64 block1);
|
||||
|
||||
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);
|
||||
inline bool operator==(const unicode_block &block) const;
|
||||
inline bool operator!=(const unicode_block &block) const;
|
||||
|
||||
private:
|
||||
uint64 fData[2];
|
||||
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);
|
||||
inline bool operator==(const unicode_block &block) const;
|
||||
inline bool operator!=(const unicode_block &block) const;
|
||||
|
||||
private:
|
||||
uint64 fData[2];
|
||||
};
|
||||
|
||||
struct edge_info {
|
||||
@@ -137,222 +138,198 @@ class BShape;
|
||||
class BString;
|
||||
class BFontPrivate;
|
||||
|
||||
|
||||
class BFont {
|
||||
public:
|
||||
BFont(void);
|
||||
BFont(const BFont &font);
|
||||
BFont(const BFont *font);
|
||||
public:
|
||||
BFont();
|
||||
BFont(const BFont &font);
|
||||
BFont(const BFont *font);
|
||||
|
||||
status_t SetFamilyAndStyle(const font_family family,
|
||||
const font_style style);
|
||||
void SetFamilyAndStyle(uint32 code);
|
||||
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);
|
||||
status_t SetFamilyAndStyle(const font_family family,
|
||||
const font_style style);
|
||||
void SetFamilyAndStyle(uint32 code);
|
||||
status_t SetFamilyAndFace(const font_family family, uint16 face);
|
||||
|
||||
void GetFamilyAndStyle(font_family *family,
|
||||
font_style *style) const;
|
||||
uint32 FamilyAndStyle(void) const;
|
||||
float Size(void) const;
|
||||
float Shear(void) const;
|
||||
float Rotation(void) const;
|
||||
uint8 Spacing(void) const;
|
||||
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;
|
||||
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);
|
||||
|
||||
int32 CountTuned(void) const;
|
||||
void GetTunedInfo(int32 index, tuned_font_info *info) const;
|
||||
void GetFamilyAndStyle(font_family *family,
|
||||
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,
|
||||
uint32 mode,
|
||||
float width) const;
|
||||
void GetTruncatedStrings(const char *stringArray[],
|
||||
int32 numStrings,
|
||||
uint32 mode,
|
||||
float width,
|
||||
BString resultArray[]) const;
|
||||
void GetTruncatedStrings(const char *stringArray[],
|
||||
int32 numStrings,
|
||||
uint32 mode,
|
||||
float width,
|
||||
char *resultArray[]) const;
|
||||
font_direction Direction() const;
|
||||
bool IsFixed() const;
|
||||
bool IsFullAndHalfFixed() const;
|
||||
BRect BoundingBox() const;
|
||||
unicode_block Blocks() const;
|
||||
font_file_format FileFormat() const;
|
||||
|
||||
float StringWidth(const char *string) const;
|
||||
float StringWidth(const char *string, int32 length) const;
|
||||
void GetStringWidths(const char *stringArray[],
|
||||
const int32 lengthArray[],
|
||||
int32 numStrings,
|
||||
float widthArray[]) const;
|
||||
int32 CountTuned() const;
|
||||
void GetTunedInfo(int32 index, tuned_font_info *info) const;
|
||||
|
||||
void GetEscapements(const char charArray[],
|
||||
int32 numChars,
|
||||
float escapementArray[]) const;
|
||||
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;
|
||||
|
||||
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 TruncateString(BString* inOut, uint32 mode,
|
||||
float width) const;
|
||||
void GetTruncatedStrings(const char *stringArray[],
|
||||
int32 numStrings, uint32 mode, float width,
|
||||
BString resultArray[]) const;
|
||||
void GetTruncatedStrings(const char *stringArray[],
|
||||
int32 numStrings, uint32 mode, float width,
|
||||
char *resultArray[]) 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;
|
||||
float StringWidth(const char *string) const;
|
||||
float StringWidth(const char *string, int32 length) const;
|
||||
void GetStringWidths(const char *stringArray[],
|
||||
const int32 lengthArray[], int32 numStrings,
|
||||
float widthArray[]) const;
|
||||
|
||||
void PrintToStream(void) const;
|
||||
|
||||
private:
|
||||
void GetEscapements(const char charArray[], int32 numChars,
|
||||
float escapementArray[]) const;
|
||||
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;
|
||||
uint16 fStyleID;
|
||||
float fSize;
|
||||
float fShear;
|
||||
float fRotation;
|
||||
uint8 fSpacing;
|
||||
uint8 fEncoding;
|
||||
uint16 fFace;
|
||||
uint32 fFlags;
|
||||
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[], 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;
|
||||
uint32 _reserved[3];
|
||||
mutable uint32 fExtraFlags;
|
||||
uint32 _reserved[2];
|
||||
|
||||
void SetPacket(void *packet) const;
|
||||
void GetTruncatedStrings64(const char *stringArray[],
|
||||
int32 numStrings,
|
||||
uint32 mode,
|
||||
float width,
|
||||
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;
|
||||
status_t _GetExtraFlags() 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_bold_font;
|
||||
extern const BFont *be_fixed_font;
|
||||
|
||||
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);
|
||||
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,
|
||||
uint16 *face, uint32 *flags=NULL);
|
||||
bool update_font_families(bool check_only);
|
||||
uint16 *face, uint32 *flags = NULL);
|
||||
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[1] = block2;
|
||||
}
|
||||
|
||||
bool unicode_block::Includes(const unicode_block &block) const {
|
||||
return (((fData[0] & block.fData[0]) == block.fData[0]) &&
|
||||
((fData[1] & block.fData[1]) == block.fData[1]));
|
||||
bool
|
||||
unicode_block::Includes(const unicode_block &block) const
|
||||
{
|
||||
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 res;
|
||||
|
||||
res.fData[0] = fData[0] & block.fData[0];
|
||||
res.fData[1] = fData[1] & block.fData[1];
|
||||
return res;
|
||||
unicode_block
|
||||
unicode_block::operator&(const unicode_block &block) const
|
||||
{
|
||||
unicode_block result;
|
||||
result.fData[0] = fData[0] & block.fData[0];
|
||||
result.fData[1] = fData[1] & block.fData[1];
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
unicode_block unicode_block::operator|(const unicode_block &block) const {
|
||||
unicode_block res;
|
||||
|
||||
res.fData[0] = fData[0] | block.fData[0];
|
||||
res.fData[1] = fData[1] | block.fData[1];
|
||||
return res;
|
||||
unicode_block
|
||||
unicode_block::operator|(const unicode_block &block) const
|
||||
{
|
||||
unicode_block result;
|
||||
result.fData[0] = fData[0] | block.fData[0];
|
||||
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[1] = block.fData[1];
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool 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
|
||||
{
|
||||
return fData[0] == block.fData[0] && fData[1] == block.fData[1];
|
||||
}
|
||||
|
||||
bool 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
|
||||
{
|
||||
return fData[0] != block.fData[0] || fData[1] != block.fData[1];
|
||||
}
|
||||
|
||||
#endif /* _FONT_H_ */
|
||||
|
||||
@@ -113,23 +113,23 @@ enum {
|
||||
|
||||
// Font-related server communications
|
||||
AS_SET_SYSTEM_FONT,
|
||||
AS_GET_SYSTEM_FONTS,
|
||||
|
||||
AS_QUERY_FONTS_CHANGED,
|
||||
AS_UPDATED_CLIENT_FONTLIST,
|
||||
AS_GET_FAMILY_NAME,
|
||||
AS_GET_STYLE_NAME,
|
||||
AS_COUNT_FONT_FAMILIES,
|
||||
AS_COUNT_FONT_STYLES,
|
||||
|
||||
AS_GET_FAMILY_AND_STYLE,
|
||||
AS_GET_FONT_DIRECTION,
|
||||
AS_GET_FAMILY_AND_STYLE_IDS,
|
||||
AS_GET_FONT_BOUNDING_BOX,
|
||||
AS_GET_TUNED_COUNT,
|
||||
AS_GET_TUNED_INFO,
|
||||
AS_GET_FONT_HEIGHT,
|
||||
AS_GET_FONT_FILE_FORMAT,
|
||||
|
||||
AS_QUERY_FONT_FIXED,
|
||||
AS_SET_FAMILY_AND_STYLE,
|
||||
|
||||
AS_COUNT_FONT_FAMILIES,
|
||||
AS_COUNT_FONT_STYLES,
|
||||
AS_GET_EXTRA_FONT_FLAGS,
|
||||
|
||||
AS_GET_STRING_WIDTHS,
|
||||
AS_GET_EDGES,
|
||||
@@ -141,10 +141,6 @@ enum {
|
||||
AS_GET_GLYPH_SHAPES,
|
||||
AS_GET_TRUNCATED_STRINGS,
|
||||
|
||||
AS_SET_SYSFONT_PLAIN,
|
||||
AS_SET_SYSFONT_BOLD,
|
||||
AS_SET_SYSFONT_FIXED,
|
||||
|
||||
// Screen methods
|
||||
AS_SCREEN_GET_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.
|
||||
*
|
||||
* Authors:
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <AppServerLink.h>
|
||||
#include <Font.h>
|
||||
#include <Message.h>
|
||||
#include <PortLink.h>
|
||||
#include <Rect.h>
|
||||
@@ -22,11 +23,11 @@
|
||||
|
||||
#include <moreUTF8.h>
|
||||
#include <truncate_string.h>
|
||||
|
||||
#include <Font.h>
|
||||
#include <FontPrivate.h>
|
||||
|
||||
|
||||
const float kUninitializedAscent = INFINITY;
|
||||
const uint32 kUninitializedExtraFlags = 0xffffffff;
|
||||
|
||||
// The actual objects which the globals point to
|
||||
static BFont sPlainFont;
|
||||
@@ -38,59 +39,53 @@ const BFont *be_bold_font = &sBoldFont;
|
||||
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
|
||||
_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;
|
||||
link.StartMessage(cmd);
|
||||
link.StartMessage(AS_GET_SYSTEM_FONTS);
|
||||
|
||||
int32 code;
|
||||
if (link.FlushWithReply(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;
|
||||
}
|
||||
|
||||
// there really isn't that much data that we need to set for such cases -- most
|
||||
// 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);
|
||||
char type[B_OS_NAME_LENGTH];
|
||||
|
||||
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
|
||||
\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,
|
||||
float size)
|
||||
{
|
||||
if (!which)
|
||||
if (which == NULL || strcmp(which, "plain")
|
||||
|| strcmp(which, "bold") || strcmp(which, "fixed"))
|
||||
return;
|
||||
|
||||
if (!strcmp(which, "plain")
|
||||
|| !strcmp(which, "bold")
|
||||
|| !strcmp(which, "fixed")) {
|
||||
BPrivate::AppServerLink link;
|
||||
|
||||
link.StartMessage(AS_SET_SYSTEM_FONT);
|
||||
link.AttachString(which);
|
||||
link.AttachString(family);
|
||||
link.AttachString(style);
|
||||
link.Attach<float>(size);
|
||||
link.Flush();
|
||||
}
|
||||
BPrivate::AppServerLink link;
|
||||
|
||||
link.StartMessage(AS_SET_SYSTEM_FONT);
|
||||
link.AttachString(which);
|
||||
link.AttachString(family);
|
||||
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 -
|
||||
|
||||
|
||||
@@ -331,7 +299,8 @@ BFont::BFont()
|
||||
fSpacing(0),
|
||||
fEncoding(0),
|
||||
fFace(0),
|
||||
fFlags(0)
|
||||
fFlags(0),
|
||||
fExtraFlags(kUninitializedExtraFlags)
|
||||
{
|
||||
if (be_plain_font != NULL && this != &sPlainFont)
|
||||
*this = *be_plain_font;
|
||||
@@ -373,7 +342,7 @@ BFont::SetFamilyAndStyle(const font_family family, const font_style style)
|
||||
|
||||
BPrivate::AppServerLink link;
|
||||
|
||||
link.StartMessage(AS_SET_FAMILY_AND_STYLE);
|
||||
link.StartMessage(AS_GET_FAMILY_AND_STYLE_IDS);
|
||||
link.AttachString(family);
|
||||
link.AttachString(style);
|
||||
link.Attach<uint16>(fFamilyID);
|
||||
@@ -412,7 +381,7 @@ BFont::SetFamilyAndStyle(uint32 fontcode)
|
||||
family = (fontcode & 0xFFFF0000) >> 16;
|
||||
|
||||
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);
|
||||
link.Attach<uint16>(family);
|
||||
@@ -446,7 +415,7 @@ status_t
|
||||
BFont::SetFamilyAndFace(const font_family family, uint16 face)
|
||||
{
|
||||
BPrivate::AppServerLink link;
|
||||
link.StartMessage(AS_SET_FAMILY_AND_STYLE);
|
||||
link.StartMessage(AS_GET_FAMILY_AND_STYLE_IDS);
|
||||
link.AttachString(family);
|
||||
link.AttachString(NULL); // no style given
|
||||
link.Attach<uint16>(fFamilyID);
|
||||
@@ -558,96 +527,76 @@ BFont::GetFamilyAndStyle(font_family *family, font_style *style) const
|
||||
|
||||
|
||||
uint32
|
||||
BFont::FamilyAndStyle(void) const
|
||||
BFont::FamilyAndStyle() const
|
||||
{
|
||||
return (fFamilyID << 16UL) | fStyleID;
|
||||
}
|
||||
|
||||
|
||||
float
|
||||
BFont::Size(void) const
|
||||
BFont::Size() const
|
||||
{
|
||||
return fSize;
|
||||
}
|
||||
|
||||
|
||||
float
|
||||
BFont::Shear(void) const
|
||||
BFont::Shear() const
|
||||
{
|
||||
return fShear;
|
||||
}
|
||||
|
||||
|
||||
float
|
||||
BFont::Rotation(void) const
|
||||
BFont::Rotation() const
|
||||
{
|
||||
return fRotation;
|
||||
}
|
||||
|
||||
|
||||
uint8
|
||||
BFont::Spacing(void) const
|
||||
BFont::Spacing() const
|
||||
{
|
||||
return fSpacing;
|
||||
}
|
||||
|
||||
|
||||
uint8
|
||||
BFont::Encoding(void) const
|
||||
BFont::Encoding() const
|
||||
{
|
||||
return fEncoding;
|
||||
}
|
||||
|
||||
|
||||
uint16
|
||||
BFont::Face(void) const
|
||||
BFont::Face() const
|
||||
{
|
||||
return fFace;
|
||||
}
|
||||
|
||||
|
||||
uint32
|
||||
BFont::Flags(void) const
|
||||
BFont::Flags() const
|
||||
{
|
||||
return fFlags;
|
||||
}
|
||||
|
||||
|
||||
font_direction
|
||||
BFont::Direction(void) const
|
||||
BFont::Direction() const
|
||||
{
|
||||
BPrivate::AppServerLink link;
|
||||
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)
|
||||
if (_GetExtraFlags() != B_OK)
|
||||
return B_FONT_LEFT_TO_RIGHT;
|
||||
|
||||
font_direction fdir;
|
||||
link.Read<font_direction>(&fdir);
|
||||
return fdir;
|
||||
return (font_direction)(fExtraFlags >> B_PRIVATE_FONT_DIRECTION_SHIFT);
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
BFont::IsFixed(void) const
|
||||
BFont::IsFixed() const
|
||||
{
|
||||
BPrivate::AppServerLink link;
|
||||
link.StartMessage(AS_QUERY_FONT_FIXED);
|
||||
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;
|
||||
_GetExtraFlags();
|
||||
return (fExtraFlags & B_IS_FIXED) != 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -659,14 +608,15 @@ BFont::IsFixed(void) const
|
||||
*/
|
||||
|
||||
bool
|
||||
BFont::IsFullAndHalfFixed(void) const
|
||||
BFont::IsFullAndHalfFixed() const
|
||||
{
|
||||
return false;
|
||||
_GetExtraFlags();
|
||||
return (fExtraFlags & B_PRIVATE_FONT_IS_FULL_AND_HALF_FIXED) != 0;
|
||||
}
|
||||
|
||||
|
||||
BRect
|
||||
BFont::BoundingBox(void) const
|
||||
BFont::BoundingBox() const
|
||||
{
|
||||
BPrivate::AppServerLink link;
|
||||
link.StartMessage(AS_GET_FONT_BOUNDING_BOX);
|
||||
@@ -685,7 +635,7 @@ BFont::BoundingBox(void) const
|
||||
|
||||
|
||||
unicode_block
|
||||
BFont::Blocks(void) const
|
||||
BFont::Blocks() const
|
||||
{
|
||||
// TODO: Add Block support
|
||||
return unicode_block();
|
||||
@@ -693,7 +643,7 @@ BFont::Blocks(void) const
|
||||
|
||||
|
||||
font_file_format
|
||||
BFont::FileFormat(void) const
|
||||
BFont::FileFormat() const
|
||||
{
|
||||
BPrivate::AppServerLink link;
|
||||
link.StartMessage(AS_GET_FONT_FILE_FORMAT);
|
||||
@@ -715,7 +665,7 @@ BFont::FileFormat(void) const
|
||||
|
||||
|
||||
int32
|
||||
BFont::CountTuned(void) const
|
||||
BFont::CountTuned() const
|
||||
{
|
||||
BPrivate::AppServerLink link;
|
||||
link.StartMessage(AS_GET_TUNED_COUNT);
|
||||
@@ -1014,7 +964,7 @@ void
|
||||
BFont::GetBoundingBoxesAsGlyphs(const char charArray[], int32 numChars, font_metric_mode mode,
|
||||
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,
|
||||
escapement_delta *delta, BRect boundingBoxArray[]) const
|
||||
{
|
||||
_GetBoundingBoxes_(charArray, numChars, mode, true, delta, boundingBoxArray);
|
||||
_GetBoundingBoxes(charArray, numChars, mode, true, delta, boundingBoxArray);
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
{
|
||||
if (!charArray || numChars < 1 || !boundingBoxArray)
|
||||
@@ -1213,9 +1163,30 @@ BFont::operator!=(const BFont &font) const
|
||||
|
||||
|
||||
void
|
||||
BFont::PrintToStream(void) const
|
||||
BFont::PrintToStream() const
|
||||
{
|
||||
printf("FAMILY STYLE %f %f %f %f %f %f\n", fSize, fShear, fRotation, fHeight.ascent,
|
||||
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
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// 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
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
* Copyright 2001-2005, Haiku, Inc.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* DarkWyrm <bpmagic@columbus.rr.com>
|
||||
* Caz <turok2@currantbun.com>
|
||||
* Axel Dörfler, axeld@pinc-software.de
|
||||
*/
|
||||
|
||||
/** Global functions and variables for the Interface Kit */
|
||||
|
||||
#include <Application.h>
|
||||
#include <InterfaceDefs.h>
|
||||
#include <Menu.h>
|
||||
@@ -53,7 +37,7 @@
|
||||
#include "truncate_string.h"
|
||||
|
||||
// Private definitions not placed in public headers
|
||||
extern "C" void _init_global_fonts();
|
||||
void _init_global_fonts_();
|
||||
extern "C" status_t _fini_interface_kit_();
|
||||
|
||||
using namespace BPrivate;
|
||||
@@ -810,7 +794,7 @@ _init_interface_kit_()
|
||||
BTextView::sWidthAtom = 0;
|
||||
BTextView::sWidths = new _BWidthBuffer_;
|
||||
|
||||
_init_global_fonts();
|
||||
_init_global_fonts_();
|
||||
|
||||
_menu_info_ptr_ = &BMenu::sMenuInfo;
|
||||
status_t status = load_menu_settings(BMenu::sMenuInfo);
|
||||
|
||||
@@ -18,16 +18,19 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
|
||||
#include <AppDefs.h>
|
||||
#include <Autolock.h>
|
||||
#include <ColorSet.h>
|
||||
#include <List.h>
|
||||
#include <ScrollBar.h>
|
||||
#include <ServerProtocol.h>
|
||||
#include <Shape.h>
|
||||
#include <String.h>
|
||||
|
||||
#include <ColorSet.h>
|
||||
#include <ServerProtocol.h>
|
||||
#include <FontPrivate.h>
|
||||
|
||||
#include "AppServer.h"
|
||||
#include "BGet++.h"
|
||||
#include "BitmapManager.h"
|
||||
@@ -38,10 +41,10 @@
|
||||
#include "DrawingEngine.h"
|
||||
#include "FontManager.h"
|
||||
#include "HWInterface.h"
|
||||
//#include "DrawState.h"
|
||||
#include "OffscreenServerWindow.h"
|
||||
#include "RAMLinkMsgReader.h"
|
||||
#include "RootLayer.h"
|
||||
#include "ServerApp.h"
|
||||
#include "ServerBitmap.h"
|
||||
#include "ServerConfig.h"
|
||||
#include "ServerCursor.h"
|
||||
@@ -52,9 +55,6 @@
|
||||
#include "Utils.h"
|
||||
#include "WinBorder.h"
|
||||
|
||||
#include "ServerApp.h"
|
||||
#include <syslog.h>
|
||||
|
||||
//#define DEBUG_SERVERAPP
|
||||
|
||||
#ifdef DEBUG_SERVERAPP
|
||||
@@ -1227,35 +1227,6 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
|
||||
gFontManager->Unlock();
|
||||
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:
|
||||
{
|
||||
FTRACE(("ServerApp %s: AS_GET_FONT_FILE_FORMAT\n", Signature()));
|
||||
@@ -1411,16 +1382,16 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
|
||||
fLink.Flush();
|
||||
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()));
|
||||
// Attached Data:
|
||||
// 1) uint16 - family ID
|
||||
// 2) uint16 - style ID
|
||||
|
||||
// Returns:
|
||||
// 1) bool - font is/is not fixed
|
||||
// 1) uint32 - extra font flags
|
||||
uint16 familyID, styleID;
|
||||
link.Read<uint16>(&familyID);
|
||||
link.Read<uint16>(&styleID);
|
||||
@@ -1430,7 +1401,18 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
|
||||
FontStyle *fontStyle = gFontManager->GetStyle(familyID, styleID);
|
||||
if (fontStyle != NULL) {
|
||||
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
|
||||
fLink.StartMessage(B_BAD_VALUE);
|
||||
|
||||
@@ -1438,10 +1420,9 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
|
||||
fLink.Flush();
|
||||
break;
|
||||
}
|
||||
case AS_SET_FAMILY_AND_STYLE:
|
||||
case AS_GET_FAMILY_AND_STYLE_IDS:
|
||||
{
|
||||
FTRACE(("ServerApp %s: AS_SET_FAMILY_AND_STYLE\n",
|
||||
Signature()));
|
||||
FTRACE(("ServerApp %s: AS_GET_FAMILY_AND_STYLE_IDS\n", Signature()));
|
||||
// Attached Data:
|
||||
// 1) font_family - name of font family to use
|
||||
// 2) font_style - name of style in family
|
||||
@@ -1527,11 +1508,9 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
|
||||
fLink.Flush();
|
||||
break;
|
||||
}
|
||||
case AS_SET_SYSFONT_PLAIN:
|
||||
case AS_SET_SYSFONT_BOLD:
|
||||
case AS_SET_SYSFONT_FIXED:
|
||||
case AS_GET_SYSTEM_FONTS:
|
||||
{
|
||||
FTRACE(("ServerApp %s: AS_SET_SYSFONT_PLAIN\n", Signature()));
|
||||
FTRACE(("ServerApp %s: AS_GET_SYSTEM_FONTS\n", Signature()));
|
||||
// Returns:
|
||||
// 1) uint16 - family ID
|
||||
// 2) uint16 - style ID
|
||||
@@ -1540,26 +1519,31 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
|
||||
// 5) uint32 - font flags
|
||||
|
||||
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.Attach<uint16>(font.FamilyID());
|
||||
fLink.Attach<uint16>(font.StyleID());
|
||||
fLink.Attach<float>(font.Size());
|
||||
fLink.Attach<uint16>(font.Face());
|
||||
fLink.Attach<uint32>(font.Flags());
|
||||
|
||||
for (int32 i = 0; i < 3; i++) {
|
||||
ServerFont font;
|
||||
switch (i) {
|
||||
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();
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user