\hypertarget{unibdf2hex_8c_source}{}\doxysection{unibdf2hex.\+c}
\label{unibdf2hex_8c_source}\index{src/unibdf2hex.c@{src/unibdf2hex.c}}
\mbox{\hyperlink{unibdf2hex_8c}{Go to the documentation of this file.}}
\begin{DoxyCode}{0}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00001}00001 \textcolor{comment}{/**}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00002}00002 \textcolor{comment}{   @file unibdf2hex.c}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00003}00003 \textcolor{comment}{}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00004}00004 \textcolor{comment}{   @brief unibdf2hex -\/ Convert a BDF file into a unifont.hex file}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00005}00005 \textcolor{comment}{}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00006}00006 \textcolor{comment}{   @author Paul Hardy, January 2008}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00007}00007 \textcolor{comment}{}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00008}00008 \textcolor{comment}{   @copyright Copyright (C) 2008, 2013 Paul Hardy}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00009}00009 \textcolor{comment}{}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00010}00010 \textcolor{comment}{   Note: currently this has hard-\/coded code points for glyphs extracted}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00011}00011 \textcolor{comment}{   from Wen Quan Yi to create the Unifont source file "{}wqy.hex"{}.}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00012}00012 \textcolor{comment}{*/}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00013}00013 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00014}00014 \textcolor{comment}{   LICENSE:}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00015}00015 \textcolor{comment}{}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00016}00016 \textcolor{comment}{      This program is free software: you can redistribute it and/or modify}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00017}00017 \textcolor{comment}{      it under the terms of the GNU General Public License as published by}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00018}00018 \textcolor{comment}{      the Free Software Foundation, either version 2 of the License, or}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00019}00019 \textcolor{comment}{      (at your option) any later version.}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00020}00020 \textcolor{comment}{   }}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00021}00021 \textcolor{comment}{      This program is distributed in the hope that it will be useful,}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00022}00022 \textcolor{comment}{      but WITHOUT ANY WARRANTY; without even the implied warranty of}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00023}00023 \textcolor{comment}{      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the }}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00024}00024 \textcolor{comment}{      GNU General Public License for more details.}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00025}00025 \textcolor{comment}{   }}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00026}00026 \textcolor{comment}{      You should have received a copy of the GNU General Public License}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00027}00027 \textcolor{comment}{      along with this program.  If not, see <http://www.gnu.org/licenses/>.}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00028}00028 \textcolor{comment}{*/}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00029}00029 }
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00030}00030 \textcolor{preprocessor}{\#include <stdio.h>}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00031}00031 \textcolor{preprocessor}{\#include <stdlib.h>}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00032}00032 \textcolor{preprocessor}{\#include <string.h>}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00033}00033 }
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00034}\mbox{\hyperlink{unibdf2hex_8c_a2e467ad6d1fb7b24985a45af8b1e7ad1}{00034}} \textcolor{preprocessor}{\#define UNISTART 0x3400 }\textcolor{comment}{///< First Unicode code point to examine}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00035}\mbox{\hyperlink{unibdf2hex_8c_afd5dcd82c8e611d544ad18b798c54d50}{00035}} \textcolor{preprocessor}{\#define UNISTOP 0x4DBF  }\textcolor{comment}{///< Last Unicode code point to examine}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00036}00036 }
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00037}\mbox{\hyperlink{unibdf2hex_8c_ad7871643c05865c80f5d8050aead2b57}{00037}} \textcolor{preprocessor}{\#define MAXBUF 256  }\textcolor{comment}{///< Maximum allowable input file line length -\/ 1}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00038}00038 }
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00039}00039 \textcolor{comment}{}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00040}00040 \textcolor{comment}{/**}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00041}00041 \textcolor{comment}{   @brief The main function.}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00042}00042 \textcolor{comment}{}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00043}00043 \textcolor{comment}{   @return Exit status is always 0 (successful termination).}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00044}00044 \textcolor{comment}{*/}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00045}00045 \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00046}\mbox{\hyperlink{unibdf2hex_8c_ae66f6b31b5ad750f1fe042a706a4e3d4}{00046}} \mbox{\hyperlink{unibdf2hex_8c_ae66f6b31b5ad750f1fe042a706a4e3d4}{main}}()}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00047}00047 \{}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00048}00048    \textcolor{keywordtype}{int} i;}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00049}00049    \textcolor{keywordtype}{int} digitsout;  \textcolor{comment}{/* how many hex digits we output in a bitmap */}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00050}00050    \textcolor{keywordtype}{int} thispoint;}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00051}00051    \textcolor{keywordtype}{char} inbuf[\mbox{\hyperlink{unibdf2hex_8c_ad7871643c05865c80f5d8050aead2b57}{MAXBUF}}];}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00052}00052    \textcolor{keywordtype}{int} bbxx, bbxy, bbxxoff, bbxyoff;}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00053}00053 }
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00054}00054    \textcolor{keywordtype}{int} descent=4; \textcolor{comment}{/* font descent wrt baseline */}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00055}00055    \textcolor{keywordtype}{int} startrow;  \textcolor{comment}{/* row to start glyph        */}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00056}00056    \textcolor{keywordtype}{unsigned} rowout;}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00057}00057 }
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00058}00058    \textcolor{keywordflow}{while} (fgets (inbuf, \mbox{\hyperlink{unibdf2hex_8c_ad7871643c05865c80f5d8050aead2b57}{MAXBUF}} -\/ 1, stdin) != NULL) \{}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00059}00059       \textcolor{keywordflow}{if} (strncmp (inbuf, \textcolor{stringliteral}{"{}ENCODING "{}}, 9) == 0) \{}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00060}00060          sscanf (\&inbuf[9], \textcolor{stringliteral}{"{}\%d"{}}, \&thispoint); \textcolor{comment}{/* get code point */}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00061}00061          \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00062}00062 \textcolor{comment}{            If we want this code point, get the BBX (bounding box) and}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00063}00063 \textcolor{comment}{            BITMAP information.}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00064}00064 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00065}00065          \textcolor{keywordflow}{if} ((thispoint >= 0x2E80 \&\& thispoint <= 0x2EFF) || \textcolor{comment}{// CJK Radicals Supplement}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00066}00066              (thispoint >= 0x2F00 \&\& thispoint <= 0x2FDF) || \textcolor{comment}{// Kangxi Radicals}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00067}00067              (thispoint >= 0x2FF0 \&\& thispoint <= 0x2FFF) || \textcolor{comment}{// Ideographic Description Characters}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00068}00068              (thispoint >= 0x3001 \&\& thispoint <= 0x303F) || \textcolor{comment}{// CJK Symbols and Punctuation (U+3000 is a space)}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00069}00069              (thispoint >= 0x3100 \&\& thispoint <= 0x312F) || \textcolor{comment}{// Bopomofo}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00070}00070              (thispoint >= 0x31A0 \&\& thispoint <= 0x31BF) || \textcolor{comment}{// Bopomofo extend}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00071}00071              (thispoint >= 0x31C0 \&\& thispoint <= 0x31EF) || \textcolor{comment}{// CJK Strokes}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00072}00072              (thispoint >= 0x3400 \&\& thispoint <= 0x4DBF) || \textcolor{comment}{// CJK Unified Ideographs Extension A}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00073}00073              (thispoint >= 0x4E00 \&\& thispoint <= 0x9FCF) || \textcolor{comment}{// CJK Unified Ideographs}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00074}00074              (thispoint >= 0xF900 \&\& thispoint <= 0xFAFF))   \textcolor{comment}{// CJK Compatibility Ideographs}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00075}00075             \{}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00076}00076             \textcolor{keywordflow}{while} (fgets (inbuf, \mbox{\hyperlink{unibdf2hex_8c_ad7871643c05865c80f5d8050aead2b57}{MAXBUF}} -\/ 1, stdin) != NULL \&\&}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00077}00077                    strncmp (inbuf, \textcolor{stringliteral}{"{}BBX "{}}, 4) != 0); \textcolor{comment}{/* find bounding box */}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00078}00078 }
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00079}00079             sscanf (\&inbuf[4], \textcolor{stringliteral}{"{}\%d \%d \%d \%d"{}}, \&bbxx, \&bbxy, \&bbxxoff, \&bbxyoff);}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00080}00080             \textcolor{keywordflow}{while} (fgets (inbuf, \mbox{\hyperlink{unibdf2hex_8c_ad7871643c05865c80f5d8050aead2b57}{MAXBUF}} -\/ 1, stdin) != NULL \&\&}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00081}00081                    strncmp (inbuf, \textcolor{stringliteral}{"{}BITMAP"{}}, 6) != 0); \textcolor{comment}{/* find bitmap start */}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00082}00082             fprintf (stdout, \textcolor{stringliteral}{"{}\%04X:"{}}, thispoint);}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00083}00083             digitsout = 0;}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00084}00084             \textcolor{comment}{/* Print initial blank rows */}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00085}00085             startrow = descent + bbxyoff + bbxy;}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00086}00086 }
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00087}00087             \textcolor{comment}{/* Force everything to 16 pixels wide */}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00088}00088             \textcolor{keywordflow}{for} (i = 16; i > startrow; i-\/-\/) \{}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00089}00089                fprintf (stdout,\textcolor{stringliteral}{"{}0000"{}});}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00090}00090                digitsout += 4;}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00091}00091             \}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00092}00092             \textcolor{keywordflow}{while} (fgets (inbuf, \mbox{\hyperlink{unibdf2hex_8c_ad7871643c05865c80f5d8050aead2b57}{MAXBUF}} -\/ 1, stdin) != NULL \&\&}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00093}00093                    strncmp (inbuf, \textcolor{stringliteral}{"{}END"{}}, 3) != 0) \{ \textcolor{comment}{/* copy bitmap until END */}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00094}00094                sscanf (inbuf, \textcolor{stringliteral}{"{}\%X"{}}, \&rowout);}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00095}00095                \textcolor{comment}{/* Now force glyph to a 16x16 grid even if they'd fit in 8x16 */}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00096}00096                \textcolor{keywordflow}{if} (bbxx <= 8) rowout <<= 8;  \textcolor{comment}{/* shift left for 16x16 glyph */}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00097}00097                rowout >>= bbxxoff;}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00098}00098                fprintf (stdout, \textcolor{stringliteral}{"{}\%04X"{}}, rowout);}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00099}00099                digitsout += 4;}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00100}00100             \}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00101}00101 }
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00102}00102             \textcolor{comment}{/* Pad for 16x16 glyph */}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00103}00103             \textcolor{keywordflow}{while} (digitsout < 64) \{}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00104}00104                fprintf (stdout,\textcolor{stringliteral}{"{}0000"{}});}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00105}00105                digitsout += 4;}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00106}00106             \}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00107}00107             fprintf (stdout,\textcolor{stringliteral}{"{}\(\backslash\)n"{}});}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00108}00108          \}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00109}00109       \}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00110}00110    \}}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00111}00111    exit (0);}
\DoxyCodeLine{\Hypertarget{unibdf2hex_8c_source_l00112}00112 \}}

\end{DoxyCode}
