-
Notifications
You must be signed in to change notification settings - Fork 47
add underline/strikethrough metrics to font engine #236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,6 +46,11 @@ class IFontsEngine : MODULE_GLOBAL_INTERFACE | |
| virtual double ascent(const Font& f) const = 0; | ||
| virtual double descent(const Font& f) const = 0; | ||
|
|
||
| virtual double underlinePosition(const Font& f) const = 0; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You added new metrics to IFontsEngine, but you should add the same to FontMetrics class. This needs to be done across the entire call stack, including FontProvider and QFontProvider. |
||
| virtual double underlineThickness(const Font& f) const = 0; | ||
| virtual double strikeoutPosition(const Font& f) const = 0; | ||
| virtual double strikeoutThickness(const Font& f) const = 0; | ||
|
|
||
| virtual bool inFont(const Font& f, char32_t ucs4) const = 0; | ||
|
|
||
| virtual double horizontalAdvance(const Font& f, const char32_t& ch) const = 0; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: musescore/muse_framework
Length of output: 2314
🏁 Script executed:
Repository: musescore/muse_framework
Length of output: 39523
🌐 Web query:
FreeType FT_Face underline_position underline_thickness TrueType OS/2 yStrikeoutPosition coordinate units baseline documentation💡 Result:
In the FreeType library and OpenType specifications, underline and strikeout metrics are handled in distinct ways depending on the structure being accessed. FT_Face Underline Metrics The FT_FaceRec structure (the underlying type of FT_Face) contains fields for underline metrics directly [1][2]: - underline_position: Specifies the position of the underline in font units; it is defined as the center of the underlining stem [1][3]. - underline_thickness: Specifies the thickness of the underline in font units [1][3]. These values are generally derived from the TrueType 'post' table [4][5]. In the FreeType API, these are members of the FT_FaceRec struct and are only relevant for scalable font formats [1][2]. OS/2 Table Metrics The OS/2 table does not contain underline position or thickness fields. Instead, it contains strikeout metrics [6][7]: - yStrikeoutSize: Specifies the thickness of the strikeout stroke in font design units [6]. It is recommended that this value match the underline thickness found in the 'post' table [6]. - yStrikeoutPosition: Specifies the position of the strikeout stroke relative to the baseline in font design units [7]. Positive values indicate distances above the baseline, while negative values indicate distances below the baseline [7]. In summary: - Underline metrics (underline_position, underline_thickness) are located in the FT_Face structure (loaded from the 'post' table) [4][1]. - Strikeout metrics (yStrikeoutSize, yStrikeoutPosition) are located in the OS/2 table [6][7]. - All these values are expressed in font design units (also called font units) [1][6].
Citations:
Normalize decoration positions to the shared coordinate contract.
Use
underlineThickness()inunderlinePosition(). NegateyStrikeoutPosition, subtract half ofstrikeoutThickness(), and accept zero as a valid OS/2 position.🧰 Tools
🪛 Clang (14.0.6)
[warning] 576-576: use a trailing return type for this function
(modernize-use-trailing-return-type)
[warning] 585-585: use a trailing return type for this function
(modernize-use-trailing-return-type)
[warning] 592-592: use a trailing return type for this function
(modernize-use-trailing-return-type)
[warning] 594-594: variable 'os2' is not initialized
(cppcoreguidelines-init-variables)
[warning] 603-603: use a trailing return type for this function
(modernize-use-trailing-return-type)
[warning] 605-605: variable 'os2' is not initialized
(cppcoreguidelines-init-variables)
🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, this metrics are taken from freetype, we don't simply connect one to another
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexpavlov96, agreed. FreeType provides the raw underline metrics, and the OS/2 table provides the raw strikeout metrics.The finding does not propose deriving strikeout metrics from underline metrics. It concerns coordinate conversion only.
underlinePosition()already negates the FreeType position because the renderer uses the opposite Y direction.strikeoutPosition()needs the same conversion foryStrikeoutPosition. It must also convert the metric center position to the decoration edge position.The
underlineThickness()call only ensures that the position adjustment uses the same clamped thickness that the caller receives.You are interacting with an AI system.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you explain what all these new metrics means?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.