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
Hide 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 {
...
@@ -71,26 +71,6 @@ typedef struct {
QPixmap pixmap[DRAW_PIXMAP_SIZE];
QPixmap pixmap[DRAW_PIXMAP_SIZE];
} draw_sPixmap;
} 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 QMouseEvent* last_event;
static QWidget* last_target;
static QWidget* last_target;
...
@@ -125,6 +105,19 @@ static QColor draw_type_to_color(FlowDrawQt* draw_ctx, int painter_type)
...
@@ -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(
static QPainter* get_painter(
QPaintDevice* window, FlowDrawQt* draw_ctx, int painter_type, int size)
QPaintDevice* window, FlowDrawQt* draw_ctx, int painter_type, int size)
{
{
...
@@ -148,13 +141,8 @@ static QPainter* get_painter(
...
@@ -148,13 +141,8 @@ static QPainter* get_painter(
painter->setBrush(QBrush(draw_type_to_color(draw_ctx, painter_type)));
painter->setBrush(QBrush(draw_type_to_color(draw_ctx, painter_type)));
painter->setPen(QPen(painter->brush(), size + 1));
painter->setPen(QPen(painter->brush(), size + 1));
painter->setBackground(QBrush(draw_ctx->background));
painter->setBackground(QBrush(draw_ctx->background));
QFont font = QFont("Helvetica");
int sizes[9] = {8, 10, 12, 14, 14, 18, 18, 18, 24};
if (painter_type == flow_eDrawType_TextHelveticaBold
painter->setFont(get_font(painter_type, sizes[size], "Helvetica"));
|| painter_type == flow_eDrawType_TextHelveticaEraseBold) {
font.setBold(true);
}
font.setPixelSize(size);
painter->setFont(font);
return painter;
return painter;
}
}
case flow_eDrawType_Green:
case flow_eDrawType_Green:
...
@@ -1196,20 +1184,6 @@ int FlowDrawQt::nav_line_erase(
...
@@ -1196,20 +1184,6 @@ int FlowDrawQt::nav_line_erase(
return line_helper(ctx, flow_eDrawType_LineErase, idx, x1, y1, x2, y2, true);
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 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 len, flow_eDrawType painter_type, int idx, double size, int dimmed,
int erase_rect)
int erase_rect)
...
@@ -1231,7 +1205,7 @@ int FlowDrawQt::text_pango_helper(FlowCtx* ctx, int x, int y, char* text,
...
@@ -1231,7 +1205,7 @@ int FlowDrawQt::text_pango_helper(FlowCtx* ctx, int x, int y, char* text,
str = QString::fromUtf8(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);
QRect rect = painter->fontMetrics().boundingRect(str);
int height = rect.height();
int height = rect.height();
...
@@ -1311,10 +1285,7 @@ int FlowDrawQt::nav_text_helper(FlowCtx* ctx, flow_eDrawType painter_type,
...
@@ -1311,10 +1285,7 @@ int FlowDrawQt::nav_text_helper(FlowCtx* ctx, flow_eDrawType painter_type,
return 1;
return 1;
}
}
int font_idx = get_font_idx(painter_type);
QPainter* painter = get_painter(painter_type, size, true);
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);
// debug_print("drawText %s at (%d, %d)\n", text, x, y);
painter->drawText(x, y, QString::fromLocal8Bit(text, len));
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,
...
@@ -1699,7 +1670,7 @@ int FlowDrawQt::get_text_extent_pango(FlowCtx* ctx, const char* text, int len,
str = QString::fromUtf8(text);
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);
QRect boundingRect = painter->fontMetrics().boundingRect(str);
...
@@ -1813,16 +1784,6 @@ void FlowDrawQt::set_white_background(FlowCtx* ctx)
...
@@ -1813,16 +1784,6 @@ void FlowDrawQt::set_white_background(FlowCtx* ctx)
toplevel->setPalette(pal);
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)
int FlowDrawQt::image_get_width(flow_tImImage image)
{
{
return ((QImage*)image)->width();
return ((QImage*)image)->width();
...
...
xtt/lib/flow/qt/flow_draw_qt.h
View file @
fbcea5c4
...
@@ -211,8 +211,6 @@ public:
...
@@ -211,8 +211,6 @@ public:
void
set_white_background
(
FlowCtx
*
ctx
);
void
set_white_background
(
FlowCtx
*
ctx
);
int
get_font_idx
(
int
gc_type
);
int
image_get_width
(
flow_tImImage
image
);
int
image_get_width
(
flow_tImImage
image
);
int
image_get_height
(
flow_tImImage
image
);
int
image_get_height
(
flow_tImImage
image
);
void
image_scale
(
float
scale
,
flow_tImImage
orig_im
,
flow_tImImage
*
im
,
void
image_scale
(
float
scale
,
flow_tImImage
orig_im
,
flow_tImImage
*
im
,
...
...
xtt/lib/glow/qt/glow_draw_qt.cqt
View file @
fbcea5c4
...
@@ -65,82 +65,6 @@
...
@@ -65,82 +65,6 @@
#define DRAW_PRESS_PIX 9
#define DRAW_PRESS_PIX 9
static char font_names[glow_eFont__][glow_eDrawFont__][DRAW_FONT_SIZE][80] = {
{ { "-*-Helvetica-Medium-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" } },
{ { "-*-times-Medium-R-Normal--8-*-*-*-*-*-ISO8859-1",
"-*-times-Bold-R-Normal--10-*-*-*-*-*-ISO8859-1",
"-*-times-Bold-R-Normal--12-*-*-*-*-*-ISO8859-1",
"-*-times-Bold-R-Normal--14-*-*-*-*-*-ISO8859-1",
"-*-times-Bold-R-Normal--14-*-*-*-*-*-ISO8859-1",
"-*-times-Bold-R-Normal--18-*-*-*-*-*-ISO8859-1",
"-*-times-Bold-R-Normal--18-*-*-*-*-*-ISO8859-1",
"-*-times-Bold-R-Normal--18-*-*-*-*-*-ISO8859-1",
"-*-times-Bold-R-Normal--24-*-*-*-*-*-ISO8859-1" },
{ "-*-times-Medium-R-Normal--8-*-*-*-*-*-ISO8859-1",
"-*-times-Medium-R-Normal--10-*-*-*-*-*-ISO8859-1",
"-*-times-Medium-R-Normal--12-*-*-*-*-*-ISO8859-1",
"-*-times-Medium-R-Normal--14-*-*-*-*-*-ISO8859-1",
"-*-times-Medium-R-Normal--14-*-*-*-*-*-ISO8859-1",
"-*-times-Medium-R-Normal--18-*-*-*-*-*-ISO8859-1",
"-*-times-Medium-R-Normal--18-*-*-*-*-*-ISO8859-1",
"-*-times-Medium-R-Normal--18-*-*-*-*-*-ISO8859-1",
"-*-times-Medium-R-Normal--24-*-*-*-*-*-ISO8859-1" } },
{ { "-*-new century schoolbook-Medium-R-Normal--8-*-*-*-*-*-ISO8859-1",
"-*-new century schoolbook-Bold-R-Normal--10-*-*-*-*-*-ISO8859-1",
"-*-new century schoolbook-Bold-R-Normal--12-*-*-*-*-*-ISO8859-1",
"-*-new century schoolbook-Bold-R-Normal--14-*-*-*-*-*-ISO8859-1",
"-*-new century schoolbook-Bold-R-Normal--14-*-*-*-*-*-ISO8859-1",
"-*-new century schoolbook-Bold-R-Normal--18-*-*-*-*-*-ISO8859-1",
"-*-new century schoolbook-Bold-R-Normal--18-*-*-*-*-*-ISO8859-1",
"-*-new century schoolbook-Bold-R-Normal--18-*-*-*-*-*-ISO8859-1",
"-*-new century schoolbook-Bold-R-Normal--24-*-*-*-*-*-ISO8859-1" },
{ "-*-new century schoolbook-Medium-R-Normal--8-*-*-*-*-*-ISO8859-1",
"-*-new century schoolbook-Medium-R-Normal--10-*-*-*-*-*-ISO8859-1",
"-*-new century schoolbook-Medium-R-Normal--12-*-*-*-*-*-ISO8859-1",
"-*-new century schoolbook-Medium-R-Normal--14-*-*-*-*-*-ISO8859-1",
"-*-new century schoolbook-Medium-R-Normal--14-*-*-*-*-*-ISO8859-1",
"-*-new century schoolbook-Medium-R-Normal--18-*-*-*-*-*-ISO8859-1",
"-*-new century schoolbook-Medium-R-Normal--18-*-*-*-*-*-ISO8859-1",
"-*-new century schoolbook-Medium-R-Normal--18-*-*-*-*-*-ISO8859-1",
"-*-new century "
"schoolbook-Medium-R-Normal--24-*-*-*-*-*-ISO8859-1" } },
{ { "-*-courier-Medium-R-Normal--8-*-*-*-m-*-ISO8859-1",
"-*-courier-Bold-R-Normal--10-*-*-*-m-*-ISO8859-1",
"-*-courier-Bold-R-Normal--12-*-*-*-m-*-ISO8859-1",
"-*-courier-Bold-R-Normal--14-*-*-*-m-*-ISO8859-1",
"-*-courier-Bold-R-Normal--14-*-*-*-m-*-ISO8859-1",
"-*-courier-Bold-R-Normal--18-*-*-*-m-*-ISO8859-1",
"-*-courier-Bold-R-Normal--18-*-*-*-m-*-ISO8859-1",
"-*-courier-Bold-R-Normal--18-*-*-*-m-*-ISO8859-1",
"-*-courier-Bold-R-Normal--24-*-*-*-m-*-ISO8859-1" },
{ "-*-courier-Medium-R-Normal--8-*-*-*-m-*-ISO8859-1",
"-*-courier-Medium-R-Normal--10-*-*-*-m-*-ISO8859-1",
"-*-courier-Medium-R-Normal--12-*-*-*-m-*-ISO8859-1",
"-*-courier-Medium-R-Normal--14-*-*-*-m-*-ISO8859-1",
"-*-courier-Medium-R-Normal--14-*-*-*-m-*-ISO8859-1",
"-*-courier-Medium-R-Normal--18-*-*-*-m-*-ISO8859-1",
"-*-courier-Medium-R-Normal--18-*-*-*-m-*-ISO8859-1",
"-*-courier-Medium-R-Normal--18-*-*-*-m-*-ISO8859-1",
"-*-courier-Medium-R-Normal--24-*-*-*-m-*-ISO8859-1" } }
};
static QMouseEvent* last_event;
static QMouseEvent* last_event;
static QWidget* last_target;
static QWidget* last_target;
...
@@ -204,6 +128,38 @@ static QColor draw_type_to_color(
...
@@ -204,6 +128,38 @@ static QColor draw_type_to_color(
}
}
}
}
#define FONT_SCALE 0.7
#define FONT_DESCENT 0.22
static QFont get_font(int font_idx, int painter_type, double size)
{
QFont res;
switch (font_idx) {
case glow_eFont_Helvetica:
res = QFont("Helvetica");
break;
case glow_eFont_Times:
res = QFont("Times");
break;
case glow_eFont_NewCenturySchoolbook:
res = QFont("Century Schoolbook L");
break;
case glow_eFont_Courier:
res = QFont("Courier 10 pitch");
break;
default:
res = QFont("Lucida Sans");
break;
}
res.setPointSizeF(FONT_SCALE * size);
if (painter_type == glow_eDrawType_TextHelveticaBold || painter_type == glow_eDrawType_TextHelveticaEraseBold) {
res.setBold(true);
}
return res;
}
static QPainter* get_painter(
static QPainter* get_painter(
QPaintDevice* window, GlowDrawQt* draw_ctx, int painter_type, int size)
QPaintDevice* window, GlowDrawQt* draw_ctx, int painter_type, int size)
{
{
...
@@ -228,13 +184,7 @@ static QPainter* get_painter(
...
@@ -228,13 +184,7 @@ static QPainter* get_painter(
painter->setPen(QPen(painter->brush(), size + 1));
painter->setPen(QPen(painter->brush(), size + 1));
painter->setBackground(QBrush(draw_ctx->background));
painter->setBackground(QBrush(draw_ctx->background));
if (size > 0) {
if (size > 0) {
QFont font = QFont("Helvetica");
painter->setFont(get_font(glow_eFont_Helvetica, painter_type, size));
if (painter_type == glow_eDrawType_TextHelveticaBold
|| painter_type == glow_eDrawType_TextHelveticaEraseBold) {
font.setBold(true);
}
font.setPixelSize(size);
painter->setFont(font);
}
}
return painter;
return painter;
}
}
...
@@ -1325,10 +1275,8 @@ int GlowDrawQt::text(GlowWind* wind, int x, int y, char* text, int len,
...
@@ -1325,10 +1275,8 @@ int GlowDrawQt::text(GlowWind* wind, int x, int y, char* text, int len,
set_clip(w, painter);
set_clip(w, painter);
}
}
int font_type = get_font_type(painter_type);
if (font_idx != glow_eFont_Helvetica) {
if (font_idx != glow_eFont_Helvetica) {
painter->setFont(
QFont(font_names[font_idx][font_type][idx]
));
painter->setFont(
get_font(font_idx, painter_type, idx
));
}
}
if (color != glow_eDrawType_Line) {
if (color != glow_eDrawType_Line) {
...
@@ -1336,7 +1284,6 @@ int GlowDrawQt::text(GlowWind* wind, int x, int y, char* text, int len,
...
@@ -1336,7 +1284,6 @@ int GlowDrawQt::text(GlowWind* wind, int x, int y, char* text, int len,
painter->setPen(QPen(painter->brush(), size + 1));
painter->setPen(QPen(painter->brush(), size + 1));
}
}
painter->setFont(QFont(font_names[font_idx][font_type][idx]));
QRect rect
QRect rect
= painter->fontMetrics().boundingRect(QString::fromLocal8Bit(text, len));
= painter->fontMetrics().boundingRect(QString::fromLocal8Bit(text, len));
painter->drawText(x, y, rect.width(), rect.height(), Qt::TextDontClip,
painter->drawText(x, y, rect.width(), rect.height(), Qt::TextDontClip,
...
@@ -1403,19 +1350,16 @@ int GlowDrawQt::text_erase(GlowWind* wind, int x, int y, char* text, int len,
...
@@ -1403,19 +1350,16 @@ int GlowDrawQt::text_erase(GlowWind* wind, int x, int y, char* text, int len,
painter_type = glow_eDrawType_TextHelveticaEraseBold;
painter_type = glow_eDrawType_TextHelveticaEraseBold;
}
}
int font_type = get_font_type(painter_type);
QPainter* painter = get_painter(w->buffer, this, painter_type, idx);
QPainter* painter = get_painter(w->buffer, this, painter_type, idx);
if (font_idx != glow_eFont_Helvetica) {
if (font_idx != glow_eFont_Helvetica) {
painter->setFont(
QFont(font_names[font_idx][font_type][idx]
));
painter->setFont(
get_font(font_idx, painter_type, idx
));
}
}
if (w->clip_on) {
if (w->clip_on) {
set_clip(w, painter);
set_clip(w, painter);
}
}
painter->setFont(QFont(font_names[font_idx][font_type][idx]));
QRect rect
QRect rect
= painter->fontMetrics().boundingRect(QString::fromLocal8Bit(text, len));
= painter->fontMetrics().boundingRect(QString::fromLocal8Bit(text, len));
painter->drawText(x, y, rect.width(), rect.height(), Qt::TextDontClip,
painter->drawText(x, y, rect.width(), rect.height(), Qt::TextDontClip,
...
@@ -1684,10 +1628,9 @@ int GlowDrawQt::get_text_extent(const char* text, int len,
...
@@ -1684,10 +1628,9 @@ int GlowDrawQt::get_text_extent(const char* text, int len,
font_idx = glow_eFont_Helvetica;
font_idx = glow_eFont_Helvetica;
}
}
int font_type = get_font_type(painter_type
);
QFont font = get_font(font_idx, painter_type, idx
);
QFontMetrics fontMetrics
QFontMetrics fontMetrics = QFontMetrics(font);
= QFontMetrics(QFont(font_names[font_idx][font_type][idx]));
QRect rect = fontMetrics.boundingRect(QString::fromLocal8Bit(text, len));
QRect rect = fontMetrics.boundingRect(QString::fromLocal8Bit(text, len));
*width = rect.width();
*width = rect.width();
int text_ascent = fontMetrics.ascent();
int text_ascent = fontMetrics.ascent();
...
@@ -2360,23 +2303,6 @@ QPoint* GlowDrawQt::points_to_qt_points_curve(
...
@@ -2360,23 +2303,6 @@ QPoint* GlowDrawQt::points_to_qt_points_curve(
return qpoints;
return qpoints;
}
}
int GlowDrawQt::get_font_type(int painter_type)
{
int font_type;
switch (painter_type) {
case glow_eDrawType_TextHelveticaBold:
case glow_eDrawType_TextHelveticaEraseBold:
font_type = glow_eDrawFont_HelveticaBold;
break;
default:
font_type = glow_eDrawFont_Helvetica;
break;
}
return font_type;
}
// Image functions
// Image functions
int GlowDrawQt::image_get_width(glow_tImImage image)
int GlowDrawQt::image_get_width(glow_tImImage image)
{
{
...
@@ -3127,38 +3053,6 @@ int GlowDrawQt::gradient_fill_polyline(GlowWind* wind, glow_sPointX* points,
...
@@ -3127,38 +3053,6 @@ int GlowDrawQt::gradient_fill_polyline(GlowWind* wind, glow_sPointX* points,
return 1;
return 1;
}
}
#define FONT_SCALE 0.7
#define FONT_DESCENT 0.22
static QFont font(int font_idx, int font_type, double size)
{
QFont res;
switch (font_idx) {
case glow_eFont_Helvetica:
res = QFont("Helvetica");
break;
case glow_eFont_Times:
res = QFont("DejaVu Serif");
break;
case glow_eFont_NewCenturySchoolbook:
res = QFont("Century Schoolbook L");
break;
case glow_eFont_Courier:
res = QFont("Courier 10 pitch");
break;
default:
res = QFont("Lucida Sans");
break;
}
res.setPointSizeF(FONT_SCALE * size);
if (font_type == glow_eDrawFont_HelveticaBold) {
res.setWeight(QFont::Bold);
}
return res;
}
int GlowDrawQt::text_qt(GlowWind* wind, int x, int y, char* text, int len,
int GlowDrawQt::text_qt(GlowWind* wind, int x, int y, char* text, int len,
glow_eDrawType painter_type, glow_eDrawType color, int idx, int highlight,
glow_eDrawType painter_type, glow_eDrawType color, int idx, int highlight,
int line, glow_eFont font_idx, double size, int rot)
int line, glow_eFont font_idx, double size, int rot)
...
@@ -3172,8 +3066,6 @@ int GlowDrawQt::text_qt(GlowWind* wind, int x, int y, char* text, int len,
...
@@ -3172,8 +3066,6 @@ int GlowDrawQt::text_qt(GlowWind* wind, int x, int y, char* text, int len,
font_idx = glow_eFont_Helvetica;
font_idx = glow_eFont_Helvetica;
}
}
int font_type = get_font_type(painter_type);
QPainter* painter = get_painter(w->buffer, this, painter_type, idx);
QPainter* painter = get_painter(w->buffer, this, painter_type, idx);
if (w->clip_on) {
if (w->clip_on) {
...
@@ -3197,7 +3089,7 @@ int GlowDrawQt::text_qt(GlowWind* wind, int x, int y, char* text, int len,
...
@@ -3197,7 +3089,7 @@ int GlowDrawQt::text_qt(GlowWind* wind, int x, int y, char* text, int len,
painter->rotate(rot);
painter->rotate(rot);
}
}
painter->setFont(
font(font_idx, font
_type, size));
painter->setFont(
get_font(font_idx, painter
_type, size));
QRect rect = painter->fontMetrics().boundingRect(str);
QRect rect = painter->fontMetrics().boundingRect(str);
int width = rect.width();
int width = rect.width();
...
@@ -3245,8 +3137,6 @@ int GlowDrawQt::text_erase_qt(GlowWind* wind, int x, int y, char* text, int len,
...
@@ -3245,8 +3137,6 @@ int GlowDrawQt::text_erase_qt(GlowWind* wind, int x, int y, char* text, int len,
painter_type = glow_eDrawType_TextHelveticaEraseBold;
painter_type = glow_eDrawType_TextHelveticaEraseBold;
}
}
int font_type = get_font_type(painter_type);
int width, height;
int width, height;
{
{
...
@@ -3259,7 +3149,7 @@ int GlowDrawQt::text_erase_qt(GlowWind* wind, int x, int y, char* text, int len,
...
@@ -3259,7 +3149,7 @@ int GlowDrawQt::text_erase_qt(GlowWind* wind, int x, int y, char* text, int len,
str = QString::fromUtf8(text);
str = QString::fromUtf8(text);
}
}
painter->setFont(
font(font_idx, font
_type, size));
painter->setFont(
get_font(font_idx, painter
_type, size));
QRect rect = painter->fontMetrics().boundingRect(str);
QRect rect = painter->fontMetrics().boundingRect(str);
width = rect.width();
width = rect.width();
...
@@ -3316,7 +3206,7 @@ int GlowDrawQt::get_text_extent_qt(const char* text, int len,
...
@@ -3316,7 +3206,7 @@ int GlowDrawQt::get_text_extent_qt(const char* text, int len,
}
}
QPainter* painter = get_painter(w->buffer, this, painter_type, 0);
QPainter* painter = get_painter(w->buffer, this, painter_type, 0);
painter->setFont(
font(font_idx, get_font_type(painter_type)
, size));
painter->setFont(
get_font(font_idx, painter_type
, size));
QString str;
QString str;
if (((GrowCtx*)ctx)->text_coding != glow_eTextCoding_UTF_8) {
if (((GrowCtx*)ctx)->text_coding != glow_eTextCoding_UTF_8) {
...
...
xtt/lib/glow/qt/glow_draw_qt.h
View file @
fbcea5c4
...
@@ -200,8 +200,6 @@ public:
...
@@ -200,8 +200,6 @@ public:
QPoint
*
points_to_qt_points
(
glow_sPointX
*
points
,
int
point_cnt
);
QPoint
*
points_to_qt_points
(
glow_sPointX
*
points
,
int
point_cnt
);
QPoint
*
points_to_qt_points_curve
(
QPoint
*
points_to_qt_points_curve
(
GlowWind
*
w
,
glow_sPointX
*
points
,
int
point_cnt
,
int
*
cnt
);
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_width
(
glow_tImImage
image
);
int
image_get_height
(
glow_tImImage
image
);
int
image_get_height
(
glow_tImImage
image
);
int
image_get_rowstride
(
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