[bugs:#2080] D2D bug with font family name and font face name
Status: open
Group: Bug
Created: Fri Feb 15, 2019 01:42 PM UTC by Zufu Liu
Last Updated: Fri Feb 15, 2019 01:42 PM UTC
Owner: Neil Hodgson
Test "Source Code Pro Semibold" (font weight: 600, font family: "Source Code Pro").
The result of main text and auto-completion box (Another: rendered with another font, Same: rendered with same font).
SCI_STYLESETFONT | GDI Text | GDI Box | D2D Text | D2D Box |
---|---|---|---|---|
Source Code Pro | Another | Another | Same | Another |
Source Code Pro Semibold | Same | Same | Another | Same |
CreateTextFormat() (FontCached::FontCached(const FontParameters &fp)
) need font family name,
LOGFONT (FormatAndMetrics::HFont()
) need font face name but font family name is used (pTextFormat->GetFontFamilyName()
).
Sent from sourceforge.net because scintill...@googlegroups.com is subscribed to https://sourceforge.net/p/scintilla/bugs/
To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/scintilla/admin/bugs/options. Or, if this is a mailing list, you can unsubscribe from the mailing list.
maybe HFONT hfont;
in FormatAndMetrics can be changed to LOGFONTW *plf
, which pointer to the LOGFONTW lf;
field (always initialized) in FontCached.
FormatAndMetrics::HFont() then can changed to
return ::CreateFontIndirectW(plf);
The font family name for pTextFormat can be got through
IDWriteGdiInterop::CreateFontFromLOGFONT().
Correct: adding LOGFONTW *plf
field. hfont is ued by SurfaceGDI.
[bugs:#2080] D2D bug with font family name and font face name
Status: open
Group: Bug
Created: Fri Feb 15, 2019 01:42 PM UTC by Zufu Liu
Last Updated: Fri Feb 15, 2019 03:36 PM UTC
Owner: Neil Hodgson
FontCached was developed for Windows 95 which had major resource problems. Windows NT+ isn't as constrained and Scintilla now does a better job of reusing Fonts in ViewStyle so FontCached should go away eventually. Pointing back from FormatAndMetrics gets in the way of this evolution to the extent that I'd feel better adding a std::wstring FormatAndMetrics::fontName
.
IDWriteGdiInterop::CreateFontFromLOGFONT goes the wrong way to retrieve the font family name - the LOGFONTW is a const argument.
Holding onto the original name doesn't ensure that the list box text looks like the text area since the list box text is always drawn with GDI. Making the text appear the same would require a complete implementation of list box item drawing that uses Direct2D + DirectWrite. This is made more difficult by the possibility of user code calling WM_SETFONT.
[bugs:#2080] D2D bug with font family name and font face name
Status: open
Group: Bug
Created: Fri Feb 15, 2019 01:42 PM UTC by Zufu Liu
Last Updated: Sat Feb 16, 2019 12:18 AM UTC
Owner: Neil Hodgson
The win32 font choosing dialog returns font face name ("Source Code Pro Semibold") in the lfFaceName field, though "Source Code Pro" is displayed in the ComboBox on Vista? and above system (https://docs.microsoft.com/en-us/windows/desktop/dlgbox/font-dialog-box).
If lfFaceName is directly passed to SCI_STYLESETFONT, it will not works in D2D for font weight other than regular and bold (the second row in above table). using IDWriteGdiInterop to get font family name could fix this.
I added a temporary fix at https://github.com/zufuliu/notepad2/commit/bca0cdb2160af7f0a5a3d1be39cc8150bf8d198f
[bugs:#2080] D2D bug with font family name and font face name
Status: open
Group: Bug
Created: Fri Feb 15, 2019 01:42 PM UTC by Zufu Liu
Last Updated: Sat Feb 16, 2019 01:02 AM UTC
Owner: Neil Hodgson
With CreateFontFromLOGFONT, condensed font could work. GetStretch() returns DWRITE_FONT_STRETCH_SEMI_CONDENSED.
[bugs:#2080] D2D bug with font family name and font face name
Status: open
Group: Bug
Created: Fri Feb 15, 2019 01:42 PM UTC by Zufu Liu
Last Updated: Sat Feb 16, 2019 02:38 AM UTC
Owner: Neil Hodgson
One half of the patch appears to change the family name given to CreateTextFormat. This could be performed by the application. It is not completely compatible with existing code and encodes a particular policy for font naming which may need to be tweaked further. In particular, special casing some weights appears fragile. It would be safer to document the difference in font naming and leave implementation choice to the application.
[bugs:#2080] D2D bug with font family name and font face name
Status: open
Group: Bug
Created: Fri Feb 15, 2019 01:42 PM UTC by Zufu Liu
Last Updated: Sat Feb 16, 2019 01:09 PM UTC
Owner: Neil Hodgson
I updated the patch to support condensed and narrow font (maybe oblique font too), the font weight restriction at the beginning of the function is removed. It's indeed overhead, unnecessary been called for each font size.
https://github.com/zufuliu/notepad2/commit/62fe1c0372107d07d9b2a77913aede8591ddada1
I added a font property table bellow. maybe it's better to add eight APIs:
SetLocaleName(string name) SetFontFamily(string name) SetFontStyle(int style) SetFontStetch(int stetch)
SetLocaleName has been discussed on https://sourceforge.net/p/scintilla/bugs/2027/
[bugs:#2080] D2D bug with font family name and font face name
Status: open
Group: Bug
Created: Fri Feb 15, 2019 01:42 PM UTC by Zufu Liu
Last Updated: Sun Feb 17, 2019 10:29 PM UTC
Owner: Neil Hodgson
Font Property Table
Platform | Win32 GDI | Win32 D2D | GTK |
---|---|---|---|
Native Font | LOGFONT | IDWriteFont/IDWriteTextFormat | PangoFontDescription |
*familyName | GetFontFamily() | set_family() | |
faceName | lfFaceName | ||
*localeName* | GetLocaleName() | ||
*style | lfItalic | DWRITE_FONT_STYLE | PangoStyle |
*stetch | DWRITE_FONT_STRETCH | PangoStretch | |
weight | lfWeight | DWRITE_FONT_WEIGHT | PangoWeight |
Platform | Cocoa | Qt | wxWidgets |
---|---|---|---|
Native Font | CTFont | QFont | wxFont |
*familyName | font name | setFamily() | |
faceName | FaceName() | ||
*localeName | |||
*style | CTFontSymbolicTraits | QFont::Style | wxFontStyle |
*stetch | CTFontSymbolicTraits | QFont::Stretch | |
weight | QFont::Weight | wxFontWeight |
SetFontFamily(string name)
can made an alias to SetFont on GTK, Cocoa and Qt.
By the way, setWeight() is not called for QFont in Font::Create() (PlatQt.cpp line 138). https://doc.qt.io/qt-5/qfont.html#setWeight
[bugs:#2080] D2D bug with font family name and font face name
Status: open
Group: Bug
Created: Fri Feb 15, 2019 01:42 PM UTC by Zufu Liu
Last Updated: Mon Feb 18, 2019 06:51 AM UTC
Owner: Neil Hodgson
The set of font attributes on different platforms is open-ended and most have not solicited any interest from Scintilla users. I'm wary of adding to the set of attributes unless there is a real need.
[bugs:#2080] D2D bug with font family name and font face name
Status: open
Group: Bug
Created: Fri Feb 15, 2019 01:42 PM UTC by Zufu Liu
Last Updated: Mon Feb 18, 2019 07:02 AM UTC
Owner: Neil Hodgson
Is there any documentation about what the localeName parameter to CreateTextFormat means?
From [#2027] it appeared to control the way that the format handles text in particular languages but given all the information about getting localized names in DirectWrite, it may just be used to look up the name in the sets of localized names of fonts.
[bugs:#2080] D2D bug with font family name and font face name
Status: open
Group: Bug
Created: Fri Feb 15, 2019 01:42 PM UTC by Zufu Liu
Last Updated: Fri Feb 22, 2019 10:01 AM UTC
Owner: Neil Hodgson
I think it's the locale (or language) of the text / script, has nothing about locale name of font. The locale name of font is only for display (the font itself) purpose, just like application name localization, it's English name and locale name refer the the same font. See "TTF Names" on https://fontforge.github.io/fontinfo.html
I can't find match articles about the meaning of the localeName
,
https://bell0bytes.eu/text-with-directwrite/
I think the localeName
maybe used in the "Script Processor" on https://docs.microsoft.com/en-us/windows/desktop/DirectWrite/introducing-directwrite
See example U+66DC from https://source.typekit.com/source-han-serif/, the same character may have different glyph in each locale / language. The locale name (Vista and above, locale name is preferred over old language id) is used to decide pick which glyph (maybe also from which font). Windows system at least has different fallback font list for each language in the registry.
By set the localeName to different values (zh-TW, zh-Hant, zh-CN, zh-Hans, ja-JP and ko-KR, you may need install additional or supplement fonts for Traditional Chinese, Simplified Chinese, Japanese and Korea) you will see different shapes for the same character without change Windows UI language or system default locale.
As previous discussed on Bug #2027. The simplest fix is pass empty string, which means current user default locale (which may diff from system default locale).
Attachments:
[bugs:#2080] D2D bug with font family name and font face name
Status: open
Group: Bug
Created: Fri Feb 15, 2019 01:42 PM UTC by Zufu Liu
Last Updated: Fri Feb 22, 2019 10:09 AM UTC
Owner: Neil Hodgson
As mentioned in my first reply, FontCached isn't needed so was removed with [ad1559].
[bugs:#2080] D2D bug with font family name and font face name
Status: open
Group: Bug
Created: Fri Feb 15, 2019 01:42 PM UTC by Zufu Liu
Last Updated: Fri Feb 22, 2019 12:37 PM UTC
Owner: Neil Hodgson
On GTK, the equivalent interface for locale is the Pango language attribute.
On Cocoa, there is a Character Shape Feature Type which may be available through NSFontFeatureSettingsAttribute on an NSFontDescriptor. There's also NSAccessibilityLanguageTextAttribute but that is likely only for accessibility.
[bugs:#2080] D2D bug with font family name and font face name
Status: open
Group: Bug
Created: Fri Feb 15, 2019 01:42 PM UTC by Zufu Liu
Last Updated: Sun Feb 24, 2019 11:55 AM UTC
Owner: Neil Hodgson
[bugs:#2080] D2D bug with font family name and font face name
Status: open
Group: Bug
Labels: font
Created: Fri Feb 15, 2019 01:42 PM UTC by Zufu Liu
Last Updated: Fri Jul 17, 2020 10:56 AM UTC
Owner: Neil Hodgson
[bugs:#2080] D2D bug with font family name and font face name
Status: open
Group: Bug
Labels: font directwrite
Created: Fri Feb 15, 2019 01:42 PM UTC by Zufu Liu
Last Updated: Fri Sep 23, 2022 12:25 PM UTC
Owner: Neil Hodgson
Close as fixed: font stretch is supported since 5.5.2, auto-completion list box is rendered with same technology as editor window since 5.5.6.
[bugs:#2080] D2D bug with font family name and font face name
Status: closed-fixed
Group: Bug
Labels: font directwrite
Created: Fri Feb 15, 2019 01:42 PM UTC by Zufu Liu
Last Updated: Wed Sep 28, 2022 10:46 PM UTC
Owner: Neil Hodgson