Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: Better Text Rendering for cairo / lua #1501

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
2a0db1d
lua text: Supporting infra
simotek Jan 14, 2023
79b81a6
lua text: initial implementation.
simotek Feb 14, 2023
24706e8
Add the ability to center and right align text.
simotek Apr 11, 2023
d5d20e8
lua text: Remove test code
simotek Apr 12, 2023
b625e93
lua text: Supporting infra
simotek Jan 14, 2023
4077ad5
lua text: initial implementation.
simotek Feb 14, 2023
00b2ec0
Commit the WIP so I can merge it
simotek Feb 12, 2024
5036cc4
Fix for #1698
simotek Feb 14, 2024
488b450
Fix comment hb-unicode.h should be hb-common.h
simotek Feb 14, 2024
b0063e5
Swap to using optional parameters
simotek Feb 14, 2024
945ce1f
Add Hack for RTL positioning
simotek Feb 15, 2024
dc7c0e0
Remove Top to Bottom Fixme's they are fixed
simotek Feb 15, 2024
ca1be94
Merge branch 'lua-text-helper2' into lua-text-helper3
simotek Feb 15, 2024
47c45af
Some general cleanup post merge
simotek Feb 15, 2024
7553faf
Attempt to fix workflows by adding freetype dep
simotek Feb 15, 2024
2c74058
Probably actually need freetype6
simotek Feb 15, 2024
7e2a662
Try again, I don't understand Ubuntu
simotek Feb 15, 2024
ac50fa7
Try something from google
simotek Feb 15, 2024
ba71b73
lua-text: Move to caching fonts in C
simotek Feb 21, 2024
8f34c9d
Revert "Fix for #1698"
simotek Feb 22, 2024
9ba643c
docs: tolua++ now works with more then lua5.1
simotek Feb 22, 2024
f4f7462
lua-text: Add docs.
simotek Feb 22, 2024
e5482ca
lua-text: Fix build with
simotek Mar 5, 2024
f9676c6
Merge branch 'main' into lua-text-helper3
simotek Oct 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/build-and-test-linux.yaml
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could probably enable this in the macos build too, if you want to take a stab at that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once I figure out why the ubuntu builds are failing i'll have a shot at enabling it.

Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ jobs:
-DBUILD_LUA_CAIRO=ON \
-DBUILD_LUA_IMLIB2=ON \
-DBUILD_LUA_RSVG=${RSVG_ENABLED} \
-DBUILD_LUA_TEXT=ON \
-DBUILD_MYSQL=ON \
-DBUILD_NVIDIA=ON \
-DBUILD_PULSEAUDIO=ON \
Expand Down
3 changes: 3 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,9 @@ Mikko Sysikaski <sisu at users dot sourceforge dot net>
Sceptik <sceptik at users dot sourceforge dot net>
--quiet patch

Simon Lees <sflees at suse dot de>
lua text

Stepan Zastupov <redchrom at gmail dot com>
WiFi signal level detection support on FreeBSD

Expand Down
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ RUN apt-get update \
libcairo2-dev \
libcurl4-openssl-dev \
libdbus-glib-1-dev \
libfontconfig-dev \
libfreetype-dev \
libharfbuzz-dev \
libical-dev \
libimlib2-dev \
libircclient-dev \
Expand Down Expand Up @@ -76,6 +79,7 @@ RUN sh -c 'if [ "$X11" = "yes" ] ; then \
-DBUILD_LUA_CAIRO=ON \
-DBUILD_LUA_IMLIB2=ON \
-DBUILD_LUA_RSVG=ON \
-DBUILD_LUA_TEXT=ON \
-DBUILD_MYSQL=ON \
-DBUILD_NVIDIA=ON \
-DBUILD_PULSEAUDIO=ON \
Expand All @@ -98,6 +102,7 @@ RUN sh -c 'if [ "$X11" = "yes" ] ; then \
-DBUILD_LUA_CAIRO=ON \
-DBUILD_LUA_IMLIB2=ON \
-DBUILD_LUA_RSVG=ON \
-DBUILD_LUA_TEXT=ON \
-DBUILD_MYSQL=ON \
-DBUILD_PULSEAUDIO=ON \
-DBUILD_RSS=ON \
Expand All @@ -121,6 +126,9 @@ RUN apt-get update \
libcairo2 \
libcurl4 \
libdbus-glib-1-2 \
libfontconfig1 \
libfreetype6 \
libharfbuzz-gobject0 \
libical3 \
libimlib2 \
libircclient1 \
Expand Down
1 change: 1 addition & 0 deletions appimage/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ cmake -G Ninja \
-DBUILD_LUA_CAIRO=ON \
-DBUILD_LUA_IMLIB2=ON \
-DBUILD_LUA_RSVG=ON \
-DBUILD_LUA_TEXT=ON \
-DBUILD_MYSQL=ON \
-DBUILD_NVIDIA=ON \
-DBUILD_PULSEAUDIO=ON \
Expand Down
1 change: 1 addition & 0 deletions cmake/ConkyBuildOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ endif(OWN_WINDOW)
option(BUILD_LUA_CAIRO "Build cairo bindings for Lua" false)
option(BUILD_LUA_IMLIB2 "Build Imlib2 bindings for Lua" false)
option(BUILD_LUA_RSVG "Build rsvg bindings for Lua" false)
option(BUILD_LUA_TEXT "Build Fontconfig Freetype and Harfbuzz bindings for Lua" false)

option(BUILD_AUDACIOUS "Build audacious (music player) support" false)

Expand Down
11 changes: 11 additions & 0 deletions cmake/ConkyPlatformChecks.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,17 @@ if(BUILD_X11)
set(luarsvg_libs ${RSVG_LIBRARIES} ${LUA_LIBRARIES})
set(luarsvg_includes ${RSVG_INCLUDE_DIRS} ${LUA_INCLUDE_DIR})
endif(BUILD_LUA_RSVG)
if(BUILD_LUA_TEXT)
if(FREETYPE_INCLUDE_DIR_freetype2)
set(FREETYPE_FOUND true)
else(FREETYPE_INCLUDE_DIR_freetype2)
message(FATAL_ERROR "Unable to find freetype library")
endif(FREETYPE_INCLUDE_DIR_freetype2)
PKG_CHECK_MODULES(FONTCONFIG REQUIRED fontconfig)
PKG_CHECK_MODULES(HARFBUZZ REQUIRED harfbuzz)
set(luatext_libs ${FREETYPE_LIBRARIES} ${FONTCONFIG_LIBRARIES} ${HARFBUZZ_LIBRARIES} ${LUA_LIBRARIES})
set(luatext_includes ${FREETYPE_INCLUDE_DIR_freetype2} ${FONTCONFIG_INCLUDE_DIRS} ${HARFBUZZ_INCLUDE_DIRS} ${LUA_INCLUDE_DIRS})
endif(BUILD_LUA_TEXT)
endif(BUILD_X11)

if(BUILD_AUDACIOUS)
Expand Down
2 changes: 2 additions & 0 deletions cmake/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@

#cmakedefine BUILD_LUA_RSVG 1

#cmakedefine BUILD_LUA_TEXT 1

#cmakedefine BUILD_IBM 1

#cmakedefine BUILD_RSS 1
Expand Down
17 changes: 17 additions & 0 deletions lua/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ if(BUILD_X11)
print_target_properties(conky-rsvg)
endif(BUILD_LUA_RSVG)


if(BUILD_LUA_CAIRO AND BUILD_LUA_IMLIB2)
include_directories(${luacairo_includes} ${luaimlib2_includes}
${CMAKE_CURRENT_SOURCE_DIR})
Expand All @@ -90,6 +91,22 @@ if(BUILD_X11)
toluapp_lib_static)
set(lua_libs ${lua_libs} conky-cairo_imlib2_helper)
endif(BUILD_LUA_CAIRO AND BUILD_LUA_IMLIB2)

if(BUILD_LUA_CAIRO AND BUILD_LUA_TEXT)
include_directories(${luacairo_includes} ${luatext_includes}
${CMAKE_CURRENT_SOURCE_DIR})
wrap_tolua(luacairo_text_helper_src cairo_text_helper.pkg)

add_library(conky-cairo_text_helper SHARED ${luacairo_text_helper_src})
set_target_properties(conky-cairo_text_helper
PROPERTIES OUTPUT_NAME "cairo_text_helper")

target_link_libraries(conky-cairo_text_helper
${luacairo_libs}
${luatext_libs}
toluapp_lib_static)
set(lua_libs ${lua_libs} conky-cairo_text_helper)
endif(BUILD_LUA_CAIRO AND BUILD_LUA_TEXT)
endif(BUILD_X11)

install(TARGETS ${lua_libs}
Expand Down
35 changes: 35 additions & 0 deletions lua/cairo_text_helper.pkg
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
$#include <cairo.h>
$#include <libcairo_text_helper.h>

typedef struct _FontData {
cairo_font_face_t *cairo_ft_face;
hb_font_t *hb_ft_font;
hb_face_t *hb_ft_face;
int font_size;
/* Internally the following two are pointers */
/* Stored here so they can be freed later */
FT_Library ft_library;
FT_Face ft_face;
}FontData;

typedef enum _cairo_text_alignment {
CAIRO_TEXT_ALIGN_LEFT = 0,
CAIRO_TEXT_ALIGN_RIGHT,
CAIRO_TEXT_ALIGN_CENTER
} cairo_text_alignment_t;

FontData * cairo_text_hp_load_font(const char *font, int font_size);

void cairo_text_hp_destroy_font(FontData *font);

void cairo_text_hp_simple_show(cairo_t *cr, int x, int y, const char *text, FontData *font);
void cairo_text_hp_simple_show_center(cairo_t *cr, int x, int y, const char *text, FontData *font);
void cairo_text_hp_simple_show_right(cairo_t *cr, int x, int y, const char *text, FontData *font);

void cairo_text_hp_intl_show(cairo_t *cr, int x, int y, cairo_text_alignment_t alignment, const char *text, FontData *font,
const char *direction, const char *script, const char *language);

int cairo_text_hp_text_width(const char *text, FontData *font,
const char *direction, const char *script, const char *language);

int cairo_text_hp_simple_text_width(const char *text, FontData *font);
Loading