bsnes/phoenix/qt/font.cpp
Tim Allen 3016e595f0 Update to v094r06 release.
byuu says:

New terminal is in. Much nicer to use now. Command history makes a major
difference in usability.

The SMP is now fully traceable and debuggable. Basically they act as
separate entities, you can trace both at the same time, but for the most
part running and stepping is performed on the chip you select.

I'm going to put off CPU+SMP interleave support for a while. I don't
actually think it'll be too hard. Will get trickier if/when we support
coprocessor debugging.

Remaining tasks:
- aliases
- hotkeys
- save states
- window geometry

Basically, the debugger's done. Just have to add the UI fluff.

I also removed tracing/memory export from higan. It was always meant to
be temporary until the debugger was remade.
2014-02-09 17:05:58 +11:00

63 lines
1.5 KiB
C++

namespace phoenix {
string pFont::serif(unsigned size, string style) {
if(size == 0) size = 8;
if(style == "") style = "Normal";
return {"Serif, ", size, ", ", style};
}
string pFont::sans(unsigned size, string style) {
if(size == 0) size = 8;
if(style == "") style = "Normal";
return {"Sans, ", size, ", ", style};
}
string pFont::monospace(unsigned size, string style) {
if(size == 0) size = 8;
if(style == "") style = "Normal";
return {"Liberation Mono, ", size, ", ", style};
}
Size pFont::size(string font, string text) {
return pFont::size(pFont::create(font), text);
}
QFont pFont::create(string description) {
lstring part;
part.split<2>(",", description);
for(auto& item : part) item.trim(" ");
string family = "Sans";
unsigned size = 8u;
bool bold = false;
bool italic = false;
if(part[0] != "") family = part[0];
if(part.size() >= 2) size = decimal(part[1]);
if(part.size() >= 3) bold = (bool)part[2].find("Bold");
if(part.size() >= 3) italic = (bool)part[2].find("Italic");
QFont qtFont;
qtFont.setFamily(family);
qtFont.setPointSize(size);
if(bold) qtFont.setBold(true);
if(italic) qtFont.setItalic(true);
return qtFont;
}
Size pFont::size(const QFont& qtFont, string text) {
QFontMetrics metrics(qtFont);
lstring lines;
lines.split("\n", text);
unsigned maxWidth = 0;
for(auto& line : lines) {
maxWidth = max(maxWidth, metrics.width(line));
}
return {maxWidth, metrics.height() * lines.size()};
}
}