Merge branch 'master' into features/menubutton

This commit is contained in:
Uwe Rathmann 2025-02-28 09:30:23 +01:00
commit f4b7aa33fe
63 changed files with 285 additions and 431 deletions

View File

@ -20,25 +20,25 @@ b) Cassowary constraint solving algorithm ( examples )
SPDX-License-Identifier: BSD 3-Clause "New" or "Revised" License SPDX-License-Identifier: BSD 3-Clause "New" or "Revised" License
Copyright (c) 2013, Nucleic Development Team Copyright (c) 2013, Nucleic Development Team
fonts ( only for running the examples ): fonts ( needed for the Material3/Fluent2 skin )
a) Material3 Icons a) Material3 Icons
Code: https://github.com/google/material-design-icons Code: https://github.com/google/material-design-icons
SPDX-License-Identifier: Apache License 2.0 SPDX-License-Identifier: Apache License 2.0
b) Fluent2 Icons b) Roboto Fonts
Code: https://github.com/googlefonts/roboto-classic
SPDX-License-Identifier: SIL Open Font License 1.1
Copyright 2011 The Roboto Project Authors
c) Fluent2 Icons
Code: https://github.com/microsoft/fluentui-system-icons Code: https://github.com/microsoft/fluentui-system-icons
SPDX-License-Identifier: MIT License SPDX-License-Identifier: MIT License
c) Segoe-UI Fonts d) Segoe-UI Fonts
Code: https://github.com/mrbvrz/segoe-ui-linux Code: https://github.com/mrbvrz/segoe-ui-linux
License: https://github.com/mrbvrz/segoe-ui-linux/blob/master/license.txt License: https://github.com/mrbvrz/segoe-ui-linux/blob/master/license.txt
d) Font Awesome
Code: https://fontawesome.com/
SPDX-License-Identifier: OFL-1.1-RFN
Copyright (c) 2024 Fonticons, Inc.

View File

@ -703,9 +703,10 @@ void Editor::setupListViewMetrics()
for ( auto state : { A::NoState, Q::Hovered, Q::Pressed } ) for ( auto state : { A::NoState, Q::Hovered, Q::Pressed } )
setBoxBorderMetrics( Q::Cell | state | Q::Selected, { 3_px, 0, 0, 0 } ); setBoxBorderMetrics( Q::Cell | state | Q::Selected, { 3_px, 0, 0, 0 } );
#if 1 #if 1
// taken from M3 - what are the actual values, TODO ... setPadding( Q::Cell, 4_px );
setPadding( Q::Cell, { 16_px, 12_px, 16_px, 12_px } ); setStrutSize( Q::Cell, -1, 40_px );
#endif #endif
} }
@ -1561,9 +1562,6 @@ void Editor::setupSpinBoxMetrics()
setSymbol( Q::UpIndicator, symbol( "chevron_up" ) ); setSymbol( Q::UpIndicator, symbol( "chevron_up" ) );
setSymbol( Q::DownIndicator, symbol( "chevron_down" ) ); setSymbol( Q::DownIndicator, symbol( "chevron_down" ) );
setPadding( Q::UpPanel, { 0, 1_px, 0, 0 } );
setPadding( Q::DownPanel, { 0, 0, 0, 1_px } );
#if 0 #if 0
// QskSpinBox::Pressed is missing yet // QskSpinBox::Pressed is missing yet
setBoxBorderMetrics( Q::Panel | Q::Pressed, { 1_px, 1_px, 1_px, 2_px } ); setBoxBorderMetrics( Q::Panel | Q::Pressed, { 1_px, 1_px, 1_px, 2_px } );
@ -1880,7 +1878,6 @@ void Editor::setupTextFieldColors(
{ {
using Q = QskTextField; using Q = QskTextField;
using A = QskAspect; using A = QskAspect;
using W = QskFluent2Skin;
const auto& pal = theme.palette; const auto& pal = theme.palette;

View File

@ -0,0 +1,26 @@
Definitions ( where possible ) taken from:
- https://www.figma.com/file/NAWMapFlXnoOb86Q2H5GKr/Windows-UI-(Community)
The Figma model uses the "Segoe Fluent Icons" [1]. Unfortunately its license is
too restrictive for being included in the QSkinny project. Fortunately similar
icons are also available from the "Fluent UI System Icons" project [2].
However glyph names/numbers and the corresponding unicode values do not match
and can't be taken 1:1 from the Figma model.
"Fluent UI System Icons" offers different icon packages ( as font ):
- FluentSystemIcons-Light.ttf
- FluentSystemIcons-Regular.ttf
- FluentSystemIcons-Filled.ttf
- FluentSystemIcons-Resizable.ttf
For some reason ( might be a bug in the downloaded version ) the checkmark
glyph offered from the "Regular" font ( pixelsize 12 ) is different
( works better ) to the one from the "Resizable" font.
That's why we decided to use the "Regular" font for now.
[1] https://learn.microsoft.com/en-us/windows/apps/design/style/segoe-fluent-icons-font
[2] https://github.com/microsoft/fluentui-system-icons

View File

@ -1,10 +0,0 @@
SVGs have been taken from https://github.com/microsoft/fluentui-system-icons/tree/main/assets.
Icons are available in different sizes. As SVGs can be scaled we only need
one version of them - chosing the '12'.
As we are replacing the colors of the SVGs using graphic filters we set the
color in the SVGs manually to black ( instead of #212121 ). So they are in
line with icons coming from somewhere else.
Names have been shortened ( ic_fluent_xyz_16_regular.svg -> xyz.svg )

View File

@ -1,3 +0,0 @@
<svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M9.85355 3.14645C10.0488 3.34171 10.0488 3.65829 9.85355 3.85355L5.35355 8.35355C5.15829 8.54882 4.84171 8.54882 4.64645 8.35355L2.64645 6.35355C2.45118 6.15829 2.45118 5.84171 2.64645 5.64645C2.84171 5.45118 3.15829 5.45118 3.35355 5.64645L5 7.29289L9.14645 3.14645C9.34171 2.95118 9.65829 2.95118 9.85355 3.14645Z" fill="black"/>
</svg>

Before

Width:  |  Height:  |  Size: 444 B

View File

@ -1,3 +0,0 @@
<svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M2.14645 4.64645C2.34171 4.45118 2.65829 4.45118 2.85355 4.64645L6 7.79289L9.14645 4.64645C9.34171 4.45118 9.65829 4.45118 9.85355 4.64645C10.0488 4.84171 10.0488 5.15829 9.85355 5.35355L6.35355 8.85355C6.15829 9.04882 5.84171 9.04882 5.64645 8.85355L2.14645 5.35355C1.95118 5.15829 1.95118 4.84171 2.14645 4.64645Z" fill="black"/>
</svg>

Before

Width:  |  Height:  |  Size: 444 B

View File

@ -1,3 +0,0 @@
<svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M2.14645 7.35355C2.34171 7.54882 2.65829 7.54882 2.85355 7.35355L6 4.20711L9.14645 7.35355C9.34171 7.54882 9.65829 7.54882 9.85355 7.35355C10.0488 7.15829 10.0488 6.84171 9.85355 6.64645L6.35355 3.14645C6.15829 2.95118 5.84171 2.95118 5.64645 3.14645L2.14645 6.64645C1.95118 6.84171 1.95118 7.15829 2.14645 7.35355Z" fill="black"/>
</svg>

Before

Width:  |  Height:  |  Size: 444 B

View File

@ -1,15 +0,0 @@
#! /bin/sh
if [ $# -eq 0 ]; then
echo "Usage $0 file ..."
exit 1
fi
for file in $*
do
base=`basename -s .svg $file`
echo "${base}.svg -> qvg/${base}.qvg"
svg2qvg ${base}.svg qvg/${base}.qvg
done
exit $status

View File

@ -0,0 +1,11 @@
#! /bin/sh
function symbol2qvg {
fontfile=FluentSystemIcons-Regular.ttf
glyph2qvg ${fontfile} 12 $1 qvg/$2.qvg
}
symbol2qvg 1724 checkmark
symbol2qvg 1792 chevron_down
symbol2qvg 1816 chevron_up

View File

@ -1338,7 +1338,7 @@ void Editor::setupListView()
using P = QPalette; using P = QPalette;
// padding for each cell // padding for each cell
setPadding( Q::Cell, QskMargins( 4, 0 ) ); setPadding( Q::Cell, QskMargins( 4, 4 ) );
for ( auto state : { A::NoState, Q::Disabled } ) for ( auto state : { A::NoState, Q::Disabled } )
{ {

View File

@ -1,21 +1,10 @@
<RCC> <RCC>
<qresource prefix="/m3"> <qresource prefix="/m3">
<!-- needed until we have fixed a rendering bug for small icons -->
<file>icons/qvg/check_small.qvg</file>
<file>icons/qvg/combo-box-arrow-closed.qvg</file>
<file>icons/qvg/combo-box-arrow-open.qvg</file>
<file>icons/qvg/segmented-button-check.qvg</file>
<file>icons/qvg/switchbutton-checked.qvg</file>
<file>icons/qvg/switchbutton-unchecked.qvg</file>
<!-- https://github.com/marella/material-design-icons/tree/main/svg/round -->
<file>icons/qvg/add.qvg</file> <file>icons/qvg/add.qvg</file>
<file>icons/qvg/arrow_drop_down.qvg</file> <file>icons/qvg/arrow_drop_down.qvg</file>
<file>icons/qvg/arrow_drop_up.qvg</file> <file>icons/qvg/arrow_drop_up.qvg</file>
<file>icons/qvg/check.qvg</file> <file>icons/qvg/check.qvg</file>
<file>icons/qvg/close.qvg</file>
<file>icons/qvg/remove.qvg</file> <file>icons/qvg/remove.qvg</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@ -227,7 +227,6 @@ void Editor::setupCheckBox()
setStrutSize( Q::Box, 18_px, 18_px ); setStrutSize( Q::Box, 18_px, 18_px );
setBoxBorderMetrics( Q::Box, 2_px ); setBoxBorderMetrics( Q::Box, 2_px );
setBoxShape( Q::Box, 2_px ); setBoxShape( Q::Box, 2_px );
setPadding( Q::Box, 3_px ); // "icon size"
QskShadowMetrics shadowMetrics( 12_px, 0.0 ); QskShadowMetrics shadowMetrics( 12_px, 0.0 );
shadowMetrics.setShapeMode( QskShadowMetrics::Ellipse ); shadowMetrics.setShapeMode( QskShadowMetrics::Ellipse );
@ -240,7 +239,7 @@ void Editor::setupCheckBox()
setGraphicRole( Q::Indicator | Q::Disabled | Q::Checked, setGraphicRole( Q::Indicator | Q::Disabled | Q::Checked,
QskMaterial3Skin::GraphicRoleSurface ); QskMaterial3Skin::GraphicRoleSurface );
const auto checkMark = symbol( "check_small" ); const auto checkMark = symbol( "check" );
for ( auto state : { A::NoState, Q::Disabled } ) for ( auto state : { A::NoState, Q::Disabled } )
{ {
const auto aspect = Q::Indicator | Q::Checked | state; const auto aspect = Q::Indicator | Q::Checked | state;
@ -337,7 +336,7 @@ void Editor::setupComboBox()
setColor( Q::Text, m_pal.onSurface ); setColor( Q::Text, m_pal.onSurface );
setFontRole( Q::Text, BodyLarge ); setFontRole( Q::Text, BodyLarge );
setStrutSize( Q::StatusIndicator, 12_px, 12_px ); setStrutSize( Q::StatusIndicator, 24_px, 24_px );
setGraphicRole( Q::StatusIndicator, QskMaterial3Skin::GraphicRoleOnSurface ); setGraphicRole( Q::StatusIndicator, QskMaterial3Skin::GraphicRoleOnSurface );
setAlignment( Q::StatusIndicator, Qt::AlignRight | Qt::AlignVCenter ); setAlignment( Q::StatusIndicator, Qt::AlignRight | Qt::AlignVCenter );
@ -346,14 +345,13 @@ void Editor::setupComboBox()
setBoxBorderColors( Q::Panel | Q::Disabled, m_pal.onSurface38 ); setBoxBorderColors( Q::Panel | Q::Disabled, m_pal.onSurface38 );
setGraphicRole( Q::Icon, QskMaterial3Skin::GraphicRoleOnSurface38 );
setColor( Q::Text | Q::Disabled, m_pal.onSurface38 ); setColor( Q::Text | Q::Disabled, m_pal.onSurface38 );
setGraphicRole( Q::StatusIndicator, QskMaterial3Skin::GraphicRoleOnSurface38 ); setGraphicRole( Q::StatusIndicator | Q::Disabled, QskMaterial3Skin::GraphicRoleOnSurface38 );
setGraphicRole( Q::Icon | Q::Disabled, QskMaterial3Skin::GraphicRoleOnSurface38 );
setSymbol( Q::StatusIndicator, symbol( "combo-box-arrow-closed" ) ); setSymbol( Q::StatusIndicator, symbol( "arrow_drop_down" ) );
setSymbol( Q::StatusIndicator | Q::PopupOpen, symbol( "combo-box-arrow-open" ) ); setSymbol( Q::StatusIndicator | Q::PopupOpen, symbol( "arrow_drop_up" ) );
} }
void Editor::setupBox() void Editor::setupBox()
@ -1120,8 +1118,8 @@ void Editor::setupSwitchButton()
setStrutSize( Q::Icon, { 16_px, 16_px } ); setStrutSize( Q::Icon, { 16_px, 16_px } );
setPadding( Q::Icon, 6_px ); setPadding( Q::Icon, 6_px );
setSymbol( Q::Icon, symbol( "switchbutton-unchecked" ) ); setSymbol( Q::Icon, symbol( "close" ) );
setSymbol( Q::Icon | Q::Checked, symbol( "switchbutton-checked" ) ); setSymbol( Q::Icon | Q::Checked, symbol( "check" ) );
setGraphicRole( Q::Icon, QskMaterial3Skin::GraphicRoleSurfaceContainerHighest ); setGraphicRole( Q::Icon, QskMaterial3Skin::GraphicRoleSurfaceContainerHighest );

View File

@ -1,202 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M18 13h-5v5c0 .55-.45 1-1 1s-1-.45-1-1v-5H6c-.55 0-1-.45-1-1s.45-1 1-1h5V6c0-.55.45-1 1-1s1 .45 1 1v5h5c.55 0 1 .45 1 1s-.45 1-1 1z"/></svg>

Before

Width:  |  Height:  |  Size: 232 B

View File

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="m8.71 11.71 2.59 2.59c.39.39 1.02.39 1.41 0l2.59-2.59c.63-.63.18-1.71-.71-1.71H9.41c-.89 0-1.33 1.08-.7 1.71z"/></svg>

Before

Width:  |  Height:  |  Size: 211 B

View File

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M8.71 12.29 11.3 9.7a.996.996 0 0 1 1.41 0l2.59 2.59c.63.63.18 1.71-.71 1.71H9.41c-.89 0-1.33-1.08-.7-1.71z"/></svg>

Before

Width:  |  Height:  |  Size: 208 B

View File

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M9 16.17 5.53 12.7a.996.996 0 1 0-1.41 1.41l4.18 4.18c.39.39 1.02.39 1.41 0L20.29 7.71a.996.996 0 1 0-1.41-1.41L9 16.17z"/></svg>

Before

Width:  |  Height:  |  Size: 221 B

View File

@ -1,4 +0,0 @@
<svg width="12" height="10" viewBox="0 0 12 10" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M4 9.4L0 5.4L1.4 4L4 6.6L10.6 0L12 1.4L4 9.4Z" fill="black"/>
</svg>

Before

Width:  |  Height:  |  Size: 175 B

View File

@ -1,4 +0,0 @@
<svg width="8" height="5" viewBox="0 0 8 5" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M0.25 0.5L4 4.25L7.75 0.5H0.25Z" fill="black"/>
</svg>

Before

Width:  |  Height:  |  Size: 157 B

View File

@ -1,4 +0,0 @@
<svg width="8" height="5" viewBox="0 0 8 5" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M0.25 0.5L4 4.25L7.75 0.5H0.25Z" transform="rotate(180 4 2.5)" fill="black"/>
</svg>

Before

Width:  |  Height:  |  Size: 187 B

View File

@ -1,15 +0,0 @@
#! /bin/sh
if [ $# -eq 0 ]; then
echo "Usage $0 file ..."
exit 1
fi
for file in $*
do
base=`basename -s .svg $file`
echo "${base}.svg -> qvg/${base}.qvg"
svg2qvg ${base}.svg qvg/${base}.qvg
done
exit $status

Binary file not shown.

View File

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M18 13H6c-.55 0-1-.45-1-1s.45-1 1-1h12c.55 0 1 .45 1 1s-.45 1-1 1z"/></svg>

Before

Width:  |  Height:  |  Size: 167 B

View File

@ -1,4 +0,0 @@
<svg width="14" height="11" viewBox="0 0 14 11" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M4.24914 8.12738L1.12164 4.99988L0.0566406 6.05738L4.24914 10.2499L13.2491 1.24988L12.1916 0.192383L4.24914 8.12738Z" fill="black"/>
</svg>

Before

Width:  |  Height:  |  Size: 246 B

View File

@ -1,4 +0,0 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M6.0001 10.78L3.2201 8.00002L2.27344 8.94002L6.0001 12.6667L14.0001 4.66668L13.0601 3.72668L6.0001 10.78Z" fill="black"/>
</svg>

Before

Width:  |  Height:  |  Size: 235 B

View File

@ -1,4 +0,0 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M12.6666 4.27337L11.7266 3.33337L7.99992 7.06004L4.27325 3.33337L3.33325 4.27337L7.05992 8.00004L3.33325 11.7267L4.27325 12.6667L7.99992 8.94004L11.7266 12.6667L12.6666 11.7267L8.93992 8.00004L12.6666 4.27337Z" fill="black"/>
</svg>

Before

Width:  |  Height:  |  Size: 339 B

View File

@ -0,0 +1,15 @@
#! /bin/sh
function symbol2qvg {
fontfile=MaterialSymbolsOutlined.ttf
glyph2qvg ${fontfile} 24 $1 qvg/$2.qvg
}
symbol2qvg 3067 check
symbol2qvg 3084 close
symbol2qvg 5022 arrow_drop_down
symbol2qvg 5023 arrow_drop_up
symbol2qvg 3082 add
symbol2qvg 3080 remove

View File

@ -14,7 +14,6 @@
#include <QskStackBoxAnimator.h> #include <QskStackBoxAnimator.h>
#include <QskPanGestureRecognizer.h> #include <QskPanGestureRecognizer.h>
#include <QQuickFramebufferObject>
#include <QGuiApplication> #include <QGuiApplication>
#include <QQuickWindow> #include <QQuickWindow>
#include <QtMath> #include <QtMath>

View File

@ -31,8 +31,8 @@ class GraphicLabel : public QskGraphicLabel
Inverted Inverted
}; };
GraphicLabel( const QskGraphic& graphic, QQuickItem* parent = nullptr ) GraphicLabel( QQuickItem* parent = nullptr )
: QskGraphicLabel( graphic, parent ) : QskGraphicLabel( parent )
{ {
setMargins( 10 ); setMargins( 10 );
setPanel( true ); setPanel( true );
@ -74,7 +74,7 @@ class GraphicLabel : public QskGraphicLabel
MainWindow::MainWindow() MainWindow::MainWindow()
{ {
auto label = new GraphicLabel( QskGraphicIO::read( QString( ":/qvg/Tux.qvg" ) ) ); auto label = new GraphicLabel();
auto invertButton = new QskPushButton( "Inverted" ); auto invertButton = new QskPushButton( "Inverted" );
invertButton->setSizePolicy( Qt::Horizontal, QskSizePolicy::Fixed ); invertButton->setSizePolicy( Qt::Horizontal, QskSizePolicy::Fixed );
@ -98,6 +98,12 @@ MainWindow::MainWindow()
setGraphicRoles( qskSkinManager->skin() ); setGraphicRoles( qskSkinManager->skin() );
} }
void MainWindow::setGraphic( const QString& path )
{
if ( auto label = findChild< QskGraphicLabel* >() )
label->setGraphic( QskGraphicIO::read( path ) );
}
void MainWindow::setGraphicRoles( QskSkin* skin ) void MainWindow::setGraphicRoles( QskSkin* skin )
{ {
// substituting black // substituting black

View File

@ -15,6 +15,7 @@ class MainWindow : public QskWindow
public: public:
MainWindow(); MainWindow();
void setGraphic( const QString& );
private Q_SLOTS: private Q_SLOTS:
void setGraphicRoles( QskSkin* ); void setGraphicRoles( QskSkin* );

View File

@ -27,6 +27,7 @@ int main( int argc, char* argv[] )
focusIndicator->setObjectName( "FocusIndicator" ); focusIndicator->setObjectName( "FocusIndicator" );
MainWindow window; MainWindow window;
window.setGraphic( ( argc > 1 ) ? argv[1] : ":/qvg/Tux.qvg" );
window.resize( 600, 400 ); window.resize( 600, 400 );
window.addItem( focusIndicator ); window.addItem( focusIndicator );
window.show(); window.show();

View File

@ -12,7 +12,7 @@
#include <QFontMetricsF> #include <QFontMetricsF>
#include <QRawFont> #include <QRawFont>
constexpr int glyphSize = 100; constexpr int glyphSize = 20;
GlyphListView::GlyphListView( QQuickItem* parentItem ) GlyphListView::GlyphListView( QQuickItem* parentItem )
: Inherited( parentItem ) : Inherited( parentItem )
@ -85,7 +85,13 @@ qreal GlyphListView::columnWidth( int col ) const
} }
case 1: case 1:
return glyphSize; {
const auto hint = strutSizeHint( Cell );
const auto padding = paddingHint( Cell );
const qreal w = glyphSize + padding.left() + padding.right();
return qMax( w, hint.width() );
}
case 2: case 2:
return m_maxNameWidth; return m_maxNameWidth;
@ -96,7 +102,11 @@ qreal GlyphListView::columnWidth( int col ) const
qreal GlyphListView::rowHeight() const qreal GlyphListView::rowHeight() const
{ {
return glyphSize + 20; const auto hint = strutSizeHint( Cell );
const auto padding = paddingHint( Cell );
const qreal h = glyphSize + padding.top() + padding.bottom();
return qMax( h, hint.height() );
} }
QVariant GlyphListView::valueAt( int row, int col ) const QVariant GlyphListView::valueAt( int row, int col ) const

View File

@ -1,10 +1,10 @@
<RCC> <RCC>
<qresource prefix="/iconfonts"> <qresource prefix="/iconfonts">
<file alias="FluentIcons.ttf">fonts/FluentSystemIcons-Resizable.ttf</file> <file alias="FluentIcons.ttf">../../designsystems/fluent2/icons/FluentSystemIcons-Regular.ttf</file>
<file alias="FontAwesomeIcons.otf">fonts/Font Awesome 6 Free-Regular-400.otf</file> <file alias="FontAwesomeIcons.otf">fonts/Font Awesome 6 Free-Regular-400.otf</file>
<file alias="IcoMoonIcons.ttf">fonts/IcoMoon-Free.ttf</file> <file alias="IcoMoonIcons.ttf">fonts/IcoMoon-Free.ttf</file>
<file alias="MaterialIcons.ttf">fonts/MaterialSymbolsOutlined.ttf</file> <file alias="MaterialIcons.ttf">../../designsystems/material3/icons/MaterialSymbolsOutlined.ttf</file>
<file alias="OctIcons.ttf">fonts/Octicons.ttf</file> <file alias="OctIcons.ttf">fonts/Octicons.ttf</file>
</qresource> </qresource>

View File

@ -1,25 +1,15 @@
a) Material3 a) Font Awesome
Code: https://github.com/google/material-design-icons
SPDX-License-Identifier: Apache License 2.0
b) Fluent2
Code: https://github.com/microsoft/fluentui-system-icons
SPDX-License-Identifier: MIT License
c) Font Awesome
Code: https://fontawesome.com/ Code: https://fontawesome.com/
SPDX-License-Identifier: OFL-1.1-RFN SPDX-License-Identifier: OFL-1.1-RFN
Copyright (c) 2024 Fonticons, Inc. Copyright (c) 2024 Fonticons, Inc.
d) IcoMoon b) IcoMoon
Code: https://github.com/Keyamoon/IcoMoon-Free Code: https://github.com/Keyamoon/IcoMoon-Free
SPDX-License-Identifier: CC-BY-4.0 SPDX-License-Identifier: CC-BY-4.0
e) Octicons c) Octicons
Code: https://github.com/primer/octicons Code: https://github.com/primer/octicons
SPDX-License-Identifier: MIT License SPDX-License-Identifier: MIT License

View File

@ -1007,6 +1007,10 @@ void QskItem::itemChange( QQuickItem::ItemChange change,
case QQuickItem::ItemRotationHasChanged: case QQuickItem::ItemRotationHasChanged:
case QQuickItem::ItemAntialiasingHasChanged: case QQuickItem::ItemAntialiasingHasChanged:
case QQuickItem::ItemDevicePixelRatioHasChanged: case QQuickItem::ItemDevicePixelRatioHasChanged:
#if QT_VERSION >= QT_VERSION_CHECK( 6, 9, 0 )
case QQuickItem::ItemScaleHasChanged:
case QQuickItem::ItemTransformHasChanged:
#endif
{ {
break; break;
} }

View File

@ -29,6 +29,25 @@ QRhi* qskRenderingHardwareInterface( const QQuickWindow* window )
return nullptr; return nullptr;
} }
bool qskIsOpenGLWindow( const QQuickWindow* window )
{
if ( window == nullptr )
return false;
const auto renderer = window->rendererInterface();
switch( renderer->graphicsApi() )
{
case QSGRendererInterface::OpenGL:
#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
case QSGRendererInterface::OpenGLRhi:
#endif
return true;
default:
return false;
}
}
QRectF qskItemRect( const QQuickItem* item ) QRectF qskItemRect( const QQuickItem* item )
{ {
auto d = QQuickItemPrivate::get( item ); auto d = QQuickItemPrivate::get( item );

View File

@ -27,6 +27,7 @@ template< typename T > class QList;
*/ */
QSK_EXPORT QRhi* qskRenderingHardwareInterface( const QQuickWindow* ); QSK_EXPORT QRhi* qskRenderingHardwareInterface( const QQuickWindow* );
QSK_EXPORT bool qskIsOpenGLWindow( const QQuickWindow* );
QSK_EXPORT bool qskIsItemInDestructor( const QQuickItem* ); QSK_EXPORT bool qskIsItemInDestructor( const QQuickItem* );
QSK_EXPORT bool qskIsItemComplete( const QQuickItem* ); QSK_EXPORT bool qskIsItemComplete( const QQuickItem* );

View File

@ -50,15 +50,18 @@ namespace PostTableParser
const auto from = reinterpret_cast< const uint8_t* >( glyphData + nglyphs ); const auto from = reinterpret_cast< const uint8_t* >( glyphData + nglyphs );
const auto to = reinterpret_cast< const uint8_t* >( blob.data() + blob.size() ); const auto to = reinterpret_cast< const uint8_t* >( blob.data() + blob.size() );
for ( auto s = from; s < to; s += *s + 1 ) if ( to > from )
strings += s;
for ( int i = 0; i < nglyphs; i++ )
{ {
const int idx = qFromBigEndian( glyphData[i] ) - 258; for ( auto s = from; s < to; s += *s + 1 )
strings += s;
if ( idx >= 0 ) for ( int i = 0; i < nglyphs; i++ )
names.insert( toString( strings[idx] ), i ); {
const int idx = qFromBigEndian( glyphData[i] ) - 258;
if ( idx >= 0 && idx < strings.size() )
names.insert( toString( strings[idx] ), i );
}
} }
} }
@ -323,6 +326,12 @@ static uint qskGlyphCount( const QRawFont& font )
return fontEngine ? fontEngine->glyphCount() : 0; return fontEngine ? fontEngine->glyphCount() : 0;
} }
static qreal qskPixelSize( const QRawFont& font )
{
const auto fontEngine = QRawFontPrivate::get( font )->fontEngine;
return fontEngine ? fontEngine->fontDef.pixelSize : 0.0;
}
static GlyphNameTable qskGlyphNameTable( const QRawFont& font ) static GlyphNameTable qskGlyphNameTable( const QRawFont& font )
{ {
const auto count = qskGlyphCount( font ); const auto count = qskGlyphCount( font );
@ -453,6 +462,10 @@ QskGraphic QskGlyphTable::glyphGraphic( uint glyphIndex ) const
if ( !path.isEmpty() ) if ( !path.isEmpty() )
{ {
// vertical glyph coordinates are in the range [-sz, 0.0]
const auto sz = qskPixelSize( m_data->font );
graphic.setViewBox( QRectF( 0.0, -sz, sz, sz ) );
QPainter painter( &graphic ); QPainter painter( &graphic );
painter.setRenderHint( QPainter::Antialiasing, true ); painter.setRenderHint( QPainter::Antialiasing, true );
painter.fillPath( path, Qt::black ); painter.fillPath( path, Qt::black );

View File

@ -907,7 +907,7 @@ void QskGraphic::drawPath( const QPainterPath& path )
if ( painter == nullptr ) if ( painter == nullptr )
return; return;
m_data->addCommand( QskPainterCommand( path ) ); addCommand( QskPainterCommand( path ) );
m_data->commandTypes |= QskGraphic::VectorData; m_data->commandTypes |= QskGraphic::VectorData;
if ( !path.isEmpty() ) if ( !path.isEmpty() )
@ -938,7 +938,7 @@ void QskGraphic::drawPixmap( const QRectF& rect,
if ( painter == nullptr ) if ( painter == nullptr )
return; return;
m_data->addCommand( QskPainterCommand( rect, pixmap, subRect ) ); addCommand( QskPainterCommand( rect, pixmap, subRect ) );
m_data->commandTypes |= QskGraphic::RasterData; m_data->commandTypes |= QskGraphic::RasterData;
const QRectF r = painter->transform().mapRect( rect ); const QRectF r = painter->transform().mapRect( rect );
@ -953,7 +953,7 @@ void QskGraphic::drawImage( const QRectF& rect, const QImage& image,
if ( painter == nullptr ) if ( painter == nullptr )
return; return;
m_data->addCommand( QskPainterCommand( rect, image, subRect, flags ) ); addCommand( QskPainterCommand( rect, image, subRect, flags ) );
m_data->commandTypes |= QskGraphic::RasterData; m_data->commandTypes |= QskGraphic::RasterData;
const QRectF r = painter->transform().mapRect( rect ); const QRectF r = painter->transform().mapRect( rect );
@ -964,7 +964,7 @@ void QskGraphic::drawImage( const QRectF& rect, const QImage& image,
void QskGraphic::updateState( const QPaintEngineState& state ) void QskGraphic::updateState( const QPaintEngineState& state )
{ {
m_data->addCommand( QskPainterCommand( state ) ); addCommand( QskPainterCommand( state ) );
if ( state.state() & QPaintEngine::DirtyTransform ) if ( state.state() & QPaintEngine::DirtyTransform )
{ {
@ -981,6 +981,11 @@ void QskGraphic::updateState( const QPaintEngineState& state )
} }
} }
void QskGraphic::addCommand( const QskPainterCommand& command )
{
m_data->addCommand( command );
}
void QskGraphic::updateBoundingRect( const QRectF& rect ) void QskGraphic::updateBoundingRect( const QRectF& rect )
{ {
QRectF br = rect; QRectF br = rect;

View File

@ -146,7 +146,9 @@ class QSK_EXPORT QskGraphic : public QPaintDevice
virtual void drawImage( const QRectF&, virtual void drawImage( const QRectF&,
const QImage&, const QRectF&, Qt::ImageConversionFlags ); const QImage&, const QRectF&, Qt::ImageConversionFlags );
virtual void updateState( const QPaintEngineState& state ); virtual void updateState( const QPaintEngineState& );
virtual void addCommand( const QskPainterCommand& );
private: private:
void updateBoundingRect( const QRectF& ); void updateBoundingRect( const QRectF& );

View File

@ -5,9 +5,38 @@
#include "QskGraphicTextureFactory.h" #include "QskGraphicTextureFactory.h"
#include "QskTextureRenderer.h" #include "QskTextureRenderer.h"
#include "QskQuick.h"
#include "QskInternalMacros.h"
#include <qquickwindow.h> #include <qquickwindow.h>
QSK_QT_PRIVATE_BEGIN
#include <private/qsgplaintexture_p.h>
QSK_QT_PRIVATE_END
static QSGTexture* qskCreatePaintedTexture( QQuickWindow* window,
const QSize& size, QskTextureRenderer::PaintHelper* helper )
{
using namespace QskTextureRenderer;
if ( qskIsOpenGLWindow( window ) )
{
const auto textureId = createTextureGL( window, size, helper );
auto texture = new QSGPlainTexture;
texture->setHasAlphaChannel( true );
texture->setOwnsTexture( true );
setTextureId( window, textureId, size, texture );
return texture;
}
else
{
return createTextureRaster( window, size, helper );
}
}
QskGraphicTextureFactory::QskGraphicTextureFactory() QskGraphicTextureFactory::QskGraphicTextureFactory()
{ {
} }
@ -77,7 +106,7 @@ QSGTexture* QskGraphicTextureFactory::createTexture( QQuickWindow* window ) cons
}; };
PaintHelper helper( m_graphic, m_colorFilter ); PaintHelper helper( m_graphic, m_colorFilter );
return QskTextureRenderer::createPaintedTexture( window, m_size, &helper ); return qskCreatePaintedTexture( window, m_size, &helper );
} }
QSize QskGraphicTextureFactory::textureSize() const QSize QskGraphicTextureFactory::textureSize() const

View File

@ -7,6 +7,7 @@
#include "QskSGNode.h" #include "QskSGNode.h"
#include "QskTextureRenderer.h" #include "QskTextureRenderer.h"
#include "QskInternalMacros.h" #include "QskInternalMacros.h"
#include "QskQuick.h"
#include <qsgimagenode.h> #include <qsgimagenode.h>
#include <qquickwindow.h> #include <qquickwindow.h>
@ -160,7 +161,7 @@ void QskPaintedNode::updateTexture( QQuickWindow* window,
{ {
auto imageNode = findImageNode( this ); auto imageNode = findImageNode( this );
if ( ( m_renderHint == OpenGL ) && QskTextureRenderer::isOpenGLWindow( window ) ) if ( ( m_renderHint == OpenGL ) && qskIsOpenGLWindow( window ) )
{ {
const auto textureId = createTextureGL( window, size, nodeData ); const auto textureId = createTextureGL( window, size, nodeData );
@ -232,5 +233,5 @@ quint32 QskPaintedNode::createTextureGL(
}; };
PaintHelper helper( this, nodeData ); PaintHelper helper( this, nodeData );
return createPaintedTextureGL( window, size, &helper ); return QskTextureRenderer::createTextureGL( window, size, &helper );
} }

View File

@ -30,8 +30,12 @@ static GLuint qskTakeTexture( QOpenGLFramebufferObject& fbo )
/* /*
See https://bugreports.qt.io/browse/QTBUG-103929 See https://bugreports.qt.io/browse/QTBUG-103929
As we create a FBO for each update of a node we can't live QOpenGLFramebufferObject::takeTexture produces a memory leak
without having this ( ugly ) workaround. that can't be accepted as we create an FBO each time we update
a texture.
The suggested workarond is to call QOpenGLSharedResourceGuard::invalidateResource()
manually. Unfortunately this is a protected method and we need this nasty hack.
*/ */
class MyFBO class MyFBO
{ {
@ -64,25 +68,6 @@ static GLuint qskTakeTexture( QOpenGLFramebufferObject& fbo )
return textureId; return textureId;
} }
bool QskTextureRenderer::isOpenGLWindow( const QQuickWindow* window )
{
if ( window == nullptr )
return false;
const auto renderer = window->rendererInterface();
switch( renderer->graphicsApi() )
{
case QSGRendererInterface::OpenGL:
#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
case QSGRendererInterface::OpenGLRhi:
#endif
return true;
default:
return false;
}
}
void QskTextureRenderer::setTextureId( QQuickWindow* window, void QskTextureRenderer::setTextureId( QQuickWindow* window,
quint32 textureId, const QSize& size, QSGTexture* texture ) quint32 textureId, const QSize& size, QSGTexture* texture )
{ {
@ -116,8 +101,8 @@ void QskTextureRenderer::setTextureId( QQuickWindow* window,
#endif #endif
} }
quint32 QskTextureRenderer::createPaintedTextureGL( quint32 QskTextureRenderer::createTextureGL(
QQuickWindow* window, const QSize& size, QskTextureRenderer::PaintHelper* helper ) QQuickWindow* window, const QSize& size, PaintHelper* helper )
{ {
/* /*
Binding GL_ARRAY_BUFFER/GL_ELEMENT_ARRAY_BUFFER to 0 seems to be enough. Binding GL_ARRAY_BUFFER/GL_ELEMENT_ARRAY_BUFFER to 0 seems to be enough.
@ -194,8 +179,8 @@ quint32 QskTextureRenderer::createPaintedTextureGL(
return qskTakeTexture( fbo ); return qskTakeTexture( fbo );
} }
static QSGTexture* qskCreateTextureRaster( QQuickWindow* window, QSGTexture* QskTextureRenderer::createTextureRaster( QQuickWindow* window,
const QSize& size, QskTextureRenderer::PaintHelper* helper ) const QSize& size, PaintHelper* helper )
{ {
const auto ratio = window ? window->effectiveDevicePixelRatio() : 1.0; const auto ratio = window ? window->effectiveDevicePixelRatio() : 1.0;
@ -216,24 +201,3 @@ static QSGTexture* qskCreateTextureRaster( QQuickWindow* window,
return window->createTextureFromImage( image, QQuickWindow::TextureHasAlphaChannel ); return window->createTextureFromImage( image, QQuickWindow::TextureHasAlphaChannel );
} }
QSGTexture* QskTextureRenderer::createPaintedTexture(
QQuickWindow* window, const QSize& size, PaintHelper* helper )
{
if ( isOpenGLWindow( window ) )
{
const auto textureId = createPaintedTextureGL( window, size, helper );
auto texture = new QSGPlainTexture;
texture->setHasAlphaChannel( true );
texture->setOwnsTexture( true );
setTextureId( window, textureId, size, texture );
return texture;
}
else
{
return qskCreateTextureRaster( window, size, helper );
}
}

View File

@ -27,16 +27,11 @@ namespace QskTextureRenderer
Q_DISABLE_COPY( PaintHelper ) Q_DISABLE_COPY( PaintHelper )
}; };
bool isOpenGLWindow( const QQuickWindow* );
void setTextureId( QQuickWindow*, void setTextureId( QQuickWindow*,
quint32 textureId, const QSize&, QSGTexture* ); quint32 textureId, const QSize&, QSGTexture* );
quint32 createPaintedTextureGL( quint32 createTextureGL( QQuickWindow*, const QSize&, PaintHelper* );
QQuickWindow*, const QSize&, QskTextureRenderer::PaintHelper* ); QSGTexture* createTextureRaster( QQuickWindow*, const QSize&, PaintHelper* );
QSK_EXPORT QSGTexture* createPaintedTexture(
QQuickWindow* window, const QSize& size, PaintHelper* helper );
} }
#endif #endif

View File

@ -21,51 +21,87 @@
#include <QPainterPath> #include <QPainterPath>
#include <QDebug> #include <QDebug>
enum Options
{
ViewBox = 1 << 0,
Antialiasing = 1 << 1
};
static void usage( const char* appName ) static void usage( const char* appName )
{ {
qWarning() << "usage: " << appName << "<fontfile> <glyphindex> <qvgfile>"; qWarning() << "usage: " << appName << "<fontfile> <pixelsize> <glyphindex> <qvgfile>";
}
static QPainterPath glyphPath( const QRawFont& font,
const qreal pixelSize, const uint glyphIndex )
{
auto path = font.pathForGlyph( glyphIndex );
path = path.simplified();
path = path.translated( 0.0, pixelSize );
return path;
}
static QskGraphic icon( const QPainterPath& path,
const qreal pixelSize, const int options )
{
QskGraphic graphic;
if ( options & ViewBox )
graphic.setViewBox( QRectF( 0.0, 0.0, pixelSize, pixelSize ) );
QPainter painter( &graphic );
if ( options & Antialiasing )
painter.setRenderHint( QPainter::Antialiasing, true );
painter.fillPath( path, Qt::black );
return graphic;
} }
int main( int argc, char* argv[] ) int main( int argc, char* argv[] )
{ {
if ( argc != 4 ) QGuiApplication app( argc, argv );
if ( argc != 5 )
{ {
usage( argv[0] ); usage( argv[0] );
return -1; return -1;
} }
QGuiApplication app( argc, argv ); bool ok;
QRawFont font( QString( argv[1] ), 16 ); const auto pixelSize = QString( argv[2] ).toDouble( &ok );
if ( !ok || ( pixelSize <= 0 ) )
{
qWarning() << "invalid pixel size:" << argv[2];
return -3;
}
const auto glyphIndex = QString( argv[3] ).toUInt( &ok );
if ( !ok )
{
qWarning() << "invalid glyph index:" << argv[3];
return -3;
}
QRawFont font( QString( argv[1] ), pixelSize );
if ( !font.isValid() ) if ( !font.isValid() )
{ {
qWarning() << "invalid font name:" << argv[1]; qWarning() << "invalid font name:" << argv[1];
return -2; return -2;
} }
bool ok; const auto path = glyphPath( font, pixelSize, glyphIndex );
const auto glyphIndex = QString( argv[2] ).toUInt( &ok );
if ( !ok )
{
qWarning() << "invalid glyph index:" << argv[2];
return -3;
}
const auto path = font.pathForGlyph( glyphIndex );
if ( path.isEmpty() ) if ( path.isEmpty() )
{ {
qWarning() << "no glyph for index:" << argv[2]; qWarning() << "no glyph for index:" << argv[3];
return -3; return -3;
} }
QskGraphic graphic; const auto graphic = icon( path, pixelSize, ViewBox | Antialiasing );
QskGraphicIO::write( graphic, argv[4] );
QPainter painter( &graphic );
painter.setRenderHint( QPainter::Antialiasing, true );
painter.fillPath( path, Qt::black );
QskGraphicIO::write( graphic, argv[3] );
return 0; return 0;
} }

View File

@ -41,6 +41,28 @@ static QRectF viewBox( QSvgRenderer& renderer )
return hasViewBox ? viewBox : QRectF( 0.0, 0.0, -1.0, -1.0 ); return hasViewBox ? viewBox : QRectF( 0.0, 0.0, -1.0, -1.0 );
} }
class Graphic : public QskGraphic
{
protected:
void addCommand( const QskPainterCommand& cmd ) override
{
#if 0
if ( cmd.type() == QskPainterCommand::State )
{
/*
QSvgRenderer enables QPainter::Antialiasing initially
However this is something we might want to decide,
when replaying the commands.
*/
auto sd = const_cast< QskPainterCommand::StateData* >( cmd.stateData() );
sd->renderHints &= ~QPainter::Antialiasing;
}
#endif
QskGraphic::addCommand( cmd );
}
};
int main( int argc, char* argv[] ) int main( int argc, char* argv[] )
{ {
if ( argc != 3 ) if ( argc != 3 )
@ -71,7 +93,7 @@ int main( int argc, char* argv[] )
if ( !renderer.load( QString( argv[1] ) ) ) if ( !renderer.load( QString( argv[1] ) ) )
return -2; return -2;
QskGraphic graphic; Graphic graphic;
graphic.setViewBox( ::viewBox( renderer ) ); graphic.setViewBox( ::viewBox( renderer ) );
QPainter painter( &graphic ); QPainter painter( &graphic );