Michael Rohan wrote:
> Hi Folks,
>
> Just posted this to comp.fonts, but figured I should try here also.
>
> Not sure if this is the correct group, but I have code that generated
> Unicode strings displayed via Java on X Windows. The strings include
> characters from the Enclosed Alphanumerics Unicode block.
Font-config can do this, though its documentation, API, and command-line
interface are all rather inscrutable. I wrote a program that can take
any character as input and give you the filename of a font with it.
Just put the two files anywhere, then:
make
./CharSearch â
I.e. put the character you're looking for as the first and only
argument. Only tested with en_US.UTF-8 as LANG environment variable.
Matt Flaschen
#include "fontconfig.h"
#include <stdio.h>
#include <locale.h>
#include <wchar.h>
#include <malloc.h>
#include <string.h>
int main(int argc, FcChar8 *argv[])
{
if(argc < 2)
{
fwprintf(stderr, L"Usage: %s c\n", argv[0]);
fwprintf(stderr, L"c is the char to search for.\n");
return -1;
}
FcChar8 *pMyChar8 = argv[1];
FcChar32 myChar32;
FcUtf8ToUcs4(pMyChar8, &myChar32, strlen(pMyChar8));
FcConfig *myConfig = FcInitLoadConfigAndFonts();
FcCharSet *myCharset = FcCharSetCreate();
FcCharSetAddChar(myCharset, myChar32);
FcPattern *myPattern = FcPatternBuild(0, FC_CHARSET, FcTypeCharSet, myCharset, (char *) 0);
FcConfigSubstitute(myConfig, myPattern, 0);
FcDefaultSubstitute(myPattern);
FcResult *result;
FcPattern *foundPattern = FcFontMatch(myConfig, myPattern, result);
FcCharSet *foundCharSet;
char * filename;
int filenameLen, filenameMax;
FcPatternGetString(foundPattern, "file", 0, &filename);
FcPatternGetCharSet(foundPattern, FC_CHARSET, 0, &foundCharSet);
if(FcCharSetHasChar(foundCharSet, myChar32) == FcTrue)
{
wprintf(L"Font file %s contains '%lc'.\n", filename, myChar32);
}
}
CC=gcc
CFLAGS=--std=c99 -I /usr/include -I /usr/include/fontconfig -L /usr/lib/ -l fontconfig
OBJ=CharSearch
CharSearch: CharSearch.c
${CC} ${CFLAGS} CharSearch.c -o ${OBJ}
clean:
rm ${OBJ}
--
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines