| 1 | /* |
| 2 | * << Haru Free PDF Library >> -- hpdf_fontdef_cnt.c |
| 3 | * |
| 4 | * URL: http://libharu.org |
| 5 | * |
| 6 | * Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp> |
| 7 | * Copyright (c) 2007-2009 Antony Dovgal <tony@daylessday.org> |
| 8 | * |
| 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. |
| 15 | * |
| 16 | */ |
| 17 | |
| 18 | #include "hpdf_conf.h" |
| 19 | #include "hpdf_utils.h" |
| 20 | #include "hpdf.h" |
| 21 | |
| 22 | /*----------------------------------------------------------------------------*/ |
| 23 | |
| 24 | static const HPDF_CID_Width MING_LIU_W_ARRAY[] = { |
| 25 | {668, 500}, |
| 26 | {669, 500}, |
| 27 | {670, 500}, |
| 28 | {671, 500}, |
| 29 | {672, 500}, |
| 30 | {673, 500}, |
| 31 | {674, 500}, |
| 32 | {675, 500}, |
| 33 | {676, 500}, |
| 34 | {677, 500}, |
| 35 | {678, 500}, |
| 36 | {679, 500}, |
| 37 | {680, 500}, |
| 38 | {681, 500}, |
| 39 | {682, 500}, |
| 40 | {683, 500}, |
| 41 | {684, 500}, |
| 42 | {685, 500}, |
| 43 | {686, 500}, |
| 44 | {687, 500}, |
| 45 | {688, 500}, |
| 46 | {689, 500}, |
| 47 | {690, 500}, |
| 48 | {691, 500}, |
| 49 | {692, 500}, |
| 50 | {693, 500}, |
| 51 | {694, 500}, |
| 52 | {696, 500}, |
| 53 | {697, 500}, |
| 54 | {698, 500}, |
| 55 | {699, 500}, |
| 56 | {814, 500}, |
| 57 | {815, 500}, |
| 58 | {816, 500}, |
| 59 | {817, 500}, |
| 60 | {818, 500}, |
| 61 | {819, 500}, |
| 62 | {820, 500}, |
| 63 | {821, 500}, |
| 64 | {822, 500}, |
| 65 | {823, 500}, |
| 66 | {824, 500}, |
| 67 | {825, 500}, |
| 68 | {826, 500}, |
| 69 | {827, 500}, |
| 70 | {828, 500}, |
| 71 | {829, 500}, |
| 72 | {830, 500}, |
| 73 | {831, 500}, |
| 74 | {832, 500}, |
| 75 | {833, 500}, |
| 76 | {834, 500}, |
| 77 | {835, 500}, |
| 78 | {836, 500}, |
| 79 | {837, 500}, |
| 80 | {838, 500}, |
| 81 | {839, 500}, |
| 82 | {840, 500}, |
| 83 | {841, 500}, |
| 84 | {842, 500}, |
| 85 | {843, 500}, |
| 86 | {844, 500}, |
| 87 | {845, 500}, |
| 88 | {846, 500}, |
| 89 | {847, 500}, |
| 90 | {848, 500}, |
| 91 | {849, 500}, |
| 92 | {850, 500}, |
| 93 | {851, 500}, |
| 94 | {852, 500}, |
| 95 | {853, 500}, |
| 96 | {854, 500}, |
| 97 | {855, 500}, |
| 98 | {856, 500}, |
| 99 | {857, 500}, |
| 100 | {858, 500}, |
| 101 | {859, 500}, |
| 102 | {860, 500}, |
| 103 | {861, 500}, |
| 104 | {862, 500}, |
| 105 | {863, 500}, |
| 106 | {864, 500}, |
| 107 | {865, 500}, |
| 108 | {866, 500}, |
| 109 | {867, 500}, |
| 110 | {868, 500}, |
| 111 | {869, 500}, |
| 112 | {870, 500}, |
| 113 | {871, 500}, |
| 114 | {872, 500}, |
| 115 | {873, 500}, |
| 116 | {874, 500}, |
| 117 | {875, 500}, |
| 118 | {876, 500}, |
| 119 | {877, 500}, |
| 120 | {878, 500}, |
| 121 | {879, 500}, |
| 122 | {880, 500}, |
| 123 | {881, 500}, |
| 124 | {882, 500}, |
| 125 | {883, 500}, |
| 126 | {884, 500}, |
| 127 | {885, 500}, |
| 128 | {886, 500}, |
| 129 | {887, 500}, |
| 130 | {888, 500}, |
| 131 | {889, 500}, |
| 132 | {890, 500}, |
| 133 | {891, 500}, |
| 134 | {892, 500}, |
| 135 | {893, 500}, |
| 136 | {894, 500}, |
| 137 | {895, 500}, |
| 138 | {896, 500}, |
| 139 | {897, 500}, |
| 140 | {898, 500}, |
| 141 | {899, 500}, |
| 142 | {900, 500}, |
| 143 | {901, 500}, |
| 144 | {902, 500}, |
| 145 | {903, 500}, |
| 146 | {904, 500}, |
| 147 | {905, 500}, |
| 148 | {906, 500}, |
| 149 | {907, 500}, |
| 150 | {7716, 500}, |
| 151 | {0xFFFF, 0} |
| 152 | }; |
| 153 | |
| 154 | |
| 155 | static HPDF_STATUS |
| 156 | MingLiU_Init (HPDF_FontDef fontdef) |
| 157 | { |
| 158 | HPDF_STATUS ret; |
| 159 | |
| 160 | HPDF_PTRACE ((" HPDF_FontDef_MingLiU_Init\n" )); |
| 161 | |
| 162 | fontdef->ascent = 800; |
| 163 | fontdef->descent = -199; |
| 164 | fontdef->cap_height = 769; |
| 165 | fontdef->font_bbox = HPDF_ToBox(0, -199, 1000, 800); |
| 166 | fontdef->flags = HPDF_FONT_SYMBOLIC + HPDF_FONT_FIXED_WIDTH + |
| 167 | HPDF_FONT_SERIF; |
| 168 | fontdef->italic_angle = 0; |
| 169 | fontdef->stemv = 78; |
| 170 | if ((ret = HPDF_CIDFontDef_AddWidth (fontdef, MING_LIU_W_ARRAY)) != |
| 171 | HPDF_OK) { |
| 172 | return ret; |
| 173 | } |
| 174 | |
| 175 | fontdef->type = HPDF_FONTDEF_TYPE_CID; |
| 176 | fontdef->valid = HPDF_TRUE; |
| 177 | |
| 178 | return HPDF_OK; |
| 179 | } |
| 180 | |
| 181 | |
| 182 | static HPDF_STATUS |
| 183 | MingLiU_Bold_Init (HPDF_FontDef fontdef) |
| 184 | { |
| 185 | HPDF_STATUS ret = MingLiU_Init (fontdef); |
| 186 | |
| 187 | if (ret != HPDF_OK) |
| 188 | return ret; |
| 189 | |
| 190 | return HPDF_CIDFontDef_ChangeStyle (fontdef, HPDF_TRUE, HPDF_FALSE); |
| 191 | } |
| 192 | |
| 193 | |
| 194 | static HPDF_STATUS |
| 195 | MingLiU_Italic_Init (HPDF_FontDef fontdef) |
| 196 | { |
| 197 | HPDF_STATUS ret = MingLiU_Init (fontdef); |
| 198 | |
| 199 | if (ret != HPDF_OK) |
| 200 | return ret; |
| 201 | |
| 202 | return HPDF_CIDFontDef_ChangeStyle (fontdef, HPDF_FALSE, HPDF_TRUE); |
| 203 | } |
| 204 | |
| 205 | static HPDF_STATUS |
| 206 | MingLiU_BoldItalic_Init (HPDF_FontDef fontdef) |
| 207 | { |
| 208 | HPDF_STATUS ret = MingLiU_Init (fontdef); |
| 209 | |
| 210 | if (ret != HPDF_OK) |
| 211 | return ret; |
| 212 | |
| 213 | return HPDF_CIDFontDef_ChangeStyle (fontdef, HPDF_TRUE, HPDF_TRUE); |
| 214 | } |
| 215 | |
| 216 | |
| 217 | HPDF_EXPORT(HPDF_STATUS) |
| 218 | HPDF_UseCNTFonts (HPDF_Doc pdf) |
| 219 | { |
| 220 | HPDF_FontDef fontdef; |
| 221 | HPDF_STATUS ret; |
| 222 | |
| 223 | if (!HPDF_HasDoc (pdf)) |
| 224 | return HPDF_INVALID_DOCUMENT; |
| 225 | |
| 226 | /* MingLiU */ |
| 227 | fontdef = HPDF_CIDFontDef_New (pdf->mmgr, "MingLiU" , |
| 228 | MingLiU_Init); |
| 229 | |
| 230 | if ((ret = HPDF_Doc_RegisterFontDef (pdf, fontdef)) != HPDF_OK) |
| 231 | return ret; |
| 232 | |
| 233 | fontdef = HPDF_CIDFontDef_New (pdf->mmgr, "MingLiU,Bold" , |
| 234 | MingLiU_Bold_Init); |
| 235 | |
| 236 | if ((ret = HPDF_Doc_RegisterFontDef (pdf, fontdef)) != HPDF_OK) |
| 237 | return ret; |
| 238 | |
| 239 | fontdef = HPDF_CIDFontDef_New (pdf->mmgr, "MingLiU,Italic" , |
| 240 | MingLiU_Italic_Init); |
| 241 | |
| 242 | if ((ret = HPDF_Doc_RegisterFontDef (pdf, fontdef)) != HPDF_OK) |
| 243 | return ret; |
| 244 | |
| 245 | fontdef = HPDF_CIDFontDef_New (pdf->mmgr, "MingLiU,BoldItalic" , |
| 246 | MingLiU_BoldItalic_Init); |
| 247 | |
| 248 | if ((ret = HPDF_Doc_RegisterFontDef (pdf, fontdef)) != HPDF_OK) |
| 249 | return ret; |
| 250 | |
| 251 | return HPDF_OK; |
| 252 | } |
| 253 | |
| 254 | |