* Added a third hinting mode: monospaced fonts only. This is especially helpful

with low resolution devices like the EeePC - small fonts can look pretty bad
  when hinting is turned on, and you still have the advantage of hinting for
  text editors and the terminal.
* Added a ServerFont::Hinting() method (that currently only evaluates the
  global hinting setting).
* Added a TODO comment on why having global settings is not what we aim for.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28837 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2008-12-31 18:44:02 +00:00
parent 16edc24aba
commit e4737a9260
11 changed files with 170 additions and 127 deletions
+8 -8
View File
@@ -221,18 +221,18 @@ get_subpixel_antialiasing(bool* subpix)
void void
set_hinting(bool hinting) set_hinting_mode(uint8 hinting)
{ {
BPrivate::AppServerLink link; BPrivate::AppServerLink link;
link.StartMessage(AS_SET_HINTING); link.StartMessage(AS_SET_HINTING);
link.Attach<bool>(hinting); link.Attach<uint8>(hinting);
link.Flush(); link.Flush();
} }
status_t status_t
get_hinting(bool* hinting) get_hinting_mode(uint8* hinting)
{ {
BPrivate::AppServerLink link; BPrivate::AppServerLink link;
@@ -240,7 +240,7 @@ get_hinting(bool* hinting)
int32 status = B_ERROR; int32 status = B_ERROR;
if (link.FlushWithReply(status) != B_OK || status < B_OK) if (link.FlushWithReply(status) != B_OK || status < B_OK)
return status; return status;
link.Read<bool>(hinting); link.Read<uint8>(hinting);
return B_OK; return B_OK;
} }
@@ -438,7 +438,7 @@ get_click_speed(bigtime_t *speed)
status_t err = _control_input_server_(&command, &reply); status_t err = _control_input_server_(&command, &reply);
if (err != B_OK) if (err != B_OK)
return err; return err;
if (reply.FindInt64("speed", speed) != B_OK) if (reply.FindInt64("speed", speed) != B_OK)
*speed = 500000; *speed = 500000;
@@ -465,7 +465,7 @@ get_mouse_speed(int32 *speed)
status_t err = _control_input_server_(&command, &reply); status_t err = _control_input_server_(&command, &reply);
if (err != B_OK) if (err != B_OK)
return err; return err;
if (reply.FindInt32("speed", speed) != B_OK) if (reply.FindInt32("speed", speed) != B_OK)
*speed = 65536; *speed = 65536;
@@ -662,12 +662,12 @@ get_modifier_key(uint32 modifier, uint32 *key)
command.AddInt32("modifier", modifier); command.AddInt32("modifier", modifier);
_control_input_server_(&command, &reply); _control_input_server_(&command, &reply);
status_t err = reply.FindInt32("key", (int32 *) &rkey); status_t err = reply.FindInt32("key", (int32 *) &rkey);
if (err != B_OK) if (err != B_OK)
return err; return err;
*key = rkey; *key = rkey;
return B_OK; return B_OK;
} }
@@ -29,23 +29,30 @@
//#define DISABLE_HINTING_CONTROL //#define DISABLE_HINTING_CONTROL
// if defined, the hinting menu is disabled (hinting not properly // if defined, the hinting menu is disabled (hinting not properly
// implemented) // implemented)
static const int32 kMsgSetAntialiasing = 'anti'; static const int32 kMsgSetAntialiasing = 'anti';
static const int32 kMsgSetHinting = 'hint'; static const int32 kMsgSetHinting = 'hint';
static const int32 kMsgSetAverageWeight = 'avrg'; static const int32 kMsgSetAverageWeight = 'avrg';
static const char* kSubpixelLabel = "LCD subpixel"; static const char* kSubpixelLabel = "LCD subpixel";
static const char* kGrayscaleLabel = "Grayscale"; static const char* kGrayscaleLabel = "Grayscale";
static const char* kNoHintingLabel = "Off"; static const char* kNoHintingLabel = "Off";
static const char* kMonospacedHintingLabel = "Monospaced Fonts Only";
static const char* kFullHintingLabel = "On"; static const char* kFullHintingLabel = "On";
// #pragma mark - private libbe API // #pragma mark - private libbe API
enum {
HINTING_MODE_OFF = 0,
HINTING_MODE_ON,
HINTING_MODE_MONOSPACED_ONLY
};
extern void set_subpixel_antialiasing(bool subpix); extern void set_subpixel_antialiasing(bool subpix);
extern status_t get_subpixel_antialiasing(bool* subpix); extern status_t get_subpixel_antialiasing(bool* subpix);
extern void set_hinting(bool hinting); extern void set_hinting_mode(uint8 hinting);
extern status_t get_hinting(bool* hinting); extern status_t get_hinting_mode(uint8* hinting);
extern void set_average_weight(unsigned char averageWeight); extern void set_average_weight(unsigned char averageWeight);
extern status_t get_average_weight(unsigned char* averageWeight); extern status_t get_average_weight(unsigned char* averageWeight);
@@ -60,11 +67,11 @@ AntialiasingSettingsView::AntialiasingSettingsView(const char* name)
if (get_subpixel_antialiasing(&fCurrentSubpixelAntialiasing) != B_OK) if (get_subpixel_antialiasing(&fCurrentSubpixelAntialiasing) != B_OK)
fCurrentSubpixelAntialiasing = false; fCurrentSubpixelAntialiasing = false;
fSavedSubpixelAntialiasing = fCurrentSubpixelAntialiasing; fSavedSubpixelAntialiasing = fCurrentSubpixelAntialiasing;
if (get_hinting(&fCurrentHinting) != B_OK) if (get_hinting_mode(&fCurrentHinting) != B_OK)
fCurrentHinting = true; fCurrentHinting = HINTING_MODE_ON;
fSavedHinting = fCurrentHinting; fSavedHinting = fCurrentHinting;
if (get_average_weight(&fCurrentAverageWeight) != B_OK) if (get_average_weight(&fCurrentAverageWeight) != B_OK)
fCurrentAverageWeight = 100; fCurrentAverageWeight = 100;
fSavedAverageWeight = fCurrentAverageWeight; fSavedAverageWeight = fCurrentAverageWeight;
@@ -75,7 +82,7 @@ AntialiasingSettingsView::AntialiasingSettingsView(const char* name)
_BuildAntialiasingMenu(); _BuildAntialiasingMenu();
fAntialiasingMenuField = new BMenuField("antialiasing", fAntialiasingMenuField = new BMenuField("antialiasing",
"Anti-aliasing type:", fAntialiasingMenu, NULL); "Anti-aliasing type:", fAntialiasingMenu, NULL);
// "average weight" in subpixel filtering // "average weight" in subpixel filtering
fAverageWeightControl = new BSlider("averageWeightControl", fAverageWeightControl = new BSlider("averageWeightControl",
"Reduce colored edges filter strength:", "Reduce colored edges filter strength:",
@@ -84,7 +91,7 @@ AntialiasingSettingsView::AntialiasingSettingsView(const char* name)
fAverageWeightControl->SetHashMarks(B_HASH_MARKS_BOTTOM); fAverageWeightControl->SetHashMarks(B_HASH_MARKS_BOTTOM);
fAverageWeightControl->SetHashMarkCount(255 / 15); fAverageWeightControl->SetHashMarkCount(255 / 15);
fAverageWeightControl->SetEnabled(false); fAverageWeightControl->SetEnabled(false);
// hinting menu // hinting menu
_BuildHintingMenu(); _BuildHintingMenu();
fHintingMenuField = new BMenuField("hinting", "Glyph hinting:", fHintingMenuField = new BMenuField("hinting", "Glyph hinting:",
@@ -170,7 +177,7 @@ AntialiasingSettingsView::MessageReceived(BMessage *msg)
case kMsgSetAntialiasing: case kMsgSetAntialiasing:
{ {
bool subpixelAntialiasing; bool subpixelAntialiasing;
if (msg->FindBool("antialiasing", &subpixelAntialiasing) != B_OK if (msg->FindBool("antialiasing", &subpixelAntialiasing) != B_OK
|| subpixelAntialiasing == fCurrentSubpixelAntialiasing) || subpixelAntialiasing == fCurrentSubpixelAntialiasing)
break; break;
fCurrentSubpixelAntialiasing = subpixelAntialiasing; fCurrentSubpixelAntialiasing = subpixelAntialiasing;
@@ -183,13 +190,13 @@ AntialiasingSettingsView::MessageReceived(BMessage *msg)
} }
case kMsgSetHinting: case kMsgSetHinting:
{ {
bool hinting; int8 hinting;
if (msg->FindBool("hinting", &hinting) != B_OK if (msg->FindInt8("hinting", &hinting) != B_OK
|| hinting == fCurrentHinting) || hinting == fCurrentHinting)
break; break;
fCurrentHinting = hinting;
set_hinting(fCurrentHinting); fCurrentHinting = hinting;
set_hinting_mode(fCurrentHinting);
Window()->PostMessage(kMsgUpdate); Window()->PostMessage(kMsgUpdate);
break; break;
@@ -224,7 +231,7 @@ AntialiasingSettingsView::_BuildAntialiasingMenu()
BMenuItem* item = new BMenuItem(kGrayscaleLabel, message); BMenuItem* item = new BMenuItem(kGrayscaleLabel, message);
fAntialiasingMenu->AddItem(item); fAntialiasingMenu->AddItem(item);
message = new BMessage(kMsgSetAntialiasing); message = new BMessage(kMsgSetAntialiasing);
message->AddBool("antialiasing", true); message->AddBool("antialiasing", true);
@@ -240,18 +247,16 @@ AntialiasingSettingsView::_BuildHintingMenu()
fHintingMenu = new BPopUpMenu("Hinting menu"); fHintingMenu = new BPopUpMenu("Hinting menu");
BMessage* message = new BMessage(kMsgSetHinting); BMessage* message = new BMessage(kMsgSetHinting);
message->AddBool("hinting", false); message->AddInt8("hinting", HINTING_MODE_OFF);
fHintingMenu->AddItem(new BMenuItem(kNoHintingLabel, message));
BMenuItem* item = new BMenuItem(kNoHintingLabel, message);
fHintingMenu->AddItem(item);
message = new BMessage(kMsgSetHinting); message = new BMessage(kMsgSetHinting);
message->AddBool("hinting", true); message->AddInt8("hinting", HINTING_MODE_ON);
fHintingMenu->AddItem(new BMenuItem(kFullHintingLabel, message));
item = new BMenuItem(kFullHintingLabel, message); message = new BMessage(kMsgSetHinting);
message->AddInt8("hinting", HINTING_MODE_MONOSPACED_ONLY);
fHintingMenu->AddItem(item); fHintingMenu->AddItem(new BMenuItem(kMonospacedHintingLabel, message));
} }
@@ -270,8 +275,20 @@ AntialiasingSettingsView::_SetCurrentAntialiasing()
void void
AntialiasingSettingsView::_SetCurrentHinting() AntialiasingSettingsView::_SetCurrentHinting()
{ {
BMenuItem *item = fHintingMenu->FindItem( const char* label = NULL;
fCurrentHinting ? kFullHintingLabel : kNoHintingLabel); switch (fCurrentHinting) {
case HINTING_MODE_OFF:
label = kNoHintingLabel;
break;
case HINTING_MODE_ON:
label = kFullHintingLabel;
break;
case HINTING_MODE_MONOSPACED_ONLY:
label = kMonospacedHintingLabel;
break;
}
BMenuItem *item = fHintingMenu->FindItem(label);
if (item != NULL) if (item != NULL)
item->SetMarked(true); item->SetMarked(true);
} }
@@ -300,9 +317,9 @@ AntialiasingSettingsView::IsDefaultable()
bool bool
AntialiasingSettingsView::IsRevertable() AntialiasingSettingsView::IsRevertable()
{ {
return (fCurrentSubpixelAntialiasing != fSavedSubpixelAntialiasing) return fCurrentSubpixelAntialiasing != fSavedSubpixelAntialiasing
|| (fCurrentHinting != fSavedHinting) || fCurrentHinting != fSavedHinting
|| (fCurrentAverageWeight != fSavedAverageWeight); || fCurrentAverageWeight != fSavedAverageWeight;
} }
@@ -317,7 +334,7 @@ AntialiasingSettingsView::Revert()
fCurrentAverageWeight = fSavedAverageWeight; fCurrentAverageWeight = fSavedAverageWeight;
set_subpixel_antialiasing(fCurrentSubpixelAntialiasing); set_subpixel_antialiasing(fCurrentSubpixelAntialiasing);
set_hinting(fCurrentHinting); set_hinting_mode(fCurrentHinting);
set_average_weight(fCurrentAverageWeight); set_average_weight(fCurrentAverageWeight);
_SetCurrentAntialiasing(); _SetCurrentAntialiasing();
@@ -45,8 +45,8 @@ protected:
bool fSavedSubpixelAntialiasing; bool fSavedSubpixelAntialiasing;
bool fCurrentSubpixelAntialiasing; bool fCurrentSubpixelAntialiasing;
bool fSavedHinting; uint8 fSavedHinting;
bool fCurrentHinting; uint8 fCurrentHinting;
unsigned char fSavedAverageWeight; unsigned char fSavedAverageWeight;
unsigned char fCurrentAverageWeight; unsigned char fCurrentAverageWeight;
}; };
+11 -11
View File
@@ -75,7 +75,7 @@ DesktopSettingsPrivate::_SetDefaults()
memcpy(fShared.colors, BPrivate::kDefaultColors, sizeof(rgb_color) * kNumColors); memcpy(fShared.colors, BPrivate::kDefaultColors, sizeof(rgb_color) * kNumColors);
gSubpixelAntialiasing = false; gSubpixelAntialiasing = false;
gDefaultHinting = true; gDefaultHintingMode = HINTING_MODE_ON;
gSubpixelAverageWeight = 120; gSubpixelAverageWeight = 120;
gSubpixelOrderingRGB = true; gSubpixelOrderingRGB = true;
} }
@@ -145,7 +145,7 @@ DesktopSettingsPrivate::_Load()
const char* family; const char* family;
const char* style; const char* style;
float size; float size;
bool hinting; int32 hinting;
if (settings.FindString("plain family", &family) == B_OK if (settings.FindString("plain family", &family) == B_OK
&& settings.FindString("plain style", &style) == B_OK && settings.FindString("plain style", &style) == B_OK
&& settings.FindFloat("plain size", &size) == B_OK) { && settings.FindFloat("plain size", &size) == B_OK) {
@@ -168,8 +168,8 @@ DesktopSettingsPrivate::_Load()
fFixedFont.SetStyle(fontStyle); fFixedFont.SetStyle(fontStyle);
fFixedFont.SetSize(size); fFixedFont.SetSize(size);
} }
if (settings.FindBool("hinting", &hinting) == B_OK) { if (settings.FindInt32("hinting", &hinting) == B_OK) {
gDefaultHinting = hinting; gDefaultHintingMode = hinting;
} }
gFontManager->Unlock(); gFontManager->Unlock();
} }
@@ -321,7 +321,7 @@ DesktopSettingsPrivate::Save(uint32 mask)
settings.AddString("fixed style", fFixedFont.Style()); settings.AddString("fixed style", fFixedFont.Style());
settings.AddFloat("fixed size", fFixedFont.Size()); settings.AddFloat("fixed size", fFixedFont.Size());
settings.AddBool("hinting", gDefaultHinting); settings.AddInt32("hinting", gDefaultHintingMode);
BFile file; BFile file;
status = file.SetTo(path.Path(), B_CREATE_FILE | B_ERASE_FILE status = file.SetTo(path.Path(), B_CREATE_FILE | B_ERASE_FILE
@@ -597,17 +597,17 @@ DesktopSettingsPrivate::SubpixelAntialiasing() const
void void
DesktopSettingsPrivate::SetHinting(bool hinting) DesktopSettingsPrivate::SetHinting(uint8 hinting)
{ {
gDefaultHinting = hinting; gDefaultHintingMode = hinting;
Save(kFontSettings); Save(kFontSettings);
} }
bool uint8
DesktopSettingsPrivate::Hinting() const DesktopSettingsPrivate::Hinting() const
{ {
return gDefaultHinting; return gDefaultHintingMode;
} }
@@ -739,7 +739,7 @@ DesktopSettings::SubpixelAntialiasing() const
} }
bool uint8
DesktopSettings::Hinting() const DesktopSettings::Hinting() const
{ {
return fSettings->Hinting(); return fSettings->Hinting();
@@ -847,7 +847,7 @@ LockedDesktopSettings::SetSubpixelAntialiasing(bool subpix)
void void
LockedDesktopSettings::SetHinting(bool hinting) LockedDesktopSettings::SetHinting(uint8 hinting)
{ {
fSettings->SetHinting(hinting); fSettings->SetHinting(hinting);
} }
+2 -2
View File
@@ -54,7 +54,7 @@ class DesktopSettings {
rgb_color UIColor(color_which which) const; rgb_color UIColor(color_which which) const;
bool SubpixelAntialiasing() const; bool SubpixelAntialiasing() const;
bool Hinting() const; uint8 Hinting() const;
uint8 SubpixelAverageWeight() const; uint8 SubpixelAverageWeight() const;
bool IsSubpixelOrderingRegular() const; bool IsSubpixelOrderingRegular() const;
@@ -81,7 +81,7 @@ class LockedDesktopSettings : public DesktopSettings {
void SetUIColor(color_which which, const rgb_color color); void SetUIColor(color_which which, const rgb_color color);
void SetSubpixelAntialiasing(bool subpix); void SetSubpixelAntialiasing(bool subpix);
void SetHinting(bool hinting); void SetHinting(uint8 hinting);
void SetSubpixelAverageWeight(uint8 averageWeight); void SetSubpixelAverageWeight(uint8 averageWeight);
void SetSubpixelOrderingRegular(bool subpixelOrdering); void SetSubpixelOrderingRegular(bool subpixelOrdering);
+52 -48
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2005-2007, Haiku. * Copyright 2005-2008, Haiku.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -19,69 +19,73 @@ struct server_read_only_memory;
class DesktopSettingsPrivate { class DesktopSettingsPrivate {
public: public:
DesktopSettingsPrivate(server_read_only_memory* shared); DesktopSettingsPrivate(
~DesktopSettingsPrivate(); server_read_only_memory* shared);
~DesktopSettingsPrivate();
status_t Save(uint32 mask = kAllSettings); status_t Save(uint32 mask = kAllSettings);
void SetDefaultPlainFont(const ServerFont& font); void SetDefaultPlainFont(const ServerFont& font);
const ServerFont& DefaultPlainFont() const; const ServerFont& DefaultPlainFont() const;
void SetDefaultBoldFont(const ServerFont& font); void SetDefaultBoldFont(const ServerFont& font);
const ServerFont& DefaultBoldFont() const; const ServerFont& DefaultBoldFont() const;
void SetDefaultFixedFont(const ServerFont& font); void SetDefaultFixedFont(const ServerFont& font);
const ServerFont& DefaultFixedFont() const; const ServerFont& DefaultFixedFont() const;
void SetScrollBarInfo(const scroll_bar_info &info); void SetScrollBarInfo(const scroll_bar_info &info);
const scroll_bar_info& ScrollBarInfo() const; const scroll_bar_info& ScrollBarInfo() const;
void SetMenuInfo(const menu_info &info); void SetMenuInfo(const menu_info &info);
const menu_info& MenuInfo() const; const menu_info& MenuInfo() const;
void SetMouseMode(mode_mouse mode); void SetMouseMode(mode_mouse mode);
mode_mouse MouseMode() const; mode_mouse MouseMode() const;
bool FocusFollowsMouse() const; bool FocusFollowsMouse() const;
void SetShowAllDraggers(bool show); void SetShowAllDraggers(bool show);
bool ShowAllDraggers() const; bool ShowAllDraggers() const;
void SetWorkspacesCount(int32 number); void SetWorkspacesCount(int32 number);
int32 WorkspacesCount() const; int32 WorkspacesCount() const;
void SetWorkspacesMessage(int32 index, BMessage& message); void SetWorkspacesMessage(int32 index,
const BMessage* WorkspacesMessage(int32 index) const; BMessage& message);
const BMessage* WorkspacesMessage(int32 index) const;
void SetUIColor(color_which which, const rgb_color color); void SetUIColor(color_which which,
rgb_color UIColor(color_which which) const; const rgb_color color);
rgb_color UIColor(color_which which) const;
void SetSubpixelAntialiasing(bool subpix); void SetSubpixelAntialiasing(bool subpix);
bool SubpixelAntialiasing() const; bool SubpixelAntialiasing() const;
void SetHinting(bool hinting); void SetHinting(uint8 hinting);
bool Hinting() const; uint8 Hinting() const;
void SetSubpixelAverageWeight(uint8 averageWeight); void SetSubpixelAverageWeight(uint8 averageWeight);
uint8 SubpixelAverageWeight() const; uint8 SubpixelAverageWeight() const;
void SetSubpixelOrderingRegular(bool SubpixelOrdering); void SetSubpixelOrderingRegular(
bool IsSubpixelOrderingRegular() const; bool subpixelOrdering);
bool IsSubpixelOrderingRegular() const;
private: private:
void _SetDefaults(); void _SetDefaults();
status_t _Load(); status_t _Load();
status_t _GetPath(BPath& path); status_t _GetPath(BPath& path);
ServerFont fPlainFont; ServerFont fPlainFont;
ServerFont fBoldFont; ServerFont fBoldFont;
ServerFont fFixedFont; ServerFont fFixedFont;
scroll_bar_info fScrollBarInfo; scroll_bar_info fScrollBarInfo;
menu_info fMenuInfo; menu_info fMenuInfo;
mode_mouse fMouseMode; mode_mouse fMouseMode;
bool fShowAllDraggers; bool fShowAllDraggers;
int32 fWorkspacesCount; int32 fWorkspacesCount;
BMessage fWorkspaceMessages[kMaxWorkspaces]; BMessage fWorkspaceMessages[kMaxWorkspaces];
server_read_only_memory& fShared; server_read_only_memory& fShared;
}; };
#endif /* DESKTOP_SETTINGS_PRIVATE_H */ #endif /* DESKTOP_SETTINGS_PRIVATE_H */
+3 -3
View File
@@ -123,7 +123,7 @@ FontCacheEntry::Init(const ServerFont& font)
// TODO: encoding from font // TODO: encoding from font
FT_Encoding charMap = FT_ENCODING_NONE; FT_Encoding charMap = FT_ENCODING_NONE;
bool hinting = gDefaultHinting; // TODO: font.Hinting(); bool hinting = font.Hinting();
if (!fEngine.Init(font.Path(), 0, font.Size(), charMap, if (!fEngine.Init(font.Path(), 0, font.Size(), charMap,
renderingType, hinting)) { renderingType, hinting)) {
@@ -220,7 +220,7 @@ FontCacheEntry::GenerateSignature(char* signature, const ServerFont& font)
// TODO: read more of these from the font // TODO: read more of these from the font
FT_Encoding charMap = FT_ENCODING_NONE; FT_Encoding charMap = FT_ENCODING_NONE;
bool hinting = gDefaultHinting; // TODO: font.Hinting(); bool hinting = font.Hinting();
uint8 averageWeight = gSubpixelAverageWeight; uint8 averageWeight = gSubpixelAverageWeight;
sprintf(signature, "%ld,%u,%d,%d,%.1f,%d,%d", sprintf(signature, "%ld,%u,%d,%d,%.1f,%d,%d",
@@ -255,7 +255,7 @@ FontCacheEntry::_RenderTypeFor(const ServerFont& font)
|| font.FalseBoldWidth() != 0.0 || font.FalseBoldWidth() != 0.0
|| font.Flags() & B_DISABLE_ANTIALIASING || font.Flags() & B_DISABLE_ANTIALIASING
|| font.Size() > 30 || font.Size() > 30
|| !gDefaultHinting) { || !font.Hinting()) {
renderingType = glyph_ren_outline; renderingType = glyph_ren_outline;
} }
+10 -8
View File
@@ -2192,14 +2192,14 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
} else } else
status = B_OK; status = B_OK;
} else { } else {
// this is perhaps not ideal - it assumes that if the // this is perhaps not ideal - it assumes that if the
// workspace is not the active one, then pull the // workspace is not the active one, then pull the
// configuration from active and store it to the specified // configuration from active and store it to the specified
// workspace. This is safer since it's assumed that the // workspace. This is safer since it's assumed that the
// active workspace has a display mode that's usable, // active workspace has a display mode that's usable,
// but at the same time the API implies that you can set // but at the same time the API implies that you can set
// a non-visible workspace to whatever mode you like // a non-visible workspace to whatever mode you like
// TODO: decide what to do here. // TODO: decide what to do here.
if (makeDefault) if (makeDefault)
fDesktop->StoreConfiguration(workspace); fDesktop->StoreConfiguration(workspace);
} }
@@ -2585,12 +2585,14 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
case AS_SET_HINTING: case AS_SET_HINTING:
{ {
bool hinting; uint8 hinting;
if (link.Read<bool>(&hinting) == B_OK) { if (link.Read<uint8>(&hinting) == B_OK && hinting < 3) {
LockedDesktopSettings settings(fDesktop); LockedDesktopSettings settings(fDesktop);
settings.SetHinting(hinting); if (hinting != settings.Hinting()) {
settings.SetHinting(hinting);
fDesktop->Redraw();
}
} }
fDesktop->Redraw();
break; break;
} }
@@ -2598,7 +2600,7 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
{ {
DesktopSettings settings(fDesktop); DesktopSettings settings(fDesktop);
fLink.StartMessage(B_OK); fLink.StartMessage(B_OK);
fLink.Attach<bool>(settings.Hinting()); fLink.Attach<uint8>(settings.Hinting());
fLink.Flush(); fLink.Flush();
break; break;
} }
+18 -4
View File
@@ -16,6 +16,7 @@
#include <Rect.h> #include <Rect.h>
#include "FontFamily.h" #include "FontFamily.h"
#include "GlobalSubpixelSettings.h"
#include "Transformable.h" #include "Transformable.h"
class BShape; class BShape;
@@ -109,7 +110,7 @@ class ServerFont {
{ return fStyle->GlyphCount(); } { return fStyle->GlyphCount(); }
uint16 CharMapCount() const uint16 CharMapCount() const
{ return fStyle->CharMapCount(); } { return fStyle->CharMapCount(); }
inline bool Hinting() const;
FT_Face GetTransformedFace(bool rotate, FT_Face GetTransformedFace(bool rotate,
bool shear) const; bool shear) const;
@@ -118,9 +119,9 @@ class ServerFont {
status_t GetGlyphShapes(const char charArray[], status_t GetGlyphShapes(const char charArray[],
int32 numChars, BShape *shapeArray[]) const; int32 numChars, BShape *shapeArray[]) const;
status_t GetHasGlyphs(const char charArray[], status_t GetHasGlyphs(const char charArray[],
int32 numBytes, bool hasArray[]) const; int32 numBytes, bool hasArray[]) const;
status_t GetEdges(const char charArray[], int32 numBytes, status_t GetEdges(const char charArray[], int32 numBytes,
edge_info edgeArray[]) const; edge_info edgeArray[]) const;
@@ -156,7 +157,7 @@ class ServerFont {
// FT_Face GetFTFace() const // FT_Face GetFTFace() const
// { return fStyle->FreeTypeFace(); }; // { return fStyle->FreeTypeFace(); };
BRect BoundingBox(); BRect BoundingBox();
void GetHeight(font_height& height) const; void GetHeight(font_height& height) const;
@@ -182,4 +183,17 @@ protected:
uint32 fEncoding; uint32 fEncoding;
}; };
inline bool ServerFont::Hinting() const
{
switch (gDefaultHintingMode) {
case HINTING_MODE_OFF:
return false;
default:
case HINTING_MODE_ON:
return true;
case HINTING_MODE_MONOSPACED_ONLY:
return IsFixedWidth();
}
}
#endif /* SERVER_FONT_H */ #endif /* SERVER_FONT_H */
@@ -9,6 +9,6 @@
// NOTE: all these are initialized in DesktopSettings.cpp // NOTE: all these are initialized in DesktopSettings.cpp
bool gSubpixelAntialiasing; bool gSubpixelAntialiasing;
bool gDefaultHinting; uint8 gDefaultHintingMode;
unsigned char gSubpixelAverageWeight; uint8 gSubpixelAverageWeight;
bool gSubpixelOrderingRGB; bool gSubpixelOrderingRGB;
@@ -1,22 +1,30 @@
/* /*
* Copyright 2008, Andrej Spielmann <andrej.spielmann@seh.ox.ac.uk>. * Copyright 2008, Andrej Spielmann <andrej.spielmann@seh.ox.ac.uk>.
* All rights reserved. Distributed under the terms of the MIT License. * All rights reserved. Distributed under the terms of the MIT License.
*
* Global settings of the app server regarding antialiasing and font hinting
*
*/ */
#ifndef GLOBAL_SUBPIXEL_SETTINGS_H #ifndef GLOBAL_SUBPIXEL_SETTINGS_H
#define GLOBAL_SUBPIXEL_SETTINGS_H #define GLOBAL_SUBPIXEL_SETTINGS_H
#include <SupportDefs.h>
// TODO: these global settings need to be removed - once we have more than one
// user, we also must support more than one setting. That's why there is a
// DesktopSettings class in the first place...
enum {
HINTING_MODE_OFF = 0,
HINTING_MODE_ON,
HINTING_MODE_MONOSPACED_ONLY
};
#define AVERAGE_BASED_SUBPIXEL_FILTERING #define AVERAGE_BASED_SUBPIXEL_FILTERING
extern bool gSubpixelAntialiasing; extern bool gSubpixelAntialiasing;
extern bool gDefaultHinting; extern uint8 gDefaultHintingMode;
// The weight with which the average of the subpixels is applied to counter // The weight with which the average of the subpixels is applied to counter
// color fringes (0 = full sharpness ... 255 = grayscale anti-aliasing) // color fringes (0 = full sharpness ... 255 = grayscale anti-aliasing)
extern unsigned char gSubpixelAverageWeight; extern uint8 gSubpixelAverageWeight;
// There are two types of LCD displays in general - the more common have // There are two types of LCD displays in general - the more common have
// sub - pixels physically ordered as RGB within a pixel, but some are BGR. // sub - pixels physically ordered as RGB within a pixel, but some are BGR.
@@ -25,5 +33,3 @@ extern unsigned char gSubpixelAverageWeight;
extern bool gSubpixelOrderingRGB; extern bool gSubpixelOrderingRGB;
#endif // GLOBAL_SUBPIXEL_SETTINGS_H #endif // GLOBAL_SUBPIXEL_SETTINGS_H