1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
|
/*
* COPYRIGHT
*
* pcb-rnd, interactive printed circuit board design
*
* ttf low level loader
* pcb-rnd Copyright (C) 2018 Tibor 'Igor2' Palinkas
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Contact:
* Project page: http://repo.hu/projects/pcb-rnd
* lead developer: http://repo.hu/projects/pcb-rnd/contact.html
* mailing list: pcb-rnd (at) list.repo.hu (send "subscribe")
*/
#ifndef PCB_TTF_LOAD_H
#define PCB_TTF_LOAD_H
#include "config.h"
#include <ft2build.h>
#include <freetype.h>
#include <math.h>
#include <genvector/vtp0.h>
#include <librnd/poly/rtree.h>
#include <librnd/poly/polyarea.h>
#include "font.h"
typedef struct pcb_ttf_s {
FT_Library library;
FT_Face face;
} pcb_ttf_t;
/* Stroker backend; this low level lib does not know how to draw anything but
calls back the stroker for outline objects */
typedef struct pcb_ttf_stroke_s pcb_ttf_stroke_t;
struct pcb_ttf_stroke_s {
FT_Outline_Funcs funcs;
void (*init)(pcb_ttf_stroke_t *s);
void (*start)(pcb_ttf_stroke_t *s, int chr);
void (*finish)(pcb_ttf_stroke_t *s);
void (*uninit)(pcb_ttf_stroke_t *s);
double x, y; /* in freeftype's coords */
double dx, dy, scale_x, scale_y;
rnd_glyph_t *glyph;
pcb_ttf_t *ttf;
unsigned want_poly:1;
vtp0_t poly_pos, poly_neg; /* of (rnd_polyarea_t *) */
rnd_pline_t *contour;
};
/* Load the ttf font from fn; return 0 on success */
FT_Error pcb_ttf_load(pcb_ttf_t *ttf, const char *fn);
int pcb_ttf_unload(pcb_ttf_t *ctx);
/* Use str to trace the outline of a glyph; returns 0 on success */
FT_Error pcb_ttf_trace(pcb_ttf_t *ctx, FT_ULong ttf_chr, FT_ULong out_chr, pcb_ttf_stroke_t *str, unsigned short int scale);
/* Convert an error code into a human readable error message */
const char *pcb_ttf_errmsg(FT_Error errnum);
#endif
|