Patch by Andrej Spielmann (GSOC):

* Extend the app_server protocol by configuration options to turn
  subpixel font rendering on/off and also make the glyph hinting optional
  (aligning of glyph shapes to the pixel grid).
* Implement the setting in the app_server and also handle the persistency.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26362 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2008-07-10 08:29:50 +00:00
parent fa6a00c628
commit b09e2f6f4b
8 changed files with 171 additions and 7 deletions
+90 -6
View File
@@ -5,12 +5,15 @@
* Authors:
* Stephan Aßmus <[email protected]>
* Axel Dörfler, [email protected]
* Andrej Spielmann, <[email protected]>
*/
#include "DesktopSettings.h"
#include "DesktopSettingsPrivate.h"
#include "Desktop.h"
#include "FontCache.h"
#include "FontCacheEntry.h"
#include "FontManager.h"
#include "ServerConfig.h"
@@ -60,7 +63,7 @@ DesktopSettingsPrivate::_SetDefaults()
strlcpy(fMenuInfo.f_style, fPlainFont.Style(), B_FONT_STYLE_LENGTH);
fMenuInfo.font_size = fPlainFont.Size();
fMenuInfo.background_color.set_to(216, 216, 216);
fMenuInfo.separator = 0;
// look of the separator (R5: (0, 1, 2), default 0)
fMenuInfo.click_to_open = true; // always true
@@ -69,6 +72,11 @@ DesktopSettingsPrivate::_SetDefaults()
fWorkspacesCount = 4;
memcpy(fShared.colors, BPrivate::kDefaultColors, sizeof(rgb_color) * kNumColors);
fFontSubpixelAntialiasing = false;
FontCacheEntry::SetDefaultRenderType(glyph_ren_native_gray8);
fHinting = true;
FontCacheEntry::SetDefaultHinting(true);
}
@@ -101,7 +109,7 @@ DesktopSettingsPrivate::_Load()
BPath path(basePath);
path.Append("workspaces");
BFile file;
status = file.SetTo(path.Path(), B_READ_ONLY);
if (status == B_OK) {
@@ -127,7 +135,7 @@ DesktopSettingsPrivate::_Load()
path = basePath;
path.Append("fonts");
status = file.SetTo(path.Path(), B_READ_ONLY);
if (status == B_OK) {
BMessage settings;
@@ -136,6 +144,8 @@ DesktopSettingsPrivate::_Load()
const char* family;
const char* style;
float size;
bool subpix;
bool hinting;
if (settings.FindString("plain family", &family) == B_OK
&& settings.FindString("plain style", &style) == B_OK
&& settings.FindFloat("plain size", &size) == B_OK) {
@@ -158,6 +168,15 @@ DesktopSettingsPrivate::_Load()
fFixedFont.SetStyle(fontStyle);
fFixedFont.SetSize(size);
}
if (settings.FindBool("font subpix", &subpix) == B_OK) {
fFontSubpixelAntialiasing = subpix;
FontCacheEntry::SetDefaultRenderType(
(subpix) ? glyph_ren_subpix : glyph_ren_native_gray8);
}
if (settings.FindBool("hinting", &hinting) == B_OK) {
fHinting = hinting;
FontCacheEntry::SetDefaultHinting(fHinting);
}
gFontManager->Unlock();
}
}
@@ -166,7 +185,7 @@ DesktopSettingsPrivate::_Load()
path = basePath;
path.Append("mouse");
status = file.SetTo(path.Path(), B_READ_ONLY);
if (status == B_OK) {
BMessage settings;
@@ -183,7 +202,7 @@ DesktopSettingsPrivate::_Load()
path = basePath;
path.Append("appearance");
status = file.SetTo(path.Path(), B_READ_ONLY);
if (status == B_OK) {
BMessage settings;
@@ -192,7 +211,7 @@ DesktopSettingsPrivate::_Load()
float fontSize;
if (settings.FindFloat("font size", &fontSize) == B_OK)
fMenuInfo.font_size = fontSize;
const char* fontFamily;
if (settings.FindString("font family", &fontFamily) == B_OK)
strlcpy(fMenuInfo.f_family, fontFamily, B_FONT_FAMILY_LENGTH);
@@ -274,6 +293,9 @@ DesktopSettingsPrivate::Save(uint32 mask)
settings.AddString("fixed style", fFixedFont.Style());
settings.AddFloat("fixed size", fFixedFont.Size());
settings.AddBool("font subpix",fFontSubpixelAntialiasing);
settings.AddBool("hinting",fHinting);
BFile file;
status = file.SetTo(path.Path(), B_CREATE_FILE | B_ERASE_FILE | B_READ_WRITE);
if (status == B_OK) {
@@ -521,6 +543,42 @@ DesktopSettingsPrivate::UIColor(color_which which) const
}
void
DesktopSettingsPrivate::SetFontSubpixelAntialiasing(bool subpix)
{
if (fFontSubpixelAntialiasing != subpix) {
fFontSubpixelAntialiasing = subpix;
FontCacheEntry::SetDefaultRenderType(
(subpix)?glyph_ren_subpix:glyph_ren_native_gray8);
Save(kFontSettings);
}
}
bool
DesktopSettingsPrivate::FontSubpixelAntialiasing() const
{
return fFontSubpixelAntialiasing;
}
void
DesktopSettingsPrivate::SetHinting(bool hinting)
{
if (fHinting != hinting) {
fHinting = hinting;
FontCacheEntry::SetDefaultHinting(hinting);
Save(kFontSettings);
}
}
bool
DesktopSettingsPrivate::Hinting() const
{
return fHinting;
}
// #pragma mark - read access
@@ -613,6 +671,19 @@ DesktopSettings::UIColor(color_which which) const
}
bool
DesktopSettings::FontSubpixelAntialiasing() const
{
return fSettings->FontSubpixelAntialiasing();
}
bool
DesktopSettings::Hinting() const
{
return fSettings->Hinting();
}
// #pragma mark - write access
@@ -691,3 +762,16 @@ LockedDesktopSettings::SetUIColor(color_which which, const rgb_color color)
}
void
LockedDesktopSettings::SetFontSubpixelAntialiasing(bool subpix)
{
fSettings->SetFontSubpixelAntialiasing(subpix);
}
void
LockedDesktopSettings::SetHinting(bool hinting)
{
fSettings->SetHinting(hinting);
}