sdl_pango: new recipe (#979)

This commit is contained in:
Schrijvers Luc
2017-01-02 13:56:25 +01:00
committed by Jérôme Duval
parent 52c6446253
commit 7c38b97118
2 changed files with 188 additions and 0 deletions

View File

@@ -0,0 +1,105 @@
From 5296b04fac8a8a447685d9c7a2287b38045e6811 Mon Sep 17 00:00:00 2001
From: begasus <begasus@gmail.com>
Date: Sun, 1 Jan 2017 00:36:49 +0100
Subject: Patch taken from http://zarb.org/~gc/t/SDL_Pango-0.1.2-API-adds.patch
diff --git a/src/SDL_Pango.c b/src/SDL_Pango.c
index 2118cd2..97d0347 100644
--- a/src/SDL_Pango.c
+++ b/src/SDL_Pango.c
@@ -729,7 +729,7 @@ SDLPango_CopyFTBitmapToSurface(
@return A pointer to the context as a SDLPango_Context*.
*/
SDLPango_Context*
-SDLPango_CreateContext()
+SDLPango_CreateContext_GivenFontDesc(const char* font_desc)
{
SDLPango_Context *context = g_malloc(sizeof(SDLPango_Context));
G_CONST_RETURN char *charset;
@@ -744,7 +744,7 @@ SDLPango_CreateContext()
pango_context_set_base_dir (context->context, PANGO_DIRECTION_LTR);
context->font_desc = pango_font_description_from_string(
- MAKE_FONT_NAME (DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE));
+ context->font_desc = pango_font_description_from_string(font_desc));
context->layout = pango_layout_new (context->context);
@@ -762,6 +762,17 @@ SDLPango_CreateContext()
}
/*!
+ Create a context which contains Pango objects.
+
+ @return A pointer to the context as a SDLPango_Context*.
+*/
+SDLPango_Context*
+SDLPango_CreateContext()
+{
+ SDLPango_CreateContext_GivenFontDesc(MAKE_FONT_NAME(DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE));
+}
+
+/*!
Free a context.
@param *context [i/o] Context to be free
@@ -1053,6 +1064,16 @@ SDLPango_SetMarkup(
pango_layout_set_font_description (context->layout, context->font_desc);
}
+void
+SDLPango_SetText_GivenAlignment(
+ SDLPango_Context *context,
+ const char *text,
+ int length,
+ SDLPango_Alignment alignment)
+{
+ SDLPango_SetText_GivenAlignment(context, text, length, SDLPANGO_ALIGN_LEFT);
+}
+
/*!
Set plain text to context.
Text must be utf-8.
diff --git a/src/SDL_Pango.h b/src/SDL_Pango.h
index 2433661..1acd96f 100644
--- a/src/SDL_Pango.h
+++ b/src/SDL_Pango.h
@@ -109,12 +109,20 @@ typedef enum {
SDLPANGO_DIRECTION_NEUTRAL /*! Neutral */
} SDLPango_Direction;
-
+/*!
+ Specifies alignment of text. See Pango reference for detail
+*/
+typedef enum {
+ SDLPANGO_ALIGN_LEFT,
+ SDLPANGO_ALIGN_CENTER,
+ SDLPANGO_ALIGN_RIGHT
+} SDLPango_Alignment;
extern DECLSPEC int SDLCALL SDLPango_Init();
extern DECLSPEC int SDLCALL SDLPango_WasInit();
+extern DECLSPEC SDLPango_Context* SDLCALL SDLPango_CreateContext_GivenFontDesc(const char* font_desc);
extern DECLSPEC SDLPango_Context* SDLCALL SDLPango_CreateContext();
extern DECLSPEC void SDLCALL SDLPango_FreeContext(
@@ -157,6 +165,12 @@ extern DECLSPEC void SDLCALL SDLPango_SetMarkup(
const char *markup,
int length);
+extern DECLSPEC void SDLCALL SDLPango_SetText_GivenAlignment(
+ SDLPango_Context *context,
+ const char *text,
+ int length,
+ SDLPango_Alignment alignment);
+
extern DECLSPEC void SDLCALL SDLPango_SetText(
SDLPango_Context *context,
const char *markup,
--
2.7.0

View File

@@ -0,0 +1,83 @@
SUMMARY="This library is a wrapper around the Pango library"
DESCRIPTION="SDL_Pango library allows you to use TrueType fonts to \
render internationalized and tagged text in SDL applications."
HOMEPAGE="http://www.libsdl.org/projects/SDL_pango/"
COPYRIGHT="2004 NAKAMURA Ken'ichi'"
LICENSE="GNU GPL v2"
REVISION="1"
SOURCE_URI="https://downloads.sf.net/sdlpango/SDL_Pango-$portVersion.tar.gz"
CHECKSUM_SHA256="7f75d3b97acf707c696ea126424906204ebfa07660162de925173cdd0257eba4"
SOURCE_DIR="SDL_Pango-$portVersion"
#Patch for Frozen-Bubble, originates from here https://sourceforge.net/p/sdlpango/patches/1/
PATCHES="sdl_pango-$portVersion.patchset"
ARCHITECTURES="!x86_gcc2 x86 x86_64"
SECONDARY_ARCHITECTURES="x86_gcc2 x86"
PROVIDES="
sdl_pango$secondaryArchSuffix = $portVersion
lib:libSDL_Pango$secondaryArchSuffix = 1.1.0 compat >= 1
"
REQUIRES="
haiku$secondaryArchSuffix
lib:libSDL$secondaryArchSuffix
lib:libpango_1.0$secondaryArchSuffix
lib:libintl$secondaryArchSuffix
lib:libfreetype$secondaryArchSuffix
lib:libgl$secondaryArchSuffix
#needed for pango
lib:libglib_2.0$secondaryArchSuffix
#needed for pangoft2
lib:libfontconfig$secondaryArchSuffix
lib:libgraphite2$secondaryArchSuffix
"
PROVIDES_devel="
sdl_pango${secondaryArchSuffix}_devel = $portVersion
devel:libSDL_Pango$secondaryArchSuffix = 1.1.0 compat >= 1
"
REQUIRES_devel="
sdl_pango$secondaryArchSuffix == $portVersion base
"
BUILD_REQUIRES="
haiku${secondaryArchSuffix}_devel
devel:libSDL$secondaryArchSuffix
devel:libpango_1.0$secondaryArchSuffix
devel:libintl$secondaryArchSuffix
devel:libfreetype$secondaryArchSuffix
devel:libgl$secondaryArchSuffix
#needed for pango
devel:libglib_2.0$secondaryArchSuffix
#needed for pangoft2
devel:libfontconfig$secondaryArchSuffix
devel:libgraphite2$secondaryArchSuffix
"
BUILD_PREREQUIRES="
cmd:aclocal
cmd:autoconf
cmd:gcc$secondaryArchSuffix
cmd:libtoolize$secondaryArchSuffix
cmd:make
cmd:pkg_config$secondaryArchSuffix
"
BUILD()
{
autoreconf -fi
runConfigure ./configure --prefix=$prefix
make $jobArgs
}
INSTALL()
{
make install
# remove libtool library file
rm $libDir/libSDL_Pango.la
prepareInstalledDevelLib libSDL_Pango
fixPkgconfig
packageEntries devel $developDir
}