Re: Finding a Font to Support a Unicode Block (X11)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux