22 #ifdef WITH_ICU_LAYOUT 23 #include "layout/ParagraphLayout.h" 24 #define ICU_FONTINSTANCE : public LEFontInstance 26 #define ICU_FONTINSTANCE 38 FontState() : fontsize(FS_END), cur_colour(TC_INVALID), prev_colour(TC_INVALID) {}
47 assert(c >= TC_BLUE && c <= TC_BLACK);
55 Swap(this->cur_colour, this->prev_colour);
78 #ifdef WITH_ICU_LAYOUT 81 le_int32 getUnitsPerEM()
const;
82 le_int32 getAscent()
const;
83 le_int32 getDescent()
const;
84 le_int32 getLeading()
const;
85 float getXPixelsPerEm()
const;
86 float getYPixelsPerEm()
const;
87 float getScaleFactorX()
const;
88 float getScaleFactorY()
const;
89 const void *getFontTable(LETag tableTag)
const;
90 const void *getFontTable(LETag tableTag,
size_t &length)
const;
91 LEGlyphID mapCharToGlyph(LEUnicode32 ch)
const;
92 void getGlyphAdvance(LEGlyphID glyph, LEPoint &advance)
const;
93 le_bool getGlyphPoint(LEGlyphID glyph, le_int32 pointNumber, LEPoint &point)
const;
111 virtual const Font *GetFont()
const = 0;
112 virtual int GetGlyphCount()
const = 0;
113 virtual const GlyphID *GetGlyphs()
const = 0;
114 virtual const float *GetPositions()
const = 0;
115 virtual int GetLeading()
const = 0;
116 virtual const int *GetGlyphToCharMap()
const = 0;
123 virtual int GetLeading()
const = 0;
124 virtual int GetWidth()
const = 0;
125 virtual int CountRuns()
const = 0;
126 virtual const VisualRun *GetVisualRun(
int run)
const = 0;
127 virtual int GetInternalCharLength(
WChar c)
const = 0;
130 virtual void Reflow() = 0;
131 virtual const Line *NextLine(
int max_width) = 0;
153 return this->str < other.
str;
170 typedef std::map<LineCacheKey, LineCacheItem> LineCache;
176 static FontColourMap fonts[FS_END];
182 Point GetCharPosition(
const char *ch)
const;
185 static void ResetFontCache(
FontSize size);
186 static void ResetLineCache();
187 static void ReduceLineCache();
TextColour colour
The colour this font has to be.
static void Swap(T &a, T &b)
Type safe swap operation.
void * buffer
Accessed by both ICU's and our ParagraphLayout::nextLine.
static LineCache * linecache
Cache of ParagraphLayout lines.
TextColour prev_colour
Text colour from before the last colour switch.
std::string str
Source string of the line (including colour and font size codes).
void SetPreviousColour()
Switch to previous colour.
Visual run contains data about the bit of text with the same font.
FontMap runs
Accessed by our ParagraphLayout::nextLine.
void SetFontSize(FontSize f)
Switch to using a new font f.
Simple mapping class targeted for small sets of data.
Functions to read fonts from files and cache them.
FontCache * fc
The font we are using.
A single line worth of VisualRuns.
Interface to glue fallback and normal layouter into one.
Functions related to the gfx engine.
Simple vector template class, with automatic delete.
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
void SetColour(TextColour c)
Switch to new colour c.
Font cache for basic fonts.
SmallMap< int, Font * > FontMap
Mapping from index to font.
Text drawing parameters, which can change while drawing a line, but are kept between multiple parts o...
TextColour cur_colour
Current text colour.
FontSize fontsize
Current font size.
FontSize
Available font sizes.
FontState state_after
Font state after the line.
Index of the normal font in the font tables.
FontState state_before
Font state at the beginning of the line.
Coordinates of a point in 2D.
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
Container with information about a font.
bool operator<(const LineCacheKey &other) const
Comparison operator for std::map.
The layouter performs all the layout work.
const char * GetCharAtPosition(const char *str, int x, FontSize start_fontsize)
Get the character from a string that is drawn at a specific position.
uint32 GlyphID
Glyphs are characters from a font.
ParagraphLayouter * layout
Layout of the line.
uint32 WChar
Type for wide characters, i.e.
Dimensions (a width and height) of a rectangle in 2D.
const char * string
Pointer to the original string.