diff --git a/src/servers/app/server/ColorSet.cpp b/src/servers/app/server/ColorSet.cpp index 63642f4285..276f49d487 100644 --- a/src/servers/app/server/ColorSet.cpp +++ b/src/servers/app/server/ColorSet.cpp @@ -159,7 +159,7 @@ printf("Initializing color settings to defaults\n"); control_text.SetColor(0,0,0); control_border.SetColor(0,0,0); control_highlight.SetColor(115,120,184); - keyboard_navigation_base.SetColor(170,50,184); + keyboard_navigation_base.SetColor(0,0,229); keyboard_navigation_pulse.SetColor(0,0,0); shine.SetColor(255,255,255); shadow.SetColor(0,0,0); diff --git a/src/servers/app/server/FontFamily.cpp b/src/servers/app/server/FontFamily.cpp index a4c9b32f2d..eb4ecbaa09 100644 --- a/src/servers/app/server/FontFamily.cpp +++ b/src/servers/app/server/FontFamily.cpp @@ -52,6 +52,10 @@ FontStyle::FontStyle(const char *filepath, FT_Face face) fbounds.Set(0,0,0,0); fFace=TranslateStyleToFace(face->style_name); fID=0; + fHeight.ascent=face->ascender; + fHeight.descent=face->descender; + fHeight.leading=face->height; + fHeight.units_per_em=face->units_per_EM; } /*! @@ -76,6 +80,21 @@ const char *FontStyle::Name(void) const return fName.String(); } +font_height FontStyle::GetHeight(const float &size) +{ + font_height fh={0,0,0}; + + // font units are 26.6 format, so we get REALLY big numbers if + // we don't do some shifting. + fh.ascent=(fHeight.ascent * size) / fHeight.units_per_em; + + // FT2's descent numbers are negative. Be's is positive + fh.descent=(fHeight.descent * size * -1) / fHeight.units_per_em; + + fh.leading=(fHeight.leading * size) / fHeight.units_per_em; + return fh; +} + /*! \brief Returns the path to the style's font file \return The style's font file path diff --git a/src/servers/app/server/FontServer.cpp b/src/servers/app/server/FontServer.cpp index 7327c80a38..b2ee1336e6 100644 --- a/src/servers/app/server/FontServer.cpp +++ b/src/servers/app/server/FontServer.cpp @@ -115,7 +115,7 @@ int32 FontServer::CountFamilies(void) */ int32 FontServer::CountStyles(const char *family) { - FontFamily *f=_FindFamily(family); + FontFamily *f=GetFamily(family); if(f) { return f->CountStyles(); @@ -129,7 +129,7 @@ int32 FontServer::CountStyles(const char *family) */ void FontServer::RemoveFamily(const char *family) { - FontFamily *f=_FindFamily(family); + FontFamily *f=GetFamily(family); if(f) { families->RemoveItem(f); @@ -151,7 +151,7 @@ const char *FontServer::GetFamilyName(uint16 id) const const char *FontServer::GetStyleName(const char *family, uint16 id) const { - FontFamily *fam=_FindFamily(family); + FontFamily *fam=GetFamily(family); FontStyle *sty; for(int32 i=0; iCountItems(); i++) { @@ -164,7 +164,7 @@ const char *FontServer::GetStyleName(const char *family, uint16 id) const FontStyle *FontServer::GetStyle(const char *family, uint16 id) const { - FontFamily *fam=_FindFamily(family); + FontFamily *fam=GetFamily(family); FontStyle *sty; for(int32 i=0; iCountItems(); i++) { @@ -182,7 +182,7 @@ FontStyle *FontServer::GetStyle(const char *family, uint16 id) const Do NOT delete the FontFamily returned by this function. */ -FontFamily *FontServer::_FindFamily(const char *name) const +FontFamily *FontServer::GetFamily(const char *name) const { if(!init) return NULL; @@ -258,7 +258,7 @@ status_t FontServer::ScanDirectory(const char *fontspath) face->charmap=charmap; - family=_FindFamily(face->family_name); + family=GetFamily(face->family_name); if(!family) { @@ -280,7 +280,6 @@ status_t FontServer::ScanDirectory(const char *fontspath) printf("\tFont Style: %s\n",face->style_name); #endif - // Has vertical metrics? style=new FontStyle(path.Path(),face); if(!family->AddStyle(style)) delete style; @@ -424,7 +423,7 @@ void FontServer::SaveList(void) */ FontStyle *FontServer::GetStyle(const char *family, const char *style) { - FontFamily *ffam=_FindFamily(family); + FontFamily *ffam=GetFamily(family); if(ffam) { @@ -443,10 +442,16 @@ FontStyle *FontServer::GetStyle(const char *family, const char *style) FontStyle *FontServer::GetStyle(const uint16 &familyid, const uint16 &styleid) { // TODO: Implement FontServer::GetStyle(id,id) + FontFamily *fam=GetFamily(familyid); + if(fam) + { + FontStyle *sty=fam->GetStyle(styleid); + return sty; + } return NULL; } -FontFamily *FontServer::GetFamily(const uint16 &familyid) +FontFamily *FontServer::GetFamily(const uint16 &familyid) const { for(int32 i=0; iCountItems(); i++) { @@ -515,7 +520,7 @@ ServerFont *FontServer::GetSystemFixed(void) */ bool FontServer::SetSystemPlain(const char *family, const char *style, float size) { - FontFamily *fam=_FindFamily(family); + FontFamily *fam=GetFamily(family); if(!fam) return false; FontStyle *sty=fam->GetStyle(style); @@ -539,7 +544,7 @@ bool FontServer::SetSystemPlain(const char *family, const char *style, float siz */ bool FontServer::SetSystemBold(const char *family, const char *style, float size) { - FontFamily *fam=_FindFamily(family); + FontFamily *fam=GetFamily(family); if(!fam) return false; FontStyle *sty=fam->GetStyle(style); @@ -563,7 +568,7 @@ bool FontServer::SetSystemBold(const char *family, const char *style, float size */ bool FontServer::SetSystemFixed(const char *family, const char *style, float size) { - FontFamily *fam=_FindFamily(family); + FontFamily *fam=GetFamily(family); if(!fam) return false; FontStyle *sty=fam->GetStyle(style); diff --git a/src/servers/app/server/LayerData.cpp b/src/servers/app/server/LayerData.cpp index d5aaf55c7b..3f517eb764 100644 --- a/src/servers/app/server/LayerData.cpp +++ b/src/servers/app/server/LayerData.cpp @@ -192,6 +192,6 @@ void LayerData::PrintToStream() const{ printf("\t FontRotation: %f\n", font.Rotation()); printf("\t FontSpacing: %ld\n", font.Spacing()); printf("\t FontEncoding: %ld\n", font.Encoding()); - printf("\t FontFace: %ld\n", font.Face()); + printf("\t FontFace: %d\n", font.Face()); printf("\t FontFlags: %lu\n", font.Flags()); } diff --git a/src/servers/app/server/ServerApp.cpp b/src/servers/app/server/ServerApp.cpp index acb861c98f..934ca80d90 100644 --- a/src/servers/app/server/ServerApp.cpp +++ b/src/servers/app/server/ServerApp.cpp @@ -1232,60 +1232,204 @@ void ServerApp::DispatchMessage(int32 code, LinkMsgReader &msg) case AS_COUNT_FONT_FAMILIES: { // Attached Data: - // None + // 1) port_id - reply port // Returns: // 1) int32 - # of font families + port_id replyport=-1; + + replylink.SetSendPort(replyport); + fontserver->Lock(); + replylink.StartMessage(SERVER_TRUE); + replylink.Attach(fontserver->CountFamilies()); + replylink.Flush(); + fontserver->Unlock(); + break; } case AS_COUNT_FONT_STYLES: { // Attached Data: // 1) font_family - name of font family + // 2) port_id - reply port // Returns: // 1) int32 - # of font styles + port_id replyport; + font_family fam; + + msg.Read(fam,sizeof(font_family)); + msg.Read(&replyport); + + replylink.SetSendPort(replyport); + + fontserver->Lock(); + FontFamily *ffam=fontserver->GetFamily(fam); + if(ffam) + { + replylink.StartMessage(SERVER_TRUE); + replylink.Attach(ffam->CountStyles()); + replylink.Flush(); + } + else + { + replylink.StartMessage(SERVER_FALSE); + replylink.Flush(); + } + + fontserver->Unlock(); break; } case AS_SET_SYSFONT_PLAIN: { // Attached Data: - // None + // port_id reply port // Returns: // 1) uint16 - family ID // 2) uint16 - style ID // 3) float - size in points // 4) uint16 - face flags - // 5) font_height - height structure + // 5) uint32 - font flags - // TODO: See if font_height is needed in SET_SYSFONT_XXXX messages + port_id replyport; + msg.Read(&replyport); + replylink.SetSendPort(replyport); + + fontserver->Lock(); + ServerFont *sf=fontserver->GetSystemPlain(); + if(sf) + { + replylink.StartMessage(SERVER_TRUE); + replylink.Attach(sf->FamilyID()); + replylink.Attach(sf->StyleID()); + replylink.Attach(sf->Size()); + replylink.Attach(sf->Face()); + replylink.Attach(sf->Flags()); + replylink.Flush(); + } + else + { + replylink.StartMessage(SERVER_FALSE); + replylink.Flush(); + } + + fontserver->Unlock(); + + delete sf; + break; + } + case AS_GET_FONT_HEIGHT: + { + // Attached Data: + // 1) uint16 family ID + // 2) uint16 style ID + // 3) float size + // 4) port_id reply port + uint16 famid,styid; + float ptsize; + port_id replyport; + + msg.Read(&famid); + msg.Read(&styid); + msg.Read(&ptsize); + msg.Read(&replyport); + + replylink.SetSendPort(replyport); + + fontserver->Lock(); + FontStyle *fstyle=fontserver->GetStyle(famid,styid); + if(fstyle) + { + replylink.StartMessage(SERVER_TRUE); + replylink.Attach(fstyle->GetHeight(ptsize)); + replylink.Flush(); + } + else + { + replylink.StartMessage(SERVER_FALSE); + replylink.Flush(); + } + + fontserver->Unlock(); break; } case AS_SET_SYSFONT_BOLD: { // Attached Data: - // None + // port_id reply port // Returns: // 1) uint16 - family ID // 2) uint16 - style ID // 3) float - size in points // 4) uint16 - face flags - // 5) font_height - height structure + // 5) uint32 - font flags + + port_id replyport; + msg.Read(&replyport); + replylink.SetSendPort(replyport); + + fontserver->Lock(); + ServerFont *sf=fontserver->GetSystemBold(); + if(sf) + { + replylink.StartMessage(SERVER_TRUE); + replylink.Attach(sf->FamilyID()); + replylink.Attach(sf->StyleID()); + replylink.Attach(sf->Size()); + replylink.Attach(sf->Face()); + replylink.Attach(sf->Flags()); + replylink.Flush(); + } + else + { + replylink.StartMessage(SERVER_FALSE); + replylink.Flush(); + } + + fontserver->Unlock(); + + delete sf; break; } case AS_SET_SYSFONT_FIXED: { // Attached Data: - // None + // port_id reply port // Returns: // 1) uint16 - family ID // 2) uint16 - style ID // 3) float - size in points // 4) uint16 - face flags - // 5) font_height - height structure + // 5) uint32 - font flags + + port_id replyport; + msg.Read(&replyport); + replylink.SetSendPort(replyport); + + fontserver->Lock(); + ServerFont *sf=fontserver->GetSystemFixed(); + if(sf) + { + replylink.StartMessage(SERVER_TRUE); + replylink.Attach(sf->FamilyID()); + replylink.Attach(sf->StyleID()); + replylink.Attach(sf->Size()); + replylink.Attach(sf->Face()); + replylink.Attach(sf->Flags()); + replylink.Flush(); + } + else + { + replylink.StartMessage(SERVER_FALSE); + replylink.Flush(); + } + + fontserver->Unlock(); + + delete sf; break; } default: