2 * << Haru Free PDF Library >> -- hpdf_fontdef_cns.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 SIMSUN_W_ARRAY[] = {
155 static const HPDF_CID_Width SIMHEI_W_ARRAY[] = {
286 /*---------------------------------------------------------------------------*/
287 /*----- SimHei Font ---------------------------------------------------------*/
291 SimSun_Init (HPDF_FontDef fontdef)
295 HPDF_PTRACE ((" HPDF_FontDef_SimSun_Init\n"));
297 fontdef->ascent = 859;
298 fontdef->descent = -140;
299 fontdef->cap_height = 683;
300 fontdef->font_bbox = HPDF_ToBox(0, -140, 996, 855);
301 fontdef->flags = HPDF_FONT_SYMBOLIC + HPDF_FONT_FIXED_WIDTH +
303 fontdef->italic_angle = 0;
305 if ((ret = HPDF_CIDFontDef_AddWidth (fontdef, SIMSUN_W_ARRAY)) !=
310 fontdef->type = HPDF_FONTDEF_TYPE_CID;
311 fontdef->valid = HPDF_TRUE;
318 SimSun_Bold_Init (HPDF_FontDef fontdef)
320 HPDF_STATUS ret = SimSun_Init (fontdef);
325 return HPDF_CIDFontDef_ChangeStyle (fontdef, HPDF_TRUE, HPDF_FALSE);
330 SimSun_Italic_Init (HPDF_FontDef fontdef)
332 HPDF_STATUS ret = SimSun_Init (fontdef);
337 return HPDF_CIDFontDef_ChangeStyle (fontdef, HPDF_FALSE, HPDF_TRUE);
341 SimSun_BoldItalic_Init (HPDF_FontDef fontdef)
343 HPDF_STATUS ret = SimSun_Init (fontdef);
348 return HPDF_CIDFontDef_ChangeStyle (fontdef, HPDF_TRUE, HPDF_TRUE);
353 SimHei_Init (HPDF_FontDef fontdef)
357 HPDF_PTRACE ((" HPDF_FontDef_SimHei_Init\n"));
359 fontdef->ascent = 859;
360 fontdef->descent = -140;
361 fontdef->cap_height = 769;
362 fontdef->font_bbox = HPDF_ToBox(-0, -140, 996, 855);
363 fontdef->flags = HPDF_FONT_SYMBOLIC + HPDF_FONT_FIXED_WIDTH;
364 fontdef->italic_angle = 0;
366 if ((ret = HPDF_CIDFontDef_AddWidth (fontdef, SIMHEI_W_ARRAY)) !=
371 fontdef->type = HPDF_FONTDEF_TYPE_CID;
372 fontdef->valid = HPDF_TRUE;
379 SimHei_Bold_Init (HPDF_FontDef fontdef)
381 HPDF_STATUS ret = SimHei_Init (fontdef);
386 return HPDF_CIDFontDef_ChangeStyle (fontdef, HPDF_TRUE, HPDF_FALSE);
391 SimHei_Italic_Init (HPDF_FontDef fontdef)
393 HPDF_STATUS ret = SimHei_Init (fontdef);
398 return HPDF_CIDFontDef_ChangeStyle (fontdef, HPDF_FALSE, HPDF_TRUE);
402 SimHei_BoldItalic_Init (HPDF_FontDef fontdef)
404 HPDF_STATUS ret = SimHei_Init (fontdef);
409 return HPDF_CIDFontDef_ChangeStyle (fontdef, HPDF_TRUE, HPDF_TRUE);
413 HPDF_EXPORT(HPDF_STATUS)
414 HPDF_UseCNSFonts (HPDF_Doc pdf)
416 HPDF_FontDef fontdef;
419 if (!HPDF_HasDoc (pdf))
420 return HPDF_INVALID_DOCUMENT;
423 fontdef = HPDF_CIDFontDef_New (pdf->mmgr, "SimSun",
426 if ((ret = HPDF_Doc_RegisterFontDef (pdf, fontdef)) != HPDF_OK)
429 fontdef = HPDF_CIDFontDef_New (pdf->mmgr, "SimSun,Bold",
432 if ((ret = HPDF_Doc_RegisterFontDef (pdf, fontdef)) != HPDF_OK)
435 fontdef = HPDF_CIDFontDef_New (pdf->mmgr, "SimSun,Italic",
438 if ((ret = HPDF_Doc_RegisterFontDef (pdf, fontdef)) != HPDF_OK)
441 fontdef = HPDF_CIDFontDef_New (pdf->mmgr, "SimSun,BoldItalic",
442 SimSun_BoldItalic_Init);
444 if ((ret = HPDF_Doc_RegisterFontDef (pdf, fontdef)) != HPDF_OK)
448 fontdef = HPDF_CIDFontDef_New (pdf->mmgr, "SimHei",
451 if ((ret = HPDF_Doc_RegisterFontDef (pdf, fontdef)) != HPDF_OK)
454 fontdef = HPDF_CIDFontDef_New (pdf->mmgr, "SimHei,Bold",
457 if ((ret = HPDF_Doc_RegisterFontDef (pdf, fontdef)) != HPDF_OK)
460 fontdef = HPDF_CIDFontDef_New (pdf->mmgr, "SimHei,Italic",
463 if ((ret = HPDF_Doc_RegisterFontDef (pdf, fontdef)) != HPDF_OK)
466 fontdef = HPDF_CIDFontDef_New (pdf->mmgr, "SimHei,BoldItalic",
467 SimHei_BoldItalic_Init);
469 if ((ret = HPDF_Doc_RegisterFontDef (pdf, fontdef)) != HPDF_OK)