Skip to content

Commit

Permalink
Removal of dependency with fontconfig.c
Browse files Browse the repository at this point in the history
  • Loading branch information
fcarlier committed Aug 30, 2013
1 parent 3bc707f commit 9a16339
Show file tree
Hide file tree
Showing 34 changed files with 49 additions and 319 deletions.
6 changes: 3 additions & 3 deletions Makefile
Expand Up @@ -30,7 +30,7 @@ fbi : LDLIBS += $(call ac_lib_mkvar,$(fbi_libs),LDLIBS)

########################################################################
# rules for fib and object files
OBJS_FBI := fb-gui.o fbi.o fbtools.o desktop.o \
OBJS_FBI := fb-gui.o fbi.o fbtools.o \
parseconfig.o fbiconfig.o \
jpegtools.o jpeg/80/transupp.o \
dither.o filter.o op.o readers.o \
Expand All @@ -39,8 +39,8 @@ OBJS_FBI := fb-gui.o fbi.o fbtools.o desktop.o \
OBJS_FBI += $(filter-out wr/%,$(call ac_lib_mkvar,$(fbi_libs),OBJS))

fbi : CFLAGS += -I/opt/fontconfig/include/ -I$(SDKSTAGE)/opt/vc/include/ -I$(SDKSTAGE)/opt/vc/include/freetype/ -I$(CROSS)/include
fbi : LDFLAGS += -lfreetype -lexpat -lfontconfig
fbi : LDLIBS += $(INCLUDES) -L/opt/fontconfig/lib/
fbi : LDFLAGS += -lfreetype -lexpat
fbi : LDLIBS += $(INCLUDES)
fbi : LDLIBS += -ljpeg -lexif -lm -lpng -lz -ltiff -lgif

fbi : $(OBJS_FBI)
Expand Down
24 changes: 6 additions & 18 deletions README
Expand Up @@ -2,19 +2,15 @@
what is it?
===========

Ida is a small and fast image viewer, motif-based. For people who
don't want the KDE/GNOME overhead. Some basic editing functions are
available too.
fbi is a small and fast image viewer, motif-based.
For people who don't want the KDE/GNOME overhead.


build
=====

Check the INSTALL file for detailed build instructions.

ida uses Motif 2.x features (utm, render tables). This means you need
openmotif, lesstif does *not* cut it.

It also uses the usual graphics libraries (libtiff, libpng, libjpeg,
...), you should have them installed to get support for these image
formats.
Expand All @@ -26,22 +22,14 @@ usage
There is a manual page, check it out.


what "ida" stands for?
what "fbi" stands for?
======================

It is just a name. The utility used to be named "iv" for "Image
Viewer", but that gave lots of name clashes. Its very likely that
people name such a tool "iv", it is also used as shortcut for
InterViews (remember Sun's Open Windows?). So i decided to rename it.

I looked for a short name starting with 'i' in a list for children
first names. I like "ida", so I picked this one. It is a old, german
name.

It is just a name ;) for FrameBuffer Image.

Have fun,

Gerd
Florent

--
Gerd Hoffmann <gerd@kraxel.org>
Project Tifaifai
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -16,4 +16,4 @@ The applications originals of Gerd Hoffmann are:
exiftran – command line tool to do lossless transformations of JPEG images. Works much like jpegtran, but unlike jpegtran it does not ignore the EXIF data ;)
thumbnail.cgi – Small and fast CGI script (written in C) to extract EXIF thumbnails from jpeg images and send them to the web browser.

In my case, i want just fbi for RaspBerry Pi
In my case, i want just "fbi" for RaspBerry Pi
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
2.09.0001FC
2.09.0003FC
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file added dither.o
Binary file not shown.
101 changes: 13 additions & 88 deletions fb-gui.c
Expand Up @@ -7,9 +7,6 @@
#include <sys/ioctl.h>
#include <linux/fb.h>

#include <fontconfig/fontconfig.h>
#include <fontconfig/fcfreetype.h>

#include "fbtools.h"
#include "dither.h"
#include "fb-gui.h"
Expand Down Expand Up @@ -607,103 +604,31 @@ void shadow_draw_text_box(FT_Face face, int x, int y, int percent, wchar_t *line

static FT_Library freetype;

//FCC1: Use "/usr/share/fonts/truetype/freefont/FreeSans.ttf", Remove fontconfig
// Voir usage de FT_Stroker_Set, ADD?
//NEW:
FT_Face initialize_fonts(char *font_path, unsigned int font_size)
//FCC: Use "/usr/share/fonts/truetype/freefont/FreeSans.ttf", Remove fontconfig
FT_Face initialize_fonts(char *font_path, int font_size)
{
FT_Face ft_face_ = NULL;
int rc;
FT_Face face = NULL;
int error;

rc = FT_Init_FreeType(&freetype);
if (rc) {
error = FT_Init_FreeType(&freetype);
if (error) {
fprintf(stderr,"FT_Init_FreeType() failed\n");
exit(1);
}
rc = FT_New_Face (freetype, "/usr/share/fonts/truetype/freefont/FreeSans.ttf", 0, &ft_face_);
if (rc)
error = FT_New_Face (freetype, font_path, 0, &face);
if (error) {
fprintf(stderr,"Unable to open font\n");
return NULL;
font_size = 16;
FT_Set_Pixel_Sizes(ft_face_, 0, font_size);
return ft_face_;
}

/*
void destroy_fonts()
{
if (freetype) {
auto error = FT_Done_FreeType(freetype);
assert(!error);
freetype = {};
ft_face_ = {};
}
}
//OLD:
*/
void font_init(void)
{
int rc;

FcInit();
rc = FT_Init_FreeType(&freetype);
if (rc) {
fprintf(stderr,"FT_Init_FreeType() failed\n");
exit(1);
}
}

FT_Face font_open(char *fcname)
{
FcResult result = 0;
FT_Face face = NULL;
FcPattern *pattern,*match;
char *fontname,*h;
FcChar8 *filename;
double pixelsize;
int rc;

// parse + match font name
pattern = FcNameParse(fcname);
FcConfigSubstitute(NULL, pattern, FcMatchPattern);
FcDefaultSubstitute(pattern);
match = FcFontMatch (0, pattern, &result);
FcPatternDestroy(pattern);
if (FcResultMatch != result)
error = FT_Set_Pixel_Sizes(face, 0, font_size);
if (error) {
fprintf(stderr,"Unable to resize font\n");
return NULL;
fontname = FcNameUnparse(match);
h = strchr(fontname, ':');
if (h)
*h = 0;

// try get the face directly
result = FcPatternGetFTFace(match, FC_FT_FACE, 0, &face);
if (FcResultMatch == result) {
fprintf(stderr,"using \"%s\", face=%p\n",fontname,face);
return face;
}

// failing that use the filename
result = FcPatternGetString (match, FC_FILE, 0, &filename);
if (FcResultMatch == result) {
result = FcPatternGetDouble(match, FC_PIXEL_SIZE, 0, &pixelsize);
if (FcResultMatch != result)
pixelsize = 16;
fprintf(stderr,"using \"%s\", pixelsize=%.2lf file=%s\n",
fontname,pixelsize,filename);
rc = FT_New_Face (freetype, filename, 0, &face);
if (rc)
return NULL;
FT_Set_Pixel_Sizes(face, 0, (int)pixelsize);
return face;
}

// oops, didn't work
return NULL;
fprintf(stderr,"pixelsize=%d file=%s\n", font_size, font_path);
return face;
}


/* ---------------------------------------------------------------------- */
/* clear screen (areas) */

Expand Down
5 changes: 1 addition & 4 deletions fb-gui.h
Expand Up @@ -26,10 +26,7 @@ void shadow_draw_string_cursor(FT_Face face, int x, int y, wchar_t *str, int pos
void shadow_draw_text_box(FT_Face face, int x, int y, int percent,
wchar_t *lines[], unsigned int count);

void font_init(void);
FT_Face font_open(char *fcname);
FT_Face initialize_fonts(char *font_path, unsigned int font_size);
//void destroy_fonts();
FT_Face initialize_fonts(char *font_path, int font_size);

void fb_clear_mem(void);
void fb_clear_screen(void);
Binary file added fb-gui.o
Binary file not shown.
Binary file added fbi
Binary file not shown.

0 comments on commit 9a16339

Please sign in to comment.