diff options
Diffstat (limited to 'hacks')
| -rw-r--r-- | hacks/.gitignore | 5 | ||||
| -rw-r--r-- | hacks/fonts.conf | 4 | ||||
| -rw-r--r-- | hacks/text-win.sh | 1 | ||||
| -rw-r--r-- | hacks/text.cc | 59 | ||||
| -rw-r--r-- | hacks/text.sh | 3 |
5 files changed, 72 insertions, 0 deletions
diff --git a/hacks/.gitignore b/hacks/.gitignore index 01dc078a3..fbadc130f 100644 --- a/hacks/.gitignore +++ b/hacks/.gitignore @@ -16,3 +16,8 @@ subtitle_alignment/dcp_4/info subtitle_alignment/dcp_4/log subtitle_alignment/dcp_4/video pixfmts +*.dll +text.png +text +text.exe +LOCAL_APPDATA_FONTCONFIG_CACHE diff --git a/hacks/fonts.conf b/hacks/fonts.conf new file mode 100644 index 000000000..2f0403761 --- /dev/null +++ b/hacks/fonts.conf @@ -0,0 +1,4 @@ +<fontconfig> +<dir>C:\windows\fonts</dir> +</fontconfig> + diff --git a/hacks/text-win.sh b/hacks/text-win.sh new file mode 100644 index 000000000..62e6fed4c --- /dev/null +++ b/hacks/text-win.sh @@ -0,0 +1 @@ +/opt/mxe/usr/bin/x86_64-w64-mingw32.shared-g++ -o text.exe text.cc $(/opt/mxe/usr/bin/x86_64-w64-mingw32.shared-pkg-config pkg-config --cflags --libs cairomm-1.0 glibmm-2.4 pangomm-1.4) diff --git a/hacks/text.cc b/hacks/text.cc new file mode 100644 index 000000000..bf391a325 --- /dev/null +++ b/hacks/text.cc @@ -0,0 +1,59 @@ +#include <cairomm/cairomm.h> +#include <pangomm.h> +#include <pangomm/init.h> +#include <glibmm.h> +#include <stdint.h> + +int main () +{ +#ifdef __MINGW32__ + putenv ("PANGOCAIRO_BACKEND=fontconfig"); + putenv ("FONTCONFIG_PATH=."); +#endif + + Pango::init (); + + int const width = 640; + int const height = 480; + uint8_t* data = new uint8_t[width * height * 4]; + + Cairo::RefPtr<Cairo::ImageSurface> surface = Cairo::ImageSurface::create ( + data, + Cairo::FORMAT_ARGB32, + width, height, + /* Cairo ARGB32 means first byte blue, second byte green, third byte red, fourth byte alpha */ + Cairo::ImageSurface::format_stride_for_width (Cairo::FORMAT_ARGB32, width) + ); + + Cairo::RefPtr<Cairo::Context> context = Cairo::Context::create (surface); + + Glib::RefPtr<Pango::Layout> layout = Pango::Layout::create (context); + + context->set_source_rgb (1, 0.2, 0.3); + context->rectangle (0, 0, width, height); + context->fill (); + + layout->set_alignment (Pango::ALIGN_LEFT); + + context->set_line_width (1); + // Cairo::FontOptions fo; + // context->get_font_options (fo); + // fo.set_antialias (Cairo::ANTIALIAS_NONE); + // context->set_font_options (fo); + + Pango::FontDescription font ("Arial"); + layout->set_font_description (font); + layout->set_markup ("Hello world!"); + + layout->update_from_cairo_context (context); + + context->set_source_rgb (1, 1, 1); + context->set_line_width (0); + context->move_to (0, 0); + context->scale (2, 2); + layout->show_in_cairo_context (context); + + surface->write_to_png ("text.png"); + + return 0; +} diff --git a/hacks/text.sh b/hacks/text.sh new file mode 100644 index 000000000..f24e9be5c --- /dev/null +++ b/hacks/text.sh @@ -0,0 +1,3 @@ +#!/bin/bash +g++ -o text text.cc `pkg-config --cflags --libs cairomm-1.0 glibmm-2.4 pangomm-1.4` +docker run -u $USER -w $(pwd) -v $(pwd):$(pwd) -e PKG_CONFIG_PATH=/opt/mxe/usr/x86_64-w64-mingw32.shared/lib/pkgconfig -it windows /bin/bash text-win.sh |
