Rewrite TTF to Bezier conversion using Freetype.
Benefits:
* Much simpler code.
* Handles the entire TTF spec, not just a small subset that
only really worked well on Windows fonts.
* Handles all character sets as well as accented characters.
* Much faster parsing, since Freetype lazily loads and
caches glyphs.
* Support for basically every kind of font that was invented,
not just TTF.
Note that OpenType features, e.g. ligatures, are not yet supported.
This means that Arabic and Devanagari scripts, among others, will
not be rendered in their proper form.
RTL scripts are not supported either, neither in TTF nor in
the text window. Adding RTL support is comparatively easy, but
given that Arabic would not be legibly rendered anyway, this is not
done so far.
2016-01-30 09:42:44 +08:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Routines to read a TrueType font as vector outlines, and generate them
|
|
|
|
// as entities, since they're always representable as either lines or
|
|
|
|
// quadratic Bezier curves.
|
|
|
|
//
|
|
|
|
// Copyright 2016 whitequark, Peter Barfuss.
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#ifndef __TTF_H
|
|
|
|
#define __TTF_H
|
|
|
|
|
|
|
|
class TtfFont {
|
|
|
|
public:
|
|
|
|
std::string fontFile;
|
|
|
|
std::string name;
|
|
|
|
FT_FaceRec_ *fontFace;
|
2016-11-02 16:59:33 +08:00
|
|
|
double capHeight;
|
Rewrite TTF to Bezier conversion using Freetype.
Benefits:
* Much simpler code.
* Handles the entire TTF spec, not just a small subset that
only really worked well on Windows fonts.
* Handles all character sets as well as accented characters.
* Much faster parsing, since Freetype lazily loads and
caches glyphs.
* Support for basically every kind of font that was invented,
not just TTF.
Note that OpenType features, e.g. ligatures, are not yet supported.
This means that Arabic and Devanagari scripts, among others, will
not be rendered in their proper form.
RTL scripts are not supported either, neither in TTF nor in
the text window. Adding RTL support is comparatively easy, but
given that Arabic would not be legibly rendered anyway, this is not
done so far.
2016-01-30 09:42:44 +08:00
|
|
|
|
|
|
|
std::string FontFileBaseName() const;
|
2016-05-07 12:20:06 +08:00
|
|
|
bool LoadFromFile(FT_LibraryRec_ *fontLibrary, bool nameOnly = true);
|
Rewrite TTF to Bezier conversion using Freetype.
Benefits:
* Much simpler code.
* Handles the entire TTF spec, not just a small subset that
only really worked well on Windows fonts.
* Handles all character sets as well as accented characters.
* Much faster parsing, since Freetype lazily loads and
caches glyphs.
* Support for basically every kind of font that was invented,
not just TTF.
Note that OpenType features, e.g. ligatures, are not yet supported.
This means that Arabic and Devanagari scripts, among others, will
not be rendered in their proper form.
RTL scripts are not supported either, neither in TTF nor in
the text window. Adding RTL support is comparatively easy, but
given that Arabic would not be legibly rendered anyway, this is not
done so far.
2016-01-30 09:42:44 +08:00
|
|
|
|
|
|
|
void PlotString(const std::string &str,
|
|
|
|
SBezierList *sbl, Vector origin, Vector u, Vector v);
|
|
|
|
};
|
|
|
|
|
|
|
|
class TtfFontList {
|
|
|
|
public:
|
|
|
|
FT_LibraryRec_ *fontLibrary;
|
|
|
|
bool loaded;
|
|
|
|
List<TtfFont> l;
|
|
|
|
|
|
|
|
TtfFontList();
|
|
|
|
~TtfFontList();
|
|
|
|
|
|
|
|
void LoadAll();
|
|
|
|
|
|
|
|
void PlotString(const std::string &font, const std::string &str,
|
|
|
|
SBezierList *sbl, Vector origin, Vector u, Vector v);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|