PEBL
2.2
Psychology Experiment Building Language - Cross-platform psychological experiment development system
validator/PlatformFont.cpp
Go to the documentation of this file.
1
//* -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*- */
3
// Name: platforms/validator/PlatformFont.cpp
4
// Purpose: Validator Platform Font Implementation
5
// Author: Shane T. Mueller, Ph.D.
6
// Copyright: (c) 2025 Shane T. Mueller <smueller@obereed.net>
7
// License: GPL 2
8
//
9
// This file is part of the PEBL project.
10
//
11
// PEBL is free software; you can redistribute it and/or modify
12
// it under the terms of the GNU General Public License as published by
13
// the Free Software Foundation; either version 2 of the License, or
14
// (at your option) any later version.
15
//
16
// PEBL is distributed in the hope that it will be useful,
17
// but WITHOUT ANY WARRANTY; without even the implied warranty of
18
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
// GNU General Public License for more details.
20
//
21
// You should have received a copy of the GNU General Public License
22
// along with PEBL; if not, write to the Free Software
23
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25
#include "
PlatformFont.h
"
26
27
PlatformFont::PlatformFont
(
const
std::string& filename)
28
:
PFont
(filename, 0, 18,
PColor
(0,0,0,255),
PColor
(255,255,255,255), true) {
29
}
30
31
PlatformFont::PlatformFont
(
const
std::string& filename,
int
style,
int
size,
32
PColor
fgcolor,
PColor
bgcolor,
bool
aa)
33
:
PFont
(filename, style, size, fgcolor, bgcolor, aa) {
34
}
35
36
PlatformFont::PlatformFont
(
PlatformFont
& font)
37
:
PFont
(font) {
38
}
39
40
PlatformFont::~PlatformFont
() {
41
}
42
43
unsigned
int
PlatformFont::GetTextWidth
(
const
std::string& text) {
44
// Dummy metric: text length * size * 0.6
45
return
static_cast<
unsigned
int
>
(text.length() *
mFontSize
* 0.6);
46
}
47
48
unsigned
int
PlatformFont::GetTextHeight
(
const
std::string& text) {
49
// Dummy metric: font size
50
return
static_cast<
unsigned
int
>
(
mFontSize
);
51
}
52
53
std::ostream&
PlatformFont::SendToStream
(std::ostream& out)
const
{
54
out <<
"PlatformFont (validator)"
;
55
return
out;
56
}
PColor
Definition
PColor.h:37
PFont
Definition
PFont.h:53
PFont::mFontSize
int mFontSize
Definition
PFont.h:106
PlatformFont
Definition
sdl/PlatformFont.h:53
PlatformFont::GetTextHeight
unsigned int GetTextHeight(const std::string &text)
Definition
sdl/PlatformFont.cpp:547
PlatformFont::SendToStream
virtual std::ostream & SendToStream(std::ostream &out) const
This sends the font descriptions to the specified stream.
Definition
sdl/PlatformFont.cpp:619
PlatformFont::PlatformFont
PlatformFont(const std::string &filename)
Definition
validator/PlatformFont.cpp:27
PlatformFont::GetTextWidth
unsigned int GetTextWidth(const std::string &text)
Definition
sdl/PlatformFont.cpp:517
PlatformFont::~PlatformFont
virtual ~PlatformFont()
Copy constructor.
Definition
sdl/PlatformFont.cpp:183
PlatformFont.h
src
platforms
validator
PlatformFont.cpp
Generated by
1.9.8