OSDN Git Service

Use proper font for 'View > Use Default Font'
authorGreyMerlin <GreyMerlin7@gmail.com>
Mon, 20 Mar 2017 20:48:58 +0000 (13:48 -0700)
committerGreyMerlin <GreyMerlin7@gmail.com>
Mon, 20 Mar 2017 20:48:58 +0000 (13:48 -0700)
commit522d3840b00c70f04706430d29e1d955868bed22
tree6241a126bb3b0ff490a8b3422d25f391b0ab79ec
parentdc5c054ce881847826aaaeeef8d29bd817fa425f
Use proper font for 'View > Use Default Font'

Symptom:
Use of the 'View > Use Default Font' menu selection always
sets the Directory Tree window to the 12-point Courier New font,
which is not the default font for that window.

Discussion:
WinMerge has an Options::Font structure that maintains an
in-memory copy of 'actual' and 'default' values for the font of
each of the Directory Tree and File View windows.  This structure
is populated at program initialization by procedure SetDefaults()
in file Src/OptionFont.cpp.  The 'default' values are generated by
this procedure, the 'actual' values are loaded from the Registry.

The existing code only queries the system for the default fixed-
size font (via the default MIME codepage) and then uses this font
as the 'default' value for the Options::Font structure for both
Directory and File windows.  This value is typically Courier New.

However, WinMerge actually uses the Menu font as the actual Directory
window font if no other font is marked as 'Specified' in the
Registry.  The default Menu font (for English, since Windows 7) is
Segoe UI.  But this use of Segoe UI is never reflected in the
Options::Font structure, nor in the Registry.

Implementation:
The procedure SetDefaults() is modified to additionally
capture the existing Menu font information for the Directory Tree
window, while continuing to use the codepage MIME font for the
File View window.

A "helper" function is added: InitializeLogFont().  It should only
be used within Src/OptionFont.cpp.  It is documented by comment in
the Src/OptionFont.h file.

The information in the Registry for the Options::Font structure
now always reflects the values of the in-memory structure, and
the values being used by the windows themselves.

Incidental changes:
* Numerous added or modified comments in Src/OptionFont.cpp
* Reordering of all Registry related code to be in the canonical
order implied by the layout of the LOGFONT structure itself.
* Explicitly cast the three boolean values (Italic, Underline,
Strikeout) to boolean to invoke the properly typed Options::Font
procedures (InitOption, SaveOption)
* Remove two unnecessary String() function references relating to
font in files Src/DirView.cpp and Src/MergeEditView.cpp
Src/DirView.cpp
Src/MergeEditView.cpp
Src/OptionsFont.cpp
Src/OptionsFont.h