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
062e4174
Commit
062e4174
authored
Aug 15, 2018
by
Christoffer Ackelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
QT: Fixed setting font from font string
parent
0e6c4ce7
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
41 deletions
+24
-41
xtt/lib/flow/qt/flow_draw_qt.cqt
xtt/lib/flow/qt/flow_draw_qt.cqt
+8
-17
xtt/lib/glow/qt/glow_draw_qt.cqt
xtt/lib/glow/qt/glow_draw_qt.cqt
+16
-24
No files found.
xtt/lib/flow/qt/flow_draw_qt.cqt
View file @
062e4174
...
...
@@ -1221,23 +1221,14 @@ int FlowDrawQt::nav_line_erase(
#define FONTSTR "Lucida Sans"
#define FONT_SCALE 0.7
static
char* font_string
(flow_eDrawType painter_type, double size)
static
QFont font
(flow_eDrawType painter_type, double size)
{
static char str[80];
switch (painter_type) {
case flow_eDrawType_TextHelveticaBold:
case flow_eDrawType_TextHelveticaEraseBold:
sprintf(str, "%s Bold %f", FONTSTR, FONT_SCALE * size);
break;
default:
sprintf(str, "%s %f", FONTSTR, FONT_SCALE * size);
}
for (char* s = str; *s; s++) {
if (*s == ',') {
*s = '.';
}
QFont res(FONTSTR);
res.setPointSizeF(FONT_SCALE * size);
if (painter_type == flow_eDrawType_TextHelveticaBold || painter_type == flow_eDrawType_TextHelveticaEraseBold) {
res.setWeight(QFont::Bold);
}
return
str
;
return
res
;
}
int FlowDrawQt::text_pango_helper(FlowCtx* ctx, int x, int y, char* text,
...
...
@@ -1261,7 +1252,7 @@ int FlowDrawQt::text_pango_helper(FlowCtx* ctx, int x, int y, char* text,
str = QString::fromUtf8(text);
}
painter->setFont(f
l(font_string(painter_type, size)
));
painter->setFont(f
ont(painter_type, size
));
QRect rect = painter->fontMetrics().boundingRect(str);
int height = rect.height();
...
...
@@ -1743,7 +1734,7 @@ int FlowDrawQt::get_text_extent_pango(FlowCtx* ctx, const char* text, int len,
str = QString::fromUtf8(text);
}
painter->setFont(f
l(font_string(painter_type, size)
));
painter->setFont(f
ont(painter_type, size
));
QRect boundingRect = painter->fontMetrics().boundingRect(str);
...
...
xtt/lib/glow/qt/glow_draw_qt.cqt
View file @
062e4174
...
...
@@ -3116,40 +3116,33 @@ int GlowDrawQt::gradient_fill_polyline(GlowWind* wind, glow_sPointX* points,
#define FONT_SCALE 0.7
#define FONT_DESCENT 0.22
static
char* font_string
(int font_idx, int font_type, double size)
static
QFont font
(int font_idx, int font_type, double size)
{
static char str[80];
char bold_str[20];
if (font_type == glow_eDrawFont_HelveticaBold) {
strcpy(bold_str, "Bold ");
} else {
strcpy(bold_str, "");
}
QFont res;
switch (font_idx) {
case glow_eFont_Helvetica:
sprintf(str, "%s %s%f", "Helvetica", bold_str, FONT_SCALE * size
);
res = QFont("Helvetica"
);
break;
case glow_eFont_Times:
sprintf(str, "%s %s%f", "DejaVu Serif", bold_str, FONT_SCALE * size
);
res = QFont("DejaVu Serif"
);
break;
case glow_eFont_NewCenturySchoolbook:
sprintf(
str, "%s %s%f", "Century Schoolbook L", bold_str, FONT_SCALE * size);
res = QFont("Century Schoolbook L");
break;
case glow_eFont_Courier:
sprintf(str, "%s %s%f", "Courier 10 pitch", bold_str, FONT_SCALE * size
);
res = QFont("Courier 10 pitch"
);
break;
default:
sprintf(str, "%s %s%f", "Lucida Sans", bold_str, FONT_SCALE * size);
}
for (char* s = str; *s; s++) {
if (*s == ',') {
*s = '.';
res = QFont("Lucida Sans");
break;
}
res.setPointSizeF(FONT_SCALE * size);
if (font_type == glow_eDrawFont_HelveticaBold) {
res.setWeight(QFont::Bold);
}
return
str
;
return
res
;
}
int GlowDrawQt::text_qt(GlowWind* wind, int x, int y, char* text, int len,
...
...
@@ -3190,7 +3183,7 @@ int GlowDrawQt::text_qt(GlowWind* wind, int x, int y, char* text, int len,
painter->rotate(rot);
}
painter->setFont(f
l(font_string(font_idx, font_type, size)
));
painter->setFont(f
ont(font_idx, font_type, size
));
QRect rect = painter->fontMetrics().boundingRect(str);
int width = rect.width();
...
...
@@ -3252,7 +3245,7 @@ int GlowDrawQt::text_erase_qt(GlowWind* wind, int x, int y, char* text, int len,
str = QString::fromUtf8(text);
}
painter->setFont(f
l(font_string(font_idx, font_type, size)
));
painter->setFont(f
ont(font_idx, font_type, size
));
QRect rect = painter->fontMetrics().boundingRect(str);
width = rect.width();
...
...
@@ -3309,8 +3302,7 @@ int GlowDrawQt::get_text_extent_qt(const char* text, int len,
}
QPainter* painter = get_painter(w->buffer, this, painter_type, 0);
painter->setFont(
fl(font_string(font_idx, get_font_type(painter_type), size)));
painter->setFont(font(font_idx, get_font_type(painter_type), size));
QString str;
if (((GrowCtx*)ctx)->text_coding != glow_eTextCoding_UTF_8) {
...
...
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