OpenTTD Source
1.11.0-beta2
|
Go to the documentation of this file.
23 #include "layout/ParagraphLayout.h"
24 #define ICU_FONTINSTANCE : public icu::LEFontInstance
26 #define ICU_FONTINSTANCE
48 assert(c >= TC_BLUE && c <= TC_BLACK);
49 if ((this->cur_colour &
TC_FORCED) == 0) this->cur_colour = c;
93 le_int32 getUnitsPerEM()
const;
94 le_int32 getAscent()
const;
95 le_int32 getDescent()
const;
96 le_int32 getLeading()
const;
97 float getXPixelsPerEm()
const;
98 float getYPixelsPerEm()
const;
99 float getScaleFactorX()
const;
100 float getScaleFactorY()
const;
101 const void *getFontTable(LETag tableTag)
const;
102 const void *getFontTable(LETag tableTag,
size_t &length)
const;
103 LEGlyphID mapCharToGlyph(LEUnicode32 ch)
const;
104 void getGlyphAdvance(LEGlyphID glyph, LEPoint &advance)
const;
105 le_bool getGlyphPoint(LEGlyphID glyph, le_int32 pointNumber, LEPoint &point)
const;
123 virtual const Font *GetFont()
const = 0;
124 virtual int GetGlyphCount()
const = 0;
125 virtual const GlyphID *GetGlyphs()
const = 0;
126 virtual const float *GetPositions()
const = 0;
127 virtual int GetLeading()
const = 0;
128 virtual const int *GetGlyphToCharMap()
const = 0;
135 virtual int GetLeading()
const = 0;
136 virtual int GetWidth()
const = 0;
137 virtual int CountRuns()
const = 0;
138 virtual const VisualRun &GetVisualRun(
int run)
const = 0;
139 virtual int GetInternalCharLength(
WChar c)
const = 0;
142 virtual void Reflow() = 0;
143 virtual std::unique_ptr<const Line> NextLine(
int max_width) = 0;
151 class Layouter :
public std::vector<std::unique_ptr<const ParagraphLayouter::Line>> {
165 return this->str < other.
str;
182 typedef std::map<LineCacheKey, LineCacheItem> LineCache;
@ TC_FORCED
Ignore colour changes from strings.
uint32 GlyphID
Glyphs are characters from a font.
char32_t WChar
Type for wide characters, i.e.
Dimensions (a width and height) of a rectangle in 2D.
void PopColour()
Switch to and pop the last saved colour on the stack.
const char * string
Pointer to the original string.
static LineCache * linecache
Cache of ParagraphLayout lines.
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
Point GetCharPosition(const char *ch) const
Get the position of a character in the layout.
static void ResetFontCache(FontSize size)
Reset cached font information.
FontCache * fc
The font we are using.
Interface to glue fallback and normal layouter into one.
ParagraphLayouter * layout
Layout of the line.
SmallMap< int, Font * > FontMap
Mapping from index to font.
A single line worth of VisualRuns.
std::string str
Source string of the line (including colour and font size codes).
Container with information about a font.
static FontColourMap fonts[FS_END]
Cache of Font instances.
FontState state_before
Font state at the beginning of the line.
@ FS_NORMAL
Index of the normal font in the font tables.
FontMap runs
Accessed by our ParagraphLayout::nextLine.
FontSize fontsize
Current font size.
Dimension GetBounds()
Get the boundaries of this paragraph.
Layouter(const char *str, int maxw=INT32_MAX, TextColour colour=TC_FROMSTRING, FontSize fontsize=FS_NORMAL)
Create a new layouter.
The layouter performs all the layout work.
static Font * GetFont(FontSize size, TextColour colour)
Get a static font instance.
Coordinates of a point in 2D.
static void ReduceLineCache()
Reduce the size of linecache if necessary to prevent infinite growth.
Visual run contains data about the bit of text with the same font.
std::stack< TextColour, std::vector< TextColour > > colour_stack
Stack of colours to assist with colour switching.
TextColour cur_colour
Current text colour.
Font cache for basic fonts.
const char * GetCharAtPosition(int x) const
Get the character that is at a position.
void SetColour(TextColour c)
Switch to new colour c.
bool operator<(const LineCacheKey &other) const
Comparison operator for std::map.
FontState state_after
Font state after the line.
static LineCacheItem & GetCachedParagraphLayout(const char *str, size_t len, const FontState &state)
Get reference to cache item.
void SetFontSize(FontSize f)
Switch to using a new font f.
Text drawing parameters, which can change while drawing a line, but are kept between multiple parts o...
static void ResetLineCache()
Clear line cache.
FontSize
Available font sizes.
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
void PushColour()
Push the current colour on to the stack.
TextColour colour
The colour this font has to be.
void * buffer
Accessed by both ICU's and our ParagraphLayout::nextLine.