Retooled the API and implemented some of the message handlers
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10789 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -555,18 +555,7 @@ void DirectDriver::SetDrawData(const DrawData *d, bool set_font_data)
|
|||||||
if(!sf)
|
if(!sf)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
FontStyle *style=d->font.Style();
|
font.SetFamilyAndStyle(sf->GetFamily(),sf->GetStyle());
|
||||||
|
|
||||||
if(!style)
|
|
||||||
return;
|
|
||||||
|
|
||||||
FontFamily *family=(FontFamily *)style->Family();
|
|
||||||
if(!family)
|
|
||||||
return;
|
|
||||||
|
|
||||||
font_family fontfamily;
|
|
||||||
strcpy(fontfamily,family->Name());
|
|
||||||
font.SetFamilyAndStyle(fontfamily,style->Name());
|
|
||||||
font.SetFlags(sf->Flags());
|
font.SetFlags(sf->Flags());
|
||||||
font.SetEncoding(sf->Encoding());
|
font.SetEncoding(sf->Encoding());
|
||||||
font.SetSize(sf->Size());
|
font.SetSize(sf->Size());
|
||||||
|
|||||||
@@ -471,14 +471,7 @@ void DisplayDriver::DrawString(const char *string, const int32 &length, const BP
|
|||||||
BPoint point(pt);
|
BPoint point(pt);
|
||||||
|
|
||||||
const ServerFont *font=&(d->font);
|
const ServerFont *font=&(d->font);
|
||||||
FontStyle *style=font->Style();
|
|
||||||
|
|
||||||
if(!style)
|
|
||||||
{
|
|
||||||
Unlock();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
FT_Face face;
|
FT_Face face;
|
||||||
FT_GlyphSlot slot;
|
FT_GlyphSlot slot;
|
||||||
FT_Matrix rmatrix,smatrix;
|
FT_Matrix rmatrix,smatrix;
|
||||||
@@ -506,7 +499,7 @@ void DisplayDriver::DrawString(const char *string, const int32 &length, const BP
|
|||||||
else
|
else
|
||||||
shear=90-(90-shearangle)*2;
|
shear=90-(90-shearangle)*2;
|
||||||
|
|
||||||
error=FT_New_Face(ftlib, style->GetPath(), 0, &face);
|
error=FT_New_Face(ftlib, font->GetPath(), 0, &face);
|
||||||
if(error)
|
if(error)
|
||||||
{
|
{
|
||||||
Unlock();
|
Unlock();
|
||||||
@@ -3740,13 +3733,6 @@ float DisplayDriver::StringWidth(const char *string, int32 length, const DrawDat
|
|||||||
Lock();
|
Lock();
|
||||||
|
|
||||||
const ServerFont *font=&(d->font);
|
const ServerFont *font=&(d->font);
|
||||||
FontStyle *style=font->Style();
|
|
||||||
|
|
||||||
if(!style)
|
|
||||||
{
|
|
||||||
Unlock();
|
|
||||||
return 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
FT_Face face;
|
FT_Face face;
|
||||||
FT_GlyphSlot slot;
|
FT_GlyphSlot slot;
|
||||||
@@ -3756,7 +3742,7 @@ float DisplayDriver::StringWidth(const char *string, int32 length, const DrawDat
|
|||||||
int32 strlength,i;
|
int32 strlength,i;
|
||||||
float returnval;
|
float returnval;
|
||||||
|
|
||||||
error=FT_New_Face(ftlib, style->GetPath(), 0, &face);
|
error=FT_New_Face(ftlib, font->GetPath(), 0, &face);
|
||||||
if(error)
|
if(error)
|
||||||
{
|
{
|
||||||
Unlock();
|
Unlock();
|
||||||
@@ -3825,13 +3811,6 @@ float DisplayDriver::StringHeight(const char *string, int32 length, const DrawDa
|
|||||||
Lock();
|
Lock();
|
||||||
|
|
||||||
const ServerFont *font=&(d->font);
|
const ServerFont *font=&(d->font);
|
||||||
FontStyle *style=font->Style();
|
|
||||||
|
|
||||||
if(!style)
|
|
||||||
{
|
|
||||||
Unlock();
|
|
||||||
return 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
FT_Face face;
|
FT_Face face;
|
||||||
FT_GlyphSlot slot;
|
FT_GlyphSlot slot;
|
||||||
@@ -3839,7 +3818,7 @@ float DisplayDriver::StringHeight(const char *string, int32 length, const DrawDa
|
|||||||
int32 strlength,i;
|
int32 strlength,i;
|
||||||
float returnval=0.0,ascent=0.0,descent=0.0;
|
float returnval=0.0,ascent=0.0,descent=0.0;
|
||||||
|
|
||||||
error=FT_New_Face(ftlib, style->GetPath(), 0, &face);
|
error=FT_New_Face(ftlib, font->GetPath(), 0, &face);
|
||||||
if(error)
|
if(error)
|
||||||
{
|
{
|
||||||
Unlock();
|
Unlock();
|
||||||
|
|||||||
@@ -37,11 +37,10 @@ FTC_Manager ftmanager;
|
|||||||
*/
|
*/
|
||||||
FontStyle::FontStyle(const char *filepath, FT_Face face)
|
FontStyle::FontStyle(const char *filepath, FT_Face face)
|
||||||
{
|
{
|
||||||
name=new BString(face->style_name);
|
fName=face->style_name;
|
||||||
cachedface=new CachedFaceRec;
|
cachedface=new CachedFaceRec;
|
||||||
cachedface->file_path=filepath;
|
cachedface->file_path=filepath;
|
||||||
family=NULL;
|
family=NULL;
|
||||||
instances=new BList(0);
|
|
||||||
has_bitmaps=(face->num_fixed_sizes>0)?true:false;
|
has_bitmaps=(face->num_fixed_sizes>0)?true:false;
|
||||||
is_fixedwidth=(face->face_flags & FT_FACE_FLAG_FIXED_WIDTH)?true:false;
|
is_fixedwidth=(face->face_flags & FT_FACE_FLAG_FIXED_WIDTH)?true:false;
|
||||||
is_scalable=(face->face_flags & FT_FACE_FLAG_SCALABLE)?true:false;
|
is_scalable=(face->face_flags & FT_FACE_FLAG_SCALABLE)?true:false;
|
||||||
@@ -49,8 +48,10 @@ FontStyle::FontStyle(const char *filepath, FT_Face face)
|
|||||||
glyphcount=face->num_glyphs;
|
glyphcount=face->num_glyphs;
|
||||||
charmapcount=face->num_charmaps;
|
charmapcount=face->num_charmaps;
|
||||||
tunedcount=face->num_fixed_sizes;
|
tunedcount=face->num_fixed_sizes;
|
||||||
path=new BString(filepath);
|
fPath=filepath;
|
||||||
fbounds.Set(0,0,0,0);
|
fbounds.Set(0,0,0,0);
|
||||||
|
fFace=TranslateStyleToFace(face->style_name);
|
||||||
|
fID=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -63,43 +64,16 @@ FontStyle::FontStyle(const char *filepath, FT_Face face)
|
|||||||
*/
|
*/
|
||||||
FontStyle::~FontStyle(void)
|
FontStyle::~FontStyle(void)
|
||||||
{
|
{
|
||||||
delete name;
|
|
||||||
delete path;
|
|
||||||
delete cachedface;
|
delete cachedface;
|
||||||
|
|
||||||
// Mark all instances as Free here
|
|
||||||
int32 index=0;
|
|
||||||
|
|
||||||
ServerFont *fs=(ServerFont*)instances->ItemAt(index);
|
|
||||||
|
|
||||||
while(fs)
|
|
||||||
{
|
|
||||||
fs->fstyle=NULL;
|
|
||||||
index++;
|
|
||||||
fs=(ServerFont*)instances->ItemAt(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
instances->MakeEmpty();
|
|
||||||
delete instances;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Returns the name of the style as a string
|
\brief Returns the name of the style as a string
|
||||||
\return The style's name
|
\return The style's name
|
||||||
*/
|
*/
|
||||||
const char *FontStyle::Name(void)
|
const char *FontStyle::Name(void) const
|
||||||
{
|
{
|
||||||
return name->String();
|
return fName.String();
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Returns a handle to the style in question, straight from FreeType's cache
|
|
||||||
\return FreeType face handle or NULL if there was an internal error
|
|
||||||
*/
|
|
||||||
FT_Face FontStyle::GetFace(void)
|
|
||||||
{
|
|
||||||
FT_Face f;
|
|
||||||
return (FTC_Manager_LookupFace(ftmanager,(FTC_FaceID)cachedface,&f)!=0)?f:NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -108,7 +82,19 @@ FT_Face FontStyle::GetFace(void)
|
|||||||
*/
|
*/
|
||||||
const char *FontStyle::GetPath(void)
|
const char *FontStyle::GetPath(void)
|
||||||
{
|
{
|
||||||
return path->String();
|
return fPath.String();
|
||||||
|
}
|
||||||
|
|
||||||
|
int32 FontStyle::GetFlags(void) const
|
||||||
|
{
|
||||||
|
int32 flags=0;
|
||||||
|
if(IsFixedWidth())
|
||||||
|
flags|=B_IS_FIXED;
|
||||||
|
|
||||||
|
if(TunedCount()>0)
|
||||||
|
flags|=B_HAS_TUNED_FONT;
|
||||||
|
|
||||||
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -116,37 +102,79 @@ const char *FontStyle::GetPath(void)
|
|||||||
\param c An ASCII character
|
\param c An ASCII character
|
||||||
\return A Unicode value for the character
|
\return A Unicode value for the character
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// TODO: Re-enable when I understand how the FT2 Cache system changed from
|
||||||
|
// 2.1.4 to 2.1.8
|
||||||
|
/*
|
||||||
int16 FontStyle::ConvertToUnicode(uint16 c)
|
int16 FontStyle::ConvertToUnicode(uint16 c)
|
||||||
{
|
{
|
||||||
FT_Face f;
|
FT_Face f;
|
||||||
if(FTC_Manager_LookupFace(ftmanager,(FTC_FaceID)cachedface,&f)!=0)
|
if(FTC_Manager_Lookup_Face(ftmanager,cachedface,&f)!=0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return FT_Get_Char_Index(f,c);
|
return FT_Get_Char_Index(f,c);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Creates a new ServerFont object for the style, given size, shear, and rotation.
|
|
||||||
\param size character size in points
|
|
||||||
\param rotation rotation in degrees
|
|
||||||
\param shear shear (slant) in degrees. 45 <= shear <= 135. 90 is vertical
|
|
||||||
\return The new ServerFont object
|
|
||||||
*/
|
*/
|
||||||
ServerFont *FontStyle::Instantiate(float size, float rotation, float shear)
|
|
||||||
|
uint16 FontStyle::TranslateStyleToFace(const char *name) const
|
||||||
{
|
{
|
||||||
ServerFont *f=new ServerFont(this, size, rotation, shear);
|
// TODO: see how R5 translates font styles to faces for FontStyle::TranslateStyleToFace
|
||||||
instances->AddItem(f);
|
if(!name)
|
||||||
return f;
|
return 0;
|
||||||
|
|
||||||
|
BString str(name);
|
||||||
|
|
||||||
|
if(str.ICompare("ultra light")==0)
|
||||||
|
return B_REGULAR_FACE;
|
||||||
|
if(str.ICompare("thin")==0)
|
||||||
|
return B_REGULAR_FACE;
|
||||||
|
if(str.ICompare("extra light")==0)
|
||||||
|
return B_REGULAR_FACE;
|
||||||
|
if(str.ICompare("light")==0)
|
||||||
|
return B_REGULAR_FACE;
|
||||||
|
if(str.ICompare("roman")==0)
|
||||||
|
return B_REGULAR_FACE;
|
||||||
|
if(str.ICompare("book")==0)
|
||||||
|
return B_REGULAR_FACE;
|
||||||
|
if(str.ICompare("regular")==0)
|
||||||
|
return B_REGULAR_FACE;
|
||||||
|
if(str.ICompare("plain")==0)
|
||||||
|
return B_REGULAR_FACE;
|
||||||
|
if(str.ICompare("medium")==0)
|
||||||
|
return B_REGULAR_FACE;
|
||||||
|
|
||||||
|
if(str.ICompare("demibold")==0)
|
||||||
|
return B_BOLD_FACE;
|
||||||
|
if(str.ICompare("bold")==0)
|
||||||
|
return B_BOLD_FACE;
|
||||||
|
if(str.ICompare("black")==0)
|
||||||
|
return B_BOLD_FACE;
|
||||||
|
if(str.ICompare("heavy")==0)
|
||||||
|
return B_BOLD_FACE;
|
||||||
|
if(str.ICompare("extra bold")==0)
|
||||||
|
return B_BOLD_FACE;
|
||||||
|
if(str.ICompare("ultra bold")==0)
|
||||||
|
return B_BOLD_FACE;
|
||||||
|
|
||||||
|
if(str.ICompare("italic")==0)
|
||||||
|
return B_ITALIC_FACE;
|
||||||
|
if(str.ICompare("oblique")==0)
|
||||||
|
return B_BOLD_FACE;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Constructor
|
\brief Constructor
|
||||||
\param namestr Name of the family
|
\param namestr Name of the family
|
||||||
*/
|
*/
|
||||||
FontFamily::FontFamily(const char *namestr)
|
FontFamily::FontFamily(const char *namestr, const uint16 &index)
|
||||||
{
|
{
|
||||||
name=new BString(namestr);
|
fName=namestr;
|
||||||
styles=new BList(0);
|
fID=index;
|
||||||
|
|
||||||
|
// will stay uninitialized until needed
|
||||||
|
fFlags=-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -158,17 +186,12 @@ FontFamily::FontFamily(const char *namestr)
|
|||||||
*/
|
*/
|
||||||
FontFamily::~FontFamily(void)
|
FontFamily::~FontFamily(void)
|
||||||
{
|
{
|
||||||
delete name;
|
FontStyle *style;
|
||||||
|
for(int32 i=0; i<fStyles.CountItems(); i++)
|
||||||
BString *string;
|
|
||||||
for(int32 i=0; i<styles->CountItems(); i++)
|
|
||||||
{
|
{
|
||||||
string=(BString *)styles->RemoveItem(i);
|
style=(FontStyle *)fStyles.RemoveItem(i);
|
||||||
if(string)
|
delete style;
|
||||||
delete string;
|
|
||||||
}
|
}
|
||||||
styles->MakeEmpty(); // should be empty, but just in case...
|
|
||||||
delete styles;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -177,7 +200,7 @@ FontFamily::~FontFamily(void)
|
|||||||
*/
|
*/
|
||||||
const char *FontFamily::Name(void)
|
const char *FontFamily::Name(void)
|
||||||
{
|
{
|
||||||
return name->String();
|
return fName.String();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -185,27 +208,39 @@ const char *FontFamily::Name(void)
|
|||||||
\param path full path to the style's font file
|
\param path full path to the style's font file
|
||||||
\param face FreeType face handle used to obtain info about the font
|
\param face FreeType face handle used to obtain info about the font
|
||||||
*/
|
*/
|
||||||
void FontFamily::AddStyle(const char *path,FT_Face face)
|
bool FontFamily::AddStyle(FontStyle *style)
|
||||||
{
|
{
|
||||||
if(!path)
|
if(!style)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
BString style(face->style_name);
|
|
||||||
FontStyle *item;
|
FontStyle *item;
|
||||||
|
|
||||||
// Don't add if it already is in the family.
|
// Don't add if it already is in the family.
|
||||||
int32 count=styles->CountItems();
|
int32 count=fStyles.CountItems();
|
||||||
for(int32 i=0; i<count; i++)
|
for(int32 i=0; i<count; i++)
|
||||||
{
|
{
|
||||||
item=(FontStyle *)styles->ItemAt(i);
|
item=(FontStyle *)fStyles.ItemAt(i);
|
||||||
if(item->name->Compare(face->style_name)==0)
|
if(item->fName==style->fName)
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
item=new FontStyle(path, face);
|
style->family=this;
|
||||||
item->family=this;
|
|
||||||
styles->AddItem(item);
|
if(fStyles.CountItems()>0)
|
||||||
|
{
|
||||||
|
item=(FontStyle *)fStyles.ItemAt(fStyles.CountItems()-1);
|
||||||
|
style->fID=item->fID+1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
style->fID=0;
|
||||||
|
|
||||||
|
fStyles.AddItem(style);
|
||||||
AddDependent();
|
AddDependent();
|
||||||
|
|
||||||
|
// force a refresh if a request for font flags is needed
|
||||||
|
fFlags=-1;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -214,33 +249,52 @@ void FontFamily::AddStyle(const char *path,FT_Face face)
|
|||||||
*/
|
*/
|
||||||
void FontFamily::RemoveStyle(const char *style)
|
void FontFamily::RemoveStyle(const char *style)
|
||||||
{
|
{
|
||||||
int32 count=styles->CountItems();
|
int32 count=fStyles.CountItems();
|
||||||
if(!style || count<1)
|
if(!style || count<1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
FontStyle *fs;
|
FontStyle *fs;
|
||||||
for(int32 i=0; i<count; i++)
|
for(int32 i=0; i<count; i++)
|
||||||
{
|
{
|
||||||
fs=(FontStyle *)styles->ItemAt(i);
|
fs=(FontStyle *)fStyles.ItemAt(i);
|
||||||
if(fs && fs->name->Compare(style)==0)
|
if(fs && fs->fName.Compare(style)==0)
|
||||||
{
|
{
|
||||||
fs=(FontStyle *)styles->RemoveItem(i);
|
fs=(FontStyle *)fStyles.RemoveItem(i);
|
||||||
if(fs)
|
if(fs)
|
||||||
{
|
{
|
||||||
delete fs;
|
delete fs;
|
||||||
RemoveDependent();
|
RemoveDependent();
|
||||||
|
|
||||||
|
// force a refresh if a request for font flags is needed
|
||||||
|
fFlags=-1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Removes a style from the family. The caller is responsible for freeing the object
|
||||||
|
\param style The style to be removed from the family
|
||||||
|
*/
|
||||||
|
void FontFamily::RemoveStyle(FontStyle *style)
|
||||||
|
{
|
||||||
|
if(fStyles.HasItem(style))
|
||||||
|
{
|
||||||
|
fStyles.RemoveItem(style);
|
||||||
|
RemoveDependent();
|
||||||
|
|
||||||
|
// force a refresh if a request for font flags is needed
|
||||||
|
fFlags=-1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Returns the number of styles in the family
|
\brief Returns the number of styles in the family
|
||||||
\return The number of styles in the family
|
\return The number of styles in the family
|
||||||
*/
|
*/
|
||||||
int32 FontFamily::CountStyles(void)
|
int32 FontFamily::CountStyles(void)
|
||||||
{
|
{
|
||||||
return styles->CountItems();
|
return fStyles.CountItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -250,14 +304,16 @@ int32 FontFamily::CountStyles(void)
|
|||||||
*/
|
*/
|
||||||
bool FontFamily::HasStyle(const char *style)
|
bool FontFamily::HasStyle(const char *style)
|
||||||
{
|
{
|
||||||
int32 count=styles->CountItems();
|
int32 count=fStyles.CountItems();
|
||||||
|
|
||||||
if(!style || count<1)
|
if(!style || count<1)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
FontStyle *fs;
|
FontStyle *fs;
|
||||||
for(int32 i=0; i<count; i++)
|
for(int32 i=0; i<count; i++)
|
||||||
{
|
{
|
||||||
fs=(FontStyle *)styles->ItemAt(i);
|
fs=(FontStyle *)fStyles.ItemAt(i);
|
||||||
if(fs && fs->name->Compare(style)==0)
|
if(fs && fs->fName.Compare(style)==0)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -268,12 +324,9 @@ bool FontFamily::HasStyle(const char *style)
|
|||||||
\param index list index of the style to be found
|
\param index list index of the style to be found
|
||||||
\return name of the style or NULL if the index is not valid
|
\return name of the style or NULL if the index is not valid
|
||||||
*/
|
*/
|
||||||
const char *FontFamily::GetStyle(int32 index)
|
FontStyle *FontFamily::GetStyle(int32 index)
|
||||||
{
|
{
|
||||||
FontStyle *fs=(FontStyle*)styles->ItemAt(index);
|
return (FontStyle*)fStyles.ItemAt(index);
|
||||||
if(!fs)
|
|
||||||
return NULL;
|
|
||||||
return fs->Name();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -285,15 +338,38 @@ const char *FontFamily::GetStyle(int32 index)
|
|||||||
*/
|
*/
|
||||||
FontStyle *FontFamily::GetStyle(const char *style)
|
FontStyle *FontFamily::GetStyle(const char *style)
|
||||||
{
|
{
|
||||||
int32 count=styles->CountItems();
|
int32 count=fStyles.CountItems();
|
||||||
if(!style || count<1)
|
if(!style || count<1)
|
||||||
return NULL;
|
return NULL;
|
||||||
FontStyle *fs;
|
FontStyle *fs;
|
||||||
for(int32 i=0; i<count; i++)
|
for(int32 i=0; i<count; i++)
|
||||||
{
|
{
|
||||||
fs=(FontStyle *)styles->ItemAt(i);
|
fs=(FontStyle *)fStyles.ItemAt(i);
|
||||||
if(fs && fs->name->Compare(style)==0)
|
if(fs && fs->fName.Compare(style)==0)
|
||||||
return fs;
|
return fs;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32 FontFamily::GetFlags(void)
|
||||||
|
{
|
||||||
|
if(fFlags==-1)
|
||||||
|
{
|
||||||
|
fFlags=0;
|
||||||
|
|
||||||
|
for(int32 i=0; i<fStyles.CountItems(); i++)
|
||||||
|
{
|
||||||
|
FontStyle *style=(FontStyle*)fStyles.ItemAt(i);
|
||||||
|
if(style)
|
||||||
|
{
|
||||||
|
if(style->IsFixedWidth())
|
||||||
|
fFlags|=B_IS_FIXED;
|
||||||
|
if(style->TunedCount()>0)
|
||||||
|
fFlags|=B_HAS_TUNED_FONT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return fFlags;
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -137,6 +137,44 @@ void FontServer::RemoveFamily(const char *family)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *FontServer::GetFamilyName(uint16 id) const
|
||||||
|
{
|
||||||
|
FontFamily *fam;
|
||||||
|
for(int32 i=0; i<families->CountItems(); i++)
|
||||||
|
{
|
||||||
|
fam=(FontFamily*)families->ItemAt(i);
|
||||||
|
if(fam && fam->GetID()==id)
|
||||||
|
return fam->Name();
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *FontServer::GetStyleName(const char *family, uint16 id) const
|
||||||
|
{
|
||||||
|
FontFamily *fam=_FindFamily(family);
|
||||||
|
FontStyle *sty;
|
||||||
|
for(int32 i=0; i<families->CountItems(); i++)
|
||||||
|
{
|
||||||
|
sty=fam->GetStyle(i);
|
||||||
|
if(sty && sty->GetID()==id)
|
||||||
|
return sty->Name();
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
FontStyle *FontServer::GetStyle(const char *family, uint16 id) const
|
||||||
|
{
|
||||||
|
FontFamily *fam=_FindFamily(family);
|
||||||
|
FontStyle *sty;
|
||||||
|
for(int32 i=0; i<families->CountItems(); i++)
|
||||||
|
{
|
||||||
|
sty=fam->GetStyle(i);
|
||||||
|
if(sty && sty->GetID()==id)
|
||||||
|
return sty;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Protected function which locates a FontFamily object
|
\brief Protected function which locates a FontFamily object
|
||||||
\param name The family to find
|
\param name The family to find
|
||||||
@@ -144,7 +182,7 @@ void FontServer::RemoveFamily(const char *family)
|
|||||||
|
|
||||||
Do NOT delete the FontFamily returned by this function.
|
Do NOT delete the FontFamily returned by this function.
|
||||||
*/
|
*/
|
||||||
FontFamily *FontServer::_FindFamily(const char *name)
|
FontFamily *FontServer::_FindFamily(const char *name) const
|
||||||
{
|
{
|
||||||
if(!init)
|
if(!init)
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -189,6 +227,7 @@ status_t FontServer::ScanDirectory(const char *fontspath)
|
|||||||
FT_Error error;
|
FT_Error error;
|
||||||
FT_CharMap charmap;
|
FT_CharMap charmap;
|
||||||
FontFamily *family;
|
FontFamily *family;
|
||||||
|
FontStyle *style;
|
||||||
|
|
||||||
stat=dir.SetTo(fontspath);
|
stat=dir.SetTo(fontspath);
|
||||||
if(stat!=B_OK)
|
if(stat!=B_OK)
|
||||||
@@ -227,7 +266,7 @@ status_t FontServer::ScanDirectory(const char *fontspath)
|
|||||||
printf("Font Family: %s\n",face->family_name);
|
printf("Font Family: %s\n",face->family_name);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
family=new FontFamily(face->family_name);
|
family=new FontFamily(face->family_name,families->CountItems());
|
||||||
families->AddItem(family);
|
families->AddItem(family);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,8 +281,11 @@ status_t FontServer::ScanDirectory(const char *fontspath)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Has vertical metrics?
|
// Has vertical metrics?
|
||||||
family->AddStyle(path.Path(),face);
|
style=new FontStyle(path.Path(),face);
|
||||||
validcount++;
|
if(!family->AddStyle(style))
|
||||||
|
delete style;
|
||||||
|
else
|
||||||
|
validcount++;
|
||||||
|
|
||||||
FT_Done_Face(face);
|
FT_Done_Face(face);
|
||||||
} // end for(i<refcount)
|
} // end for(i<refcount)
|
||||||
@@ -316,7 +358,7 @@ FT_CharMap FontServer::_GetSupportedCharmap(const FT_Face &face)
|
|||||||
*/
|
*/
|
||||||
void FontServer::SaveList(void)
|
void FontServer::SaveList(void)
|
||||||
{
|
{
|
||||||
int32 famcount=0, stycount=0,i=0,j=0;
|
/* int32 famcount=0, stycount=0,i=0,j=0;
|
||||||
FontFamily *fam;
|
FontFamily *fam;
|
||||||
FontStyle *sty;
|
FontStyle *sty;
|
||||||
BMessage fontmsg, familymsg('FONT');
|
BMessage fontmsg, familymsg('FONT');
|
||||||
@@ -371,26 +413,50 @@ void FontServer::SaveList(void)
|
|||||||
BFile file(SERVER_FONT_LIST,B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE);
|
BFile file(SERVER_FONT_LIST,B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE);
|
||||||
if(file.InitCheck()==B_OK)
|
if(file.InitCheck()==B_OK)
|
||||||
fontmsg.Flatten(&file);
|
fontmsg.Flatten(&file);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Retrieves the FontStyle object
|
\brief Retrieves the FontStyle object
|
||||||
\param family The font's family
|
\param family The font's family
|
||||||
\param face The font's style
|
\param style The font's style
|
||||||
\return The FontStyle having those attributes or NULL if not available
|
\return The FontStyle having those attributes or NULL if not available
|
||||||
*/
|
*/
|
||||||
FontStyle *FontServer::GetStyle(font_family family, font_style face)
|
FontStyle *FontServer::GetStyle(const char *family, const char *style)
|
||||||
{
|
{
|
||||||
FontFamily *ffam=_FindFamily(family);
|
FontFamily *ffam=_FindFamily(family);
|
||||||
|
|
||||||
if(ffam)
|
if(ffam)
|
||||||
{
|
{
|
||||||
FontStyle *fsty=ffam->GetStyle(face);
|
FontStyle *fsty=ffam->GetStyle(style);
|
||||||
return fsty;
|
return fsty;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Retrieves the FontStyle object
|
||||||
|
\param family ID for the font's family
|
||||||
|
\param style ID of the font's style
|
||||||
|
\return The FontStyle having those attributes or NULL if not available
|
||||||
|
*/
|
||||||
|
FontStyle *FontServer::GetStyle(const uint16 &familyid, const uint16 &styleid)
|
||||||
|
{
|
||||||
|
// TODO: Implement FontServer::GetStyle(id,id)
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
FontFamily *FontServer::GetFamily(const uint16 &familyid)
|
||||||
|
{
|
||||||
|
for(int32 i=0; i<families->CountItems(); i++)
|
||||||
|
{
|
||||||
|
FontFamily *fam=(FontFamily*)families->ItemAt(i);
|
||||||
|
if(fam->GetID()==familyid)
|
||||||
|
return fam;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Returns the current object used for the regular style
|
\brief Returns the current object used for the regular style
|
||||||
\return A ServerFont pointer which is the plain font.
|
\return A ServerFont pointer which is the plain font.
|
||||||
@@ -458,7 +524,8 @@ bool FontServer::SetSystemPlain(const char *family, const char *style, float siz
|
|||||||
|
|
||||||
if(plain)
|
if(plain)
|
||||||
delete plain;
|
delete plain;
|
||||||
plain=sty->Instantiate(size);
|
|
||||||
|
plain=new ServerFont(sty,size);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -481,7 +548,8 @@ bool FontServer::SetSystemBold(const char *family, const char *style, float size
|
|||||||
|
|
||||||
if(bold)
|
if(bold)
|
||||||
delete bold;
|
delete bold;
|
||||||
bold=sty->Instantiate(size);
|
|
||||||
|
bold=new ServerFont(sty,size);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -504,7 +572,8 @@ bool FontServer::SetSystemFixed(const char *family, const char *style, float siz
|
|||||||
|
|
||||||
if(fixed)
|
if(fixed)
|
||||||
delete fixed;
|
delete fixed;
|
||||||
fixed=sty->Instantiate(size);
|
|
||||||
|
fixed=new ServerFont(sty,size);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -367,19 +367,10 @@ int32 ServerApp::MonitorApp(void *data)
|
|||||||
void ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg)
|
void ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg)
|
||||||
{
|
{
|
||||||
LayerData ld;
|
LayerData ld;
|
||||||
|
BPortLink replylink;
|
||||||
|
|
||||||
switch(code)
|
switch(code)
|
||||||
{
|
{
|
||||||
case AS_UPDATED_CLIENT_FONTLIST:
|
|
||||||
{
|
|
||||||
STRACE(("ServerApp %s: Acknowledged update of client-side font list\n",fSignature.String()));
|
|
||||||
|
|
||||||
// received when the client-side global font list has been
|
|
||||||
// refreshed
|
|
||||||
fontserver->Lock();
|
|
||||||
fontserver->FontsUpdated();
|
|
||||||
fontserver->Unlock();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case AS_UPDATE_COLORS:
|
case AS_UPDATE_COLORS:
|
||||||
{
|
{
|
||||||
// NOTE: R2: Eventually we will have windows which will notify their children of changes in
|
// NOTE: R2: Eventually we will have windows which will notify their children of changes in
|
||||||
@@ -476,7 +467,7 @@ void ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg)
|
|||||||
|
|
||||||
void *sharedmem=fSharedMem->GetBuffer(memsize);
|
void *sharedmem=fSharedMem->GetBuffer(memsize);
|
||||||
|
|
||||||
BPortLink replylink(replyport);
|
replylink.SetSendPort(replyport);
|
||||||
if(memsize<1 || sharedmem==NULL)
|
if(memsize<1 || sharedmem==NULL)
|
||||||
{
|
{
|
||||||
replylink.StartMessage(SERVER_FALSE);
|
replylink.StartMessage(SERVER_FALSE);
|
||||||
@@ -633,7 +624,7 @@ void ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg)
|
|||||||
STRACE(("ServerApp %s: Create Bitmap (%.1f,%.1f,%.1f,%.1f)\n",
|
STRACE(("ServerApp %s: Create Bitmap (%.1f,%.1f,%.1f,%.1f)\n",
|
||||||
fSignature.String(),r.left,r.top,r.right,r.bottom));
|
fSignature.String(),r.left,r.top,r.right,r.bottom));
|
||||||
|
|
||||||
BPortLink replylink(replyport);
|
replylink.SetSendPort(replyport);
|
||||||
if(sbmp)
|
if(sbmp)
|
||||||
{
|
{
|
||||||
fBitmapList->AddItem(sbmp);
|
fBitmapList->AddItem(sbmp);
|
||||||
@@ -669,7 +660,7 @@ void ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg)
|
|||||||
msg.Read<int32>(&replyport);
|
msg.Read<int32>(&replyport);
|
||||||
|
|
||||||
ServerBitmap *sbmp=FindBitmap(bmp_id);
|
ServerBitmap *sbmp=FindBitmap(bmp_id);
|
||||||
BPortLink replylink(replyport);
|
replylink.SetSendPort(replyport);
|
||||||
if(sbmp)
|
if(sbmp)
|
||||||
{
|
{
|
||||||
STRACE(("ServerApp %s: Deleting Bitmap %ld\n",fSignature.String(),bmp_id));
|
STRACE(("ServerApp %s: Deleting Bitmap %ld\n",fSignature.String(),bmp_id));
|
||||||
@@ -788,7 +779,7 @@ void ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg)
|
|||||||
int32 replyport;
|
int32 replyport;
|
||||||
msg.Read<int32>(&replyport);
|
msg.Read<int32>(&replyport);
|
||||||
|
|
||||||
BPortLink replylink(replyport);
|
replylink.SetSendPort(replyport);
|
||||||
replylink.StartMessage(fCursorHidden ? SERVER_TRUE : SERVER_FALSE);
|
replylink.StartMessage(fCursorHidden ? SERVER_TRUE : SERVER_FALSE);
|
||||||
replylink.Flush();
|
replylink.Flush();
|
||||||
break;
|
break;
|
||||||
@@ -837,7 +828,7 @@ void ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg)
|
|||||||
{
|
{
|
||||||
// the application is expecting a reply, but plans to do literally nothing
|
// the application is expecting a reply, but plans to do literally nothing
|
||||||
// with the data, so we'll just reuse the cursor token variable
|
// with the data, so we'll just reuse the cursor token variable
|
||||||
BPortLink replylink(replyport);
|
replylink.SetSendPort(replyport);
|
||||||
replylink.StartMessage(SERVER_TRUE);
|
replylink.StartMessage(SERVER_TRUE);
|
||||||
replylink.Flush();
|
replylink.Flush();
|
||||||
}
|
}
|
||||||
@@ -862,7 +853,7 @@ void ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg)
|
|||||||
cursormanager->AddCursor(fAppCursor);
|
cursormanager->AddCursor(fAppCursor);
|
||||||
|
|
||||||
// Synchronous message - BApplication is waiting on the cursor's ID
|
// Synchronous message - BApplication is waiting on the cursor's ID
|
||||||
BPortLink replylink(replyport);
|
replylink.SetSendPort(replyport);
|
||||||
replylink.StartMessage(SERVER_TRUE);
|
replylink.StartMessage(SERVER_TRUE);
|
||||||
replylink.Attach<int32>(fAppCursor->ID());
|
replylink.Attach<int32>(fAppCursor->ID());
|
||||||
replylink.Flush();
|
replylink.Flush();
|
||||||
@@ -893,7 +884,7 @@ void ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg)
|
|||||||
port_id replyport;
|
port_id replyport;
|
||||||
msg.Read<int32>(&replyport);
|
msg.Read<int32>(&replyport);
|
||||||
|
|
||||||
BPortLink replylink(replyport);
|
replylink.SetSendPort(replyport);
|
||||||
replylink.StartMessage(SERVER_TRUE);
|
replylink.StartMessage(SERVER_TRUE);
|
||||||
replylink.Attach<scroll_bar_info>(sbi);
|
replylink.Attach<scroll_bar_info>(sbi);
|
||||||
replylink.Flush();
|
replylink.Flush();
|
||||||
@@ -919,7 +910,7 @@ void ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg)
|
|||||||
port_id replyport;
|
port_id replyport;
|
||||||
msg.Read<int32>(&replyport);
|
msg.Read<int32>(&replyport);
|
||||||
|
|
||||||
BPortLink replylink(replyport);
|
replylink.SetSendPort(replyport);
|
||||||
replylink.StartMessage(SERVER_TRUE);
|
replylink.StartMessage(SERVER_TRUE);
|
||||||
replylink.Attach<bool>(desktop->FFMouseInUse());
|
replylink.Attach<bool>(desktop->FFMouseInUse());
|
||||||
replylink.Flush();
|
replylink.Flush();
|
||||||
@@ -958,7 +949,7 @@ void ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg)
|
|||||||
port_id replyport = -1;
|
port_id replyport = -1;
|
||||||
msg.Read<int32>(&replyport);
|
msg.Read<int32>(&replyport);
|
||||||
|
|
||||||
BPortLink replylink(replyport);
|
replylink.SetSendPort(replyport);
|
||||||
replylink.StartMessage(SERVER_TRUE);
|
replylink.StartMessage(SERVER_TRUE);
|
||||||
replylink.Attach<mode_mouse>(mmode);
|
replylink.Attach<mode_mouse>(mmode);
|
||||||
replylink.Flush();
|
replylink.Flush();
|
||||||
@@ -979,12 +970,324 @@ void ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg)
|
|||||||
color=gui_colorset.AttributeToColor(whichcolor);
|
color=gui_colorset.AttributeToColor(whichcolor);
|
||||||
gui_colorset.Unlock();
|
gui_colorset.Unlock();
|
||||||
|
|
||||||
BPortLink replylink(replyport);
|
replylink.SetSendPort(replyport);
|
||||||
replylink.StartMessage(SERVER_TRUE);
|
replylink.StartMessage(SERVER_TRUE);
|
||||||
replylink.Attach<rgb_color>(color.GetColor32());
|
replylink.Attach<rgb_color>(color.GetColor32());
|
||||||
replylink.Flush();
|
replylink.Flush();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case AS_UPDATED_CLIENT_FONTLIST:
|
||||||
|
{
|
||||||
|
STRACE(("ServerApp %s: Acknowledged update of client-side font list\n",fSignature.String()));
|
||||||
|
|
||||||
|
// received when the client-side global font list has been
|
||||||
|
// refreshed
|
||||||
|
fontserver->Lock();
|
||||||
|
fontserver->FontsUpdated();
|
||||||
|
fontserver->Unlock();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case AS_QUERY_FONTS_CHANGED:
|
||||||
|
{
|
||||||
|
// Attached Data:
|
||||||
|
// 1) bool check flag
|
||||||
|
// 2) port_id reply_port
|
||||||
|
|
||||||
|
// if just checking, just give an answer,
|
||||||
|
// if not and needs updated,
|
||||||
|
// sync the font list and return true else return false
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case AS_GET_FAMILY_NAME:
|
||||||
|
{
|
||||||
|
// Attached Data:
|
||||||
|
// 1) int32 the ID of the font family to get
|
||||||
|
// 2) port_id reply port
|
||||||
|
|
||||||
|
// Returns:
|
||||||
|
// 1) font_family - name of family
|
||||||
|
// 2) uint32 - flags of font family (B_IS_FIXED || B_HAS_TUNED_FONT)
|
||||||
|
int32 famid;
|
||||||
|
port_id replyport;
|
||||||
|
|
||||||
|
msg.Read<int32>(&famid);
|
||||||
|
msg.Read<port_id>(&replyport);
|
||||||
|
|
||||||
|
replylink.SetSendPort(replyport);
|
||||||
|
|
||||||
|
fontserver->Lock();
|
||||||
|
FontFamily *ffamily=fontserver->GetFamily(famid);
|
||||||
|
if(ffamily)
|
||||||
|
{
|
||||||
|
font_family fam;
|
||||||
|
sprintf(fam,"%s",ffamily->Name());
|
||||||
|
replylink.StartMessage(SERVER_TRUE);
|
||||||
|
replylink.Attach(fam,sizeof(font_family));
|
||||||
|
replylink.Attach<int32>(ffamily->GetFlags());
|
||||||
|
replylink.Flush();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
replylink.StartMessage(SERVER_FALSE);
|
||||||
|
replylink.Flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
fontserver->Unlock();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case AS_GET_STYLE_NAME:
|
||||||
|
{
|
||||||
|
// Attached Data:
|
||||||
|
// 1) font_family The name of the font family
|
||||||
|
// 2) int32 ID of the style to get
|
||||||
|
// 3) port_id reply port
|
||||||
|
|
||||||
|
// Returns:
|
||||||
|
// 1) font_style - name of the style
|
||||||
|
// 2) uint16 - appropriate face values
|
||||||
|
// 3) uint32 - flags of font style (B_IS_FIXED || B_HAS_TUNED_FONT)
|
||||||
|
|
||||||
|
int32 styid;
|
||||||
|
port_id replyport;
|
||||||
|
font_family fam;
|
||||||
|
|
||||||
|
msg.Read(fam,sizeof(font_family));
|
||||||
|
msg.Read<int32>(&styid);
|
||||||
|
msg.Read<port_id>(&replyport);
|
||||||
|
|
||||||
|
replylink.SetSendPort(replyport);
|
||||||
|
|
||||||
|
fontserver->Lock();
|
||||||
|
FontStyle *fstyle=fontserver->GetStyle(fam,styid);
|
||||||
|
if(fstyle)
|
||||||
|
{
|
||||||
|
font_family sty;
|
||||||
|
sprintf(sty,"%s",fstyle->Name());
|
||||||
|
replylink.StartMessage(SERVER_TRUE);
|
||||||
|
replylink.Attach(sty,sizeof(font_style));
|
||||||
|
replylink.Attach<int32>(fstyle->GetFace());
|
||||||
|
replylink.Attach<int32>(fstyle->GetFlags());
|
||||||
|
replylink.Flush();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
replylink.StartMessage(SERVER_FALSE);
|
||||||
|
replylink.Flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
fontserver->Unlock();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case AS_GET_FAMILY_AND_STYLE:
|
||||||
|
{
|
||||||
|
// Attached Data:
|
||||||
|
// 1) uint16 - family ID
|
||||||
|
// 2) uint16 - style ID
|
||||||
|
// 3) port_id reply port
|
||||||
|
|
||||||
|
// Returns:
|
||||||
|
// 1) font_family The name of the font family
|
||||||
|
// 2) font_style - name of the style
|
||||||
|
int32 famid, styid;
|
||||||
|
port_id replyport;
|
||||||
|
font_family fam;
|
||||||
|
font_style sty;
|
||||||
|
|
||||||
|
msg.Read<int32>(&famid);
|
||||||
|
msg.Read<int32>(&styid);
|
||||||
|
msg.Read<port_id>(&replyport);
|
||||||
|
|
||||||
|
replylink.SetSendPort(replyport);
|
||||||
|
|
||||||
|
fontserver->Lock();
|
||||||
|
FontStyle *fstyle=fontserver->GetStyle(famid,styid);
|
||||||
|
if(fstyle)
|
||||||
|
{
|
||||||
|
sprintf(fam,"%s",fstyle->Family()->Name());
|
||||||
|
sprintf(sty,"%s",fstyle->Name());
|
||||||
|
replylink.StartMessage(SERVER_TRUE);
|
||||||
|
replylink.Attach(fam,sizeof(font_family));
|
||||||
|
replylink.Attach(sty,sizeof(font_style));
|
||||||
|
replylink.Flush();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
replylink.StartMessage(SERVER_FALSE);
|
||||||
|
replylink.Flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
fontserver->Unlock();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case AS_GET_FONT_DIRECTION:
|
||||||
|
{
|
||||||
|
// Attached Data:
|
||||||
|
// 1) uint16 - family ID
|
||||||
|
// 2) uint16 - style ID
|
||||||
|
// 3) port_id reply port
|
||||||
|
|
||||||
|
// Returns:
|
||||||
|
// 1) font_direction direction of font
|
||||||
|
/* int32 famid, styid;
|
||||||
|
port_id replyport;
|
||||||
|
|
||||||
|
msg.Read<int32>(&famid);
|
||||||
|
msg.Read<int32>(&styid);
|
||||||
|
msg.Read<port_id>(&replyport);
|
||||||
|
|
||||||
|
replylink.SetSendPort(replyport);
|
||||||
|
|
||||||
|
fontserver->Lock();
|
||||||
|
FontStyle *fstyle=fontserver->GetStyle(famid,styid);
|
||||||
|
if(fstyle)
|
||||||
|
{
|
||||||
|
font_direction dir=fstyle->GetDirection();
|
||||||
|
|
||||||
|
replylink.StartMessage(SERVER_TRUE);
|
||||||
|
replylink.Attach<font_direction>(dir);
|
||||||
|
replylink.Flush();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
replylink.StartMessage(SERVER_FALSE);
|
||||||
|
replylink.Flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
fontserver->Unlock();
|
||||||
|
*/
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case AS_GET_FONT_BOUNDING_BOX:
|
||||||
|
{
|
||||||
|
// Attached Data:
|
||||||
|
// 1) uint16 - family ID
|
||||||
|
// 2) uint16 - style ID
|
||||||
|
// 3) port_id reply port
|
||||||
|
|
||||||
|
// Returns:
|
||||||
|
// 1) BRect - box holding entire font
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case AS_GET_TUNED_COUNT:
|
||||||
|
{
|
||||||
|
// Attached Data:
|
||||||
|
// 1) uint16 - family ID
|
||||||
|
// 2) uint16 - style ID
|
||||||
|
// 3) port_id reply port
|
||||||
|
|
||||||
|
// Returns:
|
||||||
|
// 1) int32 - number of font strikes available
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case AS_GET_TUNED_INFO:
|
||||||
|
{
|
||||||
|
// Attached Data:
|
||||||
|
// 1) uint16 - family ID
|
||||||
|
// 2) uint16 - style ID
|
||||||
|
// 3) uint32 - index of the particular font strike
|
||||||
|
// 4) port_id reply port
|
||||||
|
|
||||||
|
// Returns:
|
||||||
|
// 1) tuned_font_info - info on the strike specified
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case AS_QUERY_FONT_FIXED:
|
||||||
|
{
|
||||||
|
// Attached Data:
|
||||||
|
// 1) uint16 - family ID
|
||||||
|
// 2) uint16 - style ID
|
||||||
|
// 3) port_id reply port
|
||||||
|
|
||||||
|
// Returns:
|
||||||
|
// 1) bool - font is/is not fixed
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case AS_SET_FAMILY_AND_STYLE:
|
||||||
|
{
|
||||||
|
// Attached Data:
|
||||||
|
// 1) font_family - name of font family to use
|
||||||
|
// 2) font_style - name of style in family
|
||||||
|
// 3) port_id - reply port
|
||||||
|
|
||||||
|
// Returns:
|
||||||
|
// 1) uint16 - family ID
|
||||||
|
// 2) uint16 - style ID
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case AS_SET_FAMILY_AND_FACE:
|
||||||
|
{
|
||||||
|
// Attached Data:
|
||||||
|
// 1) font_family - name of font family to use
|
||||||
|
// 2) uint16 - font face
|
||||||
|
// 3) port_id - reply port
|
||||||
|
|
||||||
|
// Returns:
|
||||||
|
// 1) uint16 - family ID
|
||||||
|
// 2) uint16 - style ID
|
||||||
|
|
||||||
|
// TODO: Check R5 for error condition behavior in SET_FAMILY_AND_FACE
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case AS_COUNT_FONT_FAMILIES:
|
||||||
|
{
|
||||||
|
// Attached Data:
|
||||||
|
// None
|
||||||
|
|
||||||
|
// Returns:
|
||||||
|
// 1) int32 - # of font families
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case AS_COUNT_FONT_STYLES:
|
||||||
|
{
|
||||||
|
// Attached Data:
|
||||||
|
// 1) font_family - name of font family
|
||||||
|
|
||||||
|
// Returns:
|
||||||
|
// 1) int32 - # of font styles
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case AS_SET_SYSFONT_PLAIN:
|
||||||
|
{
|
||||||
|
// Attached Data:
|
||||||
|
// None
|
||||||
|
|
||||||
|
// Returns:
|
||||||
|
// 1) uint16 - family ID
|
||||||
|
// 2) uint16 - style ID
|
||||||
|
// 3) float - size in points
|
||||||
|
// 4) uint16 - face flags
|
||||||
|
// 5) font_height - height structure
|
||||||
|
|
||||||
|
// TODO: See if font_height is needed in SET_SYSFONT_XXXX messages
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case AS_SET_SYSFONT_BOLD:
|
||||||
|
{
|
||||||
|
// Attached Data:
|
||||||
|
// None
|
||||||
|
|
||||||
|
// Returns:
|
||||||
|
// 1) uint16 - family ID
|
||||||
|
// 2) uint16 - style ID
|
||||||
|
// 3) float - size in points
|
||||||
|
// 4) uint16 - face flags
|
||||||
|
// 5) font_height - height structure
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case AS_SET_SYSFONT_FIXED:
|
||||||
|
{
|
||||||
|
// Attached Data:
|
||||||
|
// None
|
||||||
|
|
||||||
|
// Returns:
|
||||||
|
// 1) uint16 - family ID
|
||||||
|
// 2) uint16 - style ID
|
||||||
|
// 3) float - size in points
|
||||||
|
// 4) uint16 - face flags
|
||||||
|
// 5) font_height - height structure
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
STRACE(("ServerApp %s received unhandled message code offset %s\n",fSignature.String(),
|
STRACE(("ServerApp %s received unhandled message code offset %s\n",fSignature.String(),
|
||||||
|
|||||||
@@ -24,7 +24,6 @@
|
|||||||
// Description: Shadow BFont class
|
// Description: Shadow BFont class
|
||||||
//
|
//
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
#include "FontFamily.h"
|
|
||||||
#include "ServerFont.h"
|
#include "ServerFont.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -141,7 +140,7 @@ int32 ServerFont::CountTuned(void)
|
|||||||
font_file_format ServerFont::FileFormat(void)
|
font_file_format ServerFont::FileFormat(void)
|
||||||
{
|
{
|
||||||
// TODO: implement
|
// TODO: implement
|
||||||
return B_TRUETYPE_WINDOWS;
|
return B_TRUETYPE_WINDOWS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -153,6 +152,16 @@ BRect ServerFont::BoundingBox(void)
|
|||||||
return fbounds;
|
return fbounds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *ServerFont::GetStyle(void) const
|
||||||
|
{
|
||||||
|
return fstyle->Name();
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *ServerFont::GetFamily(void) const
|
||||||
|
{
|
||||||
|
return fstyle->Family()->Name();
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Obtains the height values for characters in the font in its current state
|
\brief Obtains the height values for characters in the font in its current state
|
||||||
\param fh pointer to a font_height object to receive the values for the font
|
\param fh pointer to a font_height object to receive the values for the font
|
||||||
@@ -163,7 +172,3 @@ void ServerFont::Height(font_height *fh)
|
|||||||
fh->descent=fheight.descent;
|
fh->descent=fheight.descent;
|
||||||
fh->leading=fheight.leading;
|
fh->leading=fheight.leading;
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
@log
|
|
||||||
* added ServerFont::operator=(const ServerFont& font).
|
|
||||||
*/
|
|
||||||
|
|||||||
@@ -774,18 +774,7 @@ void ViewDriver::SetDrawData(const DrawData *d, bool set_font_data)
|
|||||||
if(!sf)
|
if(!sf)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
FontStyle *style=d->font.Style();
|
font.SetFamilyAndStyle(sf->GetFamily(),sf->GetStyle());
|
||||||
|
|
||||||
if(!style)
|
|
||||||
return;
|
|
||||||
|
|
||||||
FontFamily *family=(FontFamily *)style->Family();
|
|
||||||
if(!family)
|
|
||||||
return;
|
|
||||||
|
|
||||||
font_family fontfamily;
|
|
||||||
strcpy(fontfamily,family->Name());
|
|
||||||
font.SetFamilyAndStyle(fontfamily,style->Name());
|
|
||||||
font.SetFlags(sf->Flags());
|
font.SetFlags(sf->Flags());
|
||||||
font.SetEncoding(sf->Encoding());
|
font.SetEncoding(sf->Encoding());
|
||||||
font.SetSize(sf->Size());
|
font.SetSize(sf->Size());
|
||||||
|
|||||||
Reference in New Issue
Block a user