Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 13132fc7 authored by Mariusz Glebocki's avatar Mariusz Glebocki

Improve built-in line/block characters drawing

Summary:
* Fix bold lines (BUG 402415).
* Make drawing pixel-perfect.
* Make line width proportional to font size.
* Move relevant code to separate file and namespace.
* Remove code for checking supported line characters from Character
  class. Information about what is supported is now in one place
  together width drawing code.
* Remove fontembedder/LineFont files (no longer used).
* Add test script for displaying supported characters table.
* Add triple and quadruple dashes (U+2504...U+250B).
* Change shade block characters (U+2591...U+2593) look. When
  antialiasing is turned on, shades are drawn as transculent solid
  rectangles with 25%, 50% and 75% alpha. This matches the characters
  name/description and their usage. Without antialiasing, previous
  method with patterns is used.

**Screenshots**

Font size: 10pt; character width: 8px
{F6602823}

Font size: 11pt; character width: 9px
{F6602824}

Font size: 12pt; character width: 10px
{F6602825}

Font size: 13-14pt; character width: 11px; w/o antialiasing
{F6602826}

Font size: 13-14pt; character width: 11px
{F6602827}

Font size: 15pt; character width: 12px
{F6602828}

Font size: 6-7pt; character width: 5px
{F6602829}

Font size: 8-9pt; character width: 7px; w/o antialiasing
{F6602830}

Font size: 8-9pt; character width: 7px
{F6602831}

Alignment test (8pt)
{F6602832}

Note: Copyrights in LineBlockCharactersDrawer.cpp are based on
`git blame -w src/TerminalDisplay.cpp` executed before moving the code
to a separate file. Years from first/last commit. Authors sorted by
year. Whitespace-only changes were ignored. Maksim's code was commited
by Waldo Bastian who mentioned him as the author in commit message
(see 5062b40d).

BUG: 402415

Test Plan:
== Common steps for all tests ==

* Open //Edit Current Profile → Appearance//.
* Turn on //Draw intense colors in bold font//.
* Turn off //Use line characters contained in font//.
* (Optional) select a font which is able to display bold characters in
  Konsole (e.g. DejaVu Sans Mono).

== Check characters validity ==

* Run `./tests/line_block_characters_table.py`.
* Open //Edit Current Profile → Appearance//.
* By switching //Use line characters contained in font// on and off,
  compare built-in characters drawing with characters from a font.
  General shape and line directions must be the same. Small offsets,
  line width differences (as long as proportions between lines in
  a character are kept), and quality differences are allowed.

== Review overall quality ==

* Run `./tests/line_block_characters_table.py`.
* Review glyphs quality in different font sizes.
* Open //Edit Current Profile → Appearance//.
* Toggle //Smooth fonts//, review quality again.

== Check alignment ==

* Display `tests/UTF-8-demo.txt`
* At the bottom of the file you can find a few alignment images. Check
  if all lines align properly. If you're unsure how it should look,
  compare it with font characters by turning on //Use line characters
  contained in font// option.

Reviewers: #konsole, #vdg, fvogt, hindenburg

Reviewed By: #konsole, hindenburg

Subscribers: hindenburg, sandsmark, fvogt, konsole-devel

Tags: #konsole

Differential Revision: https://phabricator.kde.org/D18735
parent 1c8ba770
......@@ -34,8 +34,6 @@ endif()
option(REMOVE_SENDTEXT_RUNCOMMAND_DBUS_METHODS "Konsole: remove sendText and runCommand dbus methods" OFF)
### Development tools
option(KONSOLE_BUILD_FONTEMBEDDER "Konsole: build fontembedder executable" OFF)
option(KONSOLE_GENERATE_LINEFONT "Konsole: regenerate LineFont file" OFF)
option(KONSOLE_BUILD_UNI2CHARACTERWIDTH "Konsole: build uni2characterwidth executable" OFF)
### Konsole source files shared between embedded terminal and main application
......@@ -99,6 +97,7 @@ set(konsoleprivate_SRCS ${sessionadaptors_SRCS}
ExtendedCharTable.cpp
TerminalDisplay.cpp
TerminalDisplayAccessible.cpp
LineBlockCharacters.cpp
ViewContainer.cpp
ViewManager.cpp
ViewProperties.cpp
......
......@@ -53,21 +53,6 @@ const RenditionFlags RE_STRIKEOUT = (1 << 8);
const RenditionFlags RE_CONCEAL = (1 << 9);
const RenditionFlags RE_OVERLINE = (1 << 10);
/**
* Unicode character in the range of U+2500 ~ U+257F are known as line
* characters, or box-drawing characters. Currently, konsole draws those
* characters itself, instead of using the glyph provided by the font.
* Unfortunately, the triple and quadruple dash lines (┄┅┆┇┈┉┊┋) are too
* detailed too be drawn cleanly at normal font scales without anti
* -aliasing, so those are drawn as regular characters.
*/
inline bool isSupportedLineChar(uint codePoint)
{
return ((codePoint & 0xFF80) == 0x2500 // Unicode block: Mathematical Symbols - Box Drawing
&& !(0x2504 <= codePoint && codePoint <= 0x250B)) || // Triple and quadruple dash range
(codePoint >= 0x2580 && codePoint <= 0x259F); // Block characters
}
/**
* A single character in the terminal which consists of a unicode character
* value, foreground and background colors and a set of rendition attributes
......@@ -143,15 +128,6 @@ public:
*/
friend bool operator !=(const Character &a, const Character &b);
inline bool isLineChar() const
{
if (rendition & RE_EXTENDED_CHAR) {
return false;
} else {
return isSupportedLineChar(character);
}
}
inline bool isSpace() const
{
if (rendition & RE_EXTENDED_CHAR) {
......
This diff is collapsed.
/*
This file is part of Konsole, a terminal emulator for KDE.
Copyright 2019 by Mariusz Glebocki <mglb@arccos-1.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
*/
#ifndef LINEBLOCKCHARACTERS_H
#define LINEBLOCKCHARACTERS_H
// Qt
#include <QPainter>
#include <QtGlobal>
namespace Konsole {
/**
* Helper functions for drawing characters from "Box Drawing" and "Block Elements" Unicode blocks.
*/
namespace LineBlockCharacters {
/**
* Returns true if the character can be drawn by draw() function.
*
* @param ucs4cp Character to test's UCS4 code point
*/
inline static bool canDraw(uint ucs4cp) {
return (0x2500 <= ucs4cp && ucs4cp <= 0x259F);
}
/**
* Draws character.
*
* @param paint QPainter to draw on
* @param cellRect Rectangle to draw in
* @param chr Character to be drawn
*/
void draw(QPainter &paint, const QRect &cellRect, const QChar &chr, bool bold);
} // namespace LineBlockCharacters
} // namespace Konsole
#endif // LINEBLOCKCHARACTERS_H
// WARNING: Autogenerated by "fontembedder /Volumes/Projects/KDE/src/kde/applications/konsole/src/LineFont.src".
// You probably do not want to hand-edit this!
static const quint32 LineChars[] = {
0x00007c00, 0x000fffe0, 0x00421084, 0x00e739ce, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00427000, 0x004e7380, 0x00e77800, 0x00ef7bc0,
0x00421c00, 0x00439ce0, 0x00e73c00, 0x00e7bde0, 0x00007084, 0x000e7384, 0x000079ce, 0x000f7bce,
0x00001c84, 0x00039ce4, 0x00003dce, 0x0007bdee, 0x00427084, 0x004e7384, 0x004279ce, 0x00e77884,
0x00e779ce, 0x004f7bce, 0x00ef7bc4, 0x00ef7bce, 0x00421c84, 0x00439ce4, 0x00423dce, 0x00e73c84,
0x00e73dce, 0x0047bdee, 0x00e7bde4, 0x00e7bdee, 0x00427c00, 0x0043fce0, 0x004e7f80, 0x004fffe0,
0x00e77c00, 0x00e7fde0, 0x00ef7fc0, 0x00efffe0, 0x00007c84, 0x0003fce4, 0x000e7f84, 0x000fffe4,
0x00007dce, 0x0007fdee, 0x000f7fce, 0x000fffee, 0x00427c84, 0x0043fce4, 0x004e7f84, 0x004fffe4,
0x00427dce, 0x00e77c84, 0x00e77dce, 0x0047fdee, 0x004f7fce, 0x00e7fde4, 0x00ef7fc4, 0x004fffee,
0x00efffe4, 0x00e7fdee, 0x00ef7fce, 0x00efffee, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x000f83e0, 0x00a5294a, 0x004e1380, 0x00a57800, 0x00ad0bc0, 0x004390e0, 0x00a53c00, 0x00a5a1e0,
0x000e1384, 0x0000794a, 0x000f0b4a, 0x000390e4, 0x00003d4a, 0x0007a16a, 0x004e1384, 0x00a5694a,
0x00ad0b4a, 0x004390e4, 0x00a52d4a, 0x00a5a16a, 0x004f83e0, 0x00a57c00, 0x00ad83e0, 0x000f83e4,
0x00007d4a, 0x000f836a, 0x004f93e4, 0x00a57d4a, 0x00ad836a, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00001c00, 0x00001084, 0x00007000, 0x00421000,
0x00039ce0, 0x000039ce, 0x000e7380, 0x00e73800, 0x000e7f80, 0x00e73884, 0x0003fce0, 0x004239ce
};
#2500: single horizontal line
2500
-----
#2501: triple horizontal line
2501
-----
-----
-----
#2502: single vertical line
2502
|
|
|
|
|
#2503: triple vertical line
2503
|||
|||
|||
|||
|||
#2504-250B are dashed - not handled
#250C: top-left corner (lines on bottom + right)
250C
.--
|
|
#250D: as above, but top line triple-width
250D
.--
.--
|--
|
#250E: now the vert line triple-width
250E
..--
|||
|||
#250F: and now both lines triple-width
250F
.___
|.--
||._
|||
#2510: top-right corner
2510
--.
|
|
2511
==.
==.
==|
|
2512
==..
|||
|||
2513
===.
==.|
=.||
|||
#2514: bottom-left corner
2514
|
|
.==
2515
|
|==
|==
===
2516
|||
|||
|.==
2517
|||
||.=
|.==
.===
#2518: bottm-right corner
2518
|
|
==.
2519
|
==|
==|
===
251A
|||
|||
====
251B
|||
=.||
==.|
===.
#251C: Join of vertical line and one from the right
251C
|
|
|==
|
|
251D
|
|==
|==
|==
|
251E
|||
|||
||==
|
|
251F
|
|
||==
|||
|||
2520
|||
|||
||==
|||
|||
2521
|||
|||=
||==
.|==
|
2522
|
.|==
||==
|||=
|||
2523
|||
||.=
||==
||.=
|||
#2524: Join of vertical line and one from the left
2524
|
|
==|
|
|
2525
|
==|
==|
==|
|
2526
|||
|||
==+|
|
|
2527
|
|
==+|
|||
|||
2528
|||
|||
==+|
|||
|||
2529
|||
=+||
==+|
===+
|
252A
|
=+||
==+|
===+
|||
252B
|||
=+||
==+|
=+||
|||
#252C: horizontal line joined to from below
252C
=====
|
|
252D
===
==|==
==|
|
252E
===
==|==
|==
|
252F
==+==
==|==
==|==
|
2530
=====
|||
|||
2531
===|
==||=
=|||
|||
2532
|===
=||==
||==
|||
2533
=====
==|==
=+|+=
|||
#2534: bottom line, connected to from top
2534
|
|
=====
2535
|
==|
=====
===
2536
|
|==
=====
===
2537
|
==|==
=====
=====
2538
|||
|||
=====
2539
|||
==||
=====
===|
253A
|||
||==
=|===
|===
253B
|||
==|==
=====
=====
#253C: vertical + horizontal lines intersecting
253C
|
|
=====
|
|
253D
|
==|
=====
==|
|
253E
|
|==
=====
|==
|
253F
|
==|==
=====
==|==
|
2540
|||
|||
=====
|
|
2541
|
|
=====
|||
|||
2542
|||
|||
=====
|||
|||
2543
|||
=|||
=====
==|+
|
2544
|||
||==
=====
||==
|
2545
|
==|+
=====
=|||
|||
2546
|
||==
=====
||==
|||
2547
|||
=|||=
=====
=|||=
|
2548
|
=|||=
=====
=|||=
|||
2549
|||
=|||
=====
=|||
|||
254A
|||
|||=
=====
|||=
|||
254B
|||
=|||=
=====
=|||=
|||
#254C-254F are dashed
2550
_____
_____
2551
| |
| |
| |
| |
| |
2552
|--
|
|--
|
2553
----
| |
| |
2554
+---
|
+ +-
| |
2555
--+
|
--+
|
2556
-+-+
| |
| |
2557
---+
|
-+ |
| |
2558
|
+--
|
+--
2559
| |
| |
+-+-
255A
| |
| +-
|
+---
255B
|
--+
|
--+
255C
| |
| |
-+-+
255D
| |
-+ |
|
---+
255E
|