mirror of
https://github.com/rizonesoft/Notepad3.git
synced 2026-06-14 21:09:05 +08:00
+ fix: encoding detection failure fallback: current code-page or default encoding on new (if fallback forced)
+ chg: to force UTF-8 as preffered encoding: activate encoding detection failure fallback for default encoding + chg: allow Fixedsys font for GDI rendering + chg: for new "Text File" scheme: use regular Segoe UI font
This commit is contained in:
parent
e254cef242
commit
7d6bfcc3a9
@ -1 +1 @@
|
||||
2382
|
||||
2383
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
<assemblyIdentity
|
||||
name="Notepad3"
|
||||
processorArchitecture="*"
|
||||
version="5.19.702.2382"
|
||||
version="5.19.704.2383"
|
||||
type="win32"
|
||||
/>
|
||||
<description>Notepad3 Oniguruma</description>
|
||||
|
||||
@ -49,8 +49,8 @@ class ChooseFontDialog
|
||||
{
|
||||
public:
|
||||
|
||||
explicit ChooseFontDialog(HWND hParent, const WCHAR* localeName, DPI_T dpi, LPCHOOSEFONT lpCFGDI);
|
||||
virtual ~ChooseFontDialog();
|
||||
ChooseFontDialog(HWND hParent, const WCHAR* localeName, DPI_T dpi, LPCHOOSEFONT lpCFGDI);
|
||||
~ChooseFontDialog();
|
||||
ChooseFontDialog() = delete;
|
||||
|
||||
HRESULT GetTextFormat(IDWriteTextFormat** textFormat);
|
||||
@ -131,7 +131,7 @@ ChooseFontDialog::~ChooseFontDialog()
|
||||
|
||||
/******************************************************************
|
||||
* *
|
||||
* ChooseFontDialog::ChooseFontDialog *
|
||||
* ChooseFontDialog::GetTextFormat *
|
||||
* *
|
||||
* Create and display the dialog initialized to default attributes *
|
||||
* *
|
||||
@ -696,7 +696,7 @@ BOOL ChooseFontDialog::OnInitDialog(HWND dialog, HWND hwndFocus, LPARAM lParam)
|
||||
}
|
||||
|
||||
// Select the current size
|
||||
FLOAT fCurFontSize = static_cast<FLOAT>(round(m_currentTextFormat->GetFontSize() * 10.0f) / 10.0f);
|
||||
FLOAT fCurFontSize = static_cast<FLOAT>(roundf(m_currentTextFormat->GetFontSize() * 10.0f) / 10.0f);
|
||||
StringCchPrintf(sizeName, _ARRAYSIZE(sizeName), L"%.3G", fCurFontSize);
|
||||
|
||||
SetWindowText(hwndSizes, sizeName);
|
||||
@ -791,7 +791,7 @@ static void SetChosenFontFromTextFormat(
|
||||
|
||||
StringCchCopy(lpCF->lpLogFont->lfFaceName, LF_FACESIZE, fontFamilyName);
|
||||
lpCF->lpLogFont->lfHeight = -MulDiv(static_cast<int>(lround(pointSize)), GetDeviceCaps(lpCF->hDC, LOGPIXELSY), 72);
|
||||
lpCF->iPointSize = static_cast<INT>(lround(pointSize * 10.0f));
|
||||
lpCF->iPointSize = static_cast<INT>(lroundf(pointSize * 10.0f));
|
||||
lpCF->lpLogFont->lfWeight = static_cast<LONG>(fontWeight);
|
||||
lpCF->lpLogFont->lfItalic = static_cast<BYTE>((((fontStyle == DWRITE_FONT_STYLE_ITALIC) ||
|
||||
(fontStyle == DWRITE_FONT_STYLE_OBLIQUE)) ? TRUE : FALSE));
|
||||
|
||||
@ -829,7 +829,7 @@ void LoadSettings()
|
||||
cpi_enc_t const iPrefEncIniSetting = (cpi_enc_t)Encoding_MapIniSetting(false, (int)CPI_UTF8);
|
||||
GET_ENC_VALUE_FROM_INISECTION(DefaultEncoding, iPrefEncIniSetting, CPI_NONE, INT_MAX);
|
||||
Settings.DefaultEncoding = ((Settings.DefaultEncoding == CPI_NONE) ? CPI_UTF8 : (cpi_enc_t)Encoding_MapIniSetting(true, (int)Settings.DefaultEncoding));
|
||||
GET_BOOL_VALUE_FROM_INISECTION(UseDefaultForFileEncoding, false);
|
||||
GET_BOOL_VALUE_FROM_INISECTION(UseDefaultForFileEncoding, true);
|
||||
GET_BOOL_VALUE_FROM_INISECTION(LoadASCIIasUTF8, true);
|
||||
GET_BOOL_VALUE_FROM_INISECTION(UseReliableCEDonly, true);
|
||||
GET_BOOL_VALUE_FROM_INISECTION(LoadNFOasOEM, true);
|
||||
|
||||
26
src/Edit.c
26
src/Edit.c
@ -1014,7 +1014,8 @@ bool EditLoadFile(
|
||||
// Encoding Detection
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
cpi_enc_t iPreferredEncoding = Settings.LoadASCIIasUTF8 ? CPI_UTF8 : CPI_ANSI_DEFAULT;
|
||||
// assume current code-page or default encoding (if forced)
|
||||
cpi_enc_t const iAnalyzeFallback = Settings.UseDefaultForFileEncoding ? Settings.DefaultEncoding : CPI_ANSI_DEFAULT;
|
||||
|
||||
// --- 1st check for force encodings ---
|
||||
LPCWSTR lpszExt = PathFindExtension(pszFile);
|
||||
@ -1033,7 +1034,7 @@ bool EditLoadFile(
|
||||
|
||||
if (Encoding_IsNONE(iForcedEncoding) || bForceEncDetection)
|
||||
{
|
||||
iAnalyzedEncoding = Encoding_AnalyzeText(lpData, cbNbytes4Analysis, &confidence, iPreferredEncoding);
|
||||
iAnalyzedEncoding = Encoding_AnalyzeText(lpData, cbNbytes4Analysis, &confidence, iAnalyzeFallback);
|
||||
|
||||
if (Flags.bDevDebugMode) {
|
||||
#if 1
|
||||
@ -1048,7 +1049,6 @@ bool EditLoadFile(
|
||||
#endif
|
||||
}
|
||||
}
|
||||
bool const bIsReliable = (confidence >= Settings2.AnalyzeReliableConfidenceLevel);
|
||||
|
||||
// ------------------------------------------------------
|
||||
|
||||
@ -1056,18 +1056,29 @@ bool EditLoadFile(
|
||||
{
|
||||
bool const bIsUnicode = Encoding_IsUTF8(iAnalyzedEncoding) || Encoding_IsUNICODE(iAnalyzedEncoding);
|
||||
|
||||
if (iAnalyzedEncoding == CPI_ASCII_7BIT) {
|
||||
iAnalyzedEncoding = Settings.LoadASCIIasUTF8 ? CPI_UTF8 : iPreferredEncoding; // stay on preferred
|
||||
if (iAnalyzedEncoding == CPI_NONE)
|
||||
{
|
||||
iAnalyzedEncoding = iAnalyzeFallback;
|
||||
confidence = Settings2.AnalyzeReliableConfidenceLevel;
|
||||
}
|
||||
else if (iAnalyzedEncoding == CPI_ASCII_7BIT) {
|
||||
iAnalyzedEncoding = Settings.LoadASCIIasUTF8 ? CPI_UTF8 : CPI_ANSI_DEFAULT;
|
||||
confidence = Settings2.AnalyzeReliableConfidenceLevel;
|
||||
}
|
||||
else {
|
||||
if ((bSkipUTFDetection && bIsUnicode) || (bSkipANSICPDetection && !bIsUnicode)) {
|
||||
iAnalyzedEncoding = CPI_NONE;
|
||||
confidence = 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool const bIsReliable = (confidence >= Settings2.AnalyzeReliableConfidenceLevel);
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
if (bForceEncDetection && !Encoding_IsNONE(iAnalyzedEncoding)) {
|
||||
if (bForceEncDetection && !Encoding_IsNONE(iAnalyzedEncoding))
|
||||
{
|
||||
iForcedEncoding = iAnalyzedEncoding; // no bIsReliable check (forced unreliable detection)
|
||||
}
|
||||
// --------------------------------------------------------------------------
|
||||
@ -1080,7 +1091,8 @@ bool EditLoadFile(
|
||||
// choose best encoding guess
|
||||
cpi_enc_t const iFileEncWeak = Encoding_SrcWeak(CPI_GET);
|
||||
|
||||
// remap Preferred Encoding
|
||||
// set Preferred Encoding
|
||||
cpi_enc_t iPreferredEncoding = Settings.LoadASCIIasUTF8 ? CPI_UTF8 : CPI_ANSI_DEFAULT;
|
||||
|
||||
if (bIsForced) {
|
||||
iPreferredEncoding = iForcedEncoding;
|
||||
|
||||
@ -20,7 +20,7 @@ SCLEX_NULL, IDS_LEX_DEF_TXT, L"Default Text", L"", L"",
|
||||
/* 10 */ { {_STYLE_GETSTYLEID(STY_LONG_LN_MRK)}, IDS_LEX_STD_LONG_LN, L"Long Line Marker (Colors)", L"fore:#FFC000", L"" },
|
||||
/* 11 */ { {_STYLE_GETSTYLEID(STY_X_LN_SPACE)}, IDS_LEX_STD_X_SPC, L"Extra Line Spacing (Size)", L"size:2", L"" },
|
||||
/* 12 */ { {_STYLE_GETSTYLEID(STY_BOOK_MARK)}, IDS_LEX_STD_BKMRK, L"Bookmarks and Folding (Colors, Size)", L"size:+2; fore:#000000; back:#00DC00; alpha:100", L"" },
|
||||
/* 13 */ { {_STYLE_GETSTYLEID(STY_MARK_OCC)}, IDS_LEX_STR_63262, L"Mark Occurrences (Indicator)", L"alpha:60; alpha2:60; indic_roundbox", L"" },
|
||||
/* 13 */ { {_STYLE_GETSTYLEID(STY_MARK_OCC)}, IDS_LEX_STR_63262, L"Mark Occurrences (Indicator)", L"fore:#3399FF; alpha:60; alpha2:60; indic_roundbox", L"" },
|
||||
/* 14 */ { {_STYLE_GETSTYLEID(STY_URL_HOTSPOT)}, IDS_LEX_STR_63264, L"Hyperlink Hotspots", L"fore:#0000FF; back:#0000BF; indic_plain", L"" },
|
||||
/* 15 */ { {_STYLE_GETSTYLEID(STY_MULTI_EDIT)}, IDS_LEX_STR_63354, L"Multi Edit Indicator", L"fore:#FFA000; alpha:60; alpha2:180; indic_roundbox", L"" },
|
||||
/* 16 */ { {_STYLE_GETSTYLEID(STY_IME_COLOR)}, IDS_LEX_STR_63352, L"Inline-IME Color", L"fore:#00AA00", L"" },
|
||||
@ -53,7 +53,7 @@ SCLEX_NULL, IDS_LEX_STR_63266, L"2nd Default Text", L"", L"",
|
||||
EDITLEXER lexTEXT = {
|
||||
SCLEX_NULL, IDS_LEX_TEXT_FILES, L"Text Files", L"txt; text; tmp; log; asc; doc; wtx", L"",
|
||||
&KeyWords_NULL,{
|
||||
{ {STYLE_DEFAULT}, IDS_LEX_STR_63126, L"Default", L"font:Segoe UI Semibold; size:11; semibold; smoothing:cleartype", L"" },
|
||||
{ {STYLE_DEFAULT}, IDS_LEX_STR_63126, L"Default", L"font:Segoe UI; size:11; smoothing:cleartype", L"" },
|
||||
{ {STYLE_LINENUMBER}, IDS_LEX_STD_MARGIN, L"Margins and Line Numbers", L"font:Lucida Console; size:-2", L"" },
|
||||
{ {SCI_SETEXTRAASCENT + SCI_SETEXTRADESCENT}, IDS_LEX_STD_X_SPC, L"Extra Line Spacing (Size)", L"size:-1", L"" },
|
||||
EDITLEXER_SENTINEL } };
|
||||
|
||||
@ -3013,7 +3013,7 @@ bool Style_SelectFont(HWND hwnd,LPWSTR lpszStyle,int cchStyle, LPCWSTR sLexerNam
|
||||
cf.lCustData = (LPARAM)FontSelTitle;
|
||||
//cf.Flags = CF_INITTOLOGFONTSTRUCT /*| CF_EFFECTS | CF_NOSCRIPTSEL*/ | CF_SCREENFONTS | CF_FORCEFONTEXIST | CF_ENABLEHOOK;
|
||||
//cf.Flags = CF_INITTOLOGFONTSTRUCT | CF_USESTYLE | CF_SCALABLEONLY | CF_FORCEFONTEXIST | CF_ENABLEHOOK;
|
||||
cf.Flags = CF_INITTOLOGFONTSTRUCT | CF_SCALABLEONLY | CF_FORCEFONTEXIST | CF_ENABLEHOOK;
|
||||
cf.Flags = CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS | CF_INACTIVEFONTS | CF_FORCEFONTEXIST | CF_ENABLEHOOK;
|
||||
|
||||
if (bGlobalDefaultStyle) {
|
||||
if (bRelFontSize)
|
||||
|
||||
@ -68,7 +68,7 @@
|
||||
#if defined(_MSC_VER)
|
||||
#if (_MSC_VER >= 1920)
|
||||
#if(_MSC_FULL_VER >= 192127702)
|
||||
#define VER_CPL MS Visual C++ 2019 v16.1.(0-4)
|
||||
#define VER_CPL MS Visual C++ 2019 v16.1.(0-5)
|
||||
#elif(_MSC_FULL_VER >= 192027508)
|
||||
#define VER_CPL MS Visual C++ 2019 v16.0.(0-4)
|
||||
#elif(_MSC_FULL_VER >= 192027027)
|
||||
|
||||
@ -7,8 +7,8 @@
|
||||
#define SAPPNAME "Notepad3"
|
||||
#define VERSION_MAJOR 5
|
||||
#define VERSION_MINOR 19
|
||||
#define VERSION_REV 702
|
||||
#define VERSION_BUILD 2382
|
||||
#define VERSION_REV 704
|
||||
#define VERSION_BUILD 2383
|
||||
#define SCINTILLA_VER 417
|
||||
#define ONIGURUMA_REGEX_VER 6.9.2
|
||||
#define VERSION_PATCH Oniguruma
|
||||
|
||||
Loading…
Reference in New Issue
Block a user