本文整理汇总了C++中PSFont类的典型用法代码示例。如果您正苦于以下问题:C++ PSFont类的具体用法?C++ PSFont怎么用?C++ PSFont使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PSFont类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: intersects
boolean ULabel::intersects (BoxObj& userb, Graphic* gs) {
Transformer* t = gs->GetTransformer();
PSFont* f = gs->GetFont();
Coord xmax = f->Width(_string);
Coord ymax = f->Height();
Coord tx0, ty0, tx1, ty1;
if (t != nil && t->Rotated()) {
Coord x[4], tx[5];
Coord y[4], ty[5];
x[0] = x[3] = y[0] = y[1] = 0;
x[2] = x[1] = xmax;
y[2] = y[3] = ymax;
transformList(x, y, 4, tx, ty, gs);
tx[4] = tx[0];
ty[4] = ty[0];
FillPolygonObj fp (tx, ty, 5);
return fp.Intersects(userb);
} else if (t != nil) {
t->Transform(0, 0, tx0, ty0);
t->Transform(xmax, ymax, tx1, ty1);
BoxObj b1 (tx0, ty0, tx1, ty1);
return b1.Intersects(userb);
} else {
BoxObj b2 (0, 0, xmax, ymax);
return b2.Intersects(userb);
}
}
示例2: totalGS
void StrBrowserGraphic::Natural (int& w, int& h) {
FullGraphic gs;
totalGS(gs);
PSFont* font = gs.GetFont();
w = _width - _width % font->Width("n");
h = _height - _height % font->Height();
}
示例3: GetPSFonts
void PostScriptView::ConstProcs (ostream& out) {
UList* fonts = GetPSFonts();
int nfonts = Count(fonts);
out << "/IdrawDict " << (50 + nfonts) << " dict def\n";
out << "IdrawDict begin\n\n";
if (nfonts > 0) {
for (const char** line = reencodeISO; *line != nil; ++line) {
out << *line << "\n";
}
for (UList* u = fonts->First(); u != fonts->End(); u = u->Next()) {
PSFont* font = GetFont(u);
// No way to check if the X font's encoding is iso8859-1, so...
if (strncmp(font->GetPrintFont(), "Symbol", 6) != 0) {
out << "/" << font->GetPrintFont() << " reencodeISO def\n";
} else {
out << "/" << font->GetPrintFont() << " dup findfont def\n";
}
}
out << "\n";
}
out << "/none null def\n";
out << "/numGraphicParameters 17 def\n";
out << "/stringLimit 65535 def\n\n";
}
示例4: GetOriginal
boolean TextGraphic::RotatedIntersects (BoxObj& userb, Graphic* gs) {
int beg, end, lineSize, nextBeg, ypos = 0;
const char* s = GetOriginal();
int size = strlen(s);
PSFont* f = gs->GetFont();
Coord x[4], tx[5];
Coord y[4], ty[5];
x[0] = x[1] = x[2] = x[3] = y[0] = y[1] = 0;
y[2] = y[3] = f->Height();
for (beg = 0; beg < size; beg = nextBeg) {
GetLine(s, size, beg, end, lineSize, nextBeg);
x[1] = x[2] = f->Width(&s[beg], lineSize) - 1;
transformList(x, y, 4, tx, ty, gs);
tx[4] = tx[0];
ty[4] = ty[0];
FillPolygonObj fp(tx, ty, 5);
if (fp.Intersects(userb)) {
return true;
}
y[0] -= _lineHt;
y[1] -= _lineHt;
y[2] -= _lineHt;
y[3] -= _lineHt;
}
return false;
}
示例5: pt
boolean ULabel::contains (PointObj& po, Graphic* gs) {
PointObj pt (&po);
PSFont* f = gs->GetFont();
invTransform(pt._x, pt._y, gs);
BoxObj b (0, 0, f->Width(_string), f->Height());
return b.Contains(pt);
}
示例6: CreateManipulator
Manipulator* TextOvView::CreateManipulator (
Viewer* v, Event& e, Transformer* rel, Tool* tool
) {
Manipulator* m = nil;
Editor* ed = v->GetEditor();
int tabWidth = Math::round(.5*ivinch);
if (tool->IsA(GRAPHIC_COMP_TOOL)) {
FontVar* fontVar = (FontVar*) ed->GetState("FontVar");
ColorVar* colVar = (ColorVar*) ed->GetState("ColorVar");
PSFont* font = (fontVar == nil) ? psstdfont : fontVar->GetFont();
PSColor* fg = (colVar == nil) ? psblack : colVar->GetFgColor();
int lineHt = font->GetLineHt();
Painter* painter = new Painter;
painter->FillBg(false);
painter->SetFont(font);
painter->SetColors(fg, nil);
Orientation o = v->GetOrientation();
if (o!=Rotated)
painter->SetTransformer(rel);
else {
rel = new Transformer(rel);
rel->Rotate(90.0);
painter->SetTransformer(rel);
Unref(rel);
}
m = new TextManip(v, painter, lineHt, tabWidth, tool);
} else if (tool->IsA(RESHAPE_TOOL)) {
TextGraphic* textgr = (TextGraphic*) GetGraphic();
Painter* painter = new Painter;
int lineHt = textgr->GetLineHeight();
Coord xpos, ypos;
rel = new Transformer;
const char* text = textgr->GetOriginal();
int size = strlen(text);
textgr->TotalTransformation(*rel);
rel->Transform(0, 0, xpos, ypos);
painter->FillBg(false);
painter->SetFont(textgr->GetFont());
painter->SetColors(textgr->GetFgColor(), nil);
painter->SetTransformer(rel);
Unref(rel);
m = new TextManip(
v, text, size, xpos, ypos, painter, lineHt, tabWidth, tool
);
} else {
m = OverlayView::CreateManipulator(v, e, rel, tool);
}
return m;
}
示例7: Uncollected
static boolean Uncollected (const char* name, UList* fonts) {
for (UList* u = fonts->First(); u != fonts->End(); u = u->Next()) {
PSFont* font = (PSFont*) (*u)();
if (strcmp(font->GetPrintFont(), name) == 0) {
return false;
}
}
return true;
}
示例8: CollectFonts
static void CollectFonts (GraphicComp* comp, UList* fonts) {
PSFont* font = comp->GetGraphic()->GetFont();
if (font != nil && Uncollected(font->GetPrintFont(), fonts)) {
fonts->Append(new UList(font));
}
Iterator i;
for (comp->First(i); !comp->Done(i); comp->Next(i)) {
CollectFonts(comp->GetComp(i), fonts);
}
}
示例9: GetGraphicComp
void PostScriptView::Font (ostream& out) {
PSFont* font = (PSFont*) GetGraphicComp()->GetGraphic()->GetFont();
if (font == nil) {
out << MARK << " f u\n";
} else {
const char* name = font->GetName();
const char* pf = font->GetPrintFont();
const char* ps = font->GetPrintSize();
out << MARK << " f " << name << "\n";
out << pf << " " << ps << " SetF\n";
}
}
示例10: GetGraphic
void TextComp::Interpret (Command* cmd) {
TextGraphic* gr = (TextGraphic*) GetGraphic();
if (cmd->IsA(BRUSH_CMD) || cmd->IsA(PATTERN_CMD)) {
// do nothing
} else if (cmd->IsA(FONT_CMD)) {
PSFont* font = ((FontCmd*) cmd)->GetFont();
cmd->Store(this, new VoidData(gr->GetFont()));
gr->SetFont(font);
gr->SetLineHeight(font->Height()); // hack; should be state var
Notify();
} else {
GraphicComp::Interpret(cmd);
}
}
示例11: getExtent
void ULabel::getExtent (
float& x0, float& y0, float& cx, float& cy, float& tol, Graphic* gs
) {
PSFont* f = gs->GetFont();
float width = f->Width(_string);
float height = f->Height();
if (gs->GetTransformer() == nil) {
x0 = 0;
y0 = 0;
cx = width / 2;
cy = height / 2;
} else {
transformRect(0, 0, width, height, x0, y0, cx, cy, gs);
cx = (cx + x0)/2;
cy = (cy + y0)/2;
}
tol = 0;
}
示例12: OverlayComp
TextOvComp::TextOvComp(istream& in, OverlayComp* parent)
: OverlayComp(nil, parent) {
_valid = GetParamList()->read_args(in, this);
/* correct font vertical position */
PSFont* f = _gr->GetFont();
float sep = 1 - (f ? f->GetLineHt() : 0);
Transformer* t = _gr->GetTransformer();
float dx = 0., dy = sep;
if (t != nil) {
float x0, y0, x1, y1;
t->Transform(0., 0., x0, y0);
t->Transform(0., sep, x1, y1);
dx = x1 - x0;
dy = y1 - y0;
}
_gr->Translate(dx, dy);
}
示例13: pt
boolean TextGraphic::contains (PointObj& po, Graphic* gs) {
PointObj pt (&po);
PSFont* f = gs->GetFont();
BoxObj box(0, 0, 0, f->Height());
int beg, end, lineSize, nextBeg, ypos = 0;
const char* s = GetOriginal();
int size = strlen(s);
invTransform(pt._x, pt._y, gs);
for (beg = 0; beg < size; beg = nextBeg) {
GetLine(s, size, beg, end, lineSize, nextBeg);
box._right = f->Width(&s[beg], lineSize) - 1;
if (box.Contains(pt)) {
return true;
}
box._top -= _lineHt;
box._bottom -= _lineHt;
}
return false;
}
示例14: fopen
//.........这里部分代码省略.........
buffer = newbuffer;
}
if (_linewidth > -1) {
wordbuf = new char[len+nsub+1];
for (int i = 0; i < len; i++) {
c = inbuf[i];
++nc;
if (c == ' ' || c == '\t' || c == '\n') {
if (nc > _linewidth+1) {
strcpy(buffer+buflen, "\n");
++buflen;
if (c == '\n' && nc > 1 ) {
wordbuf[wordc] = ' ';
} else {
wordbuf[wordc] = c;
}
wordbuf[wordc+1] = '\0';
nc = strlen(wordbuf);
wordc = 0;
strcpy(buffer+buflen, wordbuf);
buflen += strlen(wordbuf);
} else {
if (c == '\n' && nc > 1 && i > 0) {
wordbuf[wordc] = ' ';
wordbuf[wordc+1] = '\0';
} else if (c == '\n' && i == 0) {
wordbuf[wordc] = c;
wordbuf[wordc+1] = c;
wordbuf[wordc+2] = '\0';
nc = 0;
} else {
wordbuf[wordc] = c;
wordbuf[wordc+1] = '\0';
}
wordc = 0;
if (buffer[buflen-1] != ' ' || wordbuf[0] != ' ') {
strcpy(buffer+buflen, wordbuf);
buflen += strlen(wordbuf);
} else {
strcpy(buffer+buflen, wordbuf+1);
buflen += strlen(wordbuf) - 1;
}
}
} else {
if (c=='\\') {
c = inbuf[++i];
if (isdigit(c)) {
char buf[4];
buf[0] = c;
buf[1] = buf[2] = buf[3] = '\0';
if (isdigit(inbuf[i+1])) {
buf[1] = inbuf[++i];
if (isdigit(inbuf[i+1])) {
buf[2] = inbuf[++i];
}
}
c = ParamList::octal(buf);
}
}
wordbuf[wordc] = c;
++wordc;
}
}
delete wordbuf;
} else {
strcpy(buffer+buflen, inbuf);
buflen += strlen(inbuf);
}
fgets( inbuf, BUFSIZ, fptr);
}
/* done looping until eof or endstr is found */
}
fclose(fptr);
/* setup the graphic */
((TextGraphic*)_gr)->SetOriginal(buffer);
delete buffer;
/* correct font vertical position */
PSFont* f = _gr->GetFont();
float sep = 1 - f->GetLineHt();
Transformer* t = _gr->GetTransformer();
float dx = 0., dy = sep;
if (t != nil) {
float x0, y0, x1, y1;
t->Transform(0., 0., x0, y0);
t->Transform(0., sep, x1, y1);
dx = x1 - x0;
dy = y1 - y0;
}
_gr->Translate(dx, dy);
}