diff options
author | Raph Levien <raph@google.com> | 2013-05-22 16:14:27 -0700 |
---|---|---|
committer | Raph Levien <raph@google.com> | 2013-06-14 11:22:35 -0700 |
commit | bcc3dc5a2591a95a57e379e27cbad69c18e91e67 (patch) | |
tree | 6ba40e86f2ef0d52b2e0796f1dda0eb6e5ec4377 /sample | |
parent | 9cc9bbe1461f359f0b27c5e7645c17dda001ab1d (diff) | |
download | android_frameworks_minikin-bcc3dc5a2591a95a57e379e27cbad69c18e91e67.tar.gz android_frameworks_minikin-bcc3dc5a2591a95a57e379e27cbad69c18e91e67.tar.bz2 android_frameworks_minikin-bcc3dc5a2591a95a57e379e27cbad69c18e91e67.zip |
Introduce MinikinFont abstraction
This commit removes the direct dependency on FreeType and replaces it
with a MinikinFont abstraction, which is designed to support both
FreeType and Skia fonts (and possibly others in the future).
Also adds a "total advance" to the Layout, with an API for retrieving
it.
Change-Id: If20f92db9a43fd15b0fe9794b761ba00fb21338c
Diffstat (limited to 'sample')
-rw-r--r-- | sample/example.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/sample/example.cpp b/sample/example.cpp index 3f0ad9d..9b012ef 100644 --- a/sample/example.cpp +++ b/sample/example.cpp @@ -24,6 +24,7 @@ #include <unicode/unistr.h> #include <unicode/utf16.h> +#include <minikin/MinikinFontFreeType.h> #include <minikin/Layout.h> using std::vector; @@ -55,15 +56,17 @@ FontCollection *makeFontCollection() { if (error != 0) { printf("error loading %s, %d\n", fn, error); } - family->addFont(face); + MinikinFont *font = new MinikinFontFreeType(face); + family->addFont(font); } typefaces.push_back(family); -#if 0 +#if 1 family = new FontFamily(); const char *fn = "/system/fonts/DroidSansDevanagari-Regular.ttf"; error = FT_New_Face(library, fn, 0, &face); - family->addFont(face); + MinikinFont *font = new MinikinFontFreeType(face); + family->addFont(font); typefaces.push_back(family); #endif @@ -81,11 +84,11 @@ int runMinikinTest() { Layout layout; layout.setFontCollection(collection); layout.setProperties("font-size: 32;"); - const char *text = "hello world"; + const char *text = "fine world \xe0\xa4\xa8\xe0\xa4\xae\xe0\xa4\xb8\xe0\xa5\x8d\xe0\xa4\xa4\xe0\xa5\x87"; icu::UnicodeString icuText = icu::UnicodeString::fromUTF8(text); layout.doLayout(icuText.getBuffer(), icuText.length()); layout.dump(); - Bitmap bitmap(200, 50); + Bitmap bitmap(250, 50); layout.draw(&bitmap, 10, 40); std::ofstream o; o.open("/data/local/tmp/foo.pgm", std::ios::out | std::ios::binary); @@ -97,4 +100,4 @@ int runMinikinTest() { int main(int argc, const char** argv) { return android::runMinikinTest(); -}
\ No newline at end of file +} |