Permalink
Browse files

Cleanup #ifdefs for bitmapview.c. charinfo.c, charview.c, fontview.c

Use unicode_name() or unicode_annot(), which then chooses a library to use.
  • Loading branch information...
1 parent c073fb4 commit ecc1bb555e734f85cd0d244affce31c580faa5ab @JoesCat JoesCat committed Mar 31, 2013
Showing with 29 additions and 97 deletions.
  1. +6 −18 fontforge/bitmapview.c
  2. +4 −18 fontforge/charinfo.c
  3. +7 −18 fontforge/charview.c
  4. +12 −43 fontforge/fontview.c
View
@@ -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>
@@ -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 */
@@ -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 ) {
View
@@ -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>
@@ -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];
@@ -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 */
@@ -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 )
View
@@ -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>
@@ -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: */
@@ -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) {
View
@@ -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>
@@ -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],
@@ -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;
@@ -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) {
@@ -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,
@@ -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,
@@ -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 ) {

0 comments on commit ecc1bb5

Please sign in to comment.