23 #include "layout/ParagraphLayout.h" 24 #define ICU_FONTINSTANCE : public icu::LEFontInstance 26 #define ICU_FONTINSTANCE 39 FontState() : fontsize(FS_END), cur_colour(TC_INVALID) {}
48 assert(c >= TC_BLUE && c <= TC_BLACK);
49 if ((this->cur_colour &
TC_FORCED) == 0) this->cur_colour = c;
57 if (colour_stack.empty())
return;
67 colour_stack.push(this->cur_colour);
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;
188 static FontColourMap fonts[FS_END];
194 Point GetCharPosition(
const char *ch)
const;
197 static void ResetFontCache(
FontSize size);
198 static void ResetLineCache();
199 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.
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.
Ignore colour changes from strings.
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.