SUMO - Simulation of Urban MObility
polyfonts.c File Reference
#include <config.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <GL/gl.h>
#include "polyfonts.h"
#include "pfPSansBold16.h"
Include dependency graph for polyfonts.c:

Go to the source code of this file.

Data Structures

struct  nameValue
 
struct  vertex
 

Macros

#define abs(a)   (((a)<0) ? -(a) : (a))
 
#define DtoR   (PI/180.0)
 
#define max(a, b)   (((a) > (b)) ? (a) : (b))
 
#define min(a, b)   (((a) < (b)) ? (a) : (b))
 
#define numWeights   (sizeof(weightOffset) / sizeof(vertex))
 
#define PI   (3.1415926535897932384626433)
 
#define RtoD   (180.0/PI)
 
#define sign(a)   (((a)<0) ? -1 : (a)>0 ? 1 : 0)
 
#define unfix(value)   ((double)(value)) / ((double)pfFixScale)
 

Functions

static int comp (const void *key, const void *target)
 
static int drawWideChar (wchar_t c)
 
static double getCharAdvance (wchar_t c)
 
static int getCharBBox (wchar_t c, double *minx, double *miny, double *maxx, double *maxy)
 
static int getStringBox (char *c, double *minx, double *miny, double *maxx, double *maxy)
 
static int getStringBoxW (wchar_t *c, double *minx, double *miny, double *maxx, double *maxy)
 
static int lookupGlOp (char *op)
 
double pfdkGetStringWidth (const char *c)
 
int pfDrawChar (wchar_t c)
 
int pfDrawString (const char *c)
 
int pfDrawStringW (wchar_t *c)
 
static pfglyphpfFindGlyph (pfglyph *glyphs, int numglyphs, pfglyph *find)
 
wchar_t pfGetChar (int g)
 
double pfGetCharAdvance (wchar_t c)
 
double pfGetCharAscent (wchar_t c)
 
int pfGetCharBBox (wchar_t c, double *minx, double *miny, double *maxx, double *maxy)
 
double pfGetCharDescent (wchar_t c)
 
double pfGetCharHeight (wchar_t c)
 
double pfGetCharWidth (wchar_t c)
 
pffontpfGetCurrentFont ()
 
double pfGetFontAscent ()
 
int pfGetFontBBox (double *minx, double *miny, double *maxx, double *maxy)
 
double pfGetFontDescent ()
 
double pfGetFontHeight ()
 
char * pfGetFontName ()
 
int pfGetFontNumGlyphs ()
 
double pfGetFontWidth ()
 
static pfglyphpfGetGlyph (wchar_t c)
 
void pfGetPosition (double *x, double *y)
 
void pfSetAngleD (double a)
 
void pfSetAngleR (double a)
 
void pfSetCenter (int onOff)
 
int pfSetFont (pffont *f)
 
void pfSetPosition (double x, double y)
 
void pfSetScale (double s)
 
int pfSetScaleBox (char *c, double w, double h)
 
int pfSetScaleBoxW (wchar_t *c, double w, double h)
 
void pfSetScaleXY (double sx, double sy)
 
void pfSetSkew (double s)
 
void pfSetWeight (int w)
 
static double pfSkew (double x, double y)
 
void pfUnloadFont (pffont *font)
 
static void validate (pffont *font)
 

Variables

static nameValue glPrims []
 
static int pfCenter = 0
 
static pffontpfCurrentFont = &pfPSansBold16
 
static pffontpfDefaultFont = &pfPSansBold16
 
static double pfScaleX = 20.0
 
static double pfScaleY = 20.0
 
static double pfTextCos = 1.0
 
static double pfTextSin = 0.0
 
static double pfTextSkew = 0.0
 
static int pfTextWeight = 1
 
static double pfTextX = 0.0
 
static double pfTextY = 0.0
 
vertex weightOffset []
 

Macro Definition Documentation

◆ abs

◆ DtoR

#define DtoR   (PI/180.0)

Definition at line 63 of file polyfonts.c.

Referenced by pfSetAngleD().

◆ max

#define max (   a,
 
)    (((a) > (b)) ? (a) : (b))

Definition at line 65 of file polyfonts.c.

Referenced by TplConvert::_2int(), TplConvert::_hex2int(), MSLCM_SL2015::_wantsChangeSublane(), NLHandler::addE2Detector(), SUMOVehicleParserHelper::beginVTypeParsing(), CHBuilder< E, V >::buildContractionHierarchy(), CHRouter< E, V, PF >::buildContractionHierarchy(), NLDetectorBuilder::buildE2Detector(), MSLaneChanger::changeOpposite(), MSLeaderDistanceInfo::clear(), MSCriticalFollowerDistanceInfo::clear(), CHRouterWrapper< E, V, PF >::compute(), DijkstraRouterTT< MSEdge, SUMOVehicle, prohibited_withPermissions< MSEdge, SUMOVehicle > >::compute(), DijkstraRouterEffort< MSEdge, SUMOVehicle, prohibited_withPermissions< MSEdge, SUMOVehicle > >::compute(), AStarRouter< MSEdge, SUMOVehicle, prohibited_withPermissions< MSEdge, SUMOVehicle > >::compute(), CHRouter< E, V, PF >::compute(), computeRoutes(), NIImporter_OpenDrive::computeShapes(), MSLCM_SL2015::computeSublaneShift(), TraCIServerAPI_Simulation::convertCartesianToRoadMap(), TraCI::convertCartesianToRoadMap(), MSAbstractLaneChangeModel::decideDirection(), SPTree< CHBuilder::CHInfo, CHBuilder::CHConnection >::dijkstraTT(), PositionVector::distance2D(), MSVehicle::executeMove(), MSLaneChanger::findCandidate(), NBEdge::firstIntersection(), MSActuatedTrafficLightLogic::gapControl(), GawronCalculator< R, E, V >::gawronF(), GawronCalculator< R, E, V >::gawronG(), LogitCalculator< R, E, V >::getBetaForCLogit(), MSLane::getCriticalLeader(), TraCI_Vehicle::getDistance(), MSRoute::getDistanceBetween(), MSVehicle::getDistanceToPosition(), TraCI_Vehicle::getDrivingDistance(), TraCI_Vehicle::getDrivingDistance2D(), MSE2Collector::getEstimateQueueLength(), MSLane::getFirstVehicleInformation(), MSLane::getFollowersOnConsecutive(), MSEdge::getFreeLane(), RODFDetectorFlows::getMaxDetectorFlow(), GUITexturesHelper::getMaxTextureSize(), NBContHelper::same_connection_edge_sorter::getMinMaxRelAngles(), MSLane::getMoveReminders(), GUISUMOAbstractView::getObjectAtPosition(), MSLCM_SL2015::getSlowest(), MSCFModel::getSpeedAfterMaxDecel(), getStringBox(), getStringBoxW(), LogitCalculator< R, E, V >::getThetaForCLogit(), PublicTransportEdge< E, L, N, V >::getTravelTime(), PositionVector::indexOfClosest(), MSLCM_LC2013::informLeader(), MSE2Collector::initAuxiliaries(), PositionVector::insertAtClosest(), MESegment::jamThresholdForSpeed(), NBNodeCont::joinJunctions(), NBContHelper::maxSpeed(), VectorHelper< T >::maxValue(), VectorHelper< T >::minValue(), MSE2Collector::MSE2Collector(), NIImporter_OpenStreetMap::EdgesHandler::myStartElement(), PositionVector::nearest_offset_to_point2D(), GUIParameterTracker::onCmdSave(), SUMOVehicleParserHelper::parseFlowAttributes(), pfSetSkew(), pfSetWeight(), MSVehicle::planMoveInternal(), MSLCM_SL2015::prepareStep(), TraCIServerAPI_Vehicle::processSet(), SPTree< CHBuilder::CHInfo, CHBuilder::CHConnection >::rebuildFrom(), NIImporter_OpenStreetMap::reconstructLayerElevation(), PositionVector::removeClosest(), MSDevice_Routing::reroute(), DijkstraRouterEffort< E, V, PF >::EdgeInfo::reset(), DijkstraRouterTT< E, V, PF >::EdgeInfo::reset(), CHRouter< E, V, PF >::EdgeInfo::reset(), AStarRouter< E, V, PF >::EdgeInfo::reset(), CHBuilder< E, V >::CHInfo::reset(), Distribution_Parameterized::sample(), MSE2Collector::selectLanes(), MSFrame::setMSGlobals(), MFXAddEditTypedTable::setNumberCellParams(), CHRouter< E, V, PF >::Unidirectional::step(), PositionVector::transformToVectorCoordinates(), MSActuatedTrafficLightLogic::trySwitch(), CHBuilder< E, V >::tryUpdateFront(), MSSwarmTrafficLightLogic::updateSensitivities(), SUMOVTypeParameter::write(), NWWriter_DlrNavteq::writeNodesUnsplitted(), and GeoConvHelper::x2cartesian_const().

◆ min

◆ numWeights

#define numWeights   (sizeof(weightOffset) / sizeof(vertex))

Definition at line 129 of file polyfonts.c.

Referenced by pfSetWeight().

◆ PI

◆ RtoD

#define RtoD   (180.0/PI)

Definition at line 62 of file polyfonts.c.

◆ sign

#define sign (   a)    (((a)<0) ? -1 : (a)>0 ? 1 : 0)

◆ unfix

#define unfix (   value)    ((double)(value)) / ((double)pfFixScale)

Definition at line 136 of file polyfonts.c.

Referenced by drawWideChar().

Function Documentation

◆ comp()

static int comp ( const void *  key,
const void *  target 
)
static

Definition at line 820 of file polyfonts.c.

References pfglyph::glyph.

Referenced by pfFindGlyph().

◆ drawWideChar()

◆ getCharAdvance()

static double getCharAdvance ( wchar_t  c)
static

Definition at line 855 of file polyfonts.c.

References pfglyph::advance, and pfGetGlyph().

Referenced by getStringBox(), and getStringBoxW().

◆ getCharBBox()

static int getCharBBox ( wchar_t  c,
double *  minx,
double *  miny,
double *  maxx,
double *  maxy 
)
static

◆ getStringBox()

static int getStringBox ( char *  c,
double *  minx,
double *  miny,
double *  maxx,
double *  maxy 
)
static

Definition at line 558 of file polyfonts.c.

References getCharAdvance(), getCharBBox(), max, and min.

Referenced by pfSetScaleBox().

◆ getStringBoxW()

static int getStringBoxW ( wchar_t *  c,
double *  minx,
double *  miny,
double *  maxx,
double *  maxy 
)
static

Definition at line 598 of file polyfonts.c.

References getCharAdvance(), getCharBBox(), max, and min.

Referenced by pfSetScaleBoxW().

◆ lookupGlOp()

static int lookupGlOp ( char *  op)
static

Definition at line 188 of file polyfonts.c.

References glPrims.

Referenced by pfUnloadFont().

◆ pfdkGetStringWidth()

◆ pfDrawChar()

int pfDrawChar ( wchar_t  c)

Definition at line 1058 of file polyfonts.c.

References drawWideChar().

◆ pfDrawString()

◆ pfDrawStringW()

int pfDrawStringW ( wchar_t *  c)

Definition at line 1093 of file polyfonts.c.

References drawWideChar().

◆ pfFindGlyph()

static pfglyph* pfFindGlyph ( pfglyph glyphs,
int  numglyphs,
pfglyph find 
)
static

Definition at line 830 of file polyfonts.c.

References comp().

Referenced by pfGetGlyph().

◆ pfGetChar()

wchar_t pfGetChar ( int  g)

Definition at line 801 of file polyfonts.c.

References pfglyph::glyph, pffont::glyphs, and pffont::numglyphs.

◆ pfGetCharAdvance()

double pfGetCharAdvance ( wchar_t  c)

Definition at line 869 of file polyfonts.c.

References pfglyph::advance, pfGetGlyph(), and pfScaleX.

Referenced by pfdkGetStringWidth().

◆ pfGetCharAscent()

double pfGetCharAscent ( wchar_t  c)

Definition at line 946 of file polyfonts.c.

References pfGetCharBBox().

◆ pfGetCharBBox()

int pfGetCharBBox ( wchar_t  c,
double *  minx,
double *  miny,
double *  maxx,
double *  maxy 
)

◆ pfGetCharDescent()

double pfGetCharDescent ( wchar_t  c)

Definition at line 960 of file polyfonts.c.

References pfGetCharBBox().

◆ pfGetCharHeight()

double pfGetCharHeight ( wchar_t  c)

Definition at line 918 of file polyfonts.c.

References pfGetCharBBox().

◆ pfGetCharWidth()

double pfGetCharWidth ( wchar_t  c)

Definition at line 932 of file polyfonts.c.

References pfGetCharBBox().

◆ pfGetCurrentFont()

pffont* pfGetCurrentFont ( )

Definition at line 692 of file polyfonts.c.

References pfCurrentFont.

◆ pfGetFontAscent()

double pfGetFontAscent ( )

Definition at line 761 of file polyfonts.c.

References pfGetFontBBox().

◆ pfGetFontBBox()

int pfGetFontBBox ( double *  minx,
double *  miny,
double *  maxx,
double *  maxy 
)

◆ pfGetFontDescent()

double pfGetFontDescent ( )

Definition at line 775 of file polyfonts.c.

References pfGetFontBBox().

◆ pfGetFontHeight()

double pfGetFontHeight ( )

Definition at line 733 of file polyfonts.c.

References pfGetFontBBox().

◆ pfGetFontName()

char* pfGetFontName ( )

Definition at line 678 of file polyfonts.c.

References pffont::name.

◆ pfGetFontNumGlyphs()

int pfGetFontNumGlyphs ( )

Definition at line 789 of file polyfonts.c.

References pffont::numglyphs.

◆ pfGetFontWidth()

double pfGetFontWidth ( )

Definition at line 747 of file polyfonts.c.

References pfGetFontBBox().

◆ pfGetGlyph()

static pfglyph * pfGetGlyph ( wchar_t  c)
static

◆ pfGetPosition()

void pfGetPosition ( double *  x,
double *  y 
)

Definition at line 488 of file polyfonts.c.

References pfTextX, and pfTextY.

◆ pfSetAngleD()

void pfSetAngleD ( double  a)

Definition at line 518 of file polyfonts.c.

References DtoR, and pfSetAngleR().

◆ pfSetAngleR()

void pfSetAngleR ( double  a)

Definition at line 510 of file polyfonts.c.

References pfTextCos, and pfTextSin.

Referenced by pfSetAngleD().

◆ pfSetCenter()

void pfSetCenter ( int  onOff)

Definition at line 525 of file polyfonts.c.

References pfCenter.

◆ pfSetFont()

int pfSetFont ( pffont f)

Definition at line 152 of file polyfonts.c.

◆ pfSetPosition()

◆ pfSetScale()

◆ pfSetScaleBox()

int pfSetScaleBox ( char *  c,
double  w,
double  h 
)

Definition at line 638 of file polyfonts.c.

References getStringBox(), and pfSetScaleXY().

◆ pfSetScaleBoxW()

int pfSetScaleBoxW ( wchar_t *  c,
double  w,
double  h 
)

Definition at line 658 of file polyfonts.c.

References getStringBoxW(), and pfSetScaleXY().

◆ pfSetScaleXY()

◆ pfSetSkew()

void pfSetSkew ( double  s)

Definition at line 496 of file polyfonts.c.

References max, min, and pfTextSkew.

◆ pfSetWeight()

void pfSetWeight ( int  w)

Definition at line 503 of file polyfonts.c.

References max, min, numWeights, and pfTextWeight.

◆ pfSkew()

static double pfSkew ( double  x,
double  y 
)
static

Definition at line 145 of file polyfonts.c.

References pfTextSkew.

Referenced by drawWideChar(), pfGetCharBBox(), and pfGetFontBBox().

◆ pfUnloadFont()

◆ validate()

static void validate ( pffont font)
static

Variable Documentation

◆ glPrims

nameValue glPrims[]
static
Initial value:
=
{
{"GL_POINTS", GL_POINTS},
{"GL_LINES", GL_LINES},
{"GL_LINE_LOOP", GL_LINE_LOOP},
{"GL_LINE_STRIP", GL_LINE_STRIP},
{"GL_TRIANGLES", GL_TRIANGLES},
{"GL_TRIANGLE_STRIP", GL_TRIANGLE_STRIP},
{"GL_TRIANGLE_FAN", GL_TRIANGLE_FAN},
{"GL_QUADS", GL_QUADS},
{"GL_QUAD_STRIP", GL_QUAD_STRIP},
{"GL_POLYGON", GL_POLYGON},
}

Definition at line 172 of file polyfonts.c.

Referenced by lookupGlOp().

◆ pfCenter

int pfCenter = 0
static

Definition at line 134 of file polyfonts.c.

Referenced by drawWideChar(), and pfSetCenter().

◆ pfCurrentFont

pffont* pfCurrentFont = &pfPSansBold16
static

Definition at line 83 of file polyfonts.c.

Referenced by pfGetCurrentFont().

◆ pfDefaultFont

pffont* pfDefaultFont = &pfPSansBold16
static

Definition at line 84 of file polyfonts.c.

◆ pfScaleX

double pfScaleX = 20.0
static

◆ pfScaleY

double pfScaleY = 20.0
static

Definition at line 103 of file polyfonts.c.

Referenced by drawWideChar(), pfGetCharBBox(), pfGetFontBBox(), pfSetScale(), and pfSetScaleXY().

◆ pfTextCos

double pfTextCos = 1.0
static

Definition at line 132 of file polyfonts.c.

Referenced by drawWideChar(), and pfSetAngleR().

◆ pfTextSin

double pfTextSin = 0.0
static

Definition at line 131 of file polyfonts.c.

Referenced by drawWideChar(), and pfSetAngleR().

◆ pfTextSkew

double pfTextSkew = 0.0
static

Definition at line 108 of file polyfonts.c.

Referenced by pfGetCharBBox(), pfGetFontBBox(), pfSetSkew(), and pfSkew().

◆ pfTextWeight

int pfTextWeight = 1
static

Definition at line 109 of file polyfonts.c.

Referenced by drawWideChar(), and pfSetWeight().

◆ pfTextX

double pfTextX = 0.0
static

Definition at line 105 of file polyfonts.c.

Referenced by drawWideChar(), pfGetPosition(), and pfSetPosition().

◆ pfTextY

double pfTextY = 0.0
static

Definition at line 106 of file polyfonts.c.

Referenced by drawWideChar(), pfGetPosition(), and pfSetPosition().

◆ weightOffset

vertex weightOffset[]
Initial value:
= {
{0.0, 0.0},
{0.0, 1.0},
{1.0, 1.0},
{1.0, 0.0},
{0.0, 2.0},
{1.0, 2.0},
{2.0, 2.0},
{1.0, 2.0},
{0.0, 2.0},
}

Definition at line 116 of file polyfonts.c.