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

Unicode libs x3 #489

Merged
merged 5 commits into from
Apr 2, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion fontforge/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ libfontforge_la_SOURCES = asmfpst.c autohint.c autosave.c autotrace.c \
ttfspecial.c ufo.c unicoderange.c utils.c winfonts.c zapfnomen.c \
groups.c langfreq.c ftdelta.c autowidth2.c woff.c stamp.c \
activeinui.c pluginloading.c is_LIGATURE.c flaglist.c strlist.c \
collabclient.c collabclient.h
collabclient.c collabclient.h unicodelibinfo.c
nodist_libfontforge_la_SOURCES = libstamp.c
EXTRA_libfontforge_la_SOURCES = splinerefigure.c

Expand Down
24 changes: 6 additions & 18 deletions fontforge/bitmapview.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,6 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "fontforgeui.h"
#ifndef _NO_LIBUNINAMESLIST
#include <uninameslist.h>
#else
#ifndef _NO_LIBUNICODENAMES
#include <libunicodenames.h>
extern uninm_names_db names_db; /* Unicode character names and annotations database */
#endif
#endif
#include <gkeysym.h>
#include <utype.h>
#include <ustring.h>
Expand Down Expand Up @@ -173,6 +165,7 @@ static char *BVMakeTitles(BitmapView *bv, BDFChar *bc,char *buf) {
char *title;
SplineChar *sc;
BDFFont *bdf = bv->bdf;
char *uniname;

sc = bc->sc;
/* GT: This is the title for a window showing a bitmap character */
Expand All @@ -185,19 +178,14 @@ static char *BVMakeTitles(BitmapView *bv, BDFChar *bc,char *buf) {
sprintf(buf,_("%1$.80s at %2$d size %3$d from %4$.80s"),
sc!=NULL ? sc->name : "<Nameless>", bv->enc, bdf->pixelsize, sc==NULL ? "" : sc->parent->fontname);
title = copy(buf);
#if _NO_LIBUNINAMESLIST && _NO_LIBUNICODENAMES
#else
const char *uniname;
#ifndef _NO_LIBUNINAMESLIST
if ( (uniname=uniNamesList_name(sc->unicodeenc))!=NULL ) {
#else
if ( sc->unicodeenc!=-1 && (uniname=uninm_name(names_db,(unsigned int) sc->unicodeenc))!= NULL) {
#endif

/* Enhance 'buf' description with Nameslist.txt unicode name definition */
if ( (uniname=unicode_name(sc->unicodeenc))!=NULL ) {
strcat(buf, " ");
strcpy(buf+strlen(buf), uniname);
free(uniname);
}
#endif
return( title );
return( title );
}

void BVChangeBC(BitmapView *bv, BDFChar *bc, int fitit ) {
Expand Down
22 changes: 4 additions & 18 deletions fontforge/charinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,6 @@
*/

#include "fontforgeui.h"
#ifndef _NO_LIBUNINAMESLIST
#include <uninameslist.h>
#else
#ifndef _NO_LIBUNICODENAMES
#include <libunicodenames.h>
extern uninm_names_db names_db; /* Unicode character names and annotations database */
#endif
#endif
#include <ustring.h>
#include <math.h>
#include <utype.h>
Expand Down Expand Up @@ -1680,7 +1672,7 @@ return( true );
* subtables. */
static char *LigDefaultStr(int uni, char *name, int alt_lig ) {
const unichar_t *alt=NULL, *pt;
char *components = NULL;
char *components = NULL, *tmp;
int len;
unichar_t hack[30], *upt;
char buffer[80];
Expand All @@ -1704,13 +1696,7 @@ static char *LigDefaultStr(int uni, char *name, int alt_lig ) {
uni!=0x215f &&
!((uni>=0x0958 && uni<=0x095f) || uni==0x929 || uni==0x931 || uni==0x934)) {
alt = NULL;
#if _NO_LIBUNINAMESLIST && _NO_LIBUNICODENAMES
#else
#ifndef _NO_LIBUNINAMESLIST
} else if ( uniNamesList_name(uni)==NULL ) {
#else
} else if ( names_db==NULL ) {
#endif
} else if ( (tmp=unicode_name(65))==NULL ) { /* test for 'A' to see if library exists */
if ( (uni>=0xbc && uni<=0xbe ) || /* Latin1 fractions */
(uni>=0x2153 && uni<=0x215e ) || /* other fractions */
(uni>=0xfb00 && uni<=0xfb06 ) || /* latin ligatures */
Expand All @@ -1723,8 +1709,8 @@ static char *LigDefaultStr(int uni, char *name, int alt_lig ) {
; /* These are good */
else
alt = NULL;
#endif
}
} else
free(tmp); /* found 'A' means there is a library, now cleanup */
}
if ( alt==NULL ) {
if ( name==NULL || alt_lig )
Expand Down
25 changes: 7 additions & 18 deletions fontforge/charview.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,6 @@

#include "fontforgeui.h"
#include "cvruler.h"
#ifndef _NO_LIBUNINAMESLIST
#include <uninameslist.h>
#else
#ifndef _NO_LIBUNICODENAMES
#include <libunicodenames.h>
extern uninm_names_db names_db; /* Unicode character names and annotations database */
#endif
#endif
#include <math.h>
#include <locale.h>
#include <ustring.h>
Expand Down Expand Up @@ -2983,6 +2975,7 @@ return( ((FontView *) (cv->b.fv))->b.map->backmap[cv->b.sc->orig_pos] );
static char *CVMakeTitles(CharView *cv,char *buf) {
char *title;
SplineChar *sc = cv->b.sc;
char *uniname;

/* GT: This is the title for a window showing an outline character */
/* GT: It will look something like: */
Expand All @@ -2995,21 +2988,17 @@ static char *CVMakeTitles(CharView *cv,char *buf) {
if ( sc->changed )
strcat(buf," *");
title = copy(buf);
#if _NO_LIBUNINAMESLIST && _NO_LIBUNICODENAMES
#else
const char *uniname;
#ifndef _NO_LIBUNINAMESLIST
if ( (uniname=uniNamesList_name(sc->unicodeenc))!=NULL ) {
#else
if ( sc->unicodeenc!=-1 && (uniname=uninm_name(names_db,sc->unicodeenc))!=NULL ) {
#endif

/* Enhance 'buf' description with Nameslist.txt unicode name definition */
if ( (uniname=unicode_name(sc->unicodeenc))!=NULL ) {
strcat(buf, " ");
strcpy(buf+strlen(buf), uniname);
free(uniname);
}
#endif

if ( cv->show_ft_results || cv->dv )
sprintf(buf+strlen(buf), " (%gpt, %ddpi)", (double) cv->ft_pointsizey, cv->ft_dpi );
return( title );
return( title );
}

static void SC_RefreshTitles(SplineChar *sc) {
Expand Down
8 changes: 8 additions & 0 deletions fontforge/fontforge.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ extern void CheckIsScript(int argc, char *argv[]);
extern char *AdobeStandardEncoding[256];
extern int32 unicode_from_adobestd[256];

/* unicode_nameannot - Deprecated, but kept for older programs to access. */
#if _NO_LIBUNINAMESLIST
struct unicode_nameannot {
const char *name, *annot;
};
#endif
extern const struct unicode_nameannot * const *const *_UnicodeNameAnnot;

extern int default_fv_font_size;
extern int default_fv_antialias;
extern int default_fv_bbsized;
Expand Down
55 changes: 12 additions & 43 deletions fontforge/fontview.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,6 @@
#include "fontforgeui.h"
#include "groups.h"
#include "psfont.h"
#ifndef _NO_LIBUNINAMESLIST
#include <uninameslist.h>
#else
#ifndef _NO_LIBUNICODENAMES
#include <libunicodenames.h>
extern uninm_names_db names_db; /* Unicode character names and annotations database */
#endif
#endif
#include <gfile.h>
#include <gio.h>
#include <gresedit.h>
Expand Down Expand Up @@ -6299,19 +6291,12 @@ return;
}

if (uni != -1) {
#if _NO_LIBUNINAMESLIST && _NO_LIBUNICODENAMES
#else
/* Get unicode "Name" as defined in NameList.txt */
const char *uniname;
#ifndef _NO_LIBUNINAMESLIST
if ( (uniname=uniNamesList_name(uni))!=NULL ) {
#else
if ( (uniname=uninm_name(names_db,(unsigned int) uni))!= NULL ) {;
#endif
char *uniname;
if ( (uniname=unicode_name(uni))!=NULL ) {
/* Show unicode "Name" as defined in NameList.txt */
utf82u_strncpy(ubuffer+u_strlen(ubuffer),uniname,80);
} else
#endif
if ( uni>=0xAC00 && uni<=0xD7A3 ) {
free(uniname);
} else if ( uni>=0xAC00 && uni<=0xD7A3 ) {
sprintf( buffer, "Hangul Syllable %s%s%s",
chosung[(uni-0xAC00)/(21*28)],
jungsung[(uni-0xAC00)/28%21],
Expand Down Expand Up @@ -6522,8 +6507,6 @@ return;
}
}

#if _NO_LIBUNINAMESLIST && _NO_LIBUNICODENAMES
#else
static void utf82u_annot_strncat(unichar_t *to, const char *from, int len) {
register unichar_t ch;

Expand All @@ -6537,7 +6520,6 @@ static void utf82u_annot_strncat(unichar_t *to, const char *from, int len) {
}
*to = 0;
}
#endif

void SCPreparePopup(GWindow gw,SplineChar *sc,struct remap *remap, int localenc,
int actualuni) {
Expand Down Expand Up @@ -6584,14 +6566,8 @@ void SCPreparePopup(GWindow gw,SplineChar *sc,struct remap *remap, int localenc,
}

if ( !done ) {
#if _NO_LIBUNINAMESLIST && _NO_LIBUNICODENAMES
#else
const char *uniname;
#ifndef _NO_LIBUNINAMESLIST
if ( (uniname=uniNamesList_name(upos))!=NULL ) {
#else
if ( (uniname=uninm_name(names_db,upos))!=NULL ) {
#endif
char *uniname;
if ( (uniname=unicode_name(upos))!=NULL ) {
/* uniname=unicode "Name" as defined in NameList.txt */
#if defined( _NO_SNPRINTF )
sprintf( cspace, "%u 0x%x U+%04x \"%.25s\" %.100s", localenc, localenc, upos, sc->name==NULL?"":sc->name,
Expand All @@ -6601,9 +6577,8 @@ void SCPreparePopup(GWindow gw,SplineChar *sc,struct remap *remap, int localenc,
uniname);
#endif
utf82u_strcpy(space,cspace);
} else
#endif
if ( upos>=0xAC00 && upos<=0xD7A3 ) {
free(uniname);
} else if ( upos>=0xAC00 && upos<=0xD7A3 ) {
#if defined( _NO_SNPRINTF )
sprintf( cspace, "%u 0x%x U+%04x \"%.25s\" Hangul Syllable %s%s%s",
localenc, localenc, upos, sc->name==NULL?"":sc->name,
Expand All @@ -6629,22 +6604,16 @@ void SCPreparePopup(GWindow gw,SplineChar *sc,struct remap *remap, int localenc,
utf82u_strcpy(space,cspace);
}
}
#if _NO_LIBUNINAMESLIST && _NO_LIBUNICODENAMES
#else
const char *uniannot;
#ifndef _NO_LIBUNINAMESLIST
if ( (uniannot=uniNamesList_name(upos))!=NULL ) {
#else
if ( (uniannot=uninm_annotation(names_db,upos))!=NULL ) {
#endif
char *uniannot;
if ( (uniannot=unicode_annot(upos))!=NULL ) {
/* uniannot=unicode "Annotations" as defined in NameList.txt */
int left = sizeof(space)/sizeof(space[0]) - u_strlen(space)-1;
if ( left>4 ) {
uc_strcat(space,"\n");
utf82u_annot_strncat(space, uniannot, left-2);
}
free(uniannot);
}
#endif
if ( sc->comment!=NULL ) {
int left = sizeof(space)/sizeof(space[0]) - u_strlen(space)-1;
if ( left>4 ) {
Expand Down
4 changes: 4 additions & 0 deletions fontforge/splinefont.h
Original file line number Diff line number Diff line change
Expand Up @@ -2766,6 +2766,10 @@ extern char **NamesReadMacBinary(char *filename);
extern void SFSetOrder(SplineFont *sf,int order2);
extern int SFFindOrder(SplineFont *sf);

extern void inituninameannot(void);
extern char *unicode_name(int32 unienc);
extern char *unicode_annot(int32 unienc);

extern const char *UnicodeRange(int unienc);
extern SplineChar *SCBuildDummy(SplineChar *dummy,SplineFont *sf,EncMap *map,int i);
extern SplineChar *SFMakeChar(SplineFont *sf,EncMap *map,int i);
Expand Down
15 changes: 1 addition & 14 deletions fontforge/start.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@
*/
#include "fontforgevw.h"
#include "pluginloading.h"
#ifndef _NO_LIBUNICODENAMES
#include <libunicodenames.h>
uninm_names_db names_db; /* Unicode character names and annotations database */
#endif
#include <gfile.h>
#include <time.h>
#include <sys/time.h>
Expand Down Expand Up @@ -108,16 +104,7 @@ void InitSimpleStuff(void) {
else if ( *localeinfo.decimal_point!='.' ) coord_sep=" ";
if ( getenv("FF_SCRIPT_IN_LATIN1") ) use_utf8_in_script=false;

#ifndef _NO_LIBUNICODENAMES
char *names_db_file;

/* Load character names and annotations that come from the Unicode NamesList.txt */
/* This should not be done until after the locale has been set. */
names_db_file = uninm_find_names_db(NULL);
names_db = (names_db_file == NULL) ? ((uninm_names_db) 0) : uninm_names_db_open(names_db_file);
free(names_db_file);
/* NOTE: you need to do uninm_names_db_close(names_db); when you exit program */
#endif
inituninameannot(); /* Note: unicodenames done after locales set */

SetDefaults();
}
Expand Down
Loading