56    unsigned starting_codept;      
 
   57    unsigned cho_start,  cho_end;  
 
   58    unsigned jung_start, jung_end; 
 
   59    unsigned jong_start, jong_end; 
 
   69 main (
int argc, 
char *argv[]) {
 
   75    unsigned tmp_glyph [16];  
 
   79    struct PARAMS params = { 0xAC00,  
 
   97                        unsigned cho, 
unsigned jung, 
unsigned jong,
 
   98                        unsigned *combined_glyph);
 
  106                "Range: (U+%04X, U+%04X, U+%04X) to (U+%04X, U+%04X, U+%04X)\n",
 
  107                params.cho_start, params.jung_start, params.jong_start,
 
  108                params.cho_end,   params.jung_end,   params.jong_end);
 
  115    for (codept = 0; codept < 
MAX_GLYPHS; codept++) {
 
  116       for (i = 0; i < 16; i++) glyph[codept][i] = 0x0000;
 
  123    if (max_codept > 0x8FF) {
 
  124       fprintf (stderr, 
"\nWARNING: Hangul glyph range exceeds PUA space.\n\n");
 
  127    codept = params.starting_codept;  
 
  129    for (cho = params.cho_start; cho <= params.cho_end; cho++) {
 
  130       for (jung = params.jung_start; jung <= params.jung_end; jung++) {
 
  131          for (jong = params.jong_start; jong <= params.jong_end; jong++) {
 
  134             fprintf (params.outfp,
 
  135                      "(U+%04X, U+%04X, U+%04X)\n",
 
  151    if (params.infp  != stdin)  fclose (params.infp);
 
  152    if (params.outfp != stdout) fclose (params.outfp);
 
  166    void get_hex_range (
char *instring, 
unsigned *start, 
unsigned *end);
 
  168    int strncmp (
const char *s1, 
const char *s2, 
size_t n);
 
  173    while (arg_count < argc) {
 
  175       if (strncmp (argv [arg_count], 
"-all", 4) == 0) {
 
  176          params->starting_codept = 0x0001;
 
  185       else if (strncmp (argv [arg_count], 
"-c", 2) == 0) {
 
  187          if (arg_count < argc) {
 
  188             sscanf (argv [arg_count], 
"%X", ¶ms->starting_codept);
 
  192       else if (strncmp (argv [arg_count], 
"-j1", 3) == 0) {
 
  194          if (arg_count < argc) {
 
  196                            ¶ms->cho_start, ¶ms->cho_end);
 
  221       else if (strncmp (argv [arg_count], 
"-j2", 3) == 0) {
 
  223          if (arg_count < argc) {
 
  225                            ¶ms->jung_start, ¶ms->jung_end);
 
  250       else if (strncmp (argv [arg_count], 
"-j3", 3) == 0) {
 
  252          if (arg_count < argc) {
 
  254                            ¶ms->jong_start, ¶ms->jong_end);
 
  279       else if (strncmp (argv [arg_count], 
"-i", 2) == 0) {
 
  281          if (arg_count < argc) {
 
  282             params->infp = fopen (argv [arg_count], 
"r");
 
  283             if (params->infp == NULL) {
 
  284                fprintf (stderr, 
"\n*** ERROR: Cannot open %s for input.\n\n",
 
  291       else if (strncmp (argv [arg_count], 
"-o", 2) == 0) {
 
  293          if (arg_count < argc) {
 
  294             params->outfp = fopen (argv [arg_count], 
"w");
 
  295             if (params->outfp == NULL) {
 
  296                fprintf (stderr, 
"\n*** ERROR: Cannot open %s for output.\n\n",
 
  303       else if (strncmp (argv [arg_count], 
"-h",     2) == 0 ||
 
  304                strncmp (argv [arg_count], 
"--help", 6) == 0) {
 
  305          printf (
"\nunigen-hangul [options]\n\n");
 
  306          printf (
"     Generates Hangul syllables from an input Unifont .hex file encoded\n");
 
  307          printf (
"     in Johab 6/3/1 format.  By default, the output is the Unicode Hangul\n");
 
  308          printf (
"     Syllables range, U+AC00..U+D7A3.  Options allow the user to specify\n");
 
  309          printf (
"     a starting code point for the output Unifont .hex file, and ranges\n");
 
  310          printf (
"     in hexadecimal of the starting and ending Hangul Jamo code points:\n\n");
 
  312          printf (
"          * 1100-115E Initial consonants (choseong)\n");
 
  313          printf (
"          * 1161-11A7 Medial vowels (jungseong)\n");
 
  314          printf (
"          * 11A8-11FF Final consonants (jongseong).\n\n");
 
  316          printf (
"     A single code point or 0 to omit can be specified instead of a range.\n\n");
 
  318          printf (
"   Option    Parameters    Function\n");
 
  319          printf (
"   ------    ----------    --------\n");
 
  320          printf (
"   -h, --help              Print this message and exit.\n\n");
 
  321          printf (
"   -all                    Generate all Hangul syllables, using all modern and\n");
 
  322          printf (
"                           ancient Hangul in the Unicode range U+1100..U+11FF,\n");
 
  323          printf (
"                           U+A960..U+A97C, and U+D7B0..U+D7FB.\n");
 
  324          printf (
"                           WARNING: this will generate over 1,600,000 syllables\n");
 
  325          printf (
"                           in a 115 megabyte Unifont .hex format file.  The\n");
 
  326          printf (
"                           default is to only output modern Hangul syllables.\n\n");
 
  327          printf (
"   -c        code_point    Starting code point in hexadecimal for output file.\n\n");
 
  328          printf (
"   -j1       start-end     Choseong (jamo 1) start-end range in hexadecimal.\n\n");
 
  329          printf (
"   -j2       start-end     Jungseong (jamo 2) start-end range in hexadecimal.\n\n");
 
  330          printf (
"   -j3       start-end     Jongseong (jamo 3) start-end range in hexadecimal.\n\n");
 
  331          printf (
"   -i        input_file    Unifont hangul-base.hex formatted input file.\n\n");
 
  332          printf (
"   -o        output_file   Unifont .hex format output file.\n\n");
 
  333          printf (
"      Example:\n\n");
 
  334          printf (
"         unigen-hangul -c 1 -j3 11AB-11AB -i hangul-base.hex -o nieun-only.hex\n\n");
 
  335          printf (
"      Generates Hangul syllables using all modern choseong and jungseong,\n");
 
  336          printf (
"      and only the jongseong nieun (Unicode code point U+11AB).  The output\n");
 
  337          printf (
"      Unifont .hex file will contain code points starting at 1.  Instead of\n");
 
  338          printf (
"      specifying \"-j3 11AB-11AB\", simply using \"-j3 11AB\" will also suffice.\n\n");
 
  359    sscanf (instring, 
"%X", start);
 
  361         instring [i] != 
'\0' && instring [i] != 
'-';
 
  364    if (instring [i] == 
'-') {
 
  366       sscanf (&instring [i], 
"%X", end);
 
Define constants and function prototypes for using Hangul glyphs.
void print_glyph_hex(FILE *fp, unsigned codept, unsigned *this_glyph)
Print one glyph in Unifont hexdraw hexadecimal string style.
void combined_jamo(unsigned glyph_table[MAX_GLYPHS][16], unsigned cho, unsigned jung, unsigned jong, unsigned *combined_glyph)
Convert Hangul Jamo choseong, jungseong, and jongseong into a glyph.
#define CHO_UNICODE_START
Modern Hangul choseong start.
#define JONG_UNICODE_END
Modern Hangul jongseong end.
#define JUNG_EXTB_UNICODE_START
Hangul Extended-B jungseong start.
#define JONG_EXTB_UNICODE_END
Hangul Extended-B jongseong end.
#define CHO_EXTA_UNICODE_START
Hangul Extended-A choseong start.
#define JONG_UNICODE_START
Modern Hangul jongseong start.
#define CHO_UNICODE_END
Hangul Jamo choseong end.
#define CHO_EXTA_UNICODE_END
Hangul Extended-A choseong end.
#define JUNG_UNICODE_START
Modern Hangul jungseong start.
#define JONG_EXTB_UNICODE_START
Hangul Extended-B jongseong start.
#define JUNG_UNICODE_END
Modern Hangul jungseong end.
unsigned hangul_read_base16(FILE *infp, unsigned base[][16])
Read hangul-base.hex file into a unsigned array.
#define JUNG_EXTB_UNICODE_END
Hangul Extended-B jungseong end.
#define MAX_GLYPHS
An OpenType font has at most 65536 glyphs.
int main(int argc, char *argv[])
Program entry point.
void get_hex_range(char *instring, unsigned *start, unsigned *end)
Scan a hexadecimal range from a character string.
void parse_args(int argc, char *argv[], struct PARAMS *params)
Parse command line arguments.