LCOV - code coverage report
Current view: top level - gdraw - gdrawtxt.c (source / functions) Hit Total Coverage
Test: FontForge coverage report 2017-08-04 01:21:11+02:00 (commit d35f7e4107a9e1db65cce47c468fcc914cecb8fd) Lines: 0 48 0.0 %
Date: 2017-08-04 Functions: 0 11 0.0 %

          Line data    Source code
       1             : /* Copyright (C) 2000-2012 by George Williams */
       2             : /*
       3             :  * Redistribution and use in source and binary forms, with or without
       4             :  * modification, are permitted provided that the following conditions are met:
       5             : 
       6             :  * Redistributions of source code must retain the above copyright notice, this
       7             :  * list of conditions and the following disclaimer.
       8             : 
       9             :  * Redistributions in binary form must reproduce the above copyright notice,
      10             :  * this list of conditions and the following disclaimer in the documentation
      11             :  * and/or other materials provided with the distribution.
      12             : 
      13             :  * The name of the author may not 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 AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
      17             :  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
      18             :  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
      19             :  * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
      20             :  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
      21             :  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
      22             :  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
      23             :  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
      24             :  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
      25             :  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
      26             :  */
      27             : #include <stdlib.h>
      28             : 
      29             : #include "gdrawP.h"
      30             : #include "fontP.h"
      31             : #include "gxcdrawP.h"
      32             : #include "ustring.h"
      33             : 
      34           0 : FontInstance *GDrawSetFont(GWindow gw, FontInstance *fi) {
      35           0 :     FontInstance *old = gw->ggc->fi;
      36           0 :     gw->ggc->fi = fi;
      37           0 : return( old );
      38             : }
      39             : 
      40           0 : FontInstance *GDrawInstanciateFont(GWindow gw, FontRequest *rq) {
      41             :     GXDisplay *gdisp;
      42             :     FState *fs;
      43             :     struct font_instance *fi;
      44             : 
      45           0 :     if (gw == NULL)
      46           0 :         gw = GDrawGetRoot(NULL);
      47             : 
      48           0 :     gdisp = ((GXWindow) gw)->display;
      49           0 :     fs = gdisp->fontstate;
      50             : 
      51           0 :     if ( rq->point_size<0 )       /* It's in pixels, not points, convert to points */
      52           0 :         rq->point_size = PixelToPoint(-rq->point_size,fs->res);
      53             : 
      54           0 :     fi = calloc(1,sizeof(struct font_instance));
      55           0 :     fi->rq = *rq;
      56           0 :     fi->rq.family_name = u_copy( fi->rq.family_name );
      57           0 :     fi->rq.utf8_family_name = copy( fi->rq.utf8_family_name );
      58             : 
      59           0 : return( fi );
      60             : }
      61             : 
      62           0 : FontInstance *GDrawAttachFont(GWindow gw, FontRequest *rq) {
      63           0 :     struct font_instance *fi = GDrawInstanciateFont(gw,rq);
      64             : 
      65           0 :     if ( fi!=NULL )
      66           0 :         GDrawSetFont(gw, fi);
      67           0 : return( fi );
      68             : }
      69             : 
      70           0 : FontRequest *GDrawDecomposeFont(FontInstance *fi, FontRequest *rq) {
      71           0 :     *rq = fi->rq;
      72           0 : return( rq );
      73             : }
      74             : 
      75             : /* ************************************************************************** */
      76             : 
      77           0 : int32 GDrawDrawText(GWindow gw, int32 x, int32 y, const unichar_t *text, int32 cnt, Color col) {
      78             :     struct tf_arg arg;
      79             : 
      80           0 : return( _GXPDraw_DoText(gw,x,y,text,cnt,col,tf_drawit,&arg));
      81             : }
      82             : 
      83           0 : int32 GDrawGetTextWidth(GWindow gw,const unichar_t *text, int32 cnt) {
      84             :     struct tf_arg arg;
      85             : 
      86           0 : return( _GXPDraw_DoText(gw,0,0,text,cnt,0x0,tf_width,&arg));
      87             : }
      88             : 
      89           0 : int32 GDrawGetTextBounds(GWindow gw,const unichar_t *text, int32 cnt, GTextBounds *bounds) {
      90             :     int ret;
      91             :     struct tf_arg arg;
      92             : 
      93           0 :     memset(&arg,'\0',sizeof(arg));
      94           0 :     arg.first = true;
      95           0 :     ret = _GXPDraw_DoText(gw,0,0,text,cnt,0x0,tf_rect,&arg);
      96           0 :     *bounds = arg.size;
      97           0 : return( ret );
      98             : }
      99             : 
     100             : /* UTF8 routines */
     101             : 
     102           0 : int32 GDrawDrawText8(GWindow gw, int32 x, int32 y, const char *text, int32 cnt, Color col) {
     103             :     struct tf_arg arg;
     104             : 
     105           0 : return( _GXPDraw_DoText8(gw,x,y,text,cnt,col,tf_drawit,&arg));
     106             : }
     107             : 
     108           0 : int32 GDrawGetText8Width(GWindow gw, const char *text, int32 cnt) {
     109             :     struct tf_arg arg;
     110             : 
     111           0 : return( _GXPDraw_DoText8(gw,0,0,text,cnt,0x0,tf_width,&arg));
     112             : }
     113             : 
     114           0 : int32 GDrawGetText8Height(GWindow gw, const char *text, int32 cnt) 
     115             : {
     116             :     GTextBounds bounds;
     117           0 :     int32 ret = GDrawGetText8Bounds( gw, text, cnt, &bounds );
     118           0 :     ret = bounds.as + bounds.ds;
     119           0 :     return ret;
     120             : }
     121             : 
     122             : 
     123           0 : int32 GDrawGetText8Bounds(GWindow gw,const char *text, int32 cnt, GTextBounds *bounds) {
     124             :     int ret;
     125             :     struct tf_arg arg;
     126             : 
     127           0 :     memset(&arg,'\0',sizeof(arg));
     128           0 :     arg.first = true;
     129           0 :     ret = _GXPDraw_DoText8(gw,0,0,text,cnt,0x0,tf_rect,&arg);
     130           0 :     *bounds = arg.size;
     131           0 : return( ret );
     132             : }
     133             : 
     134             : /* End UTF8 routines */

Generated by: LCOV version 1.10