Skip to content

Commit

Permalink
+ add: more intermediate font weight constants added
Browse files Browse the repository at this point in the history
+ del: remove useless font stretch handling
  • Loading branch information
RaiKoHoff committed Apr 20, 2021
1 parent eb633d8 commit a5dd907
Show file tree
Hide file tree
Showing 10 changed files with 143 additions and 354 deletions.
3 changes: 0 additions & 3 deletions scintilla/include/Scintilla.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,6 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
// >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>>
#define SCI_STYLESETSTRIKE 3501
#define SCI_STYLEGETSTRIKE 3502
#define SCI_STYLESETSTRETCH 3503
#define SCI_STYLEGETSTRETCH 3504
#define SC_FONT_STRETCH_NORMAL 5
// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<<
#define SC_CASE_MIXED 0
#define SC_CASE_UPPER 1
Expand Down
2 changes: 1 addition & 1 deletion scintilla/src/CallTip.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ PRectangle CallTip::CallTipStart(Sci::Position pos, Point pt, int textHeight, co
inCallTipMode = true;
posStartCallTip = pos;
const XYPOSITION deviceHeight = static_cast<XYPOSITION>(surfaceMeasure->DeviceHeightFont(size));
const FontParameters fp(faceName, deviceHeight / SC_FONT_SIZE_MULTIPLIER, SC_WEIGHT_NORMAL, SC_FONT_STRETCH_NORMAL, false, 0, technology, characterSet);
const FontParameters fp(faceName, deviceHeight / SC_FONT_SIZE_MULTIPLIER, SC_WEIGHT_NORMAL, false, 0, technology, characterSet);
font = Font::Allocate(fp);
// Look for multiple lines in the text
// Only support \n here - simply means container must avoid \r!
Expand Down
28 changes: 13 additions & 15 deletions scintilla/src/Editor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -4291,8 +4291,9 @@ void Editor::SetDragPosition(SelectionPosition newPos) {
CaretPolicy(CARET_SLOP | CARET_STRICT | CARET_EVEN, slop_x),
CaretPolicy(CARET_SLOP | CARET_STRICT | CARET_EVEN, slop_y)
};
MovedCaret(newPos, posDrag, true, dragCaretPolicies);
// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<<
MovedCaret(newPos, posDrag, true, dragCaretPolicies);

caret.on = true;
FineTickerCancel(TickReason::caret);
if ((caret.active) && (caret.period > 0) && (newPos.Position() < 0))
Expand Down Expand Up @@ -4918,12 +4919,12 @@ void Editor::ButtonMoveWithModifiers(Point pt, unsigned int, int modifiers) {
DisplayCursor(Window::Cursor::hand);
SetHotSpotRange(&pt);
} else {
// >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>>
if (hoverIndicatorPos != Sci::invalidPosition)
// >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>>
if (modifiers & (SCI_ALT | SCI_CTRL)) { DisplayCursor(Window::Cursor::hand); }
// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<<
else
DisplayCursor(Window::Cursor::text);
// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<<
SetHotSpotRange(nullptr);
}
}
Expand Down Expand Up @@ -5717,16 +5718,12 @@ void Editor::StyleSetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam
case SCI_STYLESETBACK:
vs.styles[wParam].back = ColourDesired(static_cast<int>(lParam));
break;
// >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>>
case SCI_STYLESETBOLD:
vs.styles[wParam].weight = lParam != 0 ? SC_WEIGHT_BOLD : SC_WEIGHT_NORMAL;
break;
case SCI_STYLESETWEIGHT:
vs.styles[wParam].weight = static_cast<int>(lParam);
break;
case SCI_STYLESETSTRETCH:
vs.styles[wParam].stretch = static_cast<int>(lParam);
break;
case SCI_STYLESETITALIC:
vs.styles[wParam].italic = lParam != 0;
break;
Expand All @@ -5747,18 +5744,19 @@ void Editor::StyleSetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam
case SCI_STYLESETUNDERLINE:
vs.styles[wParam].underline = lParam != 0;
break;
// Added strike style, 2020-05-31
// >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>>
// Added strike style, 2020-05-31
case SCI_STYLESETSTRIKE:
vs.styles[wParam].strike = lParam != 0;
break;
// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<<
case SCI_STYLESETCASE:
vs.styles[wParam].caseForce = static_cast<Style::CaseForce>(lParam);
break;
case SCI_STYLESETCHARACTERSET:
vs.styles[wParam].characterSet = static_cast<int>(lParam);
pdoc->SetCaseFolder(nullptr);
break;
// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<<
case SCI_STYLESETVISIBLE:
vs.styles[wParam].visible = lParam != 0;
break;
Expand All @@ -5783,10 +5781,6 @@ sptr_t Editor::StyleGetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lPar
return vs.styles[wParam].weight > SC_WEIGHT_NORMAL;
case SCI_STYLEGETWEIGHT:
return vs.styles[wParam].weight;
// >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>>
case SCI_STYLEGETSTRETCH:
return vs.styles[wParam].stretch;
// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<<
case SCI_STYLEGETITALIC:
return vs.styles[wParam].italic ? 1 : 0;
case SCI_STYLEGETEOLFILLED:
Expand Down Expand Up @@ -6861,7 +6855,9 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return caretSticky;

case SCI_TOGGLECARETSTICKY:
// >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>>
caretSticky = caretSticky ? SC_CARETSTICKY_OFF : SC_CARETSTICKY_ON;
// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<<
break;

case SCI_GETCOLUMN:
Expand Down Expand Up @@ -7194,14 +7190,15 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_STYLESETBACK:
case SCI_STYLESETBOLD:
case SCI_STYLESETWEIGHT:
case SCI_STYLESETSTRETCH:
case SCI_STYLESETITALIC:
case SCI_STYLESETEOLFILLED:
case SCI_STYLESETSIZE:
case SCI_STYLESETSIZEFRACTIONAL:
case SCI_STYLESETFONT:
case SCI_STYLESETUNDERLINE:
// >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>>
case SCI_STYLESETSTRIKE:
// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<<
case SCI_STYLESETCASE:
case SCI_STYLESETCHARACTERSET:
case SCI_STYLESETVISIBLE:
Expand All @@ -7214,14 +7211,15 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_STYLEGETBACK:
case SCI_STYLEGETBOLD:
case SCI_STYLEGETWEIGHT:
case SCI_STYLEGETSTRETCH:
case SCI_STYLEGETITALIC:
case SCI_STYLEGETEOLFILLED:
case SCI_STYLEGETSIZE:
case SCI_STYLEGETSIZEFRACTIONAL:
case SCI_STYLEGETFONT:
case SCI_STYLEGETUNDERLINE:
// >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>>
case SCI_STYLEGETSTRIKE:
// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<<
case SCI_STYLEGETCASE:
case SCI_STYLEGETCHARACTERSET:
case SCI_STYLEGETVISIBLE:
Expand Down
7 changes: 0 additions & 7 deletions scintilla/src/Platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,6 @@ struct FontParameters {
const char *faceName;
XYPOSITION size;
int weight;
// >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>>
int stretch;
// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<<
bool italic;
int extraFontFlag;
int technology;
Expand All @@ -115,7 +112,6 @@ struct FontParameters {
const char *faceName_,
XYPOSITION size_=10,
int weight_=400,
int stretch_=5,
bool italic_=false,
int extraFontFlag_=0,
int technology_=0,
Expand All @@ -125,7 +121,6 @@ struct FontParameters {
faceName(faceName_),
size(size_),
weight(weight_),
stretch(stretch_),
italic(italic_),
extraFontFlag(extraFontFlag_),
technology(technology_),
Expand Down Expand Up @@ -378,8 +373,6 @@ constexpr long LongFromTwoShorts(short a,short b) noexcept {

}



} // namespace

#endif
23 changes: 6 additions & 17 deletions scintilla/src/Style.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ using namespace Scintilla;
bool FontSpecification::operator==(const FontSpecification &other) const noexcept {
return fontName == other.fontName &&
weight == other.weight &&
// >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>>
stretch == other.stretch &&
// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<<
italic == other.italic &&
size == other.size &&
characterSet == other.characterSet &&
Expand All @@ -37,10 +34,6 @@ bool FontSpecification::operator<(const FontSpecification &other) const noexcept
return fontName < other.fontName;
if (weight != other.weight)
return weight < other.weight;
// >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>>
if (stretch != other.stretch)
return stretch < other.stretch;
// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<<
if (italic != other.italic)
return italic == false;
if (size != other.size)
Expand All @@ -65,21 +58,20 @@ void FontMeasurements::ClearMeasurements() noexcept {
sizeZoomed = 2;
}

Style::Style() {
Style::Style() : FontSpecification() {
Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),
Platform::DefaultFontSize() * SC_FONT_SIZE_MULTIPLIER, nullptr, SC_CHARSET_DEFAULT,
SC_WEIGHT_NORMAL, SC_FONT_STRETCH_NORMAL, false, false, false, false, CaseForce::mixed, true, true, false);
SC_WEIGHT_NORMAL, false, false, false, false, CaseForce::mixed, true, true, false);
}

Style::Style(const Style &source) noexcept : FontMeasurements() {
Style::Style(const Style &source) noexcept : FontSpecification(), FontMeasurements() {
Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),
0, nullptr, 0,
SC_WEIGHT_NORMAL, SC_FONT_STRETCH_NORMAL, false, false, false, false, CaseForce::mixed, true, true, false);
SC_WEIGHT_NORMAL, false, false, false, false, CaseForce::mixed, true, true, false);
fore = source.fore;
back = source.back;
characterSet = source.characterSet;
weight = source.weight;
stretch = source.stretch;
italic = source.italic;
size = source.size;
fontName = source.fontName;
Expand All @@ -99,12 +91,11 @@ Style &Style::operator=(const Style &source) noexcept {
return * this;
Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),
0, nullptr, SC_CHARSET_DEFAULT,
SC_WEIGHT_NORMAL, SC_FONT_STRETCH_NORMAL, false, false, false, false, CaseForce::mixed, true, true, false);
SC_WEIGHT_NORMAL, false, false, false, false, CaseForce::mixed, true, true, false);
fore = source.fore;
back = source.back;
characterSet = source.characterSet;
weight = source.weight;
stretch = source.stretch;
italic = source.italic;
size = source.size;
fontName = source.fontName;
Expand All @@ -119,14 +110,13 @@ Style &Style::operator=(const Style &source) noexcept {

void Style::Clear(ColourDesired fore_, ColourDesired back_, int size_,
const char *fontName_, int characterSet_,
int weight_, int stretch_, bool italic_, bool eolFilled_,
int weight_, bool italic_, bool eolFilled_,
bool underline_, bool strike_, CaseForce caseForce_,
bool visible_, bool changeable_, bool hotspot_) noexcept {
fore = fore_;
back = back_;
characterSet = characterSet_;
weight = weight_;
stretch = stretch_;
italic = italic_;
size = size_;
fontName = fontName_;
Expand All @@ -149,7 +139,6 @@ void Style::ClearTo(const Style &source) noexcept {
source.fontName,
source.characterSet,
source.weight,
source.stretch,
source.italic,
source.eolFilled,
source.underline,
Expand Down
8 changes: 1 addition & 7 deletions scintilla/src/Style.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,13 @@ namespace Scintilla {
struct FontSpecification {
const char *fontName;
int weight;
// >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>>
int stretch;
// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<<
bool italic;
int size;
int characterSet;
int extraFontFlag;
FontSpecification() noexcept :
fontName(nullptr),
weight(SC_WEIGHT_NORMAL),
// >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>>
stretch(SC_FONT_STRETCH_NORMAL),
// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<<
italic(false),
size(10 * SC_FONT_SIZE_MULTIPLIER),
characterSet(0),
Expand Down Expand Up @@ -74,8 +68,8 @@ class Style : public FontSpecification, public FontMeasurements {
void Clear(ColourDesired fore_, ColourDesired back_,
int size_,
const char *fontName_, int characterSet_,
int weight_, bool italic_, bool eolFilled_,
// >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>>
int weight_, int stretch_, bool italic_, bool eolFilled_,
bool underline_, bool strike_, CaseForce caseForce_,
// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<<
bool visible_, bool changeable_, bool hotspot_) noexcept;
Expand Down
4 changes: 2 additions & 2 deletions scintilla/src/ViewStyle.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void FontRealised::Realise(Surface &surface, int zoomLevel, int technology, cons
PLATFORM_ASSERT(fs.fontName);
sizeZoomed = GetFontSizeZoomed(fs.size, zoomLevel);
const float deviceHeight = static_cast<float>(surface.DeviceHeightFont(sizeZoomed));
const FontParameters fp(fs.fontName, deviceHeight / SC_FONT_SIZE_MULTIPLIER, fs.weight, fs.stretch, fs.italic, fs.extraFontFlag, technology, fs.characterSet);
const FontParameters fp(fs.fontName, deviceHeight / SC_FONT_SIZE_MULTIPLIER, fs.weight, fs.italic, fs.extraFontFlag, technology, fs.characterSet);
font = Font::Allocate(fp);

ascent = static_cast<unsigned int>(surface.Ascent(font.get()));
Expand Down Expand Up @@ -376,7 +376,7 @@ void ViewStyle::ResetDefaultStyle() {
ColourDesired(0xff,0xff,0xff),
Platform::DefaultFontSize() * SC_FONT_SIZE_MULTIPLIER, fontNames.Save(Platform::DefaultFont()),
SC_CHARSET_DEFAULT,
SC_WEIGHT_NORMAL, SC_FONT_STRETCH_NORMAL, false, false, false, false, Style::CaseForce::mixed, true, true, false);
SC_WEIGHT_NORMAL, false, false, false, false, Style::CaseForce::mixed, true, true, false);
}

void ViewStyle::ClearStyles() {
Expand Down
2 changes: 1 addition & 1 deletion scintilla/win32/PlatWin.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -309,13 +309,13 @@ struct FontDirectWrite : public FontWin {
const std::wstring wsLocale = WStringFromUTF8(fp.localeName);
const FLOAT fHeight = static_cast<FLOAT>(fp.size);
const DWRITE_FONT_STYLE style = fp.italic ? DWRITE_FONT_STYLE_ITALIC : DWRITE_FONT_STYLE_NORMAL;

HRESULT hr = pIDWriteFactory->CreateTextFormat(wsFace.c_str(), nullptr,
static_cast<DWRITE_FONT_WEIGHT>(fp.weight),
style,
DWRITE_FONT_STRETCH_NORMAL, fHeight, wsLocale.c_str(), &pTextFormat);
if (SUCCEEDED(hr)) {
pTextFormat->SetWordWrapping(DWRITE_WORD_WRAPPING_NO_WRAP);

IDWriteTextLayout *pTextLayout = nullptr;
hr = pIDWriteFactory->CreateTextLayout(L"X", 1, pTextFormat,
100.0f, 100.0f, &pTextLayout);
Expand Down
Loading

0 comments on commit a5dd907

Please sign in to comment.