Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
proview
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Esteban Blanc
proview
Commits
fbcea5c4
Commit
fbcea5c4
authored
Aug 30, 2018
by
Christoffer Ackelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
QT: Simplified font functions
parent
d29f44c3
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
210 deletions
+57
-210
xtt/lib/flow/qt/flow_draw_qt.cqt
xtt/lib/flow/qt/flow_draw_qt.cqt
+17
-56
xtt/lib/flow/qt/flow_draw_qt.h
xtt/lib/flow/qt/flow_draw_qt.h
+0
-2
xtt/lib/glow/qt/glow_draw_qt.cqt
xtt/lib/glow/qt/glow_draw_qt.cqt
+40
-150
xtt/lib/glow/qt/glow_draw_qt.h
xtt/lib/glow/qt/glow_draw_qt.h
+0
-2
No files found.
xtt/lib/flow/qt/flow_draw_qt.cqt
View file @
fbcea5c4
...
...
@@ -71,26 +71,6 @@ typedef struct {
QPixmap pixmap[DRAW_PIXMAP_SIZE];
} draw_sPixmap;
static char font_names[draw_eFont__][DRAW_FONT_SIZE][80]
= { { "-*-Helvetica-Bold-R-Normal--8-*-*-*-P-*-ISO8859-1",
"-*-Helvetica-Bold-R-Normal--10-*-*-*-P-*-ISO8859-1",
"-*-Helvetica-Bold-R-Normal--12-*-*-*-P-*-ISO8859-1",
"-*-Helvetica-Bold-R-Normal--14-*-*-*-P-*-ISO8859-1",
"-*-Helvetica-Bold-R-Normal--14-*-*-*-P-*-ISO8859-1",
"-*-Helvetica-Bold-R-Normal--18-*-*-*-P-*-ISO8859-1",
"-*-Helvetica-Bold-R-Normal--18-*-*-*-P-*-ISO8859-1",
"-*-Helvetica-Bold-R-Normal--18-*-*-*-P-*-ISO8859-1",
"-*-Helvetica-Bold-R-Normal--24-*-*-*-P-*-ISO8859-1" },
{ "-*-Helvetica-Medium-R-Normal--8-*-*-*-P-*-ISO8859-1",
"-*-Helvetica-Medium-R-Normal--10-*-*-*-P-*-ISO8859-1",
"-*-Helvetica-Medium-R-Normal--12-*-*-*-P-*-ISO8859-1",
"-*-Helvetica-Medium-R-Normal--14-*-*-*-P-*-ISO8859-1",
"-*-Helvetica-Medium-R-Normal--14-*-*-*-P-*-ISO8859-1",
"-*-Helvetica-Medium-R-Normal--18-*-*-*-P-*-ISO8859-1",
"-*-Helvetica-Medium-R-Normal--18-*-*-*-P-*-ISO8859-1",
"-*-Helvetica-Medium-R-Normal--18-*-*-*-P-*-ISO8859-1",
"-*-Helvetica-Medium-R-Normal--24-*-*-*-P-*-ISO8859-1" } };
static QMouseEvent* last_event;
static QWidget* last_target;
...
...
@@ -125,6 +105,19 @@ static QColor draw_type_to_color(FlowDrawQt* draw_ctx, int painter_type)
}
}
#define FONT_SCALE 0.7
static QFont get_font(int painter_type, double size, const char* fontstr = "Lucida Sans")
{
QFont res(fontstr);
res.setPointSizeF(size);
if (painter_type == flow_eDrawType_TextHelveticaBold
|| painter_type == flow_eDrawType_TextHelveticaEraseBold) {
res.setBold(true);
}
return res;
}
static QPainter* get_painter(
QPaintDevice* window, FlowDrawQt* draw_ctx, int painter_type, int size)
{
...
...
@@ -148,13 +141,8 @@ static QPainter* get_painter(
painter->setBrush(QBrush(draw_type_to_color(draw_ctx, painter_type)));
painter->setPen(QPen(painter->brush(), size + 1));
painter->setBackground(QBrush(draw_ctx->background));
QFont font = QFont("Helvetica");
if (painter_type == flow_eDrawType_TextHelveticaBold
|| painter_type == flow_eDrawType_TextHelveticaEraseBold) {
font.setBold(true);
}
font.setPixelSize(size);
painter->setFont(font);
int sizes[9] = {8, 10, 12, 14, 14, 18, 18, 18, 24};
painter->setFont(get_font(painter_type, sizes[size], "Helvetica"));
return painter;
}
case flow_eDrawType_Green:
...
...
@@ -1196,20 +1184,6 @@ int FlowDrawQt::nav_line_erase(
return line_helper(ctx, flow_eDrawType_LineErase, idx, x1, y1, x2, y2, true);
}
#define FONTSTR "Lucida Sans"
#define FONT_SCALE 0.7
static QFont font(flow_eDrawType painter_type, double size)
{
QFont res(FONTSTR);
res.setPointSizeF(FONT_SCALE * size);
if (painter_type == flow_eDrawType_TextHelveticaBold
|| painter_type == flow_eDrawType_TextHelveticaEraseBold) {
res.setWeight(QFont::Bold);
}
return res;
}
int FlowDrawQt::text_pango_helper(FlowCtx* ctx, int x, int y, char* text,
int len, flow_eDrawType painter_type, int idx, double size, int dimmed,
int erase_rect)
...
...
@@ -1231,7 +1205,7 @@ int FlowDrawQt::text_pango_helper(FlowCtx* ctx, int x, int y, char* text,
str = QString::fromUtf8(text);
}
painter->setFont(
font(painter_type,
size));
painter->setFont(
get_font(painter_type, FONT_SCALE *
size));
QRect rect = painter->fontMetrics().boundingRect(str);
int height = rect.height();
...
...
@@ -1311,10 +1285,7 @@ int FlowDrawQt::nav_text_helper(FlowCtx* ctx, flow_eDrawType painter_type,
return 1;
}
int font_idx = get_font_idx(painter_type);
QPainter* painter = get_painter(painter_type, size, true);
painter->setFont(QFont(font_names[font_idx][size]));
// debug_print("drawText %s at (%d, %d)\n", text, x, y);
painter->drawText(x, y, QString::fromLocal8Bit(text, len));
...
...
@@ -1699,7 +1670,7 @@ int FlowDrawQt::get_text_extent_pango(FlowCtx* ctx, const char* text, int len,
str = QString::fromUtf8(text);
}
painter->setFont(
font(painter_type,
size));
painter->setFont(
get_font(painter_type, FONT_SCALE *
size));
QRect boundingRect = painter->fontMetrics().boundingRect(str);
...
...
@@ -1813,16 +1784,6 @@ void FlowDrawQt::set_white_background(FlowCtx* ctx)
toplevel->setPalette(pal);
}
int FlowDrawQt::get_font_idx(int painter_type)
{
if (painter_type == flow_eDrawType_TextHelveticaBold
|| painter_type == flow_eDrawType_TextHelveticaEraseBold) {
return draw_eFont_HelveticaBold;
} else {
return draw_eFont_Helvetica;
}
}
int FlowDrawQt::image_get_width(flow_tImImage image)
{
return ((QImage*)image)->width();
...
...
xtt/lib/flow/qt/flow_draw_qt.h
View file @
fbcea5c4
...
...
@@ -211,8 +211,6 @@ public:
void
set_white_background
(
FlowCtx
*
ctx
);
int
get_font_idx
(
int
gc_type
);
int
image_get_width
(
flow_tImImage
image
);
int
image_get_height
(
flow_tImImage
image
);
void
image_scale
(
float
scale
,
flow_tImImage
orig_im
,
flow_tImImage
*
im
,
...
...
xtt/lib/glow/qt/glow_draw_qt.cqt
View file @
fbcea5c4
This diff is collapsed.
Click to expand it.
xtt/lib/glow/qt/glow_draw_qt.h
View file @
fbcea5c4
...
...
@@ -200,8 +200,6 @@ public:
QPoint
*
points_to_qt_points
(
glow_sPointX
*
points
,
int
point_cnt
);
QPoint
*
points_to_qt_points_curve
(
GlowWind
*
w
,
glow_sPointX
*
points
,
int
point_cnt
,
int
*
cnt
);
int
get_font_type
(
int
painter_type
);
void
load_font
(
glow_eFont
font_idx
,
int
font_type
,
int
idx
);
int
image_get_width
(
glow_tImImage
image
);
int
image_get_height
(
glow_tImImage
image
);
int
image_get_rowstride
(
glow_tImImage
image
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment