Use native bold style drawing (+ switchable emulation)

Use native bold font for rendering characters with corresponding
attribute set. Possibility for switching to R5-like bold characters
emulation is also implemented. This one uses uses the left-down shadow
in B_OP_BLEND drawing mode instead of the rigth-down one as previously.
This commit is contained in:
Siarzhuk Zharski 2013-01-09 21:08:15 +01:00
parent 6d30b376e9
commit bbfd23abd5
4 changed files with 19 additions and 11 deletions

View File

@ -81,6 +81,7 @@ static const pref_defaults kTermDefaults[] = {
{ PREF_BLINK_CURSOR, PREF_TRUE },
{ PREF_WARN_ON_EXIT, PREF_TRUE },
{ PREF_CURSOR_STYLE, PREF_BLOCK_CURSOR },
{ PREF_EMULATE_BOLD, PREF_FALSE },
{ NULL, NULL},
};

View File

@ -155,6 +155,7 @@ static const char* const PREF_TEXT_ENCODING = "Text encoding";
static const char* const PREF_BLINK_CURSOR = "Blinking cursor";
static const char* const PREF_WARN_ON_EXIT = "Warn on exit";
static const char* const PREF_CURSOR_STYLE = "Cursor style";
static const char* const PREF_EMULATE_BOLD = "Emulate bold";
static const char* const PREF_TAB_TITLE = "Tab title";
static const char* const PREF_WINDOW_TITLE = "Window title";

View File

@ -296,6 +296,7 @@ TermView::_InitObject(const ShellParameters& shellParameters)
fFontWidth = 0;
fFontHeight = 0;
fFontAscent = 0;
fEmulateBold = false;
fFrameResized = false;
fResizeViewDisableCount = 0;
fLastActivityTime = 0;
@ -722,6 +723,9 @@ TermView::SetTermFont(const BFont *font)
int halfWidth = 0;
fHalfFont = font;
fBoldFont = font;
uint16 face = fBoldFont.Face();
fBoldFont.SetFace(B_BOLD_FACE | (face & ~B_REGULAR_FACE));
fHalfFont.SetSpacing(B_FIXED_SPACING);
@ -754,6 +758,9 @@ TermView::SetTermFont(const BFont *font)
: PrefHandler::Default()->getCursor(PREF_CURSOR_STYLE);
fCursorBlinking = PrefHandler::Default()->getBool(PREF_BLINK_CURSOR);
fEmulateBold = PrefHandler::Default() == NULL ? false
: PrefHandler::Default()->getBool(PREF_EMULATE_BOLD);
_ScrollTo(0, false);
if (fScrollBar != NULL)
fScrollBar->SetSteps(fFontHeight, fFontHeight * fRows);
@ -930,7 +937,7 @@ void
TermView::_DrawLinePart(int32 x1, int32 y1, uint32 attr, char *buf,
int32 width, bool mouse, bool cursor, BView *inView)
{
inView->SetFont(&fHalfFont);
inView->SetFont(IS_BOLD(attr) && !fEmulateBold ? &fBoldFont : &fHalfFont);
// Set pen point
int x2 = x1 + fFontWidth * width;
@ -971,22 +978,19 @@ TermView::_DrawLinePart(int32 x1, int32 y1, uint32 attr, char *buf,
inView->SetHighColor(rgb_back);
inView->FillRect(BRect(x1, y1, x2 - 1, y2 - 1));
inView->SetLowColor(rgb_back);
inView->SetHighColor(rgb_fore);
// Draw character.
inView->MovePenTo(x1, y1 + fFontAscent);
inView->DrawString((char *) buf);
// bold attribute.
if (IS_BOLD(attr)) {
inView->MovePenTo(x1 + 1, y1 + fFontAscent);
inView->SetDrawingMode(B_OP_OVER);
if (IS_BOLD(attr) && fEmulateBold) {
inView->MovePenTo(x1 - 1, y1 + fFontAscent - 1);
inView->DrawString((char *)buf);
inView->SetDrawingMode(B_OP_COPY);
inView->SetDrawingMode(B_OP_BLEND);
}
inView->MovePenTo(x1, y1 + fFontAscent);
inView->DrawString((char *)buf);
inView->SetDrawingMode(B_OP_COPY);
// underline attribute
if (IS_UNDER(attr)) {
inView->MovePenTo(x1, y1 + fFontAscent);

View File

@ -230,10 +230,12 @@ private:
// Font and Width
BFont fHalfFont;
BFont fBoldFont;
int fFontWidth;
int fFontHeight;
int fFontAscent;
struct escapement_delta fEscapement;
bool fEmulateBold;
// frame resized flag.
bool fFrameResized;