Skip to content

Commit

Permalink
Rework font rendering
Browse files Browse the repository at this point in the history
- Move font rendering from GLW to "global" code so it can also
  be used by subtitle rendering.

- Use freetype's autohinting to improve visual quality.

- Add support for bold/italic styles (either as separate font faces
  or emulated).

- Request font size as REAL_DIM instead of NOMINAL so we also include
  ascender and descender.

- Include LiberationSans-Regular (GPL:ed) font in the project instead
  of whatever was there before.

- Prepare support for multiple faces so we can load multiple character
  sets.
  • Loading branch information
andoma committed Apr 16, 2011
1 parent d299239 commit 183a843
Show file tree
Hide file tree
Showing 19 changed files with 1,059 additions and 735 deletions.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ SRCS-$(CONFIG_VDPAU) += src/video/vdpau.c

SRCS-$(CONFIG_PS3_VDEC) += src/video/ps3_vdec.c

#
# Audio subsys
#
SRCS-$(CONFIG_LIBFREETYPE) += src/text/freetype.c


#
# Audio subsys
Expand Down
1 change: 1 addition & 0 deletions configure.linux
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ enable httpserver
enable timegm
enable inotify
enable realpath
enable font_liberation
#enable libxrandr -- code does not really work yet

for opt do
Expand Down
1 change: 1 addition & 0 deletions configure.osx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ enable timegm
enable realpath
enable polarssl
enable librtmp
enable font_liberation

for opt do
optval="${opt#*=}"
Expand Down
Binary file removed glwthemes/mono/font.ttf
Binary file not shown.
Binary file not shown.
6 changes: 6 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#include "blobcache.h"
#include "i18n.h"
#include "misc/string.h"
#include "text/text.h"

#if ENABLE_HTTPSERVER
#include "networking/http_server.h"
Expand Down Expand Up @@ -319,6 +320,11 @@ main(int argc, char **argv)
av_log_set_callback(fflog);
av_register_all();

/* Freetype keymapper */
#if ENABLE_LIBFREETYPE
freetype_init();
#endif

/* Global keymapper */
keymapper_init();

Expand Down
26 changes: 2 additions & 24 deletions src/misc/pixmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ pixmap_release(pixmap_t *pm)
return;

if(pm->pm_codec == CODEC_ID_NONE) {
avpicture_free(&pm->pm_pict);
free(pm->pm_pixels);
free(pm->pm_charpos);
} else {
free(pm->pm_data);
}
Expand All @@ -71,26 +72,3 @@ pixmap_dup(pixmap_t *pm)
atomic_add(&pm->pm_refcount, 1);
return pm;
}


/**
*
*/
pixmap_t *
pixmap_create_rgb24(int width, int height, const void *pixels, int pitch)
{
pixmap_t *pm = calloc(1, sizeof(pixmap_t));

pm->pm_refcount = 1;
pm->pm_codec = CODEC_ID_NONE;

pm->pm_width = width;
pm->pm_height = height;
pm->pm_pixfmt = PIX_FMT_RGB24;

pm->pm_pict.data[0] = malloc(height * pitch);
pm->pm_pict.linesize[0] = pitch;

memcpy(pm->pm_pict.data[0], pixels, height * pitch);
return pm;
}
45 changes: 32 additions & 13 deletions src/misc/pixmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,33 +43,52 @@
typedef struct pixmap {
int pm_refcount;

int pm_orientation;
uint8_t pm_orientation;

int pm_width;
int pm_height;
uint16_t pm_width;
uint16_t pm_height;
uint16_t pm_lines; // Lines of text

int pm_flags;

#define PIXMAP_THUMBNAIL 0x1 // This is a thumbnail
#define PIXMAP_THUMBNAIL 0x1 // This is a thumbnail
#define PIXMAP_TEXT_WRAPPED 0x2 // Contains wrapped text
#define PIXMAP_TEXT_ELLIPSIZED 0x4 // Contains ellipsized text

enum CodecID pm_codec;

// if pm_codec == CODEC_ID_NONE
enum PixelFormat pm_pixfmt;
AVPicture pm_pict;
union {
struct {
// if pm_codec == CODEC_ID_NONE
uint8_t *pixels;
int *charpos;

// if pm_codec != CODEC_ID_NONE
void *pm_data;
size_t pm_size;
enum PixelFormat pixfmt;
int linesize;
int charposlen;
} raw;

struct {
// if pm_codec != CODEC_ID_NONE
void *data;
size_t size;
} codec;
};

} pixmap_t;

#define pm_data codec.data
#define pm_size codec.size

#define pm_pixfmt raw.pixfmt
#define pm_pixels raw.pixels
#define pm_linesize raw.linesize
#define pm_charpos raw.charpos
#define pm_charposlen raw.charposlen

pixmap_t *pixmap_alloc_coded(const void *data, size_t size,
enum CodecID codec);

pixmap_t *pixmap_create_rgb24(int width, int height, const void *pixels,
int pitch);

pixmap_t *pixmap_dup(pixmap_t *pm);

void pixmap_release(pixmap_t *pm);
Expand Down
Loading

0 comments on commit 183a843

Please sign in to comment.