KiCad PCB EDA Suite
font.h File Reference
#include <iostream>
#include <map>
#include <algorithm>
#include <wx/string.h>
#include <font/glyph.h>
#include <font/text_attributes.h>

Go to the source code of this file.

Classes

class  KIFONT::FONT
 FONT is an abstract base class for both outline and stroke fonts. More...
 

Namespaces

namespace  KIGFX
 The Cairo implementation of the graphics abstraction layer.
 
namespace  KIFONT
 

Typedefs

using TEXT_STYLE_FLAGS = unsigned int
 

Enumerations

enum  TEXT_STYLE {
  BOLD = 1 , ITALIC = 1 << 1 , SUBSCRIPT = 1 << 2 , SUPERSCRIPT = 1 << 3 ,
  OVERBAR = 1 << 4 , UNDERLINE = 1 << 5
}
 

Functions

bool IsBold (TEXT_STYLE_FLAGS aFlags)
 
bool IsItalic (TEXT_STYLE_FLAGS aFlags)
 
bool IsSuperscript (TEXT_STYLE_FLAGS aFlags)
 
bool IsSubscript (TEXT_STYLE_FLAGS aFlags)
 
bool IsOverbar (TEXT_STYLE_FLAGS aFlags)
 
std::string TextStyleAsString (TEXT_STYLE_FLAGS aFlags)
 
std::ostream & operator<< (std::ostream &os, const KIFONT::FONT &aFont)
 
std::ostream & operator<< (std::ostream &os, const KIFONT::FONT *aFont)
 

Variables

static constexpr double ITALIC_TILT = 1.0 / 8
 Tilt factor for italic style (this is the scaling factor on dY relative coordinates to give a tilted shape). More...
 

Typedef Documentation

◆ TEXT_STYLE_FLAGS

using TEXT_STYLE_FLAGS = unsigned int

Definition at line 63 of file font.h.

Enumeration Type Documentation

◆ TEXT_STYLE

enum TEXT_STYLE
Enumerator
BOLD 
ITALIC 
SUBSCRIPT 
SUPERSCRIPT 
OVERBAR 
UNDERLINE 

Definition at line 43 of file font.h.

44{
45 BOLD = 1,
46 ITALIC = 1 << 1,
47 SUBSCRIPT = 1 << 2,
48 SUPERSCRIPT = 1 << 3,
49 OVERBAR = 1 << 4,
50 UNDERLINE = 1 << 5
51};
@ BOLD
Definition: font.h:45
@ SUBSCRIPT
Definition: font.h:47
@ OVERBAR
Definition: font.h:49
@ UNDERLINE
Definition: font.h:50
@ ITALIC
Definition: font.h:46
@ SUPERSCRIPT
Definition: font.h:48

Function Documentation

◆ IsBold()

bool IsBold ( TEXT_STYLE_FLAGS  aFlags)
inline

Definition at line 66 of file font.h.

67{
68 return aFlags & TEXT_STYLE::BOLD;
69}

References BOLD.

◆ IsItalic()

bool IsItalic ( TEXT_STYLE_FLAGS  aFlags)
inline

Definition at line 72 of file font.h.

73{
74 return aFlags & TEXT_STYLE::ITALIC;
75}

References ITALIC.

◆ IsOverbar()

bool IsOverbar ( TEXT_STYLE_FLAGS  aFlags)
inline

Definition at line 90 of file font.h.

91{
92 return aFlags & TEXT_STYLE::OVERBAR;
93}

References OVERBAR.

Referenced by KIFONT::OUTLINE_FONT::getTextAsGlyphs().

◆ IsSubscript()

bool IsSubscript ( TEXT_STYLE_FLAGS  aFlags)
inline

Definition at line 84 of file font.h.

85{
86 return aFlags & TEXT_STYLE::SUBSCRIPT;
87}

References SUBSCRIPT.

Referenced by KIFONT::OUTLINE_FONT::getTextAsGlyphs().

◆ IsSuperscript()

bool IsSuperscript ( TEXT_STYLE_FLAGS  aFlags)
inline

Definition at line 78 of file font.h.

79{
80 return aFlags & TEXT_STYLE::SUPERSCRIPT;
81}

References SUPERSCRIPT.

Referenced by KIFONT::OUTLINE_FONT::getTextAsGlyphs().

◆ operator<<() [1/2]

std::ostream & operator<< ( std::ostream &  os,
const KIFONT::FONT aFont 
)
inline

Definition at line 274 of file font.h.

275{
276 os << "[Font \"" << aFont.GetName() << "\"" << ( aFont.IsStroke() ? " stroke" : "" )
277 << ( aFont.IsOutline() ? " outline" : "" ) << ( aFont.IsBold() ? " bold" : "" )
278 << ( aFont.IsItalic() ? " italic" : "" ) << "]";
279 return os;
280}
virtual bool IsStroke() const
Definition: font.h:112
virtual bool IsItalic() const
Definition: font.h:115
virtual bool IsBold() const
Definition: font.h:114
const wxString & GetName() const
Definition: font.h:121
virtual bool IsOutline() const
Definition: font.h:113

References KIFONT::FONT::GetName(), KIFONT::FONT::IsBold(), KIFONT::FONT::IsItalic(), KIFONT::FONT::IsOutline(), and KIFONT::FONT::IsStroke().

◆ operator<<() [2/2]

std::ostream & operator<< ( std::ostream &  os,
const KIFONT::FONT aFont 
)
inline

Definition at line 283 of file font.h.

284{
285 os << *aFont;
286 return os;
287}

◆ TextStyleAsString()

std::string TextStyleAsString ( TEXT_STYLE_FLAGS  aFlags)

Variable Documentation

◆ ITALIC_TILT

constexpr double ITALIC_TILT = 1.0 / 8
staticconstexpr

Tilt factor for italic style (this is the scaling factor on dY relative coordinates to give a tilted shape).

This is applied directly to stroke fonts, and is used as an estimate for outline fonts (which have the actual tilt built in to their polygonal glyph outlines).

Definition at line 60 of file font.h.

Referenced by KIFONT::OUTLINE_FONT::getTextAsGlyphs(), KIFONT::STROKE_FONT::GetTextAsGlyphs(), and EDA_TEXT::GetTextBox().