out_pdf.h (2207B)
1 #include <pdfio.h> 2 #include <linux/limits.h> 3 #include "core.h" 4 #include "chordpro.h" 5 6 #define MEDIABOX_HEIGHT 841.995 7 #define MEDIABOX_WIDTH 595.35 8 #define MARGIN_TOP 50.0 9 #define MARGIN_BOTTOM 50.0 10 // #define MARGIN_BOTTOM 180.0 11 #define MARGIN_HORIZONTAL 80.0 12 #define LINE_WIDTH MEDIABOX_WIDTH - MARGIN_HORIZONTAL * 2 13 #define MIN_CHORD_GAP_WIDTH 5.0 14 #define SECTION_GAP_WIDTH 10.0 15 #define TOC_DOTS_GAP_WIDTH 10.0 16 17 enum LineLocation { 18 LINE_LOCATION_OVER, 19 LINE_LOCATION_STRIKETHROUGH, 20 LINE_LOCATION_UNDER 21 }; 22 23 enum FontType { 24 FONT_TYPE_TTF, 25 FONT_TYPE_OTF 26 }; 27 28 enum NumeralSystem { 29 NUMERAL_SYSTEM_WESTERN_ARABIC, 30 NUMERAL_SYSTEM_ROMAN 31 }; 32 33 struct CharPosition { 34 int line_item_index; 35 int text_index; 36 }; 37 38 struct Obj { 39 char *name; 40 pdfio_obj_t *value; 41 }; 42 43 struct PDFText { 44 char *text; 45 struct ChoStyle *style; 46 double x; 47 double y; 48 double width; 49 }; 50 51 struct PDFImage { 52 double x; 53 double y; 54 double width; 55 double height; 56 char *name; 57 pdfio_obj_t *obj; 58 }; 59 60 struct PDFPage { 61 struct PDFText **texts; 62 struct PDFImage **images; 63 pdfio_array_t *annots; 64 struct ChordDiagram **diagrams; 65 }; 66 67 struct TocEntry { 68 int page_index; 69 double page_y; 70 char *title; 71 }; 72 73 struct PDFContent { 74 struct PDFPage **pages; 75 struct TocEntry **toc; 76 }; 77 78 struct SpaceNeeded { 79 int line_item_index; 80 int text_index; 81 int text_above_index; 82 double amount; 83 }; 84 85 struct PDFContentContext { 86 struct PDFContent *content; 87 double x; 88 double y; 89 int text; 90 int image; 91 int diagram; 92 int page; 93 int toc_entry; 94 struct SpaceNeeded **spaces; 95 double biggest_font_size; 96 size_t consumed_lyrics; 97 double prev_added_space; 98 double margin_bottom; 99 }; 100 101 struct PDFContext { 102 struct Obj **fonts; 103 struct Config *config; 104 pdfio_file_t *pdf_file; 105 double current_font_size; 106 int current_page_index; 107 char cho_dirpath[PATH_MAX]; 108 char current_font_name[200]; 109 bool diagram_font_is_base_font; 110 struct PDFContentContext t_ctx; // INFO: context for pdf_toc_create() 111 struct PDFContentContext b_ctx; // INFO: context for pdf_body_create() 112 }; 113 114 char *out_pdf_create(const char *cho_filename, const char *output_folder_or_file, struct ChoSong **songs, struct Config *config); 115 pdfio_obj_t *out_pdf_fnt_obj_get_by_name(struct PDFContext *ctx, const char *name);