2 * << Haru Free PDF Library >> -- hpdf_fontdef_jp.c
4 * URL: http://libharu.org
6 * Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp>
7 * Copyright (c) 2007-2009 Antony Dovgal <tony@daylessday.org>
9 * Permission to use, copy, modify, distribute and sell this software
10 * and its documentation for any purpose is hereby granted without fee,
11 * provided that the above copyright notice appear in all copies and
12 * that both that copyright notice and this permission notice appear
13 * in supporting documentation.
14 * It is provided "as is" without express or implied warranty.
18 #include "hpdf_conf.h"
19 #include "hpdf_utils.h"
22 /*----------------------------------------------------------------------------*/
24 static const HPDF_CID_Width MS_Gothic_W_ARRAY[] = {
282 static const HPDF_CID_Width MS_PGothic_W_ARRAY[] = {
783 static const HPDF_CID_Width MS_Mincyo_W_ARRAY[] = {
1042 static const HPDF_CID_Width MS_PMincyo_W_ARRAY[] = {
1547 /*---------------------------------------------------------------------------*/
1548 /*----- Mincyo Font ---------------------------------------------------------*/
1552 MS_Gothic_Init (HPDF_FontDef fontdef)
1556 HPDF_PTRACE ((" HPDF_FontDef_MS_Gothic_Init\n"));
1558 fontdef->ascent = 859;
1559 fontdef->descent = -140;
1560 fontdef->cap_height = 769;
1561 fontdef->font_bbox = HPDF_ToBox(-0, -136, 1000, 859);
1562 fontdef->flags = HPDF_FONT_SYMBOLIC + HPDF_FONT_FIXED_WIDTH;
1563 fontdef->italic_angle = 0;
1564 fontdef->stemv = 78;
1565 if ((ret = HPDF_CIDFontDef_AddWidth (fontdef, MS_Gothic_W_ARRAY)) !=
1570 fontdef->type = HPDF_FONTDEF_TYPE_CID;
1571 fontdef->valid = HPDF_TRUE;
1578 MS_Gothic_Bold_Init (HPDF_FontDef fontdef)
1580 HPDF_STATUS ret = MS_Gothic_Init (fontdef);
1585 return HPDF_CIDFontDef_ChangeStyle (fontdef, HPDF_TRUE, HPDF_FALSE);
1590 MS_Gothic_Italic_Init (HPDF_FontDef fontdef)
1592 HPDF_STATUS ret = MS_Gothic_Init (fontdef);
1597 return HPDF_CIDFontDef_ChangeStyle (fontdef, HPDF_FALSE, HPDF_TRUE);
1601 MS_Gothic_BoldItalic_Init (HPDF_FontDef fontdef)
1603 HPDF_STATUS ret = MS_Gothic_Init (fontdef);
1608 return HPDF_CIDFontDef_ChangeStyle (fontdef, HPDF_TRUE, HPDF_TRUE);
1613 MS_PGothic_Init (HPDF_FontDef fontdef)
1617 HPDF_PTRACE ((" HPDF_FontDef_MS_PGothic_Init\n"));
1619 fontdef->ascent = 859;
1620 fontdef->descent = -140;
1621 fontdef->cap_height = 679;
1622 fontdef->font_bbox = HPDF_ToBox(-121, -136, 996, 859);
1623 fontdef->flags = HPDF_FONT_SYMBOLIC;
1624 fontdef->italic_angle = 0;
1625 fontdef->stemv = 78;
1626 if ((ret = HPDF_CIDFontDef_AddWidth (fontdef, MS_PGothic_W_ARRAY)) !=
1631 fontdef->type = HPDF_FONTDEF_TYPE_CID;
1632 fontdef->valid = HPDF_TRUE;
1639 MS_PGothic_Bold_Init (HPDF_FontDef fontdef)
1641 HPDF_STATUS ret = MS_PGothic_Init (fontdef);
1646 return HPDF_CIDFontDef_ChangeStyle (fontdef, HPDF_TRUE, HPDF_FALSE);
1651 MS_PGothic_Italic_Init (HPDF_FontDef fontdef)
1653 HPDF_STATUS ret = MS_PGothic_Init (fontdef);
1658 return HPDF_CIDFontDef_ChangeStyle (fontdef, HPDF_FALSE, HPDF_TRUE);
1662 MS_PGothic_BoldItalic_Init (HPDF_FontDef fontdef)
1664 HPDF_STATUS ret = MS_PGothic_Init (fontdef);
1669 return HPDF_CIDFontDef_ChangeStyle (fontdef, HPDF_TRUE, HPDF_TRUE);
1674 MS_Mincyo_Init (HPDF_FontDef fontdef)
1678 HPDF_PTRACE ((" HPDF_FontDef_MS_Mincyo_Init\n"));
1680 fontdef->ascent = 859;
1681 fontdef->descent = -140;
1682 fontdef->cap_height = 769;
1683 fontdef->font_bbox = HPDF_ToBox(-0, -136, 1000, 859);
1684 fontdef->flags = HPDF_FONT_SYMBOLIC + HPDF_FONT_FIXED_WIDTH +
1686 fontdef->italic_angle = 0;
1687 fontdef->stemv = 78;
1688 if ((ret = HPDF_CIDFontDef_AddWidth (fontdef, MS_Gothic_W_ARRAY)) !=
1693 fontdef->type = HPDF_FONTDEF_TYPE_CID;
1694 fontdef->valid = HPDF_TRUE;
1701 MS_Mincyo_Bold_Init (HPDF_FontDef fontdef)
1703 HPDF_STATUS ret = MS_Mincyo_Init (fontdef);
1708 return HPDF_CIDFontDef_ChangeStyle (fontdef, HPDF_TRUE, HPDF_FALSE);
1713 MS_Mincyo_Italic_Init (HPDF_FontDef fontdef)
1715 HPDF_STATUS ret = MS_Mincyo_Init (fontdef);
1720 return HPDF_CIDFontDef_ChangeStyle (fontdef, HPDF_FALSE, HPDF_TRUE);
1724 MS_Mincyo_BoldItalic_Init (HPDF_FontDef fontdef)
1726 HPDF_STATUS ret = MS_Mincyo_Init (fontdef);
1731 return HPDF_CIDFontDef_ChangeStyle (fontdef, HPDF_TRUE, HPDF_TRUE);
1736 MS_PMincyo_Init (HPDF_FontDef fontdef)
1740 HPDF_PTRACE ((" HPDF_FontDef_MS_PMincyo_Init\n"));
1742 fontdef->ascent = 859;
1743 fontdef->descent = -140;
1744 fontdef->cap_height = 679;
1745 fontdef->font_bbox = HPDF_ToBox(-82, -136, 996, 859);
1746 fontdef->flags = HPDF_FONT_SYMBOLIC + HPDF_FONT_SERIF;
1747 fontdef->italic_angle = 0;
1748 fontdef->stemv = 78;
1749 if ((ret = HPDF_CIDFontDef_AddWidth (fontdef, MS_PGothic_W_ARRAY)) !=
1754 fontdef->type = HPDF_FONTDEF_TYPE_CID;
1755 fontdef->valid = HPDF_TRUE;
1762 MS_PMincyo_Bold_Init (HPDF_FontDef fontdef)
1764 HPDF_STATUS ret = MS_PMincyo_Init (fontdef);
1769 return HPDF_CIDFontDef_ChangeStyle (fontdef, HPDF_TRUE, HPDF_FALSE);
1774 MS_PMincyo_Italic_Init (HPDF_FontDef fontdef)
1776 HPDF_STATUS ret = MS_PMincyo_Init (fontdef);
1781 return HPDF_CIDFontDef_ChangeStyle (fontdef, HPDF_FALSE, HPDF_TRUE);
1785 MS_PMincyo_BoldItalic_Init (HPDF_FontDef fontdef)
1787 HPDF_STATUS ret = MS_PMincyo_Init (fontdef);
1792 return HPDF_CIDFontDef_ChangeStyle (fontdef, HPDF_TRUE, HPDF_TRUE);
1796 HPDF_EXPORT(HPDF_STATUS)
1797 HPDF_UseJPFonts (HPDF_Doc pdf)
1799 HPDF_FontDef fontdef;
1802 if (!HPDF_Doc_Validate (pdf))
1803 return HPDF_INVALID_DOCUMENT;
1806 fontdef = HPDF_CIDFontDef_New (pdf->mmgr, "MS-Gothic",
1809 if ((ret = HPDF_Doc_RegisterFontDef (pdf, fontdef)) != HPDF_OK)
1812 fontdef = HPDF_CIDFontDef_New (pdf->mmgr, "MS-Gothic,Bold",
1813 MS_Gothic_Bold_Init);
1815 if ((ret = HPDF_Doc_RegisterFontDef (pdf, fontdef)) != HPDF_OK)
1818 fontdef = HPDF_CIDFontDef_New (pdf->mmgr, "MS-Gothic,Italic",
1819 MS_Gothic_Italic_Init);
1821 if ((ret = HPDF_Doc_RegisterFontDef (pdf, fontdef)) != HPDF_OK)
1824 fontdef = HPDF_CIDFontDef_New (pdf->mmgr, "MS-Gothic,BoldItalic",
1825 MS_Gothic_BoldItalic_Init);
1827 if ((ret = HPDF_Doc_RegisterFontDef (pdf, fontdef)) != HPDF_OK)
1831 fontdef = HPDF_CIDFontDef_New (pdf->mmgr, "MS-PGothic",
1834 if ((ret = HPDF_Doc_RegisterFontDef (pdf, fontdef)) != HPDF_OK)
1837 fontdef = HPDF_CIDFontDef_New (pdf->mmgr, "MS-PGothic,Bold",
1838 MS_PGothic_Bold_Init);
1840 if ((ret = HPDF_Doc_RegisterFontDef (pdf, fontdef)) != HPDF_OK)
1843 fontdef = HPDF_CIDFontDef_New (pdf->mmgr, "MS-PGothic,Italic",
1844 MS_PGothic_Italic_Init);
1846 if ((ret = HPDF_Doc_RegisterFontDef (pdf, fontdef)) != HPDF_OK)
1849 fontdef = HPDF_CIDFontDef_New (pdf->mmgr, "MS-PGothic,BoldItalic",
1850 MS_PGothic_BoldItalic_Init);
1852 if ((ret = HPDF_Doc_RegisterFontDef (pdf, fontdef)) != HPDF_OK)
1856 fontdef = HPDF_CIDFontDef_New (pdf->mmgr, "MS-Mincyo",
1859 if ((ret = HPDF_Doc_RegisterFontDef (pdf, fontdef)) != HPDF_OK)
1862 fontdef = HPDF_CIDFontDef_New (pdf->mmgr, "MS-Mincyo,Bold",
1863 MS_Mincyo_Bold_Init);
1865 if ((ret = HPDF_Doc_RegisterFontDef (pdf, fontdef)) != HPDF_OK)
1868 fontdef = HPDF_CIDFontDef_New (pdf->mmgr, "MS-Mincyo,Italic",
1869 MS_Mincyo_Italic_Init);
1871 if ((ret = HPDF_Doc_RegisterFontDef (pdf, fontdef)) != HPDF_OK)
1874 fontdef = HPDF_CIDFontDef_New (pdf->mmgr, "MS-Mincyo,BoldItalic",
1875 MS_Mincyo_BoldItalic_Init);
1877 if ((ret = HPDF_Doc_RegisterFontDef (pdf, fontdef)) != HPDF_OK)
1881 fontdef = HPDF_CIDFontDef_New (pdf->mmgr, "MS-PMincyo",
1884 if ((ret = HPDF_Doc_RegisterFontDef (pdf, fontdef)) != HPDF_OK)
1887 fontdef = HPDF_CIDFontDef_New (pdf->mmgr, "MS-PMincyo,Bold",
1888 MS_PMincyo_Bold_Init);
1890 if ((ret = HPDF_Doc_RegisterFontDef (pdf, fontdef)) != HPDF_OK)
1893 fontdef = HPDF_CIDFontDef_New (pdf->mmgr, "MS-PMincyo,Italic",
1894 MS_PMincyo_Italic_Init);
1896 if ((ret = HPDF_Doc_RegisterFontDef (pdf, fontdef)) != HPDF_OK)
1899 fontdef = HPDF_CIDFontDef_New (pdf->mmgr, "MS-PMincyo,BoldItalic",
1900 MS_PMincyo_BoldItalic_Init);
1902 if ((ret = HPDF_Doc_RegisterFontDef (pdf, fontdef)) != HPDF_OK)