24 #ifdef WITH_ICU_LAYOUT 25 #include "layout/ParagraphLayout.h" 26 #define ICU_FONTINSTANCE : public icu::LEFontInstance 28 #define ICU_FONTINSTANCE 41 FontState() : fontsize(FS_END), cur_colour(TC_INVALID) {}
50 assert(c >= TC_BLUE && c <= TC_BLACK);
59 if (colour_stack.empty())
return;
69 colour_stack.push(this->cur_colour);
92 #ifdef WITH_ICU_LAYOUT 95 le_int32 getUnitsPerEM()
const;
96 le_int32 getAscent()
const;
97 le_int32 getDescent()
const;
98 le_int32 getLeading()
const;
99 float getXPixelsPerEm()
const;
100 float getYPixelsPerEm()
const;
101 float getScaleFactorX()
const;
102 float getScaleFactorY()
const;
103 const void *getFontTable(LETag tableTag)
const;
104 const void *getFontTable(LETag tableTag,
size_t &length)
const;
105 LEGlyphID mapCharToGlyph(LEUnicode32 ch)
const;
106 void getGlyphAdvance(LEGlyphID glyph, LEPoint &advance)
const;
107 le_bool getGlyphPoint(LEGlyphID glyph, le_int32 pointNumber, LEPoint &point)
const;
125 virtual const Font *GetFont()
const = 0;
126 virtual int GetGlyphCount()
const = 0;
127 virtual const GlyphID *GetGlyphs()
const = 0;
128 virtual const float *GetPositions()
const = 0;
129 virtual int GetLeading()
const = 0;
130 virtual const int *GetGlyphToCharMap()
const = 0;
137 virtual int GetLeading()
const = 0;
138 virtual int GetWidth()
const = 0;
139 virtual int CountRuns()
const = 0;
140 virtual const VisualRun *GetVisualRun(
int run)
const = 0;
141 virtual int GetInternalCharLength(
WChar c)
const = 0;
144 virtual void Reflow() = 0;
145 virtual const Line *NextLine(
int max_width) = 0;
167 return this->str < other.
str;
184 typedef std::map<LineCacheKey, LineCacheItem> LineCache;
190 static FontColourMap fonts[FS_END];
196 Point GetCharPosition(
const char *ch)
const;
199 static void ResetFontCache(
FontSize size);
200 static void ResetLineCache();
201 static void ReduceLineCache();
TextColour colour
The colour this font has to be.
void * buffer
Accessed by both ICU's and our ParagraphLayout::nextLine.
std::stack< TextColour, std::vector< TextColour > > colour_stack
Stack of colours to assist with colour switching.
static LineCache * linecache
Cache of ParagraphLayout lines.
std::string str
Source string of the line (including colour and font size codes).
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...
void PopColour()
Switch to and pop the last saved colour on the stack.
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.
void PushColour()
Push the current colour on to the stack.
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.