72 while (fgets (instring,
MAXLINE, infp) != NULL) {
73 sscanf (instring,
"%X", &codept);
76 if (codept < MAX_GLYPHS) {
78 for (i = 1; instring[i] !=
'\0' && instring[i] !=
':'; i++);
79 if (instring[i] ==
':') {
81 for (j = 0; j < 32; j++) {
82 sscanf (&instring[i],
"%2hhX", &base[codept][j]);
85 if (codept > max_codept) max_codept = codept;
125 while (fgets (instring,
MAXLINE, infp) != NULL) {
126 sscanf (instring,
"%X", &codept);
129 if (codept < MAX_GLYPHS) {
131 for (i = 1; instring[i] !=
'\0' && instring[i] !=
':'; i++);
132 if (instring[i] ==
':') {
134 for (j = 0; j < 16; j++) {
135 sscanf (&instring[i],
"%4X", &base[codept][j]);
138 if (codept > max_codept) max_codept = codept;
169 if (codept < 0xAC00 || codept > 0xD7A3) {
170 *initial = *medial = *
final = -1;
174 *initial = codept / (28 * 21);
175 *medial = (codept / 28) % 21;
176 *
final = codept % 28 - 1;
205 if (initial >= 0 && initial <= 18 &&
206 medial >= 0 && medial <= 20 &&
207 final >= 0 &&
final <= 26) {
210 codept += initial * 21 * 28;
211 codept += medial * 28;
250 int *cho_index,
int *jung_index,
int *jong_index) {
263 *jong_index = jongseong < 0 ? 0x0000 :
299 int *cho_var,
int *jung_var,
int *jong_var) {
301 int cho_variation (
int choseong,
int jungseong,
int jongseong);
359 static int choseong_var [TOTAL_JUNG + 1] = {
397#ifdef EXTENDED_HANGUL
413 if (jungseong < 0 || jungseong >= TOTAL_JUNG) {
437 static int wide_vowel [TOTAL_JUNG + 1] = {
475#ifdef EXTENDED_HANGUL
491 if (vowel >= 0 && vowel < TOTAL_JUNG) {
492 retval = wide_vowel [vowel];
532 if (jongseong >= 0) {
584 unsigned char hangul_base[][32],
unsigned char *syllable) {
587 int cho_hex, jung_hex, jong_hex;
588 unsigned char glyph_byte;
592 &cho_hex, &jung_hex, &jong_hex);
594 for (i = 0; i < 32; i++) {
595 glyph_byte = hangul_base [cho_hex][i];
596 glyph_byte |= hangul_base [jung_hex][i];
597 if (jong_hex >= 0) glyph_byte |= hangul_base [jong_hex][i];
598 syllable[i] = glyph_byte;
621 overlaps = (glyph1[i] & glyph2[i]) != 0;
623 }
while (i < 16 && overlaps == 0);
638 unsigned *combined_glyph) {
641 for (i = 0; i < 16; i++)
642 combined_glyph [i] = glyph1 [i] | glyph2 [i];
661 fprintf (fp,
"%04X:", codept);
664 for (i = 0; i < 16; i++) {
667 while (mask != 0x0000) {
668 if (mask & this_glyph [i]) {
697 fprintf (fp,
"%04X:", codept);
700 for (i = 0; i < 16; i++) {
701 fprintf (fp,
"%04X", this_glyph[i]);
718 unsigned jamo,
unsigned *jamo_glyph) {
725 if (jamo >= 0x1100 && jamo <= 0x11FF) {
726 glyph_index = jamo - 0x1100 +
JAMO_HEX;
728 else if (jamo >= 0xA960 && jamo <= 0xA97F) {
731 else if (jamo >= 0xD7B0 && jamo <= 0xD7FF) {
738 for (i = 0; i < 16; i++) {
739 jamo_glyph [i] = glyph_table [glyph_index] [i];
788 unsigned cho,
unsigned jung,
unsigned jong,
789 unsigned *combined_glyph) {
792 int cho_num, jung_num, jong_num;
793 int cho_group, jung_group, jong_group;
794 int cho_index, jung_index, jong_index;
796 unsigned tmp_glyph[16];
798 int cho_variation (
int choseong,
int jungseong,
int jongseong);
801 unsigned *combined_glyph);
805 cho_index = jung_index = jong_index = 0x000;
811 if (cho >= 0x1100 && cho <= 0x115E)
819 if (jung >= 0x1161 && jung <= 0x11A7)
827 if (jong >= 0x11A8 && jong <= 0x11FF)
840 cho_index = cho_group = 0;
843 if (jung_num < 0 && jong_num < 0) {
876 jung_index = jung_group = 0;
879 if (cho_num < 0 && jong_num < 0) {
891 else if (cho_num >= 0)
902 jong_index = jong_group = 0;
905 if (cho_num < 0 && jung_num < 0) {
907 jong_index = jung_num + 0x4A8;
920 combine_glyphs (glyph_table [cho_index], glyph_table [jung_index],
923 if (jong_index > 0) {
931 for (i = 0; i < 16; i++) {
932 tmp_glyph [i] = glyph_table [jong_index] [i] >> 1;
Define constants and function prototypes for using Hangul glyphs.
#define NJONG_EXTB
Hangul Extended-B jongseong.
#define NCHO_EXTA
Hangul Extended-A choseong.
#define CHO_VARIATIONS
6 choseong variations
#define JONG_VARIATIONS
1 jongseong variation
#define NJONG_MODERN
28 modern Hangul Jamo jongseong
#define JAMO_EXTB_HEX
Start of U+D7B0..U+D7FF glyphs.
#define CHO_UNICODE_START
Modern Hangul choseong start.
#define JAMO_EXTA_HEX
Start of U+A960..U+A97F glyphs.
#define JUNG_EXTB_UNICODE_START
Hangul Extended-B jungseong start.
#define JUNG_HEX
Location of first jungseong (will be 0x2FB)
#define NCHO_ANCIENT
ancient Hangul Jamo choseong
#define MAXLINE
Length of maximum file input line.
#define CHO_EXTA_UNICODE_START
Hangul Extended-A choseong start.
#define NCHO_MODERN
19 modern Hangul Jamo choseong
#define JAMO_HEX
Start of U+1100..U+11FF glyphs.
#define JONG_UNICODE_START
Modern Hangul jongseong start.
#define NJUNG_MODERN
21 modern Hangul Jamo jungseong
#define JUNG_UNICODE_START
Modern Hangul jungseong start.
#define JUNG_VARIATIONS
3 jungseong variations
#define NJONG_ANCIENT
ancient Hangul Jamo jongseong
#define NJUNG_ANCIENT
ancient Hangul Jamo jungseong
#define CHO_HEX
Location of first choseong (location 0x0000 is a blank glyph)
#define JONG_EXTB_UNICODE_START
Hangul Extended-B jongseong start.
#define NJUNG_EXTB
Hangul Extended-B jungseong.
#define JONG_HEX
Location of first jongseong (will be 0x421)
void print_glyph_hex(FILE *fp, unsigned codept, unsigned *this_glyph)
Print one glyph in Unifont hexdraw hexadecimal string style.
void one_jamo(unsigned glyph_table[MAX_GLYPHS][16], unsigned jamo, unsigned *jamo_glyph)
Convert Hangul Jamo choseong, jungseong, and jongseong into a glyph.
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.
void print_glyph_txt(FILE *fp, unsigned codept, unsigned *this_glyph)
Print one glyph in Unifont hexdraw plain text style.
unsigned hangul_read_base8(FILE *infp, unsigned char base[][32])
Read hangul-base.hex file into a unsigned char array.
int is_wide_vowel(int vowel)
Whether vowel has rightmost vertical stroke to the right.
void hangul_hex_indices(int choseong, int jungseong, int jongseong, int *cho_index, int *jung_index, int *jong_index)
Determine index values to the bitmaps for a syllable's components.
void hangul_decompose(unsigned codept, int *initial, int *medial, int *final)
Decompose a Hangul Syllables code point into three letters.
int glyph_overlap(unsigned *glyph1, unsigned *glyph2)
See if two glyphs overlap.
void hangul_variations(int choseong, int jungseong, int jongseong, int *cho_var, int *jung_var, int *jong_var)
Determine the variations of each letter in a Hangul syllable.
void combine_glyphs(unsigned *glyph1, unsigned *glyph2, unsigned *combined_glyph)
Combine two glyphs into one glyph.
int jong_variation(int choseong, int jungseong, int jongseong)
Return the Johab 6/3/1 jongseong variation.
int cho_variation(int choseong, int jungseong, int jongseong)
Return the Johab 6/3/1 choseong variation for a syllable.
int jung_variation(int choseong, int jungseong, int jongseong)
Return the Johab 6/3/1 jungseong variation.
void hangul_syllable(int choseong, int jungseong, int jongseong, unsigned char hangul_base[][32], unsigned char *syllable)
Given letters in a Hangul syllable, return a glyph.
unsigned hangul_compose(int initial, int medial, int final)
Compose a Hangul syllable into a code point, or 0 if none exists.
unsigned hangul_read_base16(FILE *infp, unsigned base[][16])
Read hangul-base.hex file into a unsigned array.