gonzopi

git clone https://git.tarina.org/gonzopi
Log | Files | Refs | README | LICENSE

vgft.h (2689B)


      1 /*
      2 Copyright (c) 2012, Broadcom Europe Ltd
      3 All rights reserved.
      4 
      5 Redistribution and use in source and binary forms, with or without
      6 modification, are permitted provided that the following conditions are met:
      7     * Redistributions of source code must retain the above copyright
      8       notice, this list of conditions and the following disclaimer.
      9     * Redistributions in binary form must reproduce the above copyright
     10       notice, this list of conditions and the following disclaimer in the
     11       documentation and/or other materials provided with the distribution.
     12     * Neither the name of the copyright holder nor the
     13       names of its contributors may be used to endorse or promote products
     14       derived from this software without specific prior written permission.
     15 
     16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
     17 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     18 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     19 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
     20 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     21 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     22 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
     23 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     24 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
     25 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     26 */
     27 
     28 // Font handling for graphicsx
     29 
     30 #ifndef VGFT_H
     31 #define VGFT_H
     32 
     33 #include "interface/vcos/vcos.h"
     34 #include <VG/openvg.h>
     35 #include <ft2build.h>
     36 
     37 typedef int VGFT_BOOL;
     38 #define VGFT_FALSE 0
     39 #define VGFT_TRUE (!VGFT_FALSE)
     40 
     41 #include FT_FREETYPE_H
     42 
     43 /* Returns 0 on success */
     44 extern int vgft_init(void);
     45 extern void vgft_term(void);
     46 
     47 typedef struct {
     48    VGFont vg_font;
     49    FT_Face ft_face;
     50 } VGFT_FONT_T;
     51 
     52 /** Initialise a FT->VG font */
     53 VCOS_STATUS_T vgft_font_init(VGFT_FONT_T *font);
     54 
     55 /** Load a font file from memory */
     56 VCOS_STATUS_T vgft_font_load_mem(VGFT_FONT_T *font, void *mem, size_t len);
     57 
     58 /** Convert a font into VG glyphs */
     59 VCOS_STATUS_T vgft_font_convert_glyphs(VGFT_FONT_T *font, unsigned int char_height, unsigned int dpi_x, unsigned int dpi_y);
     60 
     61 /** Release a font. */
     62 void vgft_font_term(VGFT_FONT_T *font);
     63 
     64 void vgft_font_draw(VGFT_FONT_T *font, VGfloat x, VGfloat y, const char *text, unsigned text_length, VGbitfield paint_modes);
     65 
     66 void vgft_get_text_extents(VGFT_FONT_T *font, const char *text, unsigned text_length, VGfloat start_x, VGfloat start_y, VGfloat *w, VGfloat *h);
     67 
     68 VGfloat vgft_first_line_y_offset(VGFT_FONT_T *font);
     69 
     70 #endif