summaryrefslogtreecommitdiff
path: root/src/gfx_layout.h
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2013-06-25 20:40:58 +0000
committerrubidium <rubidium@openttd.org>2013-06-25 20:40:58 +0000
commit48c1e4f87ee264dd66b665e4ae3a3f299ae2f85b (patch)
tree298c5104beafad7e68999c6fc2d8916a08456906 /src/gfx_layout.h
parent7b10e39bf104e9983548ee1b6d94e9dbb57fdb27 (diff)
downloadopenttd-48c1e4f87ee264dd66b665e4ae3a3f299ae2f85b.tar.xz
(svn r25470) -Feature-ish: use ICU's layout engine when that's available
Diffstat (limited to 'src/gfx_layout.h')
-rw-r--r--src/gfx_layout.h32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/gfx_layout.h b/src/gfx_layout.h
index 7960bf2a2..f66559e22 100644
--- a/src/gfx_layout.h
+++ b/src/gfx_layout.h
@@ -16,20 +16,45 @@
#include "gfx_func.h"
#include "core/smallmap_type.hpp"
+#ifdef WITH_ICU
+#include "layout/ParagraphLayout.h"
+#define ICU_FONTINSTANCE : public LEFontInstance
+#else /* WITH_ICU */
+#define ICU_FONTINSTANCE
+#endif /* WITH_ICU */
+
/**
* Container with information about a font.
*/
-class Font {
+class Font ICU_FONTINSTANCE {
public:
FontCache *fc; ///< The font we are using.
TextColour colour; ///< The colour this font has to be.
Font(FontSize size, TextColour colour);
+
+#ifdef WITH_ICU
+ /* Implementation details of LEFontInstance */
+
+ le_int32 getUnitsPerEM() const;
+ le_int32 getAscent() const;
+ le_int32 getDescent() const;
+ le_int32 getLeading() const;
+ float getXPixelsPerEm() const;
+ float getYPixelsPerEm() const;
+ float getScaleFactorX() const;
+ float getScaleFactorY() const;
+ const void *getFontTable(LETag tableTag) const;
+ LEGlyphID mapCharToGlyph(LEUnicode32 ch) const;
+ void getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const;
+ le_bool getGlyphPoint(LEGlyphID glyph, le_int32 pointNumber, LEPoint &point) const;
+#endif /* WITH_ICU */
};
/** Mapping from index to font. */
typedef SmallMap<int, Font *> FontMap;
+#ifndef WITH_ICU
/**
* Class handling the splitting of a paragraph of text into lines and
* visual runs.
@@ -85,6 +110,7 @@ public:
ParagraphLayout(WChar *buffer, int length, FontMap &runs);
Line *nextLine(int max_width);
};
+#endif /* !WITH_ICU */
/**
* The layouter performs all the layout work.
@@ -92,7 +118,11 @@ public:
* It also accounts for the memory allocations and frees.
*/
class Layouter : public AutoDeleteSmallVector<ParagraphLayout::Line *, 4> {
+#ifdef WITH_ICU
+ typedef UChar CharType; ///< The type of character used within the layouter.
+#else /* WITH_ICU */
typedef WChar CharType; ///< The type of character used within the layouter.
+#endif /* WITH_ICU */
size_t AppendToBuffer(CharType *buff, const CharType *buffer_last, WChar c);
ParagraphLayout *GetParagraphLayout(CharType *buff);