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:
@@ -81,6 +81,7 @@ static const pref_defaults kTermDefaults[] = {
|
|||||||
{ PREF_BLINK_CURSOR, PREF_TRUE },
|
{ PREF_BLINK_CURSOR, PREF_TRUE },
|
||||||
{ PREF_WARN_ON_EXIT, PREF_TRUE },
|
{ PREF_WARN_ON_EXIT, PREF_TRUE },
|
||||||
{ PREF_CURSOR_STYLE, PREF_BLOCK_CURSOR },
|
{ PREF_CURSOR_STYLE, PREF_BLOCK_CURSOR },
|
||||||
|
{ PREF_EMULATE_BOLD, PREF_FALSE },
|
||||||
|
|
||||||
{ NULL, NULL},
|
{ NULL, NULL},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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_BLINK_CURSOR = "Blinking cursor";
|
||||||
static const char* const PREF_WARN_ON_EXIT = "Warn on exit";
|
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_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_TAB_TITLE = "Tab title";
|
||||||
static const char* const PREF_WINDOW_TITLE = "Window title";
|
static const char* const PREF_WINDOW_TITLE = "Window title";
|
||||||
|
|||||||
@@ -296,6 +296,7 @@ TermView::_InitObject(const ShellParameters& shellParameters)
|
|||||||
fFontWidth = 0;
|
fFontWidth = 0;
|
||||||
fFontHeight = 0;
|
fFontHeight = 0;
|
||||||
fFontAscent = 0;
|
fFontAscent = 0;
|
||||||
|
fEmulateBold = false;
|
||||||
fFrameResized = false;
|
fFrameResized = false;
|
||||||
fResizeViewDisableCount = 0;
|
fResizeViewDisableCount = 0;
|
||||||
fLastActivityTime = 0;
|
fLastActivityTime = 0;
|
||||||
@@ -722,6 +723,9 @@ TermView::SetTermFont(const BFont *font)
|
|||||||
int halfWidth = 0;
|
int halfWidth = 0;
|
||||||
|
|
||||||
fHalfFont = font;
|
fHalfFont = font;
|
||||||
|
fBoldFont = font;
|
||||||
|
uint16 face = fBoldFont.Face();
|
||||||
|
fBoldFont.SetFace(B_BOLD_FACE | (face & ~B_REGULAR_FACE));
|
||||||
|
|
||||||
fHalfFont.SetSpacing(B_FIXED_SPACING);
|
fHalfFont.SetSpacing(B_FIXED_SPACING);
|
||||||
|
|
||||||
@@ -754,6 +758,9 @@ TermView::SetTermFont(const BFont *font)
|
|||||||
: PrefHandler::Default()->getCursor(PREF_CURSOR_STYLE);
|
: PrefHandler::Default()->getCursor(PREF_CURSOR_STYLE);
|
||||||
fCursorBlinking = PrefHandler::Default()->getBool(PREF_BLINK_CURSOR);
|
fCursorBlinking = PrefHandler::Default()->getBool(PREF_BLINK_CURSOR);
|
||||||
|
|
||||||
|
fEmulateBold = PrefHandler::Default() == NULL ? false
|
||||||
|
: PrefHandler::Default()->getBool(PREF_EMULATE_BOLD);
|
||||||
|
|
||||||
_ScrollTo(0, false);
|
_ScrollTo(0, false);
|
||||||
if (fScrollBar != NULL)
|
if (fScrollBar != NULL)
|
||||||
fScrollBar->SetSteps(fFontHeight, fFontHeight * fRows);
|
fScrollBar->SetSteps(fFontHeight, fFontHeight * fRows);
|
||||||
@@ -930,7 +937,7 @@ void
|
|||||||
TermView::_DrawLinePart(int32 x1, int32 y1, uint32 attr, char *buf,
|
TermView::_DrawLinePart(int32 x1, int32 y1, uint32 attr, char *buf,
|
||||||
int32 width, bool mouse, bool cursor, BView *inView)
|
int32 width, bool mouse, bool cursor, BView *inView)
|
||||||
{
|
{
|
||||||
inView->SetFont(&fHalfFont);
|
inView->SetFont(IS_BOLD(attr) && !fEmulateBold ? &fBoldFont : &fHalfFont);
|
||||||
|
|
||||||
// Set pen point
|
// Set pen point
|
||||||
int x2 = x1 + fFontWidth * width;
|
int x2 = x1 + fFontWidth * width;
|
||||||
@@ -971,22 +978,19 @@ TermView::_DrawLinePart(int32 x1, int32 y1, uint32 attr, char *buf,
|
|||||||
inView->SetHighColor(rgb_back);
|
inView->SetHighColor(rgb_back);
|
||||||
inView->FillRect(BRect(x1, y1, x2 - 1, y2 - 1));
|
inView->FillRect(BRect(x1, y1, x2 - 1, y2 - 1));
|
||||||
inView->SetLowColor(rgb_back);
|
inView->SetLowColor(rgb_back);
|
||||||
|
|
||||||
inView->SetHighColor(rgb_fore);
|
inView->SetHighColor(rgb_fore);
|
||||||
|
|
||||||
// Draw character.
|
// Draw character.
|
||||||
inView->MovePenTo(x1, y1 + fFontAscent);
|
if (IS_BOLD(attr) && fEmulateBold) {
|
||||||
inView->DrawString((char *) buf);
|
inView->MovePenTo(x1 - 1, y1 + fFontAscent - 1);
|
||||||
|
|
||||||
// bold attribute.
|
|
||||||
if (IS_BOLD(attr)) {
|
|
||||||
inView->MovePenTo(x1 + 1, y1 + fFontAscent);
|
|
||||||
|
|
||||||
inView->SetDrawingMode(B_OP_OVER);
|
|
||||||
inView->DrawString((char *)buf);
|
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
|
// underline attribute
|
||||||
if (IS_UNDER(attr)) {
|
if (IS_UNDER(attr)) {
|
||||||
inView->MovePenTo(x1, y1 + fFontAscent);
|
inView->MovePenTo(x1, y1 + fFontAscent);
|
||||||
|
|||||||
@@ -230,10 +230,12 @@ private:
|
|||||||
|
|
||||||
// Font and Width
|
// Font and Width
|
||||||
BFont fHalfFont;
|
BFont fHalfFont;
|
||||||
|
BFont fBoldFont;
|
||||||
int fFontWidth;
|
int fFontWidth;
|
||||||
int fFontHeight;
|
int fFontHeight;
|
||||||
int fFontAscent;
|
int fFontAscent;
|
||||||
struct escapement_delta fEscapement;
|
struct escapement_delta fEscapement;
|
||||||
|
bool fEmulateBold;
|
||||||
|
|
||||||
// frame resized flag.
|
// frame resized flag.
|
||||||
bool fFrameResized;
|
bool fFrameResized;
|
||||||
|
|||||||
Reference in New Issue
Block a user